[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs a63916f928 062/120: Tweak eglot mode-line menus
From: |
João Távora |
Subject: |
feature/eglot2emacs a63916f928 062/120: Tweak eglot mode-line menus |
Date: |
Thu, 20 Oct 2022 07:16:53 -0400 (EDT) |
branch: feature/eglot2emacs
commit a63916f92855aa4a0035f60a31d8a0f991194583
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Tweak eglot mode-line menus
* eglot.el (eglot-manual): Rename from eglot-read-documentation
(eglot-customize): Delete.
(eglot-menu): Rename from eglot-menu-map. Rework.
(eglot--mode-line-format): Tweak.
(eglot-menu-string): Rename from eglot-mode-line-string.
(Flymake customization): New source section.
* NEWS.md: Tweak.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/792
---
lisp/progmodes/eglot.el | 164 +++++++++++++++++++++---------------------------
1 file changed, 70 insertions(+), 94 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index c8de62c154..6d0b66c2a1 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -322,8 +322,8 @@ let the buffer grow forever."
"If non-nil, activate Eglot in cross-referenced non-project files."
:type 'boolean)
-(defcustom eglot-mode-line-string "eglot"
- "String displayed on the mode line when Eglot is active."
+(defcustom eglot-menu-string "eglot"
+ "String displayed in mode line when Eglot is active."
:type 'string)
(defvar eglot-withhold-process-id nil
@@ -1745,98 +1745,71 @@ If it is activated, also signal textDocument/didOpen."
(call-interactively what)
(force-mode-line-update t))))))
-(defun eglot-read-documentation ()
- "Open the on-line documentation."
- (interactive)
- (browse-url "https://github.com/joaotavora/eglot#readme";))
+(defun eglot-manual () "Open on-line documentation."
+ (interactive) (browse-url "https://github.com/joaotavora/eglot#readme";))
-(defun eglot-customize ()
- "Customize Eglot."
- (interactive)
- (customize-group "eglot"))
-
-(easy-menu-define eglot-menu-map nil "Eglot"
- (let ((action-help
- "Get possible code actions for the active region or the point"))
- `("Eglot"
- ;; Commands for getting information and customization.
- ["Read the documentation" eglot-read-documentation
- :help "Read the on-line documentation"]
- ["Customize Eglot" eglot-customize
- :help "Customize Eglot globally"]
- "--"
- ;; xref like commands.
- ["Find definitions" xref-find-definitions
- :help "Find definitions of the identifier at point"
- :active (eglot--server-capable :definitionProvider)]
- ["Find references" xref-find-references
- :help "Find references to the identifier at point"
- :active (eglot--server-capable :referencesProvider)]
- ["Find symbols in workspace (apropos)" xref-find-apropos
- :help "Find symbols matching a query"
- :active (eglot--server-capable :workspaceSymbolProvider)]
- ["Find declaration" eglot-find-declaration
- :help "Find declaration for the identifier at point"
- :active (eglot--server-capable :declarationProvider)]
- ["Find implementation" eglot-find-implementation
- :help "Find implementation for the identifier at point"
- :active (eglot--server-capable :implementationProvider)]
- ["Find type definition" eglot-find-typeDefinition
- :help "Find type definition for the identifier at point"
- :active (eglot--server-capable :typeDefinitionProvider)]
- "--"
- ;; LSP-related commands (mostly Eglot's own commands).
- ["Rename symbol" eglot-rename
- :help "Rename current symbol"
- :active (eglot--server-capable :renameProvider)]
- ["Format buffer" eglot-format-buffer
- :help "Format contents of the buffer"
- :active (eglot--server-capable :documentFormattingProvider)]
- ["Format region" eglot-format
- :help "Format the active region"
- :active (and (region-active-p)
- (eglot--server-capable :documentRangeFormattingProvider))]
- ["Show all diagnostics" flymake-show-buffer-diagnostics
- :help "Show diagnostics for current buffer (flymake)"]
- ["Show documentation for point" eldoc-doc-buffer
- :help "Show documentation for point in a buffer (eldoc)"]
- "--"
- ;; Code-action commands.
- ["All possible code actions" eglot-code-actions
- :help ,action-help
- :active (eglot--server-capable :codeActionProvider)]
- ["Organize imports" eglot-code-action-organize-imports
- :help ,action-help
- :visible (eglot--server-capable :codeActionProvider)]
- ["Extract" eglot-code-action-extract
- :help ,action-help
- :visible (eglot--server-capable :codeActionProvider)]
- ["Inline" eglot-code-action-inline
- :help ,action-help
- :visible (eglot--server-capable :codeActionProvider)]
- ["Rewrite" eglot-code-action-rewrite
- :help ,action-help
- :visible (eglot--server-capable :codeActionProvider)]
- ["Quickfix" eglot-code-action-quickfix
- :help ,action-help
- :visible (eglot--server-capable :codeActionProvider)])))
-
-(easy-menu-define eglot-debug-map nil "Debugging the server communication"
+(easy-menu-define eglot-menu nil "Eglot"
+ `("Eglot"
+ ;; Commands for getting information and customization.
+ ["Read manual" eglot-manual]
+ ["Customize Eglot" (lambda () (interactive) (customize-group "eglot"))]
+ "--"
+ ;; xref like commands.
+ ["Find definitions" xref-find-definitions
+ :help "Find definitions of identifier at point"
+ :active (eglot--server-capable :definitionProvider)]
+ ["Find references" xref-find-references
+ :help "Find references to identifier at point"
+ :active (eglot--server-capable :referencesProvider)]
+ ["Find symbols in workspace (apropos)" xref-find-apropos
+ :help "Find symbols matching a query"
+ :active (eglot--server-capable :workspaceSymbolProvider)]
+ ["Find declaration" eglot-find-declaration
+ :help "Find declaration for identifier at point"
+ :active (eglot--server-capable :declarationProvider)]
+ ["Find implementation" eglot-find-implementation
+ :help "Find implementation for identifier at point"
+ :active (eglot--server-capable :implementationProvider)]
+ ["Find type definition" eglot-find-typeDefinition
+ :help "Find type definition for identifier at point"
+ :active (eglot--server-capable :typeDefinitionProvider)]
+ "--"
+ ;; LSP-related commands (mostly Eglot's own commands).
+ ["Rename symbol" eglot-rename
+ :active (eglot--server-capable :renameProvider)]
+ ["Format buffer" eglot-format-buffer
+ :active (eglot--server-capable :documentFormattingProvider)]
+ ["Format active region" eglot-format
+ :active (and (region-active-p)
+ (eglot--server-capable :documentRangeFormattingProvider))]
+ ["Show Flymake diagnostics for buffer" flymake-show-buffer-diagnostics]
+ ["Show Flymake diagnostics for project" flymake-show-project-diagnostics]
+ ["Show Eldoc documentation at point" eldoc-doc-buffer]
+ "--"
+ ["All possible code actions" eglot-code-actions
+ :active (eglot--server-capable :codeActionProvider)]
+ ["Organize imports" eglot-code-action-organize-imports
+ :visible (eglot--server-capable :codeActionProvider)]
+ ["Extract" eglot-code-action-extract
+ :visible (eglot--server-capable :codeActionProvider)]
+ ["Inline" eglot-code-action-inline
+ :visible (eglot--server-capable :codeActionProvider)]
+ ["Rewrite" eglot-code-action-rewrite
+ :visible (eglot--server-capable :codeActionProvider)]
+ ["Quickfix" eglot-code-action-quickfix
+ :visible (eglot--server-capable :codeActionProvider)]))
+
+(easy-menu-define eglot-server-menu nil "Monitor server communication"
'("Debugging the server communication"
- ["Go to events buffer" eglot-events-buffer
- :help "Display the log buffer of the server communication"]
- ["Go to the stderr buffer" eglot-stderr-buffer
- :help "Display the error buffer for current LSP server"]
- ["Reconnect to server" eglot-reconnect
- :help "Reconnect to the current LSP server"]
- ["Quit server" eglot-shutdown
- :help "Politely ask the LSP server to quit"]
+ ["Reconnect to server" eglot-reconnect]
+ ["Quit server" eglot-shutdown]
"--"
- ["Customize events buffers"
+ ["LSP events buffer" eglot-events-buffer]
+ ["Server stderr buffer" eglot-stderr-buffer]
+ ["Customize event buffer size"
(lambda ()
(interactive)
- (customize-variable 'eglot-events-buffer-size))
- :help "Customize variable eglot-events-buffer-size"]))
+ (customize-variable 'eglot-events-buffer-size))]))
(defun eglot--mode-line-props (thing face defs &optional prepend)
"Helper for function `eglot--mode-line-format'.
@@ -1862,12 +1835,12 @@ Uses THING, FACE, DEFS and PREPEND."
(last-error (and server (jsonrpc-last-error server))))
(append
`(,(propertize
- eglot-mode-line-string
+ eglot-menu-string
'face 'eglot-mode-line
'mouse-face 'mode-line-highlight
- 'help-echo "Eglot: an LSP client\nmouse-1: Display minor mode menu"
+ 'help-echo "Eglot: Emacs LSP client\nmouse-1: Display minor mode menu"
'keymap (let ((map (make-sparse-keymap)))
- (define-key map [mode-line down-mouse-1] eglot-menu-map)
+ (define-key map [mode-line down-mouse-1] eglot-menu)
map)))
(when nick
`(":"
@@ -1875,9 +1848,9 @@ Uses THING, FACE, DEFS and PREPEND."
nick
'face 'eglot-mode-line
'mouse-face 'mode-line-highlight
- 'help-echo (format "Project '%s'\nmouse-1: LSP debugging menu" nick)
+ 'help-echo (format "Project '%s'\nmouse-1: LSP server control menu"
nick)
'keymap (let ((map (make-sparse-keymap)))
- (define-key map [mode-line down-mouse-1] eglot-debug-map)
+ (define-key map [mode-line down-mouse-1]
eglot-server-menu)
map))
,@(when last-error
`("/" ,(eglot--mode-line-props
@@ -1899,6 +1872,9 @@ still unanswered LSP requests to the server\n"))))))))
(add-to-list 'mode-line-misc-info
`(eglot--managed-mode (" [" eglot--mode-line-format "] ")))
+
+;;; Flymake customization
+;;;
(put 'eglot-note 'flymake-category 'flymake-note)
(put 'eglot-warning 'flymake-category 'flymake-warning)
(put 'eglot-error 'flymake-category 'flymake-error)
- feature/eglot2emacs f0b9018f52 018/120: Properly print error message of eglot-alternatives, (continued)
- feature/eglot2emacs f0b9018f52 018/120: Properly print error message of eglot-alternatives, João Távora, 2022/10/20
- feature/eglot2emacs ae7315b5f1 016/120: ; fix license statement, João Távora, 2022/10/20
- feature/eglot2emacs 49e46c3d53 017/120: Add up-to-date server executables for html/css/json, João Távora, 2022/10/20
- feature/eglot2emacs 34c7da506d 020/120: Support autoimporttext from pyright language server, João Távora, 2022/10/20
- feature/eglot2emacs 9adb310e08 021/120: Don't error out on unsupported diagnostic.codedescription, João Távora, 2022/10/20
- feature/eglot2emacs 0f44d338f1 025/120: Support optional diagnostic.tags, João Távora, 2022/10/20
- feature/eglot2emacs 0739cdcf20 031/120: Improve backwards-compatibility of eglot-mode-map, João Távora, 2022/10/20
- feature/eglot2emacs 9710754080 042/120: Add support for optional completionitem.tags, João Távora, 2022/10/20
- feature/eglot2emacs c2d97d22aa 056/120: Implement on-type-formatting support, João Távora, 2022/10/20
- feature/eglot2emacs 1d9542cbe8 059/120: Protect against empty firsttriggercharacter strings, João Távora, 2022/10/20
- feature/eglot2emacs a63916f928 062/120: Tweak eglot mode-line menus,
João Távora <=
- feature/eglot2emacs 4beab004d9 070/120: Ensure exit-function of eglot-c-at-point runs on exact match, João Távora, 2022/10/20
- feature/eglot2emacs 29f2ec2471 071/120: Consider diagnostic.code when generating flymake diagnostics, João Távora, 2022/10/20
- feature/eglot2emacs cc5d1a5a72 091/120: Always default eglot-strict-mode to nil, João Távora, 2022/10/20
- feature/eglot2emacs e74e199912 093/120: Add out-of-box support for perl lsp server, João Távora, 2022/10/20
- feature/eglot2emacs d2e842bbf5 098/120: Prefer documentchanges to changes in server-initiated edits, João Távora, 2022/10/20
- feature/eglot2emacs e5f77f8ca5 100/120: Rework readme.md about workspace configuration again, João Távora, 2022/10/20
- feature/eglot2emacs ec7d63cbe7 105/120: Don't return hash tables from e-w-configuration-plist, João Távora, 2022/10/20
- feature/eglot2emacs 1780b93d66 111/120: Make clojure-lsp handle more major modes at once, João Távora, 2022/10/20
- feature/eglot2emacs 0848387fa2 115/120: Fix docstring of eglot-list-connections-mode, João Távora, 2022/10/20
- feature/eglot2emacs cf0ba0197a 007/120: Add support for the mint language server, João Távora, 2022/10/20