From 1324baea728a11bf650303698881c682105155da Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 20 Oct 2022 20:50:34 +0300 Subject: [PATCH] Add Eglot to the menu bar * lisp/progmodes/eglot.el (eglot): Improve the doc string. * lisp/menu-bar.el (menu-bar-tools-menu): Add Eglot to the menu. --- lisp/menu-bar.el | 4 ++++ lisp/progmodes/eglot.el | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 526bccbbac9..849e0f77236 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1847,6 +1847,10 @@ mail status in mode line")) :help "Toggle automatic parsing in source code buffers (Semantic mode)" :button (:toggle . (bound-and-true-p semantic-mode)))) + (bindings--define-key menu [eglot] + '(menu-item "Language Server Support (Eglot)" eglot + :help "Start language server suitable for this buffer's major-mode")) + (bindings--define-key menu [ede] '(menu-item "Project Support (EDE)" global-ede-mode diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 0a7cb2a9aac..ada8b01fec2 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1039,26 +1039,30 @@ suitable root directory for a given LSP server's purposes." ;;;###autoload (defun eglot (managed-major-mode project class contact language-id &optional interactive) - "Manage a project with a Language Server Protocol (LSP) server. + "Start LSP server in support of PROJECT's buffers under MANAGED-MAJOR-MODE. -The LSP server of CLASS is started (or contacted) via CONTACT. -If this operation is successful, current *and future* file -buffers of MANAGED-MAJOR-MODE inside PROJECT become \"managed\" -by the LSP server, meaning information about their contents is -exchanged periodically to provide enhanced code-analysis via -`xref-find-definitions', `flymake-mode', `eldoc-mode', -`completion-at-point', among others. +This starts a Language Server Protocol (LSP) server suitable for the +buffers of PROJECT whose `major-mode' is MANAGED-MAJOR-MODE. +CLASS is the class of the LSP server to start and CONTACT specifies +how to connect to the server. Interactively, the command attempts to guess MANAGED-MAJOR-MODE -from current buffer, CLASS and CONTACT from -`eglot-server-programs' and PROJECT from +from the current buffer's `major-mode', CLASS and CONTACT from +`eglot-server-programs' looked up by the major mode, 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. +If it can't guess, it prompts the user for the mode and the server. +With a single \\[universal-argument] prefix arg, it always prompts for COMMAND. +With two \\[universal-argument], it also always prompts for MANAGED-MAJOR-MODE. + +The LSP server of CLASS is started (or contacted) via CONTACT. +If this operation is successful, current *and future* file +buffers of MANAGED-MAJOR-MODE inside PROJECT become \"managed\" +by the LSP server, meaning the information about their contents is +exchanged periodically with the server to provide enhanced +code-analysis via `xref-find-definitions', `flymake-mode', +`eldoc-mode', and `completion-at-point', among others. PROJECT is a project object as returned by `project-current'. -- 2.39.5