[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs 904556f662 058/120: Easier initializationoptions in
From: |
João Távora |
Subject: |
feature/eglot2emacs 904556f662 058/120: Easier initializationoptions in eglot-server-programs |
Date: |
Thu, 20 Oct 2022 07:16:53 -0400 (EDT) |
branch: feature/eglot2emacs
commit 904556f662fa188c97f3b56d3555c58a3dc84afe
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Easier initializationoptions in eglot-server-programs
Per https://github.com/joaotavora/eglot/issues/845.
* NEWS.md: Update.
* eglot.el (eglot-server-programs): Document new syntax.
(eglot-initialization-options): Can use initializationOptions from
server's saved initargs.
(eglot--connect): Allow a plist to be appended to a server
contact.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/901
---
lisp/progmodes/eglot.el | 51 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index d71e5966a8..ade8a7c711 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -218,17 +218,24 @@ CONTACT can be:
PROGRAM is called with ARGS and is expected to serve LSP requests
over the standard input/output channels.
+* A list (PROGRAM [ARGS...] :initializationOptions OPTIONS),
+ whereupon PROGRAM is called with ARGS as in the first option,
+ and the LSP \"initializationOptions\" JSON object is
+ constructed from OPTIONS. If OPTIONS is a unary function, it
+ is called with the server instance and should return a JSON
+ object.
+
* A list (HOST PORT [TCP-ARGS...]) where HOST is a string and
PORT is a positive integer for connecting to a server via TCP.
Remaining ARGS are passed to `open-network-stream' for
upgrading the connection with encryption or other capabilities.
* A list (PROGRAM [ARGS...] :autoport [MOREARGS...]), whereupon a
- combination of the two previous options is used. First, an
- attempt is made to find an available server port, then PROGRAM
- is launched with ARGS; the `:autoport' keyword substituted for
- that number; and MOREARGS. Eglot then attempts to establish a
- TCP connection to that port number on the localhost.
+ combination of previous options is used. First, an attempt is
+ made to find an available server port, then PROGRAM is launched
+ with ARGS; the `:autoport' keyword substituted for that number;
+ and MOREARGS. Eglot then attempts to establish a TCP
+ connection to that port number on the localhost.
* A cons (CLASS-NAME . INITARGS) where CLASS-NAME is a symbol
designating a subclass of `eglot-lsp-server', for representing
@@ -627,7 +634,11 @@ treated as in `eglot-dbind'."
(cl-defgeneric eglot-initialization-options (server)
"JSON object to send under `initializationOptions'."
- (:method (_s) eglot--{})) ; blank default
+ (:method (s)
+ (let ((probe (plist-get (eglot--saved-initargs s) :initializationOptions)))
+ (cond ((functionp probe) (funcall probe s))
+ (probe)
+ (t eglot--{})))))
(cl-defgeneric eglot-register-capability (server method id &rest params)
"Ask SERVER to register capability METHOD marked with ID."
@@ -1116,18 +1127,22 @@ This docstring appeases checkdoc, that's all."
(setq autostart-inferior-process inferior)
connection))))
((stringp (car contact))
- `(:process
- ,(lambda ()
- (let ((default-directory default-directory))
- (make-process
- :name readable-name
- :command (setq server-info (eglot--cmd contact))
- :connection-type 'pipe
- :coding 'utf-8-emacs-unix
- :noquery t
- :stderr (get-buffer-create
- (format "*%s stderr*" readable-name))
- :file-handler t)))))))
+ (let* ((probe (cl-position-if #'keywordp contact))
+ (more-initargs (and probe (cl-subseq contact probe)))
+ (contact (cl-subseq contact 0 probe)))
+ `(:process
+ ,(lambda ()
+ (let ((default-directory default-directory))
+ (make-process
+ :name readable-name
+ :command (setq server-info (eglot--cmd contact))
+ :connection-type 'pipe
+ :coding 'utf-8-emacs-unix
+ :noquery t
+ :stderr (get-buffer-create
+ (format "*%s stderr*" readable-name))
+ :file-handler t)))
+ ,@more-initargs)))))
(spread (lambda (fn) (lambda (server method params)
(let ((eglot--cached-server server))
(apply fn server method (append params
nil))))))
- feature/eglot2emacs a598352750 104/120: Allow eglot-workspace-configuration to be a plist, (continued)
- feature/eglot2emacs a598352750 104/120: Allow eglot-workspace-configuration to be a plist, João Távora, 2022/10/20
- feature/eglot2emacs b633c29648 112/120: Rename "eglot -> eglot" in docstrings, João Távora, 2022/10/20
- feature/eglot2emacs 5b902b5cbb 110/120: Add support for "single server, multiple modes", João Távora, 2022/10/20
- feature/eglot2emacs 4071eaf8ad 116/120: * eglot.el (version): actually bump to 1.9, João Távora, 2022/10/20
- feature/eglot2emacs 9801e217f9 118/120: Rework header of eglot.el, João Távora, 2022/10/20
- feature/eglot2emacs 77f3157dcd 048/120: Use new jdtls script for eclipse jdt, João Távora, 2022/10/20
- feature/eglot2emacs 349f6b5f78 050/120: Don't advertise didchangewatchedfiles on tramp, João Távora, 2022/10/20
- 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 <=
- 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, 2022/10/20
- 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