Fork me on GitHub

Hey team, does someone have a config a nvim or some such config I could look at, for commands like “add missing require/import”? (I know, but I don’t think the “add-missing-require” call is there) Will play with it soon, but if there are more files I could look at for inspiration would appreciate it!


Maybe we should link your config @U11EL3P9U if you agree 🙂

👍 1

Sure, as an example of course 😉


ah! looks like add-missing-libspec is what I wanted. Thanks team


@U0C5DE6RK I suggest you always use the code actions as if there is a available way to import the ns, it will be there


Thanks Eric. Apologies for the noobie question here, but am not quite sure I understand the codeaction bit. Would you mind expanding a bit deeper?


(in dharrigan’s vimrc, I see:

call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'add-missing-libspec', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1]})
is add-missing-libspec here a codeaction, or something else?)


Ah, I think I understand. code-actions are the commands listed here ( — and I guess coc may already have mappings to them. Will check coc to see how to invoke the correct code action to add missing require.


yes, the server return the available code actions, and you, user, select what you want to execute


if that function could be required/imported, then the server will return a code action for that on that line 🙂


I have some keymaps for code-actions if you need a second source for your vim config

thanks 2

oo I see!

yes 2

Okay, one more noob question: Say I have

nnoremap <silent> crml :call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'move-to-let', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1, input('Binding name: ')]})<CR>
Could I do above with a codeAction? If I do @UMMMKKADU ac , I don’t see move-to-let as an option. If I try
:call CocActionAsync('codeAction',          'move-to-let')
It says it is unsupported That keyboard shortcut does seem to work though


if the move to let action show on code actions, it should work for the current buffer cursor


oh, not sure clojure-lsp suggest the move to let as a code action

👍 1

if not, only calling manually indeed


(indeed, it does not seem to show) Okay, I think I understand this much better. Thanks team!


I think that's the only one missing on code actions :thinking_face: we could add that


Cool! May have mistunderstood a bit more. What about something like “extract-function”? If I hover over a form, and run coc-codeaction, I still only see these suggestions:


yeah, that one too 😂

❤️ 1

xD — indeed could be nice add! if you like can make an issue on GH. I don’t know when I’ll have time, but could add to my someday to write a pr. Great work on lsp team — my vim setup has become object of envy from friends — it’s so darn cool now.


glad to hear 😄 Yeah, feel free to open an issue or PR 🙂

❤️ 1

Okay, one final noob q for the day:


whenever I run code-action, it seems like I only get these 4 results. For example, in this one I expected to find thread-first or something like this


are you with the cursor inside the ( ?


was outside. Interestingly, inside ( does not show any codeactions.


howeever, if I visually select the form, it shows up!


yeah, that depends on how vim sens that buffer position, on emacs it works on both

👍 1

@U0C5DE6RK visual select is also where the "move to let" is hiding. You just need to select something inside of a let-block

❤️ 2

ah, awesome @UJY23QLS1! Thanks

👍 1

Okay, one more noob question. Looks like add-missing-libspec command can auto-import namespaces. It seems to fail with java classes though. (i.e if I hover over FlexmarkHtmlConverter, and run add-missing-libspec, would love it do: (:import (com.vladsch.flexmark.html2md.converter FlexmarkHtmlConverter)) ) Is something like this supported with clojure-lsp yet? If yes, what’s the way to trigger it?


ATM clojure-lsp don't know too much about java, it doesn't know about the available java on classpath, but you can manually import it with add-import-to-namespace

👍 1