[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 5b24d46fa2: Fix #940: Allow :initializationOption
From: |
ELPA Syncer |
Subject: |
[elpa] externals/eglot 5b24d46fa2: Fix #940: Allow :initializationOptions in eglot-server-programs |
Date: |
Sat, 17 Sep 2022 19:57:33 -0400 (EDT) |
branch: externals/eglot
commit 5b24d46fa2c5711ddbdb9cc050ef04ea2516b830
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix #940: Allow :initializationOptions in eglot-server-programs
Also see #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.
---
NEWS.md | 3 ++-
eglot-tests.el | 3 ++-
eglot.el | 41 +++++++++++++++++++++--------------------
3 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 534cd1c914..f771327191 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -21,7 +21,7 @@ New menus help discover Eglot's features and show which of
them are
supported by the current server. Menus can be customized away via
`eglot-menu-string`, making space in mode-line.
-##### Easier to use LSP initialize.initializationOptions ([#901][github#901],
[#845][github#845])
+##### Easier to use LSP initialize.initializationOptions ([#901][github#901],
[#845][github#845], [#940][github#940])
In `eglot-server-programs` a plist may be appended to the usual list
of strings passed as command line arguments. The value of its
`:initializationOptions` key constructs the corresponding LSP JSON
@@ -400,6 +400,7 @@ and now said bunch of references-->
[github#901]: https://github.com/joaotavora/eglot/issues/901
[github#905]: https://github.com/joaotavora/eglot/issues/905
[github#922]: https://github.com/joaotavora/eglot/issues/922
+[github#940]: https://github.com/joaotavora/eglot/issues/940
[github#952]: https://github.com/joaotavora/eglot/issues/952
[github#967]: https://github.com/joaotavora/eglot/issues/967
[github#994]: https://github.com/joaotavora/eglot/issues/994
diff --git a/eglot-tests.el b/eglot-tests.el
index 16591446da..0146503d9c 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -1066,7 +1066,8 @@ are bound to the useful return values of
(eglot--guessing-contact (interactive-p prompt-args guessed-class
guessed-contact)
(should (equal (not prompt-args) (not interactive-p)))
(should (equal guessed-class 'eglot-lsp-server))
- (should (equal guessed-contact '("a-missing-executable.exe"))))))
+ (should (or prompt-args
+ (equal guessed-contact '("a-missing-executable.exe")))))))
(ert-deftest eglot-server-programs-executable-multiple-major-modes ()
(let ((eglot-server-programs '(((bar-mode foo-mode) "some-executable")))
diff --git a/eglot.el b/eglot.el
index ff94d5ca5f..493bfcc7d6 100644
--- a/eglot.el
+++ b/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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/eglot 5b24d46fa2: Fix #940: Allow :initializationOptions in eglot-server-programs,
ELPA Syncer <=