1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00
Commit graph

1183 commits

Author SHA1 Message Date
João Távora
2d1e891eea Eglot: half-decent pull diagnostics support
Implement basic LSP 3.17 pull diagnostics ('textDocument/diagnostic').
Only diagnostics for the current document are requested.  This is
chiefly because virtually no server has been found to support the
'relatedDocumentSupport' sub-capability which would allow to test this.

* etc/EGLOT-NEWS: Announce pull diagnostics support.

* lisp/progmodes/eglot.el (eglot-client-capabilities): Announce
:diagnostic capability.
(eglot--flymake-diag-type): New function.
(eglot--flymake-make-diag): New function.
(eglot--flymake-push-report-fn): Rename from
eglot--current-flymake-report-fn.
(eglot-flymake-backend): Check for :diagnosticProvider and dispatch
to pull or push path.
(eglot--flymake-pull): New function.
(eglot--flymake-push): Rename from eglot--report-to-flymake.
(eglot-handle-notification textDocument/publishDiagnostics): Use
eglot--flymake-make-diag helper.
(eglot-ignored-server-capabilities): Add diagnosticProvider
2025-12-14 22:01:29 +00:00
João Távora
27f0a3fd86 Eglot: revert changes to eglot-rename's interface (bug#79757)
After some weeks of testing, I've changed by mind on this.  Having the
current name appear passed the INITIAL-VALUE to read-from-minibuffer is
a jarring backward-incompatible change.  There is no evidence that the
majority of renames are simple tweaks to the existing names, and even
less evidence that these tweaks happen frequently at the end of the
symbol.

Therefore it's better for the ergonomics of this commonly used command
to leave the code as it was and simply rely on C-n to bring in the
default value (which is the current symbol name), instead of forcing
users accustomed to the previous behaviour remember to press sth like
M-DEL to clean the input.

* lisp/progmodes/eglot.el (eglot-rename): Tweak.
2025-11-30 13:52:30 +00:00
Eli Zaretskii
ae4416f8f7 eglot: add "ty" LSP server for Python to 'eglot-server-programs'
* lisp/progmodes/eglot.el (eglot-server-programs): Add "ty" LSP
server for Python.  Patch by Steve Purcell <steve@sanityinc.com>.
2025-11-29 13:21:56 +02:00
João Távora
a542ed23e4 Eglot: re-do semantic tokens again (bug#79374)
After a week of intense testing, found out there were various insidious
bugs related to out-of-date requests that rear their heads in different
typing patterns.  One way to sort this out and still minimize the number
of requests is to have Eglot's semtok code be aware of the states a
request for tokens can be in: inexistent/invalid, unsent, sent, valid.

The needs and optimization opportunities for servers that support "full"
and "full/delta" requests are considerably different from the ones of
servers which only support "full" and "range".  The latter seem to be in
the minority, so for now I've removed the range requests.  These servers
should still work with "full" requests.

In a further bug, at least two servers (clangd and lean) were found to
plainly abuse the semanticTokens/refresh server request.  This confuses
the state logic.  The solution is to simply no-op this request handler,
it doesn't seem to do anything useful.

Finally, when auto-reverting with preserve-modes (as done by vc-revert
and auto-revert-mode), the font-lock state needs to be reinitialized.
Fixed this in eglot--after-revert-hook.

* lisp/progmodes/eglot.el (eglot-client-capabilities): Don't announce
ranged request support.
(eglot--docver): Rename from eglot--versioned-identifier.
(eglot--diagnostics)
(eglot--flymake-diagnostics)
(eglot-handle-notification)
(eglot--signal-textDocument/didOpen)
(eglot--report-to-flymake)
(eglot--apply-text-edits)
(eglot--VersionedTextDocumentIdentifier): Use eglot--docver.
(eglot--send-changes-hook): Rename from eglot--document-changed-hook.
(eglot--after-change): Don't run eglot--send-changes-hook here.
(eglot--signal-textDocument/didChange): Run it here.
(eglot--semtok-state): Rename from eglot--semtok-cache.
(eglot--semtok-inflight): Delete.
(eglot--handle-request semanticTokens/refresh): Nullify.
(eglot-semantic-tokens-mode): Tweak.
(eglot--semtok-after-send-changes): New hook.
(eglot--semtok-request)
(eglot--semtok-font-lock): Rewrite.
(eglot--after-revert-hook): Reinitialize semtok state.

Co-authored-by: Lua Viana Reis <me@lua.blog.br>
2025-11-28 21:32:20 +00:00
João Távora
80a84130a4 ; Eglot: remove/address a FIXME added by Stefan Monnier
According to the commit msg of:

   commit 0816da8e78
   Author: João Távora <joaotavora@gmail.com>
   Date:   Mon Oct 21 16:07:38 2019 +0100

This is needed because M-x vc-revert preserves (or used to
preserve) major modes on revert.

* lisp/progmodes/eglot.el (eglot--after-revert-hook): Remove FIXME
comment.
2025-11-28 21:24:56 +00:00
Anatolii Smolianinov
6b389a61c1 Eglot: use symbol at point as default in eglot-rename (bug#79757)
* lisp/progmodes/eglot.el (eglot-rename): Tweak.

Copyright-paperwork-exempt: yes
2025-11-18 20:53:55 +00:00
João Távora
c81d8fd490 ; Eglot: minor documentation cleanup of last change
* lisp/progmodes/eglot.el (eglot--semtok-cache)
(eglot--semtok-inflight): Minimally enhance docstrings.
(eglot--semtok-font-lock-2): Remove FIXME comment.

bug#79374
2025-11-16 22:16:40 +00:00
João Távora
7469ee7e27 Eglot: rework semtok feature again
This time, I bit the bullet and made eglot--semtok-cache a list
of responses.  This is motivated by "range" request which happen
in for multiple regions asynchronously.  They must all be
(eventually) sent and cannot stomp on each others' cache.

Figuring out when to delete outdated entries from
eglot--semtok-cache is also tricky.  It must be done only once
we're certain an outdated entry cannot be reused for a "delta"
request.

* lisp/progmodes/eglot.el (eglot--semtok-cache): Reword docstring.
(eglot--semtok-apply-delta-edits): Tweak variable name.
(eglot--semtok-request): Rework again.
(eglot--semtok-font-lock): Rework.
(eglot--semtok-font-lock-1): DATA no longer optional.
2025-11-16 15:26:48 +00:00
João Távora
cc9ec87e53 Eglot: rework semtok feature again
This version was tested with the clangd, rust-analyzer and lean servers.
Each server is slightly different.

The main change is to recognize that that eglot--semtok-request is a
promise to get some data for BEG to END and a promise to flush it.  The
eglot--semtok-inflight variable is overhauled so that it more precisely
encodes this information.

The lean server insists on many workspace/semanticTokens/refresh waiting
for a textDocument/semanticTokens/full request from our part, but we
don't give in.  The spec doesn't actually say what types of requests the
clients should issue.  It eventualy gives up.  The only thing we do on
this request is to flush everything we know.  After this flush, the
font-lock machinery will know what to do.

* lisp/progmodes/eglot.el (eglot--async-request): Return id.
(eglot--semtok-inflight): Redesign variable.
(eglot-handle-request): Just flush.
(eglot--semtok-request): Rewrite.
(eglot--semtok-font-lock): Tweak.
2025-11-16 03:03:35 +00:00
João Távora
f772fe526a Eglot: fix bug in eglot--semtok-font-lock
The entry condition to eglot--semtok-font-lock-1, which checks
if the region to refontify is contained in the recorded region
in eglot--semtok-cache was blatantly wrong.  It used 'beg'
twice!

* lisp/progmodes/eglot.el (eglot--semtok-font-lock): Fix bug.
2025-11-14 22:29:34 +00:00
João Távora
f83c35788a Eglot: invalidate local semtok cache at server's bidding
When the server sends workspace/semanticTokens/refresh, calling
font-lock-flush isn't enough.  It will trigger a new
eglot--semtok-font-lock call, but we can't assume anything about
the validity of eglot--semtok-cache.

Clangd seems to send workspace/semanticTokens/refresh when
complicated enough changes happen in an LSP document.  If the
buffer-local eglot--semtok-cache isn't flushed we'll likely
request a delta, and clangd may still supply it, but it won't
apply correctly to the outdated local state.

* lisp/progmodes/eglot.el (eglot--semtok-cache)
(eglot--semtok-inflight): Move up here.
(eglot-handle-request): Flush the eglot--semtok-cache.
2025-11-14 15:45:37 +00:00
João Távora
d81bb68ed0 Eglot: janitorial cleanup
* lisp/progmodes/eglot.el (eglot--lsp-position-to-point): Use
eglot--widening.
(eglot--lsp-position-to-point): Use eglot--widening.
(eglot-range-region): New util.
(eglot-format)
(eglot--code-action-params)
(eglot--update-hints-1)
(eglot--semtok-request): Use eglot-range-region.
(eglot--after-change): Add comment.

eglot-range-region is an idea by Lua Viana Reis <me@lua.blog.br>
2025-11-14 15:45:37 +00:00
João Távora
6126ab8d82 Eglot: tweak some semtok functions to be more debug-friendly
* lisp/progmodes/eglot.el (eglot--semtok-request): Return value
records return reason.
(eglot--semtok-font-lock-1): Return number of painted tokens and
exit locus.
(eglot--semtok-decode-token): Rename
from eglot--semtok-token-faces.  Rework.
(eglot--semtok-font-lock-1): Use eglot--semtok-decode-token.
2025-11-13 22:18:46 +00:00
João Távora
2f196548f5 Eglot: tidy overlay cleanup code
And turn off semtok when tearing down eglot--managed-mode.

* lisp/progmodes/eglot.el (eglot--delete-overlays): New helper.
(eglot--managed-mode): Turn off minor modes and cleanup here.
(eglot--managed-mode-off): Not here.
(eglot-highlight-eldoc-function)
(eglot-code-action-suggestion): Use eglot--overlay prop.
(eglot-inlay-hints-mode): Use eglot--delete-overlays.
2025-11-13 22:18:46 +00:00
João Távora
f466c0c43d Eglot: don't use eglot--semtok-idle-timer (bug#79374)
Don't have evidence for the usefulness of this technique yet.

* lisp/progmodes/eglot.el (eglot--semtok-idle-timer): Delete.
(eglot--semtok-request): Simplify.
2025-11-12 21:26:02 +00:00
João Távora
6337ff8214 Eglot: rework semtok defcustoms and face calculation (bug#79374)
* lisp/progmodes/eglot.el (eglot-semantic-tokens-faces)
(eglot-semantic-tokens-modifier-faces): Delete.
(eglot--semtok-types, eglot--semtok-modifiers): Rename from
eglot-semantic-tokens-faces and
eglot-semantic-tokens-modifier-faces.
(eglot-client-capabilities): Tweak.
(eglot--lsp-interface-alist): Add SemanticTokensLegend.
(eglot--connect): Don't initialize a server.
(eglot--semtok-define-things): New helper.
(eglot-lsp-server): Just one slot needed.
(eglot--semtok-token-faces): Rework.
2025-11-12 21:26:02 +00:00
João Távora
583493cb21 Eglot: debounce consecutive semtok full/delta requests (bug#79374)
Many back-to-back calls for 'eglot--semtok-request' and small
regions occur even on trivial fast edits.  Even though it's
cheap and harmless to send many delta rquests, it's nicer to
just send just one.

The debouncing from jsonrpc-async-request isn't enough.  When a response
to a semtok request is received, it's important to remember which
regions to flush.  Font-lock logic will then do its magic and coalesce
those regions into one before invoking eglot--semtok-font-lock, and
eglot--semtok-font-lock-1 will have up-to-date data to work with.

* lisp/progmodes/eglot.el (eglot--semtok-inflight): New variable.
(eglot--semtok-request): Use it.
2025-11-12 21:26:02 +00:00
João Távora
2d153ab44a Eglot: rework semtok again to use only font-lock (bug#79374)
Stefan's idea to use ONLY font-lock instead of jit-lock seems more
promising and less buggy.  I did have to add this slightly odd
eglot--semtok-font-lock-2 kludge.  Other than that, it seems fine.

* lisp/progmodes/eglot.el (eglot-semantic-tokens-mode): Now use
ONLY font-lock.
(eglot--semtok-request): Rework, don't call painting function
here.
(eglot--semtok-font-lock): Rename from eglot--semtok-jit-lock and
use a single arg.  Maybe call eglot--semtok-font-lock-2.  Return
nil or risk crashing Emacs.
(eglot--semtok-font-lock-1): Rework slightly.
(eglot--semtok-font-lock-2): New helper.
(eglot-region-range): Delete.
2025-11-12 21:26:02 +00:00
João Távora
7ead81da1d Eglot: rework semtok to use only jit-lock (bug#79374)
Kept the general structure but clarified the code paths.

Simplify many things.  Instead of font-lock-add-keywords, use
jit-lock-register exclusively.  Works, but slightly problematic,
since when editing the buffer the existing enriched face
information is first removed, then re-added.  Will try other
approaches.

* lisp/progmodes/eglot.el (eglot-lsp-server): Tweak doc.
(eglot--semtok-request-full-on-idle): Delete.  Integrated into caller.
(eglot--semtok-jit-lock): Rename from eglot--semtok-propertize.  Rework.
(eglot--semtok-jit-lock-1): Extract from old eglot--semtok-propertize.
(eglot-semantic-tokens-mode): Use new eglot--semtok-jit-lock name.
(eglot--semtok-put-cache)
(eglot--semtok-ingest-range-response)
(eglot--semtok-ingest-delta-response)
(eglot--semtok-ingest-full-response): Delete helpers.
(eglot--semtok-apply-delta-edits): Rework with more cl-loopy idioms.
(eglot--semtok-flush-region): Delete.
(eglot--semtok-request): Now takes a region as argument.  Rework extensively.
(eglot-connect-hook): Don't put
eglot--semtok-initialize here.
(eglot--connect): Rather here.
(eglot--semtok-token-faces): New helper.
(eglot--semtok-font-lock): Delete.
(eglot--semtok-initialize): Rework.
(eglot-semantic-tokens-mode): Simplify.
2025-11-12 21:26:02 +00:00
João Távora
c65a556829 Eglot: fix bug on server-intiated semtok refresh (bug#79374)
src/emacs -Q src/cm.c \
   --eval '(trace-function (quote eglot--semtok-propertize))' \
   --eval '(trace-function (quote eglot--semtok-request))' \
   --eval '(trace-function (quote font-lock-flush))' -f eglot

More trace-values will show that too many full requests are being
sent.

* lisp/progmodes/eglot.el
(eglot-handle-request): Don't bump eglot--versioned-identifier,
since that confuses semtok bootstrap in a new file with clangd.
2025-11-12 21:26:01 +00:00
João Távora
cfd77501d7 Eglot: rework semtok code (bug#79374)
* lisp/progmodes/eglot.el (eglot-semantic-tokens-faces)
(eglot-semantic-tokens-modifier-faces): Move up to defcustom section.
(eglot--semtok-request-full-on-idle, eglot-handle-request)
(eglot--semtok-build-face-map, eglot--semtok-initialize)
(eglot-semantic-tokens-mode): Move into semantic tokens section.
(eglot--semtok-font-lock): Rename from
eglot--semtok-fontify-tokens.
(eglot-semantic-tokens-mode): Use eglot--semtok-font-lock.
(eglot--semtok-ingest-delta-response): Rename from
eglot--semtok-ingest-full/delta-response
(eglot--semtok-request): Use new function.
2025-11-12 21:26:01 +00:00
Lua Viana Reis
51d0b3ef98 Eglot: add semantic token (semtok) support (bug#79374)
* lisp/progmodes/eglot.el (eglot-semantic-tokens-faces)
(eglot-semantic-tokens-modifier-faces): New defcustom..
(eglot-ignored-server-capabilities): Tweak.
(eglot-client-capabilities): Advertise semtok support.
(eglot-lsp-server): Tweak.
(eglot-region-range): New helper.
(eglot-connect-hook): Add eglot--semtok-initialize.
(eglot--maybe-activate-editing-mode): Activate
eglot-semantic-tokens-mode.
(eglot--semtok-idle-timer, eglot--semtok-cache)
(eglot--semtok-put-cache, eglot--semtok-ingest-range-response)
(eglot--semtok-ingest-full-response)
(eglot--semtok-apply-delta-edits)
(eglot--semtok-ingest-full/delta-response)
(eglot--semtok-flush-region, eglot--semtok-request)
(eglot--semtok-propertize, eglot--semtok-fontify-tokens)
(eglot--semtok-request-full-on-idle): New helpers.
(eglot-handle-request workspace/semanticTokens/refresh): New
request handler.
(eglot--semtok-build-face-map, eglot--semtok-initialize): New
helpers.
(eglot-semantic-tokens-mode): New minor mode.
(desktop): Mention eglot-semantic-tokens-mode.
(command-modes tweak): Add eglot-semantic-tokens-mode.

Co-authored-by: João Távora <joaotavora@gmail.com>
2025-11-12 21:25:38 +00:00
Spencer Baugh
411e8068dc Eglot: consider invisibility in eldoc one-liners (bug#79779)
Since we keep the invisible characters of all the
server-supplied markdown, we risk that the first lines are
entirely invisible.  This defeats the :echo calculation in
eglot-hover-eldoc-function.

Fallout of bug#79552.

* lisp/progmodes/eglot.el (eglot-hover-eldoc-function): Fix.

Co-authored-by: João Távora <joaotavora@gmail.com>
2025-11-10 11:33:48 +00:00
João Távora
94a4bf8a39 Eglot: release version 1.19
* lisp/progmodes/eglot.el (Version): Bump to 1.19.
(Package-Requires): Require Flymake 1.4.2

* etc/EGLOT-NEWS: Announce new version.
2025-10-23 21:47:04 +01:00
João Távora
1e7981fd86 Eglot: don't send JSONRPC params in 'shutdown' request (bug#79653)
See also bug#66144.
Github-reference: https://github.com/joaotavora/eglot/discussions/1540

* lisp/progmodes/eglot.el (eglot-shutdown): Pass :jsonrpc-omit
(Package-Requires): Require jsonrpc 1.0.26.

* etc/EGLOT-NEWS: Announce bugfix.
2025-10-23 21:46:22 +01:00
Pooya Moradi
f362cef564 Eglot: Add LSP server for TOML.
* lisp/progmodes/eglot.el (eglot-server-programs): Add LSP server
for TOML.  (Bug#79605)

Copyright-paperwork-exempt: yes
2025-10-11 12:37:20 +03:00
Spencer Baugh
3ec87212a4 Eglot: make markup invisible instead of deleting it (bug#79552)
We use gfm-view-mode to render Markdown before we hand over the string
to ElDoc (which usually put it in a 'special' mode "*eldoc*" buffer).
'gfm-view-mode' adds keymap text properties to make links clickable.  It
also makes some of the markup invisible with a special 'invisible'
property value which is specific to 'gfm-view-mode'.  We used to delete
the latter, therefore breaking the link-clicking.  Simply resetting the
regions with non-nil 'invisible' to 't' instead of deleting them fixes
this.  See also https://github.com/joaotavora/eglot/discussions/1238

* lisp/progmodes/eglot.el: Make invisible markup invisible
instead of deleting it.

* etc/EGLOT-NEWS: Mention bugfix.

Co-authored-by: João Távora <joaotavora@gmail.com>
2025-10-03 09:44:56 +01:00
Brian Leung
e06684067d Eglot: Really fix neocmakelsp invocation
* lisp/progmodes/eglot.el (eglot-server-programs): Remove an
incorrect extra layer of parentheses.  (Bug#79394)
2025-09-06 16:42:33 +03:00
João Távora
5db70442e5 Eglot: really fix bug#79259
The previous change actually introduced a bug in a closely
related but distinct place.  We need to address the off-by-one
in the 'substring' call, not the 'add-face-text-property'.

* lisp/progmodes/eglot.el (eglot--sig-info): Fixup.
2025-09-03 08:16:15 +01:00
João Távora
53f5a07beb Eglot: fix likely off-by-1 in LabelOffsetSupport feature (bug#79259)
This feature was tweaked and last tested with a 2019 edition of
the 'ccls' LSP.  The spec does not clearly specify this number
to be 0-indexed, but it would make sense that it would be so.
So there's not need to 1+ - correct the numbers at all before
using them in substring.  This would fix the Haskell server use
of this feature (which is bug#79259)

* lisp/progmodes/eglot.el (eglot--sig-info): Fix likely off-by-1.
2025-08-30 11:44:56 +01:00
Steven Allen
4ab16d701e Eglot: escape literal % characters in URIs
Escape literal % characters in Eglot URIs

Otherwise, a literal % in a file-name will be interpreted (by the
language server) as if it were a part of a percent-encoded sequence.

See Bug#78984 for context on why `url-path-allowed-chars' cannot be
changed to escape literal % characters.

* lisp/progmodes/eglot.el (eglot--uri-path-allowed-chars): Escape %,
remove the redundant variable definition.
* test/lisp/progmodes/eglot-tests.el (eglot-test-path-to-uri-escape):
test it.
2025-08-30 11:19:19 +01:00
Eli Zaretskii
218fc1cc04 ; * lisp/progmodes/eglot.el (eglot--managed-mode): Pacify byte-compiler. 2025-08-19 19:18:28 +03:00
Gerd Möllmann
ab577467e4 ; Revert last change in eglot
* lisp/progmodes/eglot.el (eglot--managed-mode):
Use revert-buffer-in-progress-p again.
2025-08-19 14:43:58 +02:00
Gerd Möllmann
e92da50e05 ; Pacify byte-compiler
* lisp/progmodes/eglot.el (eglot--managed-mode): Use
revert-buffer-in-progress instead of
revert-buffer-in-progress-p.
* lisp/vc/vc-hooks.el (vc-dir-resynch-file): Declare some
functions.
2025-08-19 13:05:00 +02:00
Juri Linkov
80f2f07c48 Add alternative "ruby-lsp" to eglot-server-programs.
* lisp/progmodes/eglot.el (eglot-server-programs):
Add "ruby-lsp" to eglot-alternatives for ruby-mode and ruby-ts-mode.
https://shopify.github.io/ruby-lsp/editors.html#emacs-eglot
2025-06-25 20:07:17 +03:00
Eli Zaretskii
056ba8c569 Merge from origin/emacs-30
df9636f892 ; * doc/misc/use-package.texi (Hooks): Fix typo (bug#77609).
36afdd2f6f Fix documentation of use-package's ':hook' keyword
d0c90bc9bf * test/infra/gitlab-ci.yml (.job-template): Make it more ...
b8f24cbdbb ; * lisp/emacs-lisp/find-func.el (find-function): Doc fix.
e0c6f3e765 Fix todo-mode item insertion bug (bug#78506)
328b316764 Add support for Pyrefly LSP for Python
2025-05-24 06:55:24 -04:00
Yuan Fu
0b2ba13c97
Eglot: always call ElDoc callbacks in correct buffer (bug#78530)
Some minor modes adds their own eldoc display function to
'eldoc-display-functions' hook buffer-locally.  So when eldoc
uses 'eldoc-display-functions' to display docs, it should use
the buffer-local value of the hook.

But that's not always the case. In 'eldoc--invoke-strategy', the
code that runs 'eldoc-display-functions' hook is wrapped in a
callback function that eventually gets passed to each
documentation function in 'eldoc-documentation-functions'. So
now it's the documentation functions' responsibility to call the
eldoc callback in the original buffer.

All the eglot documentation functions indeed do that, using
'eglot--when-buffer-window' to switch to the original buffer
when calling the eldoc callback. But
'eglot-code-action-suggestion' is the exception, the callback is
called outside of the 'eglot--when-buffer-window' form.

This patch fixes that.

This bug was originally reported on eldoc-box [1]. The user
found that eldoc-box's display function are rarely called, even
though the minor mode is turned on. This patch fixes the issue.

[1] https://github.com/casouri/eldoc-box/issues/126#issuecomment-2896611278

* lisp/progmodes/eglot.el (eglot-code-action-suggestion): Move
the funcall form into the eglot--when-buffer-window form.
2025-05-21 22:42:35 -07:00
Jostein Kjønigsen
328b316764 Add support for Pyrefly LSP for Python
* lisp/progmodes/eglot.el (eglot-server-programs): Add config
for Pyrefly.  (Bug#78492)
2025-05-19 14:50:20 +03:00
Eli Zaretskii
b3e280faba Eglot: Fix parsing file:// URIs on MS-Windows
* lisp/progmodes/eglot.el (eglot-uri-to-path): Remove the leading
slash in MS-Windows file names only if they begin with a slash.
This adjusts the function to the recent fix for bug#76982 in
'url-generic-parse-url', which previously would produce file names
that begin with an extra slash.  (Bug#78392)
2025-05-13 14:45:04 +03:00
João Távora
c69c18b732 Eglot: fix call hierarchy navigation again (bug#78367, bug#78250)
* lisp/progmodes/eglot.el (eglot--hierarchy-label): Fix again.
2025-05-11 11:14:18 +01:00
João Távora
7617c7a6e4 Eglot: fix navigation in eglot-hierarchy-mode (bug#78250)
* lisp/progmodes/eglot.el (eglot--hierarchy-label):  Take PARENT-URI. Rework.
(eglot--hierarchy-2): Rework.
2025-05-08 23:13:28 +01:00
Elijah Gabe Pérez
852d50ecfc Eglot: bind mouse-1 to margin and mode-line code actions
* lisp/progmodes/eglot.el (eglot-mode-line-action-suggestion):
advertise mouse-1.
(eglot-diagnostics-map): Bind left-margin mouse-1
(eglot-code-action-suggestion): Advertise mouse 1.  Simplify.

Co-authored-by: João Távora <joaotavora@gmail.com>
2025-05-06 10:58:52 +01:00
João Távora
660ebdddf6 Eglot: allow other keys in window/logMessage (bug#77948)
* lisp/progmodes/eglot.el (eglot-handle-notification window/logMessage): Fix.
2025-05-04 08:27:43 +01:00
João Távora
dd5ae0f3ba Eglot: tweak previous change (clear Flymake 'Wait' state)
When we don't have anything to give to Flymake, we still want to
signal we're alive so the mode-line doesn't show a confusing
'Wait'.

* lisp/progmodes/eglot.el (eglot--report-to-flymake): Clear 'Wait'
state.
2025-04-30 22:45:44 +01:00
João Távora
7ae275f04c Eglot: improve diagnostic-reporting performance
After a change in the buffer has occured, it is often the case
that Flymake is quicker to ask for diagnostics than the server
is to supply them to us.  If we're still stuck with old outdated
diagnostics, don't forward them to Flymake, even if it eagerly
asks us for them.

* etc/EGLOT-NEWS (Changes in upcoming Eglot): Announce changes.

* lisp/progmodes/eglot.el
(eglot--diagnostics): Rework.
(eglot--report-to-flymake): Also take version.
(eglot-handle-notification textDocument/publishDiagnostics)
(eglot--managed-mode)
(eglot-flymake-backend): Tweak call to eglot--report-to-flymake.
2025-04-29 12:23:06 +01:00
João Távora
01f97fabfe Eglot: require bug-fixed Flymake 1.4.1 (bug#77856)
* lisp/progmodes/eglot.el (Package-Requires) Require Flymake 1.4.1.
2025-04-23 08:35:30 +01:00
João Távora
7ac6b33560 Eglot: use richer diagnostic-making capability of Flymake 1.4.0
* lisp/progmodes/eglot.el (Package-Requires): Require Flymake
1.4.0.
(eglot-handle-notification): Tweak.
2025-04-20 23:20:33 +01:00
João Távora
c5b97b7b32 Eglot: be aware of LSP version of contextual diagnostics
In certain situations, Eglot has to report to the server parts
of the diagnostics that it itself sent us.  The server may use
this as context to compute code actions, for example.  Eglot
selects diagnostics by asking Flymake, looking for the ones that
contain Eglot-specific cookies.

But when doing so, it is important to also be aware of the LSP
document version these each of these diagnostics pertain to,
since if a diagonstic in the buffer pertains to an older version
of the LSP document (because Flymake fired or the server hasn't
pushed a new set), that diagnostics 'eglot-lsp-data' cookie is
invalid and possibly harmful.

An example is when a diagnostic extends all the way to the end
of the buffer.  If we attempt to fix by shortening the buffer,
an Eldoc-started code actions request may be sent to the server
considering the soon-to-be-deleted Flymake diagnostic as
context.  But that diagnostic's 'eglot-lsp-data' cookie is no
longer valid and when processing that context we try to go past
point-max and burp an annoying error.

Best to check the version of the diagnostic (if we have it) and
ignore the ones that don't match the document version.

* lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up.
(eglot--flymake-diagnostics, eglot--diag-to-lsp-diag): New helpers.
(eglot-handle-notification): Record LSP doc version in diagnostics.
(eglot--code-action-bounds)
(eglot--code-action-params): Use eglot--flymake-diagnostics.
2025-04-17 00:31:38 +01:00
João Távora
3e22c73fb6 Eglot: announce support for diagnostic version checks (bug#77588)
* lisp/progmodes/eglot.el (eglot-client-capabilities): Mention versionSupport.
2025-04-08 22:16:27 +01:00
João Távora
13f439ce98 Eglot: check textDocument/publishDiagnostics version (bug#77588)
* lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up.
(eglot-handle-notification textDocument/publishDiagnostics): Check
eglot--versioned-identifier
2025-04-08 08:46:17 +01:00