Fork me on GitHub
#vim
<
2019-10-11
>
fredmonroe01:10:43

hi everyone, i used to program in clojure a while ago - at that time vim wasn't supported as well as emacs, there was no such thing as a language server, etc... i feel like things might be different now, and while i can get by in spacemacs i would prefer to use neovim. Could someone point me at a 2019 friendly setup for neovim? I have been using coc for most of my other languages and have clojure-lsp working but i get a LOT of errors (unknown namespace, unknown symbol, etc) and i'm thinking i have something setup wrong. if anyone could point me at their dotfiles as an example or an up to date tutorial i would be grateful, thanks (p.s. - something that works well for clojure and clojurescript would be great) thank you for any help

walterl01:10:26

Hi @fredmonroe. Mine probably isn't a lot better than what you've got, but it's working well: https://github.com/walterl/dotfiles/tree/master/nvim

walterl01:10:52

If you're using vim-fireplace, make sure that you have it connected to a running nrepl. That enables a bunch more interactive functionality.

walterl01:10:49

But it seems like there are quite a few cool alternatives going around, with authors in this channel ๐Ÿ™‚

fredmonroe01:10:35

haha yes - i have some paralysis because of that (e.g. - https://github.com/clojure-vim/acid.nvim)

walterl01:10:41

oh, something that may not be clear from the dotfiles: I have clj-kondo in my $PATH, so ale picks it up and uses it automagically https://github.com/borkdude/clj-kondo

๐Ÿ‘ 4
walterl01:10:04

One day I should also get around to adding this to my dotfiles repo:

$ cat ~/.lsp/config.edn 
{"macro-defs"
 {clojure.java.jdbc/with-db-connection
  [:bindings :bound-elements]

  clojure.java.jdbc/with-db-transaction
  [:bindings :bound-elements]

  metabase.api.common/defendpoint
  [:element
   {:pred :string}
   {:pred :string}
   :function-params-and-bodies]

  schema.core/defn
  [{:element :declaration, :tags [:local]}
   ':-
   :element  ; return value signature
   {:pred :string}  ; docstring
   [{:element [:param ':- :element], :repeat true}]  ; parameters
   :bound-elements  ; body
   ]

  schema.core/defmethod
  [{:element :declaration, :tags [:local]}
   :element
   ':-
   :element  ; return value signature
   {:pred :string}  ; docstring
   [{:element [:param ':- :element], :repeat true}]  ; parameters
   :bound-elements  ; body
   ]}}

walterl01:10:35

It helps with some of those red lines that clojure-lsp generates ๐Ÿ˜‰

fredmonroe01:10:10

oh! very helpful - i feel like some of my errors are related to arguments in macros - ("let-release", "with-release") - would this help with those?

walterl01:10:10

My config won't help for those macros you mention, but if you add something similar to ~/.lsp/config.edn, it can. Docs are here: https://github.com/snoe/clojure-lsp#macro-defs, but there's a few details undocumented. So if you want to go deep, check out clojure-lsp's parsing code: https://github.com/snoe/clojure-lsp/blob/master/src/clojure_lsp/parser.clj

fredmonroe01:10:12

you are awesome thanks much. if you ever need help w/ fastai/python or something in that kind of realm i'm your guy - pretty rusty on clojure these days

๐Ÿ˜ฌ 4
walterl01:10:40

gtg, but if you don't manage with the macro-defs, leave them (and the definitions of the macros) here and I'll have a look later

๐Ÿ‘ 4
๐Ÿ™ 4
fredmonroe01:10:34

this is a simple example, i'll work on it myself, just to show you: (time (dotimes [i 10000] * Unknown symbol: i (mv! t (col a i) y))) * Unknwon symbol: i

snoe05:10:27

@fredmonroe && @clojurians-slack100 I'd be happy to take your macrodefs as contributions too, my stance is clojure.core and popular library macros should be included.

fredmonroe05:10:58

@snoe Iโ€™m so noob Iโ€™m still trying to figure out which errors are just me setting things up wrong - but will definitely share macrodefs once I know what Iโ€™m doing

fredmonroe05:10:25

Thank you for making closure-lsp!

dharrigan06:10:58

@fredmonroe you may also want to consider conjure instead of fireplace (#conjure). It's a plugin for neovim that uses an io-repl - has support for coc (using coc-conjure) and will shortly (to be merged into master) have the ability to hook into REBL

Aleksander10:10:09

didn't know about coc-conjure, I somehow had autocompletion with coc and conjure installed anyway ...

Aleksander10:10:31

is there a way to check what happens on pressing tab? what function gets called?

dharrigan12:10:38

you can use :CocInfo and you can tail /tmp/lsp.out

fredmonroe23:10:30

thanks @U11EL3P9U it looks pretty nice, will try it - do you have any public dotfiles i could look at to see how you approach things in general?

dharrigan06:10:05

(and hook into lots of things)

sogaiu06:10:25

by io-repl, do you mean prepl?

dominicm06:10:52

๐Ÿ˜น here's 10 ways to set up, you wanted help with picking one right?

๐Ÿ˜‚ 4
dharrigan07:10:28

yes, io-prepl ๐Ÿ™‚

sogaiu07:10:48

thanks for the clarification ๐Ÿ™‚

Olical08:10:56

Hey, at least we have options now in Vim land ๐Ÿ˜„

Olical08:10:34

Even if we're all dabbling in different things. I suppose there's only about 12 of us in the Vim+Clojure Venn diagram so there's enough room for each of us to have a totally different setup ๐Ÿ˜ฌ

dominicm08:10:50

12 people. 12 plugins. Which 13 will you choose?

dominicm08:10:04

Here's a spanner for you guys: what would it take to "language server" these 12 plugins. How can we make it so we aren't all rewriting each other's plugins all the time in order to build on top of a different base is slight set of differences.

Olical12:10:53

I thought about this for a long time before I started work and realised LSP is designed for static languages, not lisps. I live and die by the eval, LSP has zero awareness about languages which involve evaluations to develop things. It can do some stuff that is common with other languages, but I couldn't find anything that would let me run code in a structured way. I found that it wouldn't be worth it since I don't want static analysis, I want a running program to tell me things.

Olical12:10:49

It's probably doable, I just didn't like the idea of writing that approach myself and wanted a Clojure program driving Neovim talking to other Clojure programs without the weight of someone else's API design on my mind.

dominicm13:10:24

LSP can have extensions :) e.g. For eval

snoe14:10:56

Well I think LSP's cross editor support is something that would be good for the clojure community, it's crazy that every editor has to reinvent this stuff (and follow a similar path to vim). I think paredit commands could be useful but parinfer is basically impossible in lsp because of it's async nature. REPL commands could definitely be done, but putting all of, for instance, cider in lsp might be a mistake and would certainly run up against the protocol. I would love to have this conversation though. Maybe time for an #lsp channel?

๐Ÿ‘ 4
dominicm08:10:20

For example, a UI library for clojure displays might be one way of doing that. And it could be wired into different connection managers. You pass it a map of info and it would display the doc however the user wants it (repl buffer, echo, preview buffer, etc)

Stefan08:10:35

Honestly, I feel the amount of choice is a double-edged sword. For (relative) beginners (to clojure, not vim) it is very hard if not impossible to choose the right set of plugins, some of which are even conflicting (e.g. I discovered that slurp/barf from vim-sexp (I think) donโ€™t work well when you have parinfer smart mode enabled). This is a great selling point of Calva/VSCode IMHO: just click โ€œinstallโ€ and you have something that works quite well so that you can get started and have all that setup stuff out of the way. For me it would be great if someone(s) in this community would stand up and create a clear recommendation for beginners: install <these plugins> and youโ€™re good to go. And, as a relative beginner/newcomer I would strongly suggest that parinfer smart mode should be part of that set of recommended plugins.

๐Ÿ‘ 16
dominicm08:10:06

Fireplace. Vim-sexp. Async-clj-omni. Asyncomplete.nvim. Vim-sexp-for-regular-people.

Stefan09:10:43

Cool, so now please all maintainers of plugins put that in their READMEโ€™s (โ€œRecommended set of vim plugins for Clojure beginners: โ€ฆโ€œ) ๐Ÿ™‚

Stefan09:10:45

Interesting by the way that I havenโ€™t heard of โ€œasync-clj-omniโ€ and โ€œasyncomplete.nvimโ€ yet even though I already have quite a bunch of plugins installed, Iโ€™ll check them out.

Stefan09:10:12

Is there an easy way to get refactoring in that set of plugins?

dominicm09:10:59

Moar plugins. :)

dominicm09:10:32

Clj-refactor. nvim is out there, might need some changes to work again.

emak09:10:18

I started learning clojure in vim about 2 years ago with these 4 plugins and they made me super happy since then.

dominicm09:10:20

When I last looked there's only one rainbow plugin that works properly. I can't remember the details. I've personally never found them useful, so I turned them off.

Stefan09:10:57

Iโ€™m using luochen1990/rainbow (https://github.com/luochen1990/rainbow), it works well for me.

emak09:10:43

also this doc helped me a lot to setup the interactive workflow in cljs with Fireplace https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-with-Vim

sogaiu10:10:38

thanks all for sharing this info!

dharrigan08:10:42

We have made separate attempts to implement Smart Mode in Cursive, Vim, Atom, and Emacs through some wrangling that made integration very difficult and delicate, and ultimately incomplete.

Stefan09:10:37

I was not aware of that. Iโ€™ve been using smart mode for a while, and even though it doesnโ€™t always do the right thing, for me itโ€™s still valuable. But maybe that indeed rules it out for the default set of plugins.

dominicm08:10:47

For a beginner to clojure and not vim. Those plugins are what you want. The completion ones are maybe optional.

sogaiu10:10:04

is there some way to get a "set" of plugins? have been thinking that such sets could be convenient for trying out various combinations -- whether one is a beginner or not.

Aleksander10:10:18

there is SpaceVim that has a Clojure layer

sogaiu10:10:25

didn't know about spacevim, thanks for mentioning that :)

Aleksander10:10:29

after working in Spacemacs for some time I really can see the value of distributions - they do save lots of time

dominicm13:10:50

There's packages in vim now. That would work.

mjw13:10:01

Iโ€™ve been using vim-iced (`coc.nvim` has been extremely flaky for me, so Iโ€™ve been using it only for TypeScript/JavaScript): https://github.com/mwistrand/dotfiles/tree/master/config/nvim

Stefan13:10:38

Never came across that one before. Has an impressive feature set! I will definitely try it!

๐Ÿ‘ 8
snoe14:10:56

Well I think LSP's cross editor support is something that would be good for the clojure community, it's crazy that every editor has to reinvent this stuff (and follow a similar path to vim). I think paredit commands could be useful but parinfer is basically impossible in lsp because of it's async nature. REPL commands could definitely be done, but putting all of, for instance, cider in lsp might be a mistake and would certainly run up against the protocol. I would love to have this conversation though. Maybe time for an #lsp channel?

๐Ÿ‘ 4
dave14:10:17

i'd be interested to zero in on what exactly are the categories of plugins, which plugins are available in each category, and what makes somebody choose one over the other i think paredit vs. parinfer might be one category completion is another category. linting is another. etc.

dave14:10:56

i would bet that part of the problem is that we have some plugins (cough ALE cough) that do too much and cross the lines between categories

๐Ÿ‘ 12
dave14:10:37

like, if you have to choose between X plugin that does ABC, and Y plugin that does BCD, what do you do if you want ABCD?

dave14:10:54

seems like it would be better if we just had separate plugins for A, B, C, and D

๐Ÿ’ฏ 4
dominicm14:10:38

I've speculated that ALE is the result of building upon an emerging ecosystem at just the wrong time such that scope creeped.

snoe14:10:02

right, that's my sense too

snoe14:10:52

I think most people don't 'choose' they pick what their coworkers use or what they got to work initially.

snoe14:10:05

cough emacs

dominicm14:10:56

I'm discussing less LSP itself though, and more of a in-vim standard. Although the LSP clients may be amenable to taking this role. I'm talking about something that perhaps uses the socket repl or nrepl and passes the result to an LSP client to display.

dominicm14:10:25

I guess I'm thinking of an "IDE client library" for vim.

dominicm14:10:17

But I'm happy to suggest making it clojure specific. The transport is irrelevant. We are all talking about the same thing. Arglists always look the same.

dave14:10:42

isn't LSP meant to serve the purpose of IDE support in Whatever Text Editor?

snoe14:10:43

I think an IDE client library is exactly the goal of lsp

dave14:10:49

ha, jinx ๐Ÿ™‚

dominicm14:10:00

Yeah. I'm not sure how agnostic they are of that transport though.

dominicm14:10:21

Maybe we should be working on lsp to prepl tools

snoe15:10:11

yeah, I get it, Jonathan Blow explicitly calls out lsp in his End of Civilization talk. But my feeling is that there's so much momentum across editors for lsp that taking advantage of the existing clients is a quicker path.

๐Ÿ‘ 4
Darrell15:10:28

Hi all. Iโ€™m drinking from the Clojure fire hose at the moment with Vim Fireplace. It it possible with Fireplace, or perhaps something else, to attach a debugger at a breakpoint in my code?

dominicm15:10:04

@darrell I use debug-nrepl for this. It starts a repl in the middle of your code and then you can make evaluations or continue.

dominicm15:10:17

The gfred library

dominicm15:10:26

On mobile now, else I'd link

Darrell15:10:39

No problem. I found it, thanks!

dominicm15:10:43

Scope capture is also very good in this space