NoahTheDuke / coc-clojure

coc.nvim plugin for clojure-lsp
Mozilla Public License 2.0
32 stars 3 forks source link

Loading clojure-lsp doesn't go away on a non-clojure file #7

Closed dharrigan closed 2 years ago

dharrigan commented 2 years ago

Hi,

If I have a non-clojure file, say a sql file, in a clojure project and open it up in neovim, the message Loading clojure-lsp along with the little spinner is displayed, but doesn't go away. I don't recall this happening before.

-=david=-

NoahTheDuke commented 2 years ago

I added activationEvents for this scenario: https://github.com/NoahTheDuke/coc-clojure/blob/774754bf41583845422a28d9a68f7e13502b28a4/package.json#L44-L49

It seemed prudent to assume that opening a file in a clojure project should start loading clojure-lsp, even if the initial file isn't a clojure file. For example, you open the sql file and then use ctrl-p or an equivalent to find the file that uses it, it would be nice to have clojure-lsp already going.

Do you find it negatively impacts your work to have it loading when opening non-clojure files?

dharrigan commented 2 years ago

Not negatively, but it's spinning and spinning, and thus quite distracting (i.e., I'm sitting in the sql file, looking/editing at it for quite a while). Could it happen that if clojure-lsp doesn't respond within, say 10-15 seconds, that the Loading Clojure-lsp is subsequentially disposed?

NoahTheDuke commented 2 years ago

That does sound annoying. I wonder why it's taking so long to load/crashing and not loading at all. Is the code base available for me to poke around in? Maybe I can recreate your issue.

dharrigan commented 2 years ago

I think having the activation events is too presumptive, there are other files in a clojure project (i.e., one that contains a deps.edn for example) that are being edited, i.e., sql files, docker files, readme files, i.e., anything not .clj or .edn. A project could (and in my case does) contain loads and loads of non-clojure files that needs working upon.

Having it simply be on the language being clojure (reverting the change) seems a nice original balance, since for example in my autocmd for vim, I have the language set to clojure if I load a edn file or a cljs file, thus narrowing the scope of when the clojure-lsp should be "started".

NoahTheDuke commented 2 years ago

Let me think on this today, cuz my workflow is "single vim window for all work in a given repository", and being able to seamlessly go from readme to clojure without any pause (while I wait for clojure-lsp to load) is really nice.

dharrigan commented 2 years ago

No problemo. Looking forward to hearing your thoughts on this.

dharrigan commented 2 years ago

Hi, just did a quick test. If I edit your package.json, removing the activation events (keeping the onLangauge:clojure) and build, then if I open up a sql file the clojure-lsp is not loaded (as expected). As soon as I edit a clj file, clojure-lsp is loaded (as expected).

❯ ps aux | rg clojure-lsp
david     574529  4.8  0.8 645288 537832 ?       Sl   15:17   0:06 /bin/clojure-lsp
david     577464  0.0  0.0   9544  6372 pts/10   S+   15:19   0:00 rg -L --hidden --no-ignore-vcs --glob !.git/* -i clojure-lsp

If I then delete the clj buffer completely, the /bin/clojure-lsp process is kept around by neovim/coc. Thus, if then I open up a new buffer of a clj file, there is nothing to load, the spinner doesn't display and clojure-lsp is immediately available.

I think that would suit you still, as having vim open and bouncing between files doesn't mean that clojure-lsp is unloaded and loaded each time. It's loaded once (on opening a clojure file) and kept around until vim quits.

If you can verify that your side, then I suppose reverting back to the original activationEvent would be appropriate.

dharrigan commented 2 years ago

Hi @NoahTheDuke, any chance of removing the activation events (so I can delete my fork? :-))

Thank you.

NoahTheDuke commented 2 years ago

Done, sorry for the delay.