Culprit:
commit a6ef458e38
Author: João Távora <joaotavora@gmail.com>
Date: Tue Dec 26 00:31:29 2023 +0000
Eglot: partial fix for middle-of-symbol completions
The decision to restore the buffer state to when the last LSP
completion set was invoked is rock-solid (because that the state
those completions' edits apply to).
However, when caching the LSP completions across multiple
eglot-completion-at-point calls, we must make sure to also restore the
values of the local values, such as 'bounds-string'. This allows us
to do that restoration.
* lisp/progmodes/eglot.el (eglot-completion-at-point): Also
restore bounds-string from capf session cache.
Github-reference: https://github.com/joaotavora/eglot/issues/1349
Any completion style except for eglot--dumb-flex spells trouble for
Eglot, for the well known reason that LSP is geared towards completion
tooltips and none of Emacs' partial-completion shenanigans.
This commit puts a "try-completion" function that doesn't return nil
in the eglot--dumb-flex completion style so that other styles aren't
tried (partial-completion, in particular, errors out).
The function often doesn't do anything very useful, but at least it
doesn't stop the more usual *Completions* buffer from appearing.
* lisp/progmodes/eglot.el (eglot--dumb-tryc): New helper.
(completion-styles-alist): Add it to the dumb-flex style.
Up to and including Emacs 29, :size 0 was an alias for :size 1.
Emacs 30 gained support for :size 0 hash tables (bug#68244).
* lisp/progmodes/eglot.el (eglot--{}): Define as truly zero-sized.
5bb5590dec Fix blunder in labeled_narrow_to_region
78ddb32fad Fix documentation of icon-elements
725a3f32f8 ; Fix typos in symbol names
6653ee66ca Improve two docstrings in ox-latex
7d869a0402 Doc fix in auth-source-read-char-choice
f149de223b Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
1f97a87879 Fix info-xref-tests
51f391998b Add @kindex in manuals for existing keybindings on 'C-x x...
Invoking code actions without a marked region or over a symbol
will trip certain servers up since BEG and END in eglot-code-actions
will be nil, causing 'eglot--pos-to-lsp-position' to assume point (which
is OK) but the 'flymake-diagnostics' call to return all diagnostics.
This causes an absolutely undecipherable JavaScript backtrace to be
sent back to Eglot from typescript-language-server.
Github-reference: https://github.com/joaotavora/eglot/issues/847
* lisp/progmodes/eglot.el (eglot--code-action-bounds): Avoid returning
(list nil nil)
Github-reference: https://github.com/joaotavora/eglot/issues/847
Servers like typescript-language-server, when asked for {"only" :
"source.organizeImports"}, return actions with the
"source.organizeImports.ts" kind. Eglot rejected these actions, but
according to the spec:
Kinds are a hierarchical list of identifiers separated by `.` [...]
The set of kinds is open.
So I guess we can use string-prefix-p
* lisp/progmodes/eglot.el (eglot-code-actions): Use string-prefix-p.
This reverts commit 4dcbf61c15.
It's not correct, breaks tests. I declare it impossible to make C-M-i
use of 'try-completion' behave sanely with LSP in its current state.
YMMV. Use a completion tooltip, like Company.
The 'try-completion' completion operation, used mostly in vanilla
'completion-at-point' invoked with C-M-i is close to impossible to get
right in LSP because of the arbitrary edits handled in
':exit-function'.
When this operation is invoked on the table, returning the pattern
argument unchanged somehow (TM) makes a sole completion show the
*Completions* buffer, where selecting it will recover context
necessary for `:exit-function' and call that function. It doesn't
break any other cases I know, and that's good enough for now.
https://github.com/joaotavora/eglot/issues/1339
* lisp/progmodes/eglot.el (eglot-completion-at-point): Return pattern
when 'try-completion' is invoked.
* lisp/progmodes/eglot.el (eglot-completion-at-point): Fix
completion reversion in :exit-function.
In a rust-ts-mode buffer such as this main.rs file
fn main() {
let v: usize = 1;
v.c<cursor-here>1234.1234567890
}
the server wants to edit the line to read, after C-M-i and selecting
"count_ones"
v.count_ones<cursor-here>.1234567890
But it couldn't apply the edit to the correct initial state because
that state wasn't correctly restored. This commit fixes that.
However, if the initial state is
v.count_on1234.1234567890
then completion still fails, because the 'try-completion' call in
eglot-completion-at-point will just return complete to "count_ones"
and Emacs doesn't consider this a completion "exit", so it'll
completely ignore the exit function.
I think 'try-completion' (and 'test-completion') simply can't be used
here (for one, they obey styles, and styles are off-limits in LSP),
but I'll leave that for another commit.
Github-reference: https://github.com/joaotavora/eglot/issues/1339
Otherwise, it'll be really hard to use it in the recommended fashion:
(defun my/project-find-function (dir)
(when-let ((match
(and (bound-and-true-p eglot-lsp-context)
(locate-dominating-file dir "some-marker-file"))))
`(transient . ,match)))
(add-hook 'project-find-functions #'my/project-find-function)
because 'bound-and-true-p' will never return t even when the hook is called
from eglot--current-project.
Github-reference: https://github.com/joaotavora/eglot/discussions/1336
Github-reference: https://github.com/joaotavora/eglot/discussions/1337
* lisp/progmodes/eglot.el (eglot-lsp-context): Declare normally.
bf4ccb0be0 ; * lisp/term.el (term--xterm-paste): Fix last change.
0d9e2e448d ; * doc/lispref/functions.texi (Function Documentation): ...
791cc5065d Fix shaping of Sinhala text
efcbf0b5ab Add use cases of (fn) documentation facility.
c3331cb365 Fix pasting into terminal-mode on term.el
5be94e2bce Fix opening directory trees from Filesets menu
6b6e770a1f Eglot: Add ruff-lsp as an alternative Python server
ed8a8a5ba1 Fix symbol name in Multisession Variables examples
400ef15bdc js-ts-mode: Fix font-lock rules conflict
c165247c30 Add indentation rules for bracketless statements in js-ts...
7f1bd69cd1 Fix c-ts-mode bracketless indentation for BSD style (bug#...
e23068cb9a Add missing indent rules in c-ts-mode (bug#66152)
d2c4b926ac Fix treesit-default-defun-skipper (bug#66711)
9874561f39 Fix treesit-node-field-name and friends (bug#66674)
eace9e1122 python-ts-mode: Highlight default parameters
23c06c7c30 Update to Org 9.6.13
ruff-lsp [1] is an LSP server for Ruff [2], [3], a fast Python linter
and code formatter.
It supports surfacing Ruff diagnostics and providing Code Actions to
fix them, but is intended to be used alongside another Python LSP in
order to support features like navigation and autocompletion.
[1]: https://github.com/astral-sh/ruff-lsp
[2]: https://github.com/astral-sh/ruff
[3]: https://docs.astral.sh/ruff/
* lisp/progmodes/eglot.el (eglot-server-programs): Add ruff-lsp.
Copyright-paperwork-exempt: yes
In the specific situation of visiting a buffer via M-. with
eglot-extend-to-xref set to t, it was found that buffer was first
visited in fundamental mode, running after-change-major-mode-hook, and
then again in the proper major mode for the file. The call to
eglot-current-server of the first visit returned non-nil which cause
two didOpen notifications to be issued for the same file.
Furthermore, in the first call, eglot--languageId to returned nil,
prompting an error from servers such as rust-analyzer.
See also: https://github.com/joaotavora/eglot/discussions/1330
* lisp/progmodes/eglot.el (eglot-current-server): Watch out for
fundamental-mode.
EIEIO is an innacurate emulation of CLOS in many aspects and one of
them in accessor definition. Before this commit
commit 6c47931a1a
Author: Brandon <brandon.irizarry@gmail.com>
Date: Sat Nov 4 17:11:32 2023 -0400
Make EIEIO ':accessor' behave like ':reader' when reading (bug#66938)
An :initform-less, non-:initarg'ed slot with be read using an
:accessor which would just return nil. This is EIEIO specific of
course, but it made for (my) sloppy programming in jsonrpc.el and
eglot.el.
Tightening up the rules a bit meant these things broke and now I'm
fixing them.
* lisp/jsonrpc.el (jsonrpc-connection): Add a bunch of :initform nil
(jsonrpc-process-connection): Add a bunch of :initform nil
* lisp/progmodes/eglot.el (eglot-lsp-server): Add a bunch of :initform nil
bug#67150
* lisp/progmodes/eglot.el (eglot-server-programs): Update
language-id for languages handled by typescript-language-server.
(cherry picked from commit 1fe9498880)
Don't use flex style to do any completion sorting.
Previously, it was thought that the 'flex' completion style was only
kicking in to do (approximate) fontification of the completions
returned by the server, but it was found that it was also doing some
its own sorting in certain situation of non-empty matching patterns.
Replaced it with a new eglot--dumb-flex style which does only
fontification.
Github-reference: https://github.com/joaotavora/eglot/discussions/1306
* lisp/progmodes/eglot.el (eglot-completion-at-point): Rework.
(eglot--dumb-flex, eglot--dumb-allc): New helpers.
(completion-category-defaults): Rework Eglot-specific category.
(completion-styles-alist): Add Eglot-specific style.
* etc/EGLOT-NEWS: Mention change.
* lisp/progmodes/eglot.el (eglot--code-action-bounds): Rename from
eglot--code-action-bounds. Rework to consider diagnostics.
(eglot-code-actions): Use new eglot--code-action-bounds.
(eglot--code-action): Use new eglot--code-action-bounds.
* etc/EGLOT-NEWS: mention change.
GitHub-reference: https://github.com/joaotavora/eglot/discussions/1295
bug#60338
The variable 'eglot-confirm-server-edits' replaces the obsolete
'eglot-confirm-server-initiated-edits' and brings about a new
confirmation model, making it possible to have only certain commands
require user confirmation. This was achieved careful usage of the
'this-command' and 'last-command' variables.
There are now two types of confirmation: the usual
minibuffer summary and a temporary 'diff-mode' buffer to display the
proposed changes, so the user can apply them one by one.
Thanks to Philip Kaludercic for the diff-mode idea and implementation.
Co-authored-by: Philip Kaludercic <philipk@posteo.net>
* doc/misc/eglot.texi (Eglot Variables): Describe
'eglot-confirm-server-edits'.
* etc/EGLOT-NEWS (latest): Mention change.
* lisp/progmodes/eglot.el (diff-mode): Require it.
(eglot-confirm-server-initiated-edits): Obsolete it.
(eglot-confirm-server-edits): New variable.
(eglot-handle-request workspace/applyEdit): Use 'last-command'
(eglot-execute t t): Use 'this-command'.
(eglot--apply-workspace-edit): Rework.
(eglot-rename): Use 'this-command'.