single out the Eglot client because it does completions differently

This commit is contained in:
XeroOl 2024-04-27 00:45:18 -05:00
parent f96620a028
commit a4251e5d21
2 changed files with 12 additions and 3 deletions

View File

@ -200,8 +200,14 @@ Every time the client sends a message, it gets handled by a function in the corr
(let [input-range (message.multisym->range self file ?symbol -1)
?completions (field-completion self file ?symbol split)]
(if ?completions
(each [_ completion (ipairs ?completions)]
(set completion.textEdit {:newText completion.label :range input-range})))
(if self.EGLOT_COMPLETION_QUIRK_MODE
(let [prefix (string.gsub (tostring ?symbol) "[^.:]*$" "")]
(each [_ completion (ipairs ?completions)]
(set completion.filterText (.. prefix completion.label))
(set completion.insertText (.. prefix completion.label))
(set completion.textEdit {:newText completion.label :range input-range})))
(each [_ completion (ipairs ?completions)]
(set completion.textEdit {:newText completion.label :range input-range}))))
?completions))))

View File

@ -131,7 +131,10 @@ However, when not an option, fennel-ls will fall back to positionEncoding=\"utf-
(set self.modules {})
(set self.root-uri params.rootUri)
(set self.position-encoding (choose-position-encoding params))
(set self.configuration (make-configuration (?. params :initializationOptions :fennel-ls))))
(set self.configuration (make-configuration (?. params :initializationOptions :fennel-ls)))
;; Eglot does completions differently than every other client I've seen so far, in that it considers foo.bar to be one "symbol".
;; If the user types `foo.b`, every other client accepts `bar` as a completion, bun eglot wants the full `foo.bar` multisym.
(set self.EGLOT_COMPLETION_QUIRK_MODE (= (?. params :clientInfo :name) :Eglot)))
(λ write-configuration [self ?configuration]
(set self.configuration (make-configuration ?configuration)))