branch: externals/elpa commit 8448d9b03b2813971093fd8420e739ee0b1856dd Author: João Távora <joaotav...@gmail.com> Commit: João Távora <joaotav...@gmail.com>
Work with any old directory, no formal project needed Actually, uses a "transient project" which project-current returns if desperate. * README.md: Update * eglot.el (eglot--current-process) (eglot--current-process-or-lose): Simplify. (eglot): Maybe prompt user for project. --- README.md | 10 +++++----- eglot.el | 18 ++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 39ec752..4683951 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@ Eglot (add-to-list 'load-path "/path/to/eglot") (require 'eglot) ; Requires emacs 26! -;; Now find some project file inside some Git-controlled dir +;; Now find some source file, any source file M-x eglot ``` *That's it*. If you're lucky, this guesses the LSP executable to start -for the language of your choice, or it prompts you to enter one: +for the language of your choice. Otherwise, it prompts you to enter one: `M-x eglot` currently guesses and works out-of-the-box with: @@ -29,9 +29,9 @@ customize `eglot-server-programs`: (add-to-list 'eglot-server-programs '(fancy-mode . ("fancy-language-server" "--args""))) ``` -Let me know how well it works and I'll add it to the list, or submit a -PR. You can also enter a `server:port` pattern to connect to an LSP -server. To skip the guess and always be prompted use `C-u M-x eglot`. +Let me know how well it works and we can add it to the list. You can +also enter a `server:port` pattern to connect to an LSP server. To +skip the guess and always be prompted use `C-u M-x eglot`. # Commands and keybindings diff --git a/eglot.el b/eglot.el index 2e872dc..c1b63ea 100644 --- a/eglot.el +++ b/eglot.el @@ -24,8 +24,7 @@ ;;; Commentary: -;; M-x eglot in some file under some .git controlled dir should get -;; you started, but see README.md. +;; Simply M-x eglot should be enough to get you started, but see README.md. ;;; Code: @@ -79,15 +78,13 @@ lasted more than that many seconds." (defun eglot--current-process () "The current logical EGLOT process." - (let* ((cur (project-current)) - (processes (and cur (gethash cur eglot--processes-by-project)))) - (cl-find major-mode processes :key #'eglot--major-mode))) + (let* ((probe (or (project-current) (cons 'transient default-directory)))) + (cl-find major-mode (gethash probe eglot--processes-by-project) + :key #'eglot--major-mode))) (defun eglot--current-process-or-lose () "Return the current EGLOT process or error." - (or (eglot--current-process) - (eglot--error "No current EGLOT process%s" - (if (project-current) "" " (Also no current project)")))) + (or (eglot--current-process) (eglot--error "No current EGLOT process"))) (defmacro eglot--define-process-var (var-sym initval &optional doc) @@ -326,11 +323,8 @@ MANAGED-MAJOR-MODE. INTERACTIVE is t if called interactively." (interactive (eglot--interactive)) - (let* ((project (project-current)) + (let* ((project (project-current 'maybe)) (short-name (eglot--project-short-name project))) - (unless project (eglot--error "Cannot work without a current project!")) - (unless command (eglot--error "Don't know how to start EGLOT for %s buffers" - major-mode)) (let ((current-process (eglot--current-process))) (if (and (process-live-p current-process) interactive