diff --git a/src/fennel-ls/handlers.fnl b/src/fennel-ls/handlers.fnl index ae0d3f3..460deef 100644 --- a/src/fennel-ls/handlers.fnl +++ b/src/fennel-ls/handlers.fnl @@ -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)))) diff --git a/src/fennel-ls/state.fnl b/src/fennel-ls/state.fnl index 7e16b8a..3b4449b 100644 --- a/src/fennel-ls/state.fnl +++ b/src/fennel-ls/state.fnl @@ -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)))