Fork me on GitHub

For this code:

(defn foo []


If I am on the (foo) in the comment block, go to definition works. However, if my cursor is on the (foo) in the last line, go to definition fails (`[coc.nvim] definition not found`). Is it possible to support go to definition from forms in a discard?


It'd be a little bit harder as we would need to clj-kondo provide analysis for commented forms, but sounds possible. Not sure how common would be that too... WDYT @U04V15CAJ?


I tend to use discard forms instead of comment forms for Rich Comments as my editor/plugin has a very-useful “eval top-level form” command that lets me run code without moving my cursor to a specific location. I don't know how common my use case is.


Clj-kondo already provides analysis for that unless you disable that with skip-comments true


But not in discarded forms, those are just ignored


@U0510902N For comparison, Calva treats forms inside comment as top-level forms so the usual shortcut for eval works (even tho' they are not really top-level forms). Perhaps you could petition the coc.nvim maintainer(s) to add support for that too?


@U04V70XH6 that's awesome. Conjure (my repl plugin) is getting closer to supporting that reliably. It works for me sometimes, could be related to a Neovim bug.


I just did lsp-clojure-server-info and I see this entry: > :port “NREPL only available on :debug profile (`make debug-cli`)“, what’s the story of this? Is this an nrepl port to lsp itself or can you pass a port to lsp of the running project?


LSP itself for debugging clojure-lsp :)


neat. I was wondering if you could provide a port to your running repl. Would be awesome if i could tell it there’s a socket repl at 50505 and it can query all it likes


Not sure if I understood but that would probably not work with native images


I updated to the latest version 2022.07.24-18.25.43 so I could try out the experimental scanning feature, but I haven't enabled it yet. I did notice that the startup status messages don't seem to be coming through. Were they removed?


ah, thank you for that, must have missed it


It looks like the coc.nvim project globally disabled startup progress indicators recently. I was able to get the progress back by adding:

"progressOnInitialization": true
to the clojure-lsp language server config. Here's the for reference. Now the progress shows up in the lower right as a not-too-pretty-but-very-useful popup.

👍 3

nice find, thanks!


Do you know why coc disabled that by default?


It looks like they added the new floating window and disabled it by default.


It looks like the coc.nvim project globally disabled startup progress indicators recently. I was able to get the progress back by adding:

"progressOnInitialization": true
to the clojure-lsp language server config. Here's the for reference. Now the progress shows up in the lower right as a not-too-pretty-but-very-useful popup.

👍 3

I've noticed when I have something like (:require [ :as io]) I don't get autocompletion/doc suggestions from the LSP when I am writing something like (io/| ) in the source file where | is my cursor position. I do get such help if I write out the whole () and I do get such help if I've required [clojure.string :as s] and am writing something like (s/| ) . I haven't tracked down which ones this works for and which it does not but just curious if this is a known issue? Or is it a specific editor issue? (I'm using neovim w/ conjure and coc.nvim).


I suspect you are using a outdated clojure-lsp, what's you version?


clojure-lsp 2022.07.24-18.25.43


clojure.string working and not is weird. Could you create a repro sample where I can try?


Also, check clojure-lsp server logs


Will do. How do I check the logs?


In trying to make that little sample repo for you, I'm getting slightly different behavior. The (s/| automatically pops up with suggestions with a [LS] designation as the source, but if I do (io/| and then press TAB I do now get the suggestions with a [CLJ] source.


Not sure what is that, probably something from your editor, but I'd guess one is from the LSP and the other from the repl or built-in editor


Unless I have already written something like (io/reader ...) before because then it autosuggests that only with the [A] source which I think means it's just reading the file for current suggestions.

👍 1

Here are those logs


I think the multiple :resolve-completion-item was when I was TAB -ing through the suggestions for (s/| and then after that I tried with (io/|


So if I had to guess, the LS is giving the suggestions for clojure.string and then the repl/editor is giving the spotty suggestions for even when using the full namespace instead of just (io/


@U9J50BY4C from the logs we can see clojure-lsp is returning completion items, which looks correct. Is there a repro where I can try?


Hmmm. Are you asking for me to get a setup on github for neovim with conjure and coc.nvim configurations? I'm not sure how that would work. Otherwise, I would just be putting up a bare bones clojure repo that requires in [ :as io]. No worries though, it might just be some silly thing I have in my setup, I wouldn't want you spending a lot of time on that.


I just need the project so I can try exactly what you are trying and check if the project setup is correct


Here ya go: I feel like I'm already taking up too much of your time though


it seems to work on emacs, so maybe something with vim? could you get logs between client and server


I'll work on getting that for you. I'm also asking in #conjure to see if this is just my setup or if others are seeing the same issue.


I think this is the log you are looking for?

2022-07-27T12:08:45.809 INFO (pid:2543) [services] - registered service "languageserver.clojure-lsp"                                                                                                 
2022-07-27T12:08:45.818 INFO (pid:2543) [coc-conjure] - CoC conjure enabled!                                                                                                                         
2022-07-27T12:08:45.839 INFO (pid:2543) [plugin] - coc.nvim initialized with node: v18.4.0 after 224ms                                                                                               
2022-07-27T12:08:57.371 INFO (pid:2543) [services] - clojure-lsp state change: stopped => starting                                                                                                   
2022-07-27T12:08:57.398 INFO (pid:2543) [language-client-index] - Language server "languageserver.clojure-lsp" started with 2742                                                                     
2022-07-27T12:08:59.501 INFO (pid:2543) [services] - clojure-lsp state change: starting => running                                                                                                   
2022-07-27T12:08:59.543 INFO (pid:2543) [services] - service languageserver.clojure-lsp started                                                                                                      
2022-07-27T12:09:15.101 WARN (pid:2543) [completion] - Suggest not triggered with input "", minimal trigger input length: 1                                                                          
2022-07-27T12:09:15.102 WARN (pid:2543) [handler-format] - Format on type provider not found for buffer: file:///home/chaselambert/projects/clojure/scratch/src/scratch/core.clj                     
2022-07-27T12:09:23.608 INFO (pid:2543) [attach] - receive notification: startCompletion [                                                                                                           
    word: 'io/',                                                                                                                                                                                     
    bufnr: 3,                                                                                                                                                                                        
    col: 1,                                                                                                                                                                                          
    disabled: [],                                                                                                                                                                                    
    filepath: '/home/chaselambert/projects/clojure/scratch/src/scratch/core.clj',                                                                                                                    
    indentkeys: '',                                                                                                                                                                                  
    blacklist: [],                                                                                                                                                                                   
    line: '(io/)',                                                                                                                                                                                   
    filetype: 'clojure',                                                                                                                                                                             
    linenr: 6,                                                                                                                                                                                       
    input: 'io/',                                                                                                                                                                                    
    colnr: 5,                                                                                                                                                                                        
    changedtick: 489                                                                                                                                                                                 
2022-07-27T12:09:39.062 INFO (pid:2543) [attach] - receive notification: openLog [] 


First I checked the autocompletion with (s/| and then I did it with (io/|


No, it should be a log which logs whant client and server are sending and receiving, usually as json


Ok, I think I'm seeing that but it might be 3000+ lines long


I can open it in the editor using the command the coc.nvim docs told me to use but I don't know where that file is quite yet. lol sorry give me a second


I think it's best to restart the server, repro the bug and then get the log, to avoid too many logs


Yeah, I've done that. It's still 1200 lines but I just can't figure out how to save it or find it in my system. It's like a temporary vim buffer that disappears showing at output:///languageserver.clojure-lsp Sorry about this, I'm trying to figure it out

👍 1

I guess I have the tracing log set to "verbose" I can change that and give you a smaller log.


From the logs it seems you tried to complete for the code (i|) ?


hmmm, maybe it's trying autocompletion too quickly then. I'm definitely getting the cursor to (io/ and just letting it sit there. Someone else on the #conjure channel is seeing the same behavior.


From the logs, this is the code sent on the last didChange request:

(ns scratch.core\n  (:require \n    [ :as io]))\n\n(i)\n\n\n(defn -main [])\n


I think line 1216 is showing the (io/| properly now


right, but no completion requests after that 😅


Haha, I thought that was the whole issue lol


My guess is that your editor is requesting completion and caching it


I can try with the (s/| first and see how that looks different.


s is a small alias, rename it to str just to be similar to io


ok, will do.


Also, check if there is no flag to disable client completion cache if any, just to confirm there is nothing wrong on server side but on client


lol, now I'm not getting [LS] completion for str or io


So is it working as expected?


I have to step away for a brief moment. When I get back I'll look for that client completion cache stuff

👍 1

What's weird is the language server autocompletion works for s but not for str


And not for clojure.string/


So I imagine something is going on with coc.nvim and the language server. or the way conjure brings them both together.

☝️ 1

I'm seeing the same behavior with s vs string with the former completing and the latter not, very odd


I think I tracked it down to a recent change in coc.nvim. I did some git bisecting to weed out the commit where it stops working. See this thread in #conjure:

👍 1

nice find; for completion I often find I have to manually trigger around / with this from the coc doc

" Use <c-space> to trigger completion.
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
  inoremap <silent><expr> <c-@> coc#refresh()


I am now curious to compare the LSP experience with coc.nvim vs the inbuilt tools. I've been fighting off making the switch to a lua (or maybe even fennel) config but that could change if coc.nvim is starting to fall behind the LSP integrations of the "native" solution. Of course if it's just a tiny bug I could be making a mountain out of a molehill here


I suspect they both have tradeoffs; most clients do as they are all trying to play catch up with vscode and the spec and fit it into their editor's quirks.


Just for closure, this problem seems to have fixed itself when updating to the latest version of coc.nvim . (Also note that that update does include some frustrating breaking changes to the autocompletion workflow but it was decently easy to fix by using the changed example config on the main repo


Thanks for the update @U9J50BY4C!