Fork me on GitHub
#vim
<
2022-09-07
>
seepel01:09:23

Hi there. I have a project where I have a clojure web server that serves cljs that is built using shadow-cljs. I'm trying to use https://github.com/liquidz/vim-iced-multi-session to get repls for both my server and client, but I can't quite figure out the right steps to run. Does anyone know of step by step instructions that I can follow?

sheluchin09:09:11

You can start your JVM with the iced command that comes with vim-iced, and set it up to run the shadow-cljs server as well. I start mine with this command (adjust your aliases according to your needs):

iced repl :main --force-shadow-cljs -A:dev:shadow-cljs:repl/reveal
Then in vim, navigate to your namespace that manages running your http server. At that point you can connect to the running instance using https://liquidz.github.io/vim-iced/vim-iced.html#%3AIcedConnect (`<Leader>'`). This will connect to your CLJS REPL at first. You can then change to the CLJ REPL using https://liquidz.github.io/vim-iced/vim-iced.html#%3AIcedCycleSession, require the file with <Leader>eb, and evaluate whatever function in your namespace starts the http server. In my case that's just something like https://github.com/fulcrologic/fulcro-rad-template/blob/main/src/dev/development.clj#L29-L32 which uses mount to start the required components. Then as you switch between CLJ/CLJS buffers, use IcedCycleSession to activate the correct environments. One of the tricky bits is once everything is running, you need to have a browser window running the active CLJS build (your web page, not the shadow-cljs console) to use the CLJS REPL. At least that's how I do it. I tried to use vim-iced-multi-session once, but something about it didn't work or I was doing it wrong -- I can't remember now, but I've been meaning to give it another try. Having some indicator of which session you're in would be nice, but I'm not sure vim-iced-multi-session has vim-airline support at the moment. I'd love to know if there's somehow I can improve this workflow. It feels a little awkward, but it works.

seepel01:09:28

Thanks for the detailed explanation. I think that makes sense. Unfortunately I don't think I have my dependencies setup right. I'm using deps.edn on the server side. It seems that the shadow-cljs clj repl cannot find datomic. So far I've been getting around this by running shadow-cljs separately. I suppose it's time to learn how this all works 🙈

seepel01:09:14

Awesome, after sorting out my dependencies this seems to be working for me! Thank you so much! > I can't remember now, but I've been meaning to give it another try. If you sort it out I'd love to hear about it! > Having some indicator of which session you're in would be nice, but I'm not sure vim-iced-multi-session has vim-airline support at the moment. This is the first thing I went looking for, the multi-session documentation has an example for lightline, but my vim-fu is not strong enough to translate that to airline 🙂. If I could get it to work in the first place...

sheluchin10:09:34

@U03NXD9TGBD Glad to hear it helped. I'll try to keep you posted if I have a successful run at the session manager add-on. Good luck!

uochan21:09:49

@U03NXD9TGBD Sorry for late reaction. @UPWHQK562 Thanks for your great supporting! vim-iced-multi-session is a plugin to switch the connection seamlessly to a separately launched nREPL server. https://twitter.com/uochan/status/1395870452656996352 So, it is designed for use when two nREPL servers (clj/cljs) are running for a single project, and not for switching between clj/cljs for a single nREPL connection.

walterl06:09:33

Have you gone through Conjure's basics by running :ConjureSchool? I remember it being quite nice

Pagoda 5B06:09:17

not yet actually I should

practicalli-johnny08:09:56

There are lots of plugins you could use and go loopy about deciding which ones to use. I spent a month looking through plugins and changed my config quite a lot. https://github.com/practicalli/neovim-config-redux For a Clojure REPL you only need Conjure package. For a feature rich Clojure development experience you will need 10-20 plugins depending on your needs Or use one of the many community configurations it there

👀 2
walterl06:09:14

I guess this is just one of those features of the [n]vim ecosystem: there are many options for most things. Perhaps even too many options. 😅 Maybe just go with the first option that looks OK to you, and look at alternatives when you can/want/need to. My setup is https://github.com/walterl/dotfiles/tree/master/_config/nvim, but you'll get a bunch of other recommendations from the people in this channel too.

walterl06:09:48

You're welcome to ask about more specific components too. E.g. I use hrsh7th/nvim-cmp for completion.

Pagoda 5B06:09:16

I’ve found a “fennel+aniseed”-based conf somewhere else, using nvim-cmp too. But yours will be much more useful for me (I don’t want to turn my scripts to fennel). Thanks a lot

walterl06:09:47

You probably saw https://github.com/rafaeldelboni/nvim-fennel-lsp-conjure-as-clojure-ide. I used it myself for a while, but basically merged/ported it back into my old config. I like the plugins choices, but the fennel not so much.

1
Martynas Maciulevičius06:09:23

I wrote my plugin with fennel. It has some of the Clojure's feel but the sequences and maps aren't there. And it seems unfinished sometimes. But I saw that once you abstract on top of it then you're okay.

walterl06:09:57

Yeah, I've used it some myself, but don't think it's worth it for config.

Martynas Maciulevičius13:09:34

I agree. I think that the big strength of Clojure-like languages is DSLs and what abstraction you could have with them. But if you constantly need to tinker with integration then it's not very nice.

👍 1
walterl06:09:22

I haven't really used anything other than Neovim since I started using Clojure (about 3 years ago), but I can say that it's quite a nice experience.

walterl06:09:22

Besides having a REPL connection (Conjure), the single most important piece of functionality is hooking up https://clojure-lsp.io/. Again, you have a couple of options when it comes to LSP client. I went with Neovim's recently added built-in LSP support, configured with https://github.com/neovim/nvim-lspconfig. Another very popular option is https://github.com/neoclide/coc.nvim.

thanks2 1
Martynas Maciulevičius07:09:14

Reply to https://clojurians.slack.com/archives/C02KAFNDT7X/p1662533946505149?thread_ts=1662402329.639959&amp;cid=C02KAFNDT7X > having extra configs and keys for Scala & Calva messes up things too much Well I configured LSP for nvim and I don't use paredit at all. I didn't try to enable this kind of plugin per-filetype but it's totally doable in vim. For instance Conjure only binds when clojure buffer type is used. So I think you can do it with some hacking. But for instance I don't see how I could force turn off nvim LSP (not the server but whole plugin) by filetype. So you may get into the same trouble too.

walterl07:09:05

:help vim.lsp.stop_client()

Pagoda 5B07:09:48

my issue was with configuring VSCode with daily job settings and Calva. Using calva added a lot of extraneous things that I don’t care about during my Scala development

Martynas Maciulevičius07:09:28

Yes but my concern wasn't about LSP in particular but about plugins that bind without any regard to buffer type. For instance if I would want to enable some kind of date increasing plugin in some buffers but not in others then I would need the support from the plugin itself, I think :thinking_face:

Martynas Maciulevičius07:09:08

But the flipside of that is that you have to write that into a config. And on VSCode you don't have to write configs but you get all plugins at once. It's nice that we have this option but there is a price.

practicalli-johnny09:09:23

I am using Neovim commercially at my current job, it works very well. It uses Conjure for the REPL connection, LSP for static analysis and has pages for autocompletion, git/GitHub and a list of other features https://github.com/practicalli/neovim-config-redux There are always improvements that could be made, but it works well for now

thanks2 1
dave15:09:09

I also use Neovim professionally for writing Clojure code. It works great! My setup includes Conjure, CoC, clojure-lsp, vim-sexp and parinfer-rust

1
sheluchin11:09:14

I'm curious to try https://github.com/harrygallagher4/nvim-parinfer-rust in hopes that it will help with the https://github.com/eraserhd/parinfer-rust/issues/123 issue I get with the main parinfer-rust. The installation instructions suggest to install parinfer-rust as an opt plugin, which is a packer.nvim option. Does anyone know if there's an equivalent option to use with vim-plug?

dave15:09:04

Ooh, I didn't know about this! Seems promising. I also use vim-plug and it isn't clear to me from the README how to install it. Curious if anyone here knows how to do it.

dave15:09:04

https://github.com/harrygallagher4/nvim-parinfer-rust/issues/6 I opened an issue just now to see what the author thinks.

sheluchin15:09:33

Thanks! There look to be quite a few Parinfer versions out there but none have really hit the sweet spot for me yet.

dave16:09:27

eraserhd/parinfer-rust is awesome, despite being buggy

sheluchin16:09:22

Oh yeah, for sure. I could never stop using it, but fiddling around with indents in certain situations is annoying and takes away from the structural editing value prop of Clojure.

sheluchin16:09:32

I've been trying to find one that works well for me...

dave16:09:08

I think there are two camps of people: the paredit people and the parinfer people. If you're more interested in structural editing and you want the indentation to happen automatically, then you'll have an easier time with paredit. If you're more interested in indentation (i.e. less interested in structural editing) and you want the parens/brackets/etc. to be adjusted automatically based on indentation, then you'll have an easier time with parinfer.

sheluchin16:09:52

I gave Paredit a try at the beginning of my Clojure journey and for reasons I cannot recall now, decided that I liked Parinfer better. I think I'm too used to it to change at this point. Just based on the number of forks out there, I'm optimistic that any of the minor annoyances with it will eventually be ironed out.

dave16:09:20

I'm sort of in the same boat. I don't know why, but parinfer just feels better to me.

Proctor20:09:17

How does one use (neo)vim and not just default to thinking in structural editing…. 😛

Proctor20:09:33

I picked (defaulted to????) paredit because people sold that structural editing to me, and it felt in line with the ci( and dap, and the like…

nate02:09:00

Same for me. I started with vim-sexp (and vim-sexp mappings for regular people) for structural editing. Works wonderfully and it's fast.

sheluchin12:09:47

@US03ZP2F5 well, they both do structural editing, no? I mean, at least with vim-sexp's and LSP's help. I just remember trying both Paredit and Parinfer and the latter feeling more natural, so I stuck with it.

Proctor12:09:00

@UPWHQK562 I was being tongue in cheek, 😉 I haven’t looked too much at Parinfer because people mentioned paredit is structural editing. I joke with the folks who use Emacs and prefer paredit because of structural editing, that they should be using (neo)vim because if they like structural editing that is normal mode editing in (neo)vim

sheluchin11:09:22

Shoot, harrygallagher4/nvim-parinfer-rust got updated with install instructions for vim-plug, but unfortunately doesn't seem to have any impact on the typing lag issue (#123).

😞 1