[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs 523547321e 102/120: Allow :initializationoptions in
From: |
João Távora |
Subject: |
feature/eglot2emacs 523547321e 102/120: Allow :initializationoptions in eglot-server-programs |
Date: |
Thu, 20 Oct 2022 07:17:07 -0400 (EDT) |
branch: feature/eglot2emacs
commit 523547321e4caca6fc966bd71ecd7b60a6e98f73
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Allow :initializationoptions in eglot-server-programs
Also see https://github.com/joaotavora/eglot/issues/1038.
This feature was poorly tested, and simply wouldn't work when trying
to initialize the server object.
The simple solution is to ignore :initializationOptions initarg in
this context. It is still stored separately as and accessed as the
'eglot--saved-initargs' slot.
Another complication arises in eglot--guess-contact, which tried too
hard to be able to compose an interactive prompt (when the server
program can't be found). The solution is just to give up when
:autoport or :initializationOptions is found. It's not easy or
practical to have the user provide non-string arguments via a string
interface like the minibuffer.
* eglot.el (initialize-instance :before eglot-lsp-server): Don't pass
:initializationOptions initarg onward.
(eglot--guess-contact): Simplify. Don't try heroics with
:autoport and :initializationOptions.
* eglot-tests.el (eglot-server-programs-simple-missing-executable):
Update test.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/940
---
lisp/progmodes/eglot.el | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index ff94d5ca5f..493bfcc7d6 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -796,6 +796,9 @@ treated as in `eglot-dbind'."
:documentation
"Represents a server. Wraps a process for LSP communication.")
+(cl-defmethod initialize-instance :before ((_server eglot-lsp-server)
&optional args)
+ (cl-remf args :initializationOptions))
+
;;; Process management
(defvar eglot--servers-by-project (make-hash-table :test #'equal)
@@ -929,10 +932,10 @@ be guessed."
(base-prompt
(and interactive
"Enter program to execute (or <host>:<port>): "))
- (program-guess
+ (full-program-invocation
(and program
- (combine-and-quote-strings (cl-subst ":autoport:"
- :autoport guess))))
+ (cl-every #'stringp guess)
+ (combine-and-quote-strings guess)))
(prompt
(and base-prompt
(cond (current-prefix-arg base-prompt)
@@ -942,25 +945,23 @@ be guessed."
((and program
(not (file-name-absolute-p program))
(not (eglot--executable-find program t)))
- (concat (format "[eglot] I guess you want to run `%s'"
- program-guess)
- (format ", but I can't find `%s' in PATH!"
program)
- "\n" base-prompt)))))
+ (if full-program-invocation
+ (concat (format "[eglot] I guess you want to run
`%s'"
+ full-program-invocation)
+ (format ", but I can't find `%s' in PATH!"
+ program)
+ "\n" base-prompt)
+ (eglot--error
+ (concat "`%s' not found in PATH, but can't form"
+ " an interactive prompt for to fix %s!")
+ program guess))))))
(contact
(or (and prompt
- (let ((s (read-shell-command
- prompt
- program-guess
- 'eglot-command-history)))
- (if (string-match "^\\([^\s\t]+\\):\\([[:digit:]]+\\)$"
- (string-trim s))
- (list (match-string 1 s)
- (string-to-number (match-string 2 s)))
- (cl-subst
- :autoport ":autoport:" (split-string-and-unquote s)
- :test #'equal))))
- guess
- (eglot--error "Couldn't guess for `%s'!" managed-mode))))
+ (read-shell-command
+ prompt
+ full-program-invocation
+ 'eglot-command-history))
+ guess)))
(list managed-mode (eglot--current-project) class contact language-id)))
(defvar eglot-lsp-context)
- feature/eglot2emacs 965e1378f1 053/120: Use bounds of thing at point when asking for code actions, (continued)
- feature/eglot2emacs 965e1378f1 053/120: Use bounds of thing at point when asking for code actions, João Távora, 2022/10/20
- feature/eglot2emacs a38ce8b28f 052/120: Add simple support for workspacefolders, João Távora, 2022/10/20
- feature/eglot2emacs cb562118cb 047/120: Don't strip invisible text when formatting hover string, João Távora, 2022/10/20
- feature/eglot2emacs 904556f662 058/120: Easier initializationoptions in eglot-server-programs, João Távora, 2022/10/20
- feature/eglot2emacs 49e56e47d8 066/120: Solve flymake diagnostics synchronization problems, João Távora, 2022/10/20
- feature/eglot2emacs 917e8ffa31 080/120: Add support for jedi-language-server, João Távora, 2022/10/20
- feature/eglot2emacs 9dbc18cbfa 084/120: Tweak some details, fix some bugs, João Távora, 2022/10/20
- feature/eglot2emacs 2a12f622dc 087/120: Eglot-workspace-configuration can be a function, João Távora, 2022/10/20
- feature/eglot2emacs 1986c4df88 089/120: Reply more reasonably to server's workspace/applyedit, João Távora, 2022/10/20
- feature/eglot2emacs bef332a983 101/120: Adjust last commit about workspace configuration, João Távora, 2022/10/20
- feature/eglot2emacs 523547321e 102/120: Allow :initializationoptions in eglot-server-programs,
João Távora <=
- feature/eglot2emacs 68b9c03b44 106/120: Don't use three-argument plist-get, João Távora, 2022/10/20
- feature/eglot2emacs 0829d5e7a2 107/120: Revert "fix jdtls support", João Távora, 2022/10/20
- feature/eglot2emacs b205479035 108/120: Fix blunder in eglot--guess-contact, João Távora, 2022/10/20
- feature/eglot2emacs b07fa37d04 113/120: Add half-baked m-x eglot-list-connections, João Távora, 2022/10/20
- feature/eglot2emacs 4f1f06375a 045/120: Prevent empty diagnostic tags vector hiding main fontification, João Távora, 2022/10/20
- feature/eglot2emacs be47552331 049/120: Change capability 'documentchanges' to t, João Távora, 2022/10/20
- feature/eglot2emacs 27ba1994fe 038/120: ; fix thinko in last commit, João Távora, 2022/10/20