Since nowadays I tend to have a lot of concurrent worktrees and projects in flight I jump between, the memory usage in clojure-lsp gets to be a lot. So I made https://github.com/nvoxland/clojure-lite-lsp which: • Uses a single indexer process across all projects • Uses a shared SQLite for the data rather than memory • The per-project LSP instance is a lightweight db-query process • No support for editing-related LSP operations, just help with reading Overall, on a large clojure project it ends up with about 300mb for the indexer (auto starts/stops on demand) plus 20mb per project I have open. The db approach trades off some speed, but in practice it's not been noticable. Let me know what you think. I looked a bit at trying to make it a mode clojure-lsp could run in, but it seemed enough different that it ended up a completely different codebase.
Thanks for sharing, I think we can think on how to have this lite mode on clojure-lsp itself, I can see usages and things that we could disable to make it faster for people that seek this
will take a closer look later
Thanks for looking. The code is mostly vibed, and counting it as beta/experimentation for now.
the general notion of “just be a convenient interface over a db of kondo analysis and don’t worry about editing actions” allows for interesting implementations
I did try a bit with doing some LRU paging of the in-memory data clojure-lsp had but wasn't able to get the overall memory down as much in that vs. just purely running off the db. You may be able to figure out a better way to do that, though, @ericdallo It's also doing content-based hashing so that it's able to re-use the same indexed data across worktrees where most of the codebase is the same.
i vibed one in rust with basically instructions of “power go to definition, find usages and then keep kondo analysis for lsp” and it starts up in milliseconds. super nice
i found out that clojure-lsp doesn't handle auto-namespaced keywords in completions. is this intentional? or something y'all are interested in supporting?
I think that's supposed to work
it's probably intended to work, but right now it doesn't and leads to weird interactions in my editor where the resulting completion list is [] and thus fails to complete anything 😩
cc @ericdallo
hmm, in my own editor I don't get any keyword completion right now
is keyword completion something you have to opt into?
nope, but you may have opt-out if you are excluding keywords analysis in config
I have not
I don't get any completion here:
(ns foo)
::foo/bar
::foo/baz
::foo/bar
:fooo/bar
:foo
(defn foo [])
(foo)
:fo<TAB>so it's supposed to work yes, troubleshooting like https://clojure-lsp.io/troubleshooting/#client-server-log is a good way to know if it's a client or server issue
will have to drop, but can check replies of this later
aliased namespaced keywords (a/foo) work, as you solved in a 2023 pr. but auto namespaced keywords (foo) don't autocomplete because rewrite clj reads them as :?_current-ns_?/foo and not :some.ns/foo
and rewrite-clj doesn't work at all if you try to get completions on ::| because it can't parse :: meaningfully lol
i gotta ask @lee about that, maybe we can make rewrite-clj handle that better
note that clj-kondo deals with this fine. we decided not to handle this in rewrite-clj as it's not a clojure environment, just a reader, but if I recall correctly, we do have provided options for it
i.e. you can give rewrite-clj the options it needs based on the ns form yourself
oh i mean a double colon with nothing else
oh right
(::| ) where the pipe is my cursor
I don't know if this even needs to go through rewrite-clj for clojure-lsp
well, the current code path does lol
oh this has been "in discussion" in rewrite-clj for 6 years lol: https://github.com/clj-commons/rewrite-clj/issues/87
i just commented with this situation, so i'll follow up there and hopefully we can get it "fixed" there and then upstream in everything else
Please don’t judge an issue by its age. We likely gave it some good thought but did not land on path is all.
oh yeah, i'm laughing to have rediscovered an existing discussion after spending a couple hours wrestling with this in clojure-lsp alone
lol i spent a couple hours seeing if i could wrangle rewrite-clj to accept invalid keywords and have to call it quits. it's a tricky problem and i am not up to the task, so i'll settle for solving the slightly easier problem of valid autoresolved keywords in clojure-lsp
good catch @nbtheduke, yeah this was never supported indeed in lsp and as you saw it i't not trivial, but I'm open to improve that parse code in clojure-lsp to support it
i put up a clojure-lsp PR to fix the ::fo| use case, and i'm exploring how to accomplish invalid keywords/symbols in rewrite-clj but that's a much larger project for later lol