[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 40bba97 08/10: Per #687: provide context for fine
From: |
Stefan Monnier |
Subject: |
[elpa] externals/eglot 40bba97 08/10: Per #687: provide context for finer project-find-functions |
Date: |
Wed, 19 May 2021 21:52:14 -0400 (EDT) |
branch: externals/eglot
commit 40bba97b0ab81ea3e70884b754d59a2e5af5e5f5
Author: João Távora <joaotavora@gmail.com>
Commit: GitHub <noreply@github.com>
Per #687: provide context for finer project-find-functions
* eglot.el (eglot--guess-contact): Use eglot--current-project.
(eglot): Adjust docstring.
(eglot-lsp-context): New variable.
(eglot--current-project): New helper.
(eglot--maybe-activate-editing-mode, eglot--eclipse-jdt-contact):
Use eglot--current-project.
---
eglot.el | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/eglot.el b/eglot.el
index 29024ad..fc82367 100644
--- a/eglot.el
+++ b/eglot.el
@@ -777,7 +777,6 @@ be guessed."
((not guessed-mode)
(eglot--error "Can't guess mode to manage for `%s'"
(current-buffer)))
(t guessed-mode)))
- (project (or (project-current) `(transient . ,default-directory)))
(lang-id-and-guess (eglot--lookup-mode guessed-mode))
(language-id (car lang-id-and-guess))
(guess (cdr lang-id-and-guess))
@@ -827,7 +826,21 @@ be guessed."
:test #'equal))))
guess
(eglot--error "Couldn't guess for `%s'!" managed-mode))))
- (list managed-mode project class contact language-id)))
+ (list managed-mode (eglot--current-project) class contact language-id)))
+
+(defvar eglot-lsp-context)
+(put 'eglot-lsp-context 'variable-documentation
+ "Dynamically non-nil when searching for projects in LSP context.")
+
+(defun eglot--current-project ()
+ "Return a project object for Eglot's LSP purposes.
+This relies on `project-current' and thus on
+`project-find-functions'. Functions in the latter
+variable (which see) can query the value `eglot-lsp-context' to
+decide whether a given directory is a project containing a
+suitable root directory for a given LSP server's purposes."
+ (let ((eglot-lsp-context t))
+ (or (project-current) `(transient . ,default-directory))))
;;;###autoload
(defun eglot (managed-major-mode project class contact language-id
@@ -844,13 +857,16 @@ exchanged periodically to provide enhanced code-analysis
via
Interactively, the command attempts to guess MANAGED-MAJOR-MODE
from current buffer, CLASS and CONTACT from
-`eglot-server-programs' and PROJECT from `project-current'. If
-it can't guess, the user is prompted. With a single
+`eglot-server-programs' and PROJECT from
+`project-find-functions'. The search for active projects in this
+context binds `eglot-lsp-context' (which see).
+
+If it can't guess, the user is prompted. With a single
\\[universal-argument] prefix arg, it always prompt for COMMAND.
With two \\[universal-argument] prefix args, also prompts for
MANAGED-MAJOR-MODE.
-PROJECT is a project instance as returned by `project-current'.
+PROJECT is a project object as returned by `project-current'.
CLASS is a subclass of `eglot-lsp-server'.
@@ -1537,8 +1553,7 @@ If it is activated, also signal textDocument/didOpen."
eglot--cached-server
(setq eglot--cached-server
(cl-find major-mode
- (gethash (or (project-current)
- `(transient . ,default-directory))
+ (gethash (eglot--current-project)
eglot--servers-by-project)
:key #'eglot--major-mode))))
(setq eglot--unreported-diagnostics `(:just-opened . nil))
@@ -2939,9 +2954,8 @@ If INTERACTIVE, prompt user for details."
((string= system-type "darwin") "config_mac")
((string= system-type "windows-nt") "config_win")
(t "config_linux"))))
- (project (or (project-current) `(transient . ,default-directory)))
(workspace
- (expand-file-name (md5 (project-root project))
+ (expand-file-name (md5 (project-root (eglot--current-project)))
(concat user-emacs-directory
"eglot-eclipse-jdt-cache"))))
(unless jar
- [elpa] externals/eglot updated (fc221c8 -> 1ac06d0), Stefan Monnier, 2021/05/19
- [elpa] externals/eglot efac602 02/10: Fix #673: declare eglot--cached-server before use, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot a0a6218 01/10: Fix #670: make eglot-current-server work in notification handlers, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot 9330397 03/10: Close #677: switch default langserver for OCaml to ocamllsp, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot c6e05e0 04/10: Per #677: mention ocaml-lsp in the README, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot 6f27bc1 06/10: Allow LSP languageId to be overridden via eglot-server-programs, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot 3f1ad3b 07/10: Close #685: Fix Emacs 28 warning by avoiding positional args in define-minor-mode, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot 40bba97 08/10: Per #687: provide context for finer project-find-functions,
Stefan Monnier <=
- [elpa] externals/eglot b06589b 09/10: Fix #679: correct path/URI when using TRAMP from MS Windows, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot 1ac06d0 10/10: Fix #76: manage cross-referenced files outside project in same server, Stefan Monnier, 2021/05/19
- [elpa] externals/eglot 98943f1 05/10: Add a completion-category-defaults entry, Stefan Monnier, 2021/05/19