This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-29
Channels
- # announcements (4)
- # babashka (66)
- # beginners (7)
- # cljs-dev (6)
- # clojure (12)
- # clojure-europe (28)
- # clojure-nl (1)
- # clojure-norway (75)
- # clojure-uk (16)
- # clojuredesign-podcast (1)
- # clojurescript (16)
- # datascript (6)
- # deps-new (2)
- # dev-tooling (40)
- # exercism (1)
- # fulcro (92)
- # hyperfiddle (25)
- # lsp (19)
- # malli (1)
- # meander (2)
- # nrepl (9)
- # off-topic (5)
- # pathom (1)
- # practicalli (1)
- # re-frame (20)
- # reitit (14)
- # releases (1)
- # sci (86)
- # shadow-cljs (216)
- # sql (13)
- # testing (4)
- # tools-deps (4)
- # vscode (3)
Every once in a while I have trouble getting completions from lsp-mode
in emacs. I spent some time debugging this and it looks like sometimes when I try to active completions on some e.g. (some-alias/|)
form (`|` is the cursor) LSP sends a textDocument/documentHighlight
request instead of a textDocument/completion
. Any idea what might cause this?
usually the buffer I'm working gets stuck in this state for a while and I can usually fix it by doing random stuff (clear the form and try again, save the file, etc) until the completions start working again.
It feels like there's a cache of previous completions somewhere in lsp-mode
and when I run completion-at-point
it will a) sometimes fetch completions from LSP with textDocument/completion
, b) display the completion choices (in corfu
) and c) also send a textDocument/documentHighlight
.
When everything is working I can observe all three a,b, and c happening or sometimes only b and c (I guess LSP is using the cache here).
But sometimes it seems only c happens, as if the cache is empty but LSP still decides not to query for the completions, or something like that.
Or this could just as well be some configuration issue between corfu
and lsp-mode
, even though I've tried following https://github.com/minad/corfu/wiki#configuring-corfu-for-lsp-mode :man-shrugging:
My guess is a misconfiguration with Corfu, I never used it, and my completions are 100% stable and I use it and trigger manually a lot as well
yeah, seems likely
I had the same issues with corfu + eglot. I am back on company mode and it works flawlessly now
I did on eglot back then. I thought it was the culprit and corfu maintainer was involved in the discussion
I did some more testing by disabling corfu and/or starting a new session with lsp-start-plain
and in both cases I could replicate the issue.
But when testing completions on some random java project with the eclipse jdtls LSP server I could not replicate the issue :thinking_face:
Interesting, so it happens only with clojure-lsp? I can try repro the issue but never had that before
yeah, but on the other hand I've spent 99.9% of the time testing this with clojure-lsp
. There's a few too many moving pieces here so I think I'll just try to bisect when and where this happens (or not happens).
I did find some tickets where lsp-mode
+ the typescript lsp server exhibited something a bit similar (https://github.com/emacs-lsp/lsp-mode/issues/3961 and the related https://github.com/typescript-language-server/typescript-language-server/issues/631) where, if I understood correctly, there was some issue in the language server. But most of the discussions about the internal details of the LSP completion protocols goes way over my head so no idea if these are in any way relevant to what I'm experiencing.
I think I'll try to test some other language servers and also setup calva so I can try another lsp client with clojure-lsp to see where I can replicate this.
Yeah that would be helpful, vscode LSP client tends to be stable so it's good to prove if an issue is on server or not
I'm unable to replicate the exact issue in vscodium + calva, so I guess this rules out clojure-lsp
. I'll see if I can setup eglot
to check if this only occurs with lsp-mode
I did notice one silly case where completions fail for both emacs and vscodium: writing multiple incomplete forms, e.g. something like
(ns some-ns
(:require [some-lib :as a]
[other-lib :as b]))
(a/) ;<- "Invalid symbol: a/."
(b/) ;<- "Invalid symbol: b/."
where moving the cursor after either a/
or b/
will fail to provide completions. But fix (or remove) one of them and then the other one works again. But I guess this is a rather silly example, not sure how often people would write incomplete forms like that.