all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
@ 2023-06-24 19:40 Wilhelm Kirschbaum
  2023-06-24 20:07 ` Wilhelm Kirschbaum
  0 siblings, 1 reply; 7+ messages in thread
From: Wilhelm Kirschbaum @ 2023-06-24 19:40 UTC (permalink / raw)
  To: 64274


Calling imenu when eglot is enabled it will request
textDocument/documentSymbol even if the server has not declared it 
as a
capability.  I believe this issue is with `eglot-imenu'.

The client will recover if the server replies with an error, but 
outputs
an ugly error.

In GNU Emacs 30.0.50 (build 11, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-06-24 built on 
 melissa.local
Repository revision: a3df33f1c2f8beb08ea9fc4b91eaeae78db79489
Repository branch: master
System Description: Arch Linux

Configured using:
 'configure --with-pgtk --with-tree-sitter --with-json
 --with-native-compilation=aot'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ 
JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY 
PDUMPER
PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF 
TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM GTK3 ZLIB
Important settings:
  value of $LANG: en_ZA.UTF-8
  locale-coding-system: utf-8-unix

Major mode: mu4e:main

Minor modes in effect:
  mu4e-search-minor-mode: t
  mu4e-update-minor-mode: t
  mu4e-context-minor-mode: t
  global-floatpays-mode: t
  marginalia-mode: t
  savehist-mode: t
  vertico-mode: t
  global-corfu-mode: t
  electric-pair-mode: t
  yas-global-mode: t
  global-flycheck-mode: t
  global-treesit-auto-mode: t
  global-diff-hl-mode: t
  global-git-commit-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  global-jinx-mode: t
  which-key-mode: t
  override-global-mode: t
  pixel-scroll-precision-mode: t
  repeat-mode: t
  winner-mode: t
  save-place-mode: t
  which-function-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  overwrite-mode: overwrite-mode-binary

Load-path shadows:
/home/wilhelm/.config/emacs/elpa/transient-20230602.2121/transient 
hides /usr/local/share/emacs/30.0.50/lisp/transient

Features:
(shadow mm-archive sort smiley gnus-cite mail-extr textsec 
uni-scripts
idna-mapping ucs-normalize uni-confusable textsec-check qp view 
emacsbug
goto-addr tramp-cmds magit-extras consult-imenu misearch 
multi-isearch
shortdoc completion help-fns radix-tree pulse bug-reference 
tramp-cache
time-stamp tramp-sh tramp tramp-loaddefs trampver 
tramp-integration
tramp-compat face-remap files-x sgml-mode dired-aux vc-hg vc-bzr 
vc-src
vc-sccs vc-cvs vc-rcs gnus-dired diff-hl-dired cape 
display-line-numbers
disp-table whitespace init.el mu4e-alert advice time ht alert 
log4e
notifications gntp mu4e mu4e-org mu4e-main mu4e-view gnus-art 
mm-uu
mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group 
gnus-undo
gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source 
utf7 nnoo
parse-time iso8601 gnus-spec gnus-int gnus-range gnus-win gnus 
nnheader
range mu4e-headers mu4e-compose mu4e-draft mu4e-actions smtpmail
mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message 
flow-fill
mule-util hl-line mu4e-contacts mu4e-update mu4e-folders 
mu4e-server
mu4e-context mu4e-obsolete mu4e-vars mu4e-helpers mu4e-config ido 
srht
plz git-related verb js c-ts-common denote mastodon 
mastodon-search
mastodon-toot facemenu mastodon-iso persist mastodon-http request
flycheck-package package-build package-build-badges package-recipe
package-lint let-alist finder lisp-mnt eat elfeed-show 
elfeed-search shr
pixel-fill kinsoku elfeed-csv elfeed elfeed-curl elfeed-log 
elfeed-db
elfeed-lib url-queue url-file xml-query fontaine 
modus-vivendi-theme
modus-themes embark-consult consult magit-bookmark bookmark 
embark-org
org-element org-persist xdg org-id org-refile avl-tree embark ffap
marginalia savehist orderless vertico kind-icon svg-lib svg dom 
xml
corfu-terminal popon corfu elec-pair posframe yasnippet-snippets
yasnippet flycheck treesit-auto avy org-toc org-contrib org-clock
ob-shell ob-elixir async ob-async org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-src ob-comint org-pcomplete org-list
org-footnote org-faces org-entities ob-emacs-lisp ob-core ob-eval
org-cycle org-table ol org-fold org-fold-core org-keys oc 
org-loaddefs
cal-menu calendar cal-loaddefs org-version org-compat org-macs 
yaml-mode
terraform-mode hcl-mode php-mode mode-local speedbar ezimage 
dframe
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align 
php-face
php php-project cc-engine cc-vars cc-defs markdown-mode color 
noutline
outline erlang-start erlang etags fileloop generator tempo align 
mix
elixir-ts-mode heex-ts-mode eglot external-completion jsonrpc xref
flymake-proc flymake project ert debug backtrace find-func
dockerfile-mode sh-script smie treesit executable pcmpl-args 
pcmpl-linux
pcmpl-unix git-modes gitignore-mode gitconfig-mode conf-mode
gitattributes-mode diff-hl log-view vc-dir ewoc vc git-timemachine
vc-git vc-dispatcher magit-submodule magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch 
magit-clone
magit-remote magit-commit magit-sequence magit-notes 
magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files 
magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
magit-diff smerge-mode diff diff-mode git-commit log-edit message
sendmail yank-media puny rfc822 mml mml-sec epa epg rfc6068 
epg-config
gnus-util time-date mm-decode mm-bodies mm-encode mail-parse 
rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev 
mail-utils
gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert
magit-margin magit-transient magit-process with-editor comp 
comp-cstr
warnings rx shell pcomplete server magit-mode transient magit-git
magit-base magit-section format-spec cursor-sensor crm functions 
jinx
compat use-package-bind-key which-key ripgrep thingatpt grep ag 
vc-svn
compile text-property-search comint ansi-osc ansi-color find-dired 
s
dired-rainbow dired-subtree dired-hacks-utils dash dired 
dired-loaddefs
all-the-icons all-the-icons-faces data-material data-weathericons
data-octicons data-fileicons data-faicons data-alltheicons
exec-path-from-shell edmacro kmacro bind-key easy-mmode
use-package-ensure use-package-core finder-inf ag-autoloads
all-the-icons-autoloads avy-autoloads cape-autoloads
consult-dir-autoloads corfu-terminal-autoloads corfu-autoloads
deft-autoloads denote-autoloads diff-hl-autoloads
dired-rainbow-autoloads dired-subtree-autoloads
dired-hacks-utils-autoloads dockerfile-mode-autoloads
dumb-jump-autoloads eat-autoloads elfeed-autoloads 
elpher-autoloads
embark-consult-autoloads consult-autoloads embark-autoloads
emmet-mode-autoloads erc-hl-nicks-autoloads erc-image-autoloads
erlang-autoloads exec-path-from-shell-autoloads exunit-autoloads
fireplace-autoloads flycheck-package-autoloads flycheck-autoloads
fontaine-autoloads git-modes-autoloads git-timemachine-autoloads
jinx-autoloads kind-icon-autoloads lsp-mode-autoloads f-autoloads
lv-autoloads magit-autoloads pcase git-commit-autoloads
marginalia-autoloads markdown-mode-autoloads mastodon-autoloads
mix-autoloads mu4e-alert-autoloads ht-autoloads alert-autoloads
log4e-autoloads gntp-autoloads ob-async-autoloads async-autoloads
ob-elixir-autoloads orderless-autoloads org-contrib-autoloads
org-roam-autoloads magit-section-autoloads emacsql-autoloads
ox-hugo-autoloads package-build-autoloads derived 
package-lint-autoloads
pcmpl-args-autoloads persist-autoloads php-mode-autoloads
pkg-info-autoloads epl-autoloads popon-autoloads popup-autoloads
posframe-autoloads request-autoloads ripgrep-autoloads 
spinner-autoloads
srht-autoloads plz-autoloads svg-lib-autoloads 
terraform-mode-autoloads
hcl-mode-autoloads tomelr-autoloads transient-autoloads
treesit-auto-autoloads ts-autoloads s-autoloads dash-autoloads
verb-autoloads vertico-autoloads web-mode-autoloads 
which-key-autoloads
with-editor-autoloads info compat-autoloads yaml-mode-autoloads
yasnippet-snippets-autoloads yasnippet-autoloads package 
browse-url url
url-proxy url-privacy url-expand url-methods url-history 
url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers 
url-parse
auth-source eieio eieio-core cl-macs password-cache json map 
byte-opt gv
bytecomp byte-compile url-vars native cl-extra help-mode 
pixel-scroll
cua-base subr-x repeat winner ring saveplace cl-seq which-func 
imenu
autorevert filenotify cus-edit pp cus-load icons wid-edit 
cl-loaddefs
cl-lib early-init rmc iso-transl tooltip cconv eldoc paren 
electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd 
fontset
image regexp-opt fringe tabulated-list replace newcomment 
text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow 
isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple 
cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang 
vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew 
greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button 
loaddefs
theme-loaddefs faces cus-face macroexp files window 
text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget 
keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk 
pgtk
lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 1274429 1936458) (symbols 48 80205 135)
 (strings 32 316832 86354) (string-bytes 1 10274587)
 (vectors 16 143778) (vector-slots 8 3608027 4190577)
 (floats 8 1424 3487) (intervals 56 17512 19707) (buffers 984 69))





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
  2023-06-24 19:40 bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities Wilhelm Kirschbaum
@ 2023-06-24 20:07 ` Wilhelm Kirschbaum
  2023-06-24 21:56   ` João Távora
  0 siblings, 1 reply; 7+ messages in thread
From: Wilhelm Kirschbaum @ 2023-06-24 20:07 UTC (permalink / raw)
  To: Wilhelm Kirschbaum; +Cc: 64274

[-- Attachment #1: Type: text/plain, Size: 47 bytes --]


Here is a naive patch which fixes it for me.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-eglot-imenu-when-the-server-does-not-support-it.patch --]
[-- Type: text/x-patch, Size: 2202 bytes --]

From 9a1389305d92f0e08d39d2ff5540cb494c012f12 Mon Sep 17 00:00:00 2001
From: Wilhelm H Kirschbaum <wkirschbaum@gmail.com>
Date: Sat, 24 Jun 2023 21:54:30 +0200
Subject: [PATCH 1/1] Fix eglot-imenu when the server does not support it

A language server might not support textDocument/documentSymbol, so we
need to check first.

* lisp/progmodes/eglot.el (eglot-imenu): Check for the
textDocument/documentSymbol capability before requesting.
---
 lisp/progmodes/eglot.el | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index e2478f2dde3..265cfc88579 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3351,16 +3351,17 @@ eglot--imenu-DocumentSymbol
 (defun eglot-imenu ()
   "Eglot's `imenu-create-index-function'.
 Returns a list as described in docstring of `imenu--index-alist'."
-  (let* ((res (eglot--request (eglot--current-server-or-lose)
-                              :textDocument/documentSymbol
-                              `(:textDocument
-                                ,(eglot--TextDocumentIdentifier))
-                              :cancel-on-input non-essential))
-         (head (and (cl-plusp (length res)) (elt res 0))))
-    (when head
-      (eglot--dcase head
-        (((SymbolInformation)) (eglot--imenu-SymbolInformation res))
-        (((DocumentSymbol)) (eglot--imenu-DocumentSymbol res))))))
+  (when (eglot--server-capable :textDocument/documentSymbol)
+    (let* ((res (eglot--request (eglot--current-server-or-lose)
+                                :textDocument/documentSymbol
+                                `(:textDocument
+                                  ,(eglot--TextDocumentIdentifier))
+                                :cancel-on-input non-essential))
+           (head (and (cl-plusp (length res)) (elt res 0))))
+      (when head
+        (eglot--dcase head
+          (((SymbolInformation)) (eglot--imenu-SymbolInformation res))
+          (((DocumentSymbol)) (eglot--imenu-DocumentSymbol res)))))))
 
 (cl-defun eglot--apply-text-edits (edits &optional version)
   "Apply EDITS for current buffer if at VERSION, or if it's nil."
-- 
2.41.0


[-- Attachment #3: Type: text/plain, Size: 9 bytes --]


Wilhelm

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
  2023-06-24 20:07 ` Wilhelm Kirschbaum
@ 2023-06-24 21:56   ` João Távora
  2023-06-24 22:35     ` Wilhelm Kirschbaum
  0 siblings, 1 reply; 7+ messages in thread
From: João Távora @ 2023-06-24 21:56 UTC (permalink / raw)
  To: Wilhelm Kirschbaum; +Cc: 64274

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

Thanks, i think the patch is in the right direction, but you could use
eglot--server-capable-or-lose.

Can you test it?

João

On Sat, Jun 24, 2023, 21:12 Wilhelm Kirschbaum <wkirschbaum@gmail.com>
wrote:

>
> Here is a naive patch which fixes it for me.
>
>
> Wilhelm
>

[-- Attachment #2: Type: text/html, Size: 669 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
  2023-06-24 21:56   ` João Távora
@ 2023-06-24 22:35     ` Wilhelm Kirschbaum
  2023-06-24 23:06       ` João Távora
  0 siblings, 1 reply; 7+ messages in thread
From: Wilhelm Kirschbaum @ 2023-06-24 22:35 UTC (permalink / raw)
  To: João Távora; +Cc: 64274


> Thanks, i think the patch is in the right direction, but you 
> could use eglot--server-capable-or-lose.
>

The idea is to transparently just fall back to the non-eglot imenu 
and
not sure if I want to see a warning for this every time imenu gets
called. 

> Can you test it?

I tested eglot--server-capable-or-lose and it is not ideal, 
because not
only does it not fall back, it spams the warning and if the 
languages.

>
> João
>
> On Sat, Jun 24, 2023, 21:12 Wilhelm Kirschbaum 
> <wkirschbaum@gmail.com> wrote:
>
>  Here is a naive patch which fixes it for me.
>
>  Wilhelm






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
  2023-06-24 22:35     ` Wilhelm Kirschbaum
@ 2023-06-24 23:06       ` João Távora
  2023-06-24 23:21         ` Wilhelm Kirschbaum
  0 siblings, 1 reply; 7+ messages in thread
From: João Távora @ 2023-06-24 23:06 UTC (permalink / raw)
  To: Wilhelm Kirschbaum; +Cc: 64274

Wilhelm Kirschbaum <wkirschbaum@gmail.com> writes:

>> Thanks, i think the patch is in the right direction, but you could
>> use eglot--server-capable-or-lose.
>>
>
> The idea is to transparently just fall back to the non-eglot imenu and
> not sure if I want to see a warning for this every time imenu gets
> called. > Can you test it?

OK, this makes sense.  Then please test this instead.

João

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index e2478f2dde3..c353ab6fce0 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3348,9 +3348,11 @@ eglot--imenu-DocumentSymbol
                             (mapcar (lambda (c) (apply #'dfs c)) children))))))
     (mapcar (lambda (s) (apply #'dfs s)) res)))
 
-(defun eglot-imenu ()
+(cl-defun eglot-imenu ()
   "Eglot's `imenu-create-index-function'.
 Returns a list as described in docstring of `imenu--index-alist'."
+  (unless (eglot--server-capable :textDocument/documentSymbol)
+    (cl-return-from eglot-imenu))
   (let* ((res (eglot--request (eglot--current-server-or-lose)
                               :textDocument/documentSymbol
                               `(:textDocument





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
  2023-06-24 23:06       ` João Távora
@ 2023-06-24 23:21         ` Wilhelm Kirschbaum
  2023-07-01 22:07           ` João Távora
  0 siblings, 1 reply; 7+ messages in thread
From: Wilhelm Kirschbaum @ 2023-06-24 23:21 UTC (permalink / raw)
  To: João Távora; +Cc: 64274



> OK, this makes sense.  Then please test this instead.
>
> João
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index e2478f2dde3..c353ab6fce0 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -3348,9 +3348,11 @@ eglot--imenu-DocumentSymbol
>                              (mapcar (lambda (c) (apply #'dfs 
>                              c)) children))))))
>      (mapcar (lambda (s) (apply #'dfs s)) res)))
>  
> -(defun eglot-imenu ()
> +(cl-defun eglot-imenu ()
>    "Eglot's `imenu-create-index-function'.
>  Returns a list as described in docstring of 
>  `imenu--index-alist'."
> +  (unless (eglot--server-capable :textDocument/documentSymbol)
> +    (cl-return-from eglot-imenu))
>    (let* ((res (eglot--request (eglot--current-server-or-lose)
>                                :textDocument/documentSymbol
>                                `(:textDocument

Yes, this works. Thank you. :)

Wilhelm





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities
  2023-06-24 23:21         ` Wilhelm Kirschbaum
@ 2023-07-01 22:07           ` João Távora
  0 siblings, 0 replies; 7+ messages in thread
From: João Távora @ 2023-07-01 22:07 UTC (permalink / raw)
  To: Wilhelm Kirschbaum, 64274-done

Pushed this patch to master and marking this done.

João

On Sun, Jun 25, 2023 at 12:22 AM Wilhelm Kirschbaum
<wkirschbaum@gmail.com> wrote:
>
>
>
> > OK, this makes sense.  Then please test this instead.
> >
> > João
> >
> > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> > index e2478f2dde3..c353ab6fce0 100644
> > --- a/lisp/progmodes/eglot.el
> > +++ b/lisp/progmodes/eglot.el
> > @@ -3348,9 +3348,11 @@ eglot--imenu-DocumentSymbol
> >                              (mapcar (lambda (c) (apply #'dfs
> >                              c)) children))))))
> >      (mapcar (lambda (s) (apply #'dfs s)) res)))
> >
> > -(defun eglot-imenu ()
> > +(cl-defun eglot-imenu ()
> >    "Eglot's `imenu-create-index-function'.
> >  Returns a list as described in docstring of
> >  `imenu--index-alist'."
> > +  (unless (eglot--server-capable :textDocument/documentSymbol)
> > +    (cl-return-from eglot-imenu))
> >    (let* ((res (eglot--request (eglot--current-server-or-lose)
> >                                :textDocument/documentSymbol
> >                                `(:textDocument
>
> Yes, this works. Thank you. :)
>
> Wilhelm



-- 
João Távora





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-01 22:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-24 19:40 bug#64274: 30.0.50; Eglot requests textDocument/documentSymbol if its not declared in the server capabilities Wilhelm Kirschbaum
2023-06-24 20:07 ` Wilhelm Kirschbaum
2023-06-24 21:56   ` João Távora
2023-06-24 22:35     ` Wilhelm Kirschbaum
2023-06-24 23:06       ` João Távora
2023-06-24 23:21         ` Wilhelm Kirschbaum
2023-07-01 22:07           ` João Távora

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.