This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-09
Channels
- # announcements (3)
- # beginners (61)
- # biff (20)
- # cider (13)
- # clerk (6)
- # clojure (58)
- # clojure-brasil (5)
- # clojure-europe (30)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-uk (5)
- # clr (25)
- # core-async (2)
- # cursive (19)
- # datahike (5)
- # datalevin (1)
- # docker (1)
- # emacs (3)
- # fulcro (4)
- # hoplon (3)
- # hyperfiddle (91)
- # java (2)
- # juxt (5)
- # london-clojurians (1)
- # lsp (38)
- # malli (12)
- # nrepl (9)
- # off-topic (7)
- # polylith (15)
- # portal (49)
- # rdf (2)
- # re-frame (43)
- # releases (2)
- # shadow-cljs (30)
- # spacemacs (15)
- # sql (36)
- # tools-build (20)
- # xtdb (3)
Consistency in Emacs completion (not entirely sure this is the right place 🙂 ) doesn’t feel great to me. With the patches in this https://clojurians.slack.com/archives/CPABC1H61/p1683265127373769 I can load up a file and have a pretty good completion experience with no REPL. Not everything works Thread/ for example (System/ does work) and I guess anything you need the REPL for - importantly local project namespaces work nicely. I fire up CIDER which takes over and things like Thread/ start to work but local project namespaces don’t complete until I remember to evaluate the relevant files or every file in the project (sometimes that’s not possible). Is it possible to have CIDER completion fallback to LSP completion? Or am I doing something wrong?
Hmm, sorry, my fallback was about something else, find-definition: https://github.com/borkdude/prelude/blob/3018a3b99de894167a01d0273768f9fc077f92a3/personal/init.el#L412-L421 but perhaps you can create a similar completion fallback, haven't tried myself
(add-hook 'cider-mode-hook (lambda () (remove-hook 'completion-at-point-functions #'cider-complete-at-point t)))
that would make lsp do completion even in cider enabled buffers. There's no merging of candidates
Perhaps these tricks can be captured in the clojure-lsp docs / cc @UKFSJSM38
You can use cape (https://github.com/minad/cape) to combine lsp and cider completions, if that’s closer to what you want.
Yeah, it’s nice - just add something like this to completion-at-point-functions
: (cape-super-capf #'cider-complete-at-point #'lsp-completion-at-point)
(Well, not quite “just add” - either make sure it’s before the lsp and cider functions, or remove them).
The completion of .java files ( like JDK classes) is WIP in a open PR waiting for clj-kondo, soon should be available
I was thinking in have a page in clojure-lsp docs with tips and tweaks for each editor for the most common questions, would be helpful indeed
> The completion of .java files ( like JDK classes) is WIP in a open PR waiting for clj-kondo, That was the thread I referred to - some things like Thread/ didn’t work still - and I guess any macro stuff.
I did this
;; Add extensions
(use-package cape
:init
(defalias 'cape-cider-lsp
(cape-super-capf #'cider-complete-at-point #'lsp-completion-at-point))
(add-to-list 'completion-at-point-functions #'cape-cider-lsp)
(add-to-list 'completion-at-point-functions #'cape-file))
(use-package cider
:hook (cider-mode . (lambda () (add-to-list 'completion-at-point-functions #'cape-cider-lsp))))
And it worked a treat, using cider and falling back to lsp when cider didn’t find anythingI got tired of trying to setup clojure-lsp with vim. is there just a way I can find all references to a symbol using the cli?
there is no API function to find references yet, nobody asked for that yet as well, so please open a issue
it wasn’t for lack of guides, I followed three of them I found and had no luck
I’ll make an issue, thank you for your work
is there any part of the api I could call from a script so I could put together a cmd like clj-refs foo.bar/baz
from a project root
@U061E2UBT what vim was this? neovim even has lsp functionality built-in now right?
All the information you need comes from clj-kondo analysis, you can use it directly: https://github.com/clj-kondo/clj-kondo/tree/master/analysis You can even get this analysis through babashka and https://github.com/clj-kondo/clj-kondo-bb to make a quick CLI tool
I’m using neovim. It looks like it has native support for it, but I just now looked it up after reading your comment
k. perhaps @U7ERLH6JX can help you out, he also uses neovim + clojure-lsp
(I found this: https://github.com/lispyclouds/dotfiles/blob/09d9ec58fc418fe9850e45ad7bf881a3a131834b/nvim/lua/plugins/lsp.lua#L16)
thanks, I’ve run out of time to figure out much else today, but good to know kondo has an api for finding all refs to a var
thanks for the references
@UKFSJSM38 here’s the issue I filed as promised: https://github.com/clojure-lsp/clojure-lsp/issues/1572
This repo contains some stuff as well https://github.com/rafaeldelboni/cajus-nvim
@U061E2UBT would you like to find references in nvim too or just the command line?
if its just from nvim, my nvim dotfiles like mentioned or the standard lsp setup works. when on the symbol, running :lua vim.lsp.buf.references()
should do it. this could be bound to some key(s).
happy to answer any nvim specific things! also thanks a ton for parinfer, cant live without it 😄
thanks! I’ll have to look at this when I have more time, I’ll try the lua method next
These are the minimal steps that should get you going on clojure-lsp on nvim: • Make sure clojure-lsp is installed and on PATH • https://github.com/neovim/nvim-lspconfig is installed in nvim using your favourite package manager • This config is there to hook clojure-lsp up:
local lspconfig = require("lspconfig")
lspconfig.clojure_lsp.setup({})
• Opening up a clojure file after all this is done, should get everything working
• Bonus: https://github.com/gpanders/nvim-parinfer 😛
The setup I have is a bit more involved and nuanced but same in spirit.