vim

seepel 2022-09-07T01:55:23.777139Z

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?

walterl 2022-09-07T01:58:19.025239Z

@liquidz.uo ☝️ 🙂

sheluchin 2022-09-07T09:41:11.265179Z

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.

seepel 2022-09-08T01:03:28.542529Z

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 🙈

seepel 2022-09-08T01:57:14.562529Z

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...

sheluchin 2022-09-08T10:38:34.633969Z

@sean888 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!

2022-09-09T21:29:49.162009Z

@sean888 Sorry for late reaction. @alex.sheluchin 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.

Pagoda 5B 2022-09-07T06:15:32.979279Z

walterl 2022-09-07T06:18:33.738369Z

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

Pagoda 5B 2022-09-07T06:42:17.464489Z

not yet actually I should

practicalli-johnny 2022-09-07T08:55:56.600669Z

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
Pagoda 5B 2022-09-07T06:15:45.001219Z

walterl 2022-09-07T06:23:14.140969Z

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.

walterl 2022-09-07T06:23:48.221379Z

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

Pagoda 5B 2022-09-07T06:51:16.613939Z

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

walterl 2022-09-07T06:53:47.436349Z

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čius 2022-09-07T06:58:23.600869Z

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.

walterl 2022-09-07T06:58:57.123449Z

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

Martynas Maciulevičius 2022-09-07T13:46:34.035649Z

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
Pagoda 5B 2022-09-07T06:15:54.705929Z

walterl 2022-09-07T06:25:22.360759Z

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.

walterl 2022-09-07T06:29:22.622149Z

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.

1
Martynas Maciulevičius 2022-09-07T07:06:14.356269Z

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.

walterl 2022-09-07T07:16:05.609389Z

:help vim.lsp.stop_client()

Pagoda 5B 2022-09-07T07:17:48.071829Z

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čius 2022-09-07T07:18:28.391129Z

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 🤔

walterl 2022-09-07T07:22:14.722939Z

vim-plug allows loading plugins by file type: https://github.com/junegunn/vim-plug#on-demand-loading-of-plugins

👍 1
Martynas Maciulevičius 2022-09-07T07:24:08.701779Z

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-johnny 2022-09-07T09:02:23.114939Z

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

1
dave 2022-09-07T15:27:09.670279Z

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
sheluchin 2022-09-07T11:31:14.698739Z

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?

dave 2022-09-07T15:30:04.332799Z

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.

dave 2022-09-07T15:32:04.594909Z

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

sheluchin 2022-09-07T15:35:33.848279Z

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

dave 2022-09-07T16:17:27.054929Z

eraserhd/parinfer-rust is awesome, despite being buggy

sheluchin 2022-09-07T16:19:22.611499Z

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.

sheluchin 2022-09-07T16:26:32.361079Z

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

dave 2022-09-07T16:29:08.058179Z

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.

sheluchin 2022-09-07T16:33:52.196879Z

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.

dave 2022-09-07T16:37:20.490259Z

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

2022-09-07T20:24:17.436839Z

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

2022-09-07T20:25:33.716929Z

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…

nate 2022-09-08T02:47:00.597589Z

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

sheluchin 2022-09-08T12:36:47.180379Z

@steven.proctor 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.

2022-09-08T12:46:00.456869Z

@alex.sheluchin 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

sheluchin 2022-09-15T11:29:22.584509Z

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