This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-16
Channels
- # adventofcode (24)
- # announcements (3)
- # aws (3)
- # babashka (16)
- # beginners (88)
- # biff (5)
- # calva (27)
- # cider (15)
- # cljs-dev (70)
- # clojure (87)
- # clojure-austin (3)
- # clojure-belgium (6)
- # clojure-europe (59)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojure-uk (3)
- # clojurescript (37)
- # data-science (2)
- # datalevin (40)
- # datomic (1)
- # emacs (23)
- # events (2)
- # graalvm (13)
- # graphql (7)
- # gratitude (1)
- # holy-lambda (193)
- # inf-clojure (15)
- # lsp (27)
- # malli (9)
- # off-topic (20)
- # polylith (6)
- # reitit (29)
- # releases (2)
- # scittle (13)
- # shadow-cljs (51)
- # transit (15)
- # xtdb (29)
Should Clojure LSP support completion of function names in a library using the aliases defined in the requires of an ns forms?
In this example (https://github.com/practicalli-john/completion-testing) I was expecting completion when typing edn/
or io/
but with LSP alone there is no completion of function names in these libraries. The full library name is recognised, i.e.
but functions are also not completed when using the full name
(ns practicalli.project
(:require [ :as io]
[clojure.edn :as edn]))
(def config (-> "deps.edn"
slurp
)) ; typing edn/ here does not show completions
This has been tested with LSP :: lsp-mode <tel:202211302254|20221130.2254>, Emacs 28.1, gnu/linux and similar results with Neovim 8 (although that does seem to autocomplete when the full name is used, i.e.
).
When using CIDER / Conjure with the REPL (without LSP) then completion works for the aliases as soon as I evaluate the relevant buffer or ns form.
Switching LSP back on blocks the completion that CIDER was providing, so there may also be a conflict in the client or a missing setting.
The completion from Conjure for aliases still works via the REPL with Clojure LSP enabled though, also suggesting there is an issue with Emacs lsp client.
Does this make any sense? Any known issues?Make sure you have https://github.com/ericdallo/dotfiles/blob/master/.doom.d/config.el#L58 in your config
Thanks. I've added that config but still have the same issue. There must be another issue with the Emacs configuration somewhere, I'll investigate further. Good to know it should be working though. Thank you
So completion is working for some namepaces (without any additional config), i.e. if I add a practicalli/utils.clj
file to the project and require [practicalli.utils :as utils]
then I get completion on utils/
So it seems to be namespace specific, but those are two namespaces from org.clojure/clojure so should be there in every project....
I'll do some more investigation.
Sounds like classpath scan issues, so completino and lots of other features may be working only for project analysis, can you confirm you clojure-lsp version via lsp-clojure-server-info
?
:server-version "2022.11.03-00.14.57",
:clj-kondo-version "2022.11.02",
If i manually copy the clojure/edn.clj from the Clojure source code into the project src
directory, then LSP is autocompleting. so I concur it seems some kind of class path issue.
I see there is a newer version of clojure-lsp, so I will give that a tryI seem to have success 🤞
I updated clojure-lsp, lsp-mode in Emacs, clojure-cli, removed an .lsp config and then removed my usual .config/clojure-lsp
configuration (that is when even utils would not complete any more). Adding my config back in and restarting everything and it seem to work now, both in Emacs and Neovim. Hopefully it stays that way.
Thanks for the advice.
@U05254DQM why would updating those matter? was the old .lsp config just a project specific one or was that a global config? I suspect if anything it might be the .config/clojure-lsp if that somehow aged and is broken. Asking because (as you know) i have the same issue.
i don-t have a .config/clojure-lsp in my project or root. So that can't be it.
I dont have any idea why it works and there are still a few inconsistencies, especially with aliases from the Clojure library. I'll experiment with other libraries.
Further experiments just make this even more weird, specifically in Emacs. Neovim seems to be working consistently at the moment.
In Emacs, some alias names for a library wont complete, but changing the name to something very different then does make it complete. Some libraries will complete with the fully qualified domain, eg. clojure.inspector but [clojure.inspector :as inspector]
doest not complete on inspector/
. If I change that to [clojure.inspector :as gadget]
then it will complete on gadget/
Totally bizarre. This suggests that some names are discarded or somehow clash, but this is just a wild guess and have no idea if that is even feasible or relevant.
As its now working on Neovim, it seems specific to the lsp client side in Emacs and/or completion config, or possibly a conflict with Cider (clojure-mode as this happens without the REPL running). It may also be related to LSP client package versions and/or configuration.
Yeah, john this is the behavior i have been seeing as well. Making an error report it has been really hard and because it comes and goes im always tempted to just move on and deal with it, but it's been a huge thorn in my side.
There is a way to debug that and for sure know if it's a server or client side issue, enable lsp-log-io
restart server, and then lsp-show-workspace-log
will show the communication between client and server and you can check what server is returning during completion
request
@UKFSJSM38 i don't have a lsp-show-workspace-log command.
my emacs command finder needs AI
I always search like lsp workspace show
, then the search results are always great and would avoid mistypes like that
oh weird, that does show it
adding the dashes apparently locks it down too much
thats super helpful.
What would the autocomplete look like in the logs roughly? There is so much activity. i don't see anything obvious.