This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-23
Channels
- # announcements (3)
- # aws (1)
- # beginners (44)
- # biff (6)
- # calva (31)
- # cider (26)
- # clerk (12)
- # clj-kondo (9)
- # clojure (17)
- # clojure-dev (18)
- # clojure-europe (13)
- # clojure-norway (45)
- # clojure-uk (4)
- # clojurescript (34)
- # datomic (54)
- # dev-tooling (14)
- # emacs (19)
- # events (7)
- # honeysql (2)
- # hyperfiddle (51)
- # lsp (34)
- # malli (24)
- # matrix (1)
- # missionary (5)
- # off-topic (27)
- # re-frame (6)
- # reagent (18)
- # releases (2)
- # sci (6)
- # shadow-cljs (88)
- # vim (9)
More questions about completions: how does clojure-lsp
handle keyword completions (ie. how are the available candidates chosen/found)?
In my current setup it looks like completing something like :foo|
suggests candidates like :foo/bar
, :foobar
etc but this seems to require that these keywords appear in the same namespace
yeah, we have custom logic for those things https://github.com/clojure-lsp/clojure-lsp/blob/2124c1c3e0d2e3fcd00eb128fe55b0c0843111c4/lib/src/clojure_lsp/feature/completion.clj#L627-L642
your case may be https://github.com/clojure-lsp/clojure-lsp/blob/2124c1c3e0d2e3fcd00eb128fe55b0c0843111c4/lib/src/clojure_lsp/feature/completion.clj specifically
So AFAI remember, we don't have logic to exclude namespaced keywrods, so :foo|
will bring all namespaced and simple keywords
Ah sorry, I may have been unclear in my problem statement: what I'm seeing is that if I go to a different namespace, completing for :foo|
returns no matches
That is, the set of all possible candidates seems to be derived from the keywords from the current namespace, and nowhere else
ah, ok. Does that also apply to keywords like :foo/bar
?
checking https://github.com/clojure-lsp/clojure-lsp/blob/2124c1c3e0d2e3fcd00eb128fe55b0c0843111c4/lib/src/clojure_lsp/feature/completion.clj#L302, yes, and I think it's not intended, but a tech issue. we complete only things available in the current ns for when we identified it's a keyword
I think that deserves a issue, but I'd like to see more use cases in the issue for why that makes sense
interesting, I guess there's some special handling for clojure.spec? Registering a spec in ns1 with some keyword enabled completion for that kw in ns2.
I'm not finding the code proving that works, but it should, I did for spec and reframe keyword-defs
ah https://github.com/clojure-lsp/clojure-lsp/blob/2124c1c3e0d2e3fcd00eb128fe55b0c0843111c4/lib/src/clojure_lsp/feature/completion.clj#L635-L642, there is a difference for those 2 conds
right, ok. Well I'm quite happy to know this is at least somewhat the expected behaviour and thanks a bunch for investigating this
regarding the use case: we use a lot of qualified keywords for datomic attributes, like :user/first-name
and such and it might be nice to be able to complete those anywhere
yeah, that makes sense, that would be useful for my day development with datomic as well 😂 I think we only present those keywords if they were written in the current ns indeed, would be nice to improve that if this behavior is confirmed for namespaced keywords, not sure for simple keywords
I can write up a feature request issue for this with some use case examples
piggybacking on this conversion - is there an option to enable global keyword completions for all keywords a la intellij + cursive?
Meaning let's say I have :access-token
in one namespace and I am in a different namespace, I'd like to get that completion too.
cursive doesn´t use lsp, it has it's own way of completions. There is https://github.com/clojure-lsp/clojure-lsp-intellij but it's not compatible with cursive
I think the idea was that cursive already provides completion for all keywords so would it be possible for clojure-lsp to also support such a functionality
sad RAM noises in my 200k+ loc clojure projects 🙂
clojure-lsp already has all keyword analysis, so that should not affect performance 🤞 but is that a thing? when do you want to complete keywords from other ns in this ns?

like, should we show only project keywords? keywords from deps as well? I'm not understanding exactly when this is useful
Let's say you use a long keyword several times in your codebase, something like :user-settings
. Not only do you save keystrokes when you need to introduce it to a different namespace, but more importantly you save on keyword implosion since in a large codebase it's a matter of when not if before someone adds :users-settings
Yes, you get more completions but they've never bothered me since you can easily narrow down to the one you want and modern completion sorting algorithms are quite good at getting you there with a few keystrokes.