Commit Graph

31901 Commits

Author SHA1 Message Date
Christian Clason
5f11efe423 vim-patch:d15114c: runtime(compiler): include svelte-check compiler
closes: vim/vim#16704

d15114c148

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2025-02-22 16:17:11 +01:00
phanium
e641155b02 fix(runtime): avoid E31 in ftplugin (#32578)
fix: twice nunmap in ftplugin
2025-02-22 14:17:35 +01:00
Christian Clason
2e5b560482 feat(treesitter): table of contents for checkhealth, markdown (#32282)
Problem: It's difficult to navigate large structured text files (vim
help, checkhealth, Markdown).

Solution: Support `gO` for table of contents and `]]`/`[[` for moving
between headings for all these filetypes using treesitter queries.

Refactor: colorization of highlight groups is moved to the `help` ftplugin
while headings-related functionality is implemented in a private
`vim.treesitter` module for possible future use for other filetypes.
2025-02-22 13:07:21 +01:00
zeertzjq
5cead869fb vim-patch:9.1.1135: 'suffixesadd' doesn't work with multiple items (#32573)
Problem:  'suffixesadd' doesn't work with multiple items
          (after 9.1.1122).
Solution: Don't concat multiple suffixes together.
          (zeertzjq)

fixes: vim/vim#16694
closes: vim/vim#16699

bf595ae4ac
2025-02-22 08:38:12 +00:00
Mathias Fussenegger
8d7eb03040 fix(lsp): unify get_completion_word for textEdits/insertText
Problem:

After https://github.com/neovim/neovim/pull/32377 selecting snippets
provided by luals inserted the multi-line text before accepting the
candidates. That's inconsistent with servers who provide `textEdit`
instead of `insertText` and having lines shift up/down while cycling
through the completion candidates is a bit irritating.

Solution:

Use the logic used for `textEdit` snippets also for `insertText`
2025-02-22 09:33:54 +01:00
Sören Tempel
db2c3d1143 fix(tests): filter out lines with __typeof__ keyword (#32524)
Problem: On 32-bit architectures, musl libc makes heavy use of
__typeof__ as part of its __REDIR macro for optional backwards
compatibility with 32-bit time_t values. Unfortunately, the
__typeof__ keyword is not supported by the LuaJIT C parser.

Solution: Filter out the keyword in filter_complex_blocks.
2025-02-22 07:37:15 +08:00
zeertzjq
59b672fda2 vim-patch:9.1.1132: Mark positions wrong after triggering multiline completion (#32564)
Problem:  Mark positions wrong after triggering multiline completion.
Solution: Call deleted_lines_mark() after deleting lines.
          (zeertzjq)

closes: vim/vim#16687

060e6556e2

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2025-02-21 23:07:47 +00:00
zeertzjq
f3f94d2c37 vim-patch:partial:9.1.1131: potential out-of-memory issue in search.c (#32565)
Problem:  potential out-of-memory issue in search.c
Solution: improve situation and refactor search.c slightly
          (John Marriott)

- In function update_search_stat():
  add a check for a theoretical null pointer reference, set and remember
  the length of lastpat, remove the three calls to STRLEN() and use the
  various string's associated lengths instead, add a check for an
  out-of-memory condition.

- In function search_for_fuzz_match():
  remove a call to strnsave() and thus avoid having to add a check for
  an out-of-memory condition, also replace the call to STRLEN() by
  ml_get_buf_len().

closes: vim/vim#16689

b79fa3d9c8

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-02-21 22:49:59 +00:00
zeertzjq
cdedfc3743 fix(marks): truncate double-width inline virt_text consistently (#32560)
- Fix wrong cursor position with 'listchars' "precedes".
- Always show the '<' truncation character.
2025-02-21 22:35:10 +00:00
zeertzjq
4ff813e5c6 vim-patch:9.1.1130: 'listchars' "precedes" is not drawn on Tabs. (#32563)
Problem:  'listchars' "precedes" is not drawn on Tabs.
Solution: Only draw 'listchars' "precedes" when not skipping over cells.
          (zeertzjq)

fixes: vim/vim#5927
closes: vim/vim#16691

13f100e932
2025-02-21 22:05:32 +00:00
Riley Bruins
cbad2c6628 perf(treesitter): don't block when finding injection ranges
**Problem:** Currently, parsing is asynchronous, but it involves a
(sometimes lengthy) step which finds all injection ranges for a tree by
iterating over that language's injection queries. This causes edits in
large files to be extremely slow, and also causes a long stutter during
the initial parse of a large file.

**Solution:** Break up the injection query iteration over multiple event
loop iterations.
2025-02-21 18:10:24 +01:00
zeertzjq
2e0a563828 test: adjust multibyte virtual text test (#32557)
Having more chars after a double-width char makes it easier to spot the
bug where truncating it causes the pending chars to be lost.
2025-02-21 20:57:41 +08:00
Riley Bruins
55b165ac15 fix(treesitter): TSNode:field() returns all children with the given field 2025-02-21 09:47:02 +00:00
Christian Clason
3e39250a79 vim-patch:3cb4148: runtime(sieve): set fileformat=dos in filetype plugin
References:
https://datatracker.ietf.org/doc/html/rfc5228#section-2.2

closes: vim/vim#16685

3cb41489dc

Co-authored-by: David Mandelberg <david@mandelberg.org>
2025-02-21 10:03:52 +01:00
Christian Clason
2b7d9d1900 vim-patch:27f5136: runtime(mail): add commentstring '> %s' to ftplugin
The new native commenting functionality is currently not used when
editing mail. One could reasonably expect it to change the "quote" state
of any given line in the mail (i.e. the preceding ">"), which would be
very handy and feel natural when editing mail. Especially since the
current file already uses "setlocal comments+=n:>".

Solution: Add commentstring to `> %s` to be used in files of type mail.

closes: vim/vim#16669

27f5136761

Co-authored-by: Lucas Eekhof <105216949+eekhof@users.noreply.github.com>
2025-02-21 10:03:52 +01:00
Christian Clason
40dfc4ebd1 vim-patch:106899e: runtime(dnsmasq): include simple filetype plugin
closes: vim/vim#16671

106899eb21

Co-authored-by: dringsim <dringsim@qq.com>
2025-02-21 10:03:52 +01:00
Christian Clason
9996a36cd5 vim-patch:911742a: runtime(dosini): Add support for # comments to ftplugin
runtime/syntax/dosini.vim supports both ; and # as comments, and I think
a bunch of the files detected as dosini do too, so add support for # to
the ftplugin.

closes: vim/vim#16681

911742a975

Co-authored-by: David Mandelberg <david@mandelberg.org>
2025-02-21 10:03:52 +01:00
Riley Bruins
562056c875 perf(treesitter): only search for injections within the parse range
Co-authored-by: Jaehwang Jung <tomtomjhj@gmail.com>
2025-02-21 09:56:21 +01:00
Riley Bruins
b533c0f222 ci: add "_" to luacheck's list of global variables 2025-02-21 09:56:21 +01:00
luukvbaal
08f7c22377 fix(messages): list_cmd kind for :registers, :au[g] #32531
Problem:  No kind for `:registers/autocmd/augroup` messages. `:registers`
          chunks are emitted as separate `msg_show` events.

Solution: Add the `list_cmd` kind to the message. Introduce a new
          `msg_ext_skip_flush` variable to set to true around a
          group of to be paired message chunks.
2025-02-20 16:40:21 -08:00
zeertzjq
f4cd5a33b6 vim-patch:9.1.1127: preinsert text is not cleaned up correctly (#32544)
Problem:  when 'completeopt' is set to preinsert the preinserted text is
          not cleared when adding new leader (Yee Cheng Chin)
Solution: add a condition to delete preinsert text in edit function
          (glepnir)

closes: vim/vim#16672

52fd867f5e

Co-authored-by: glepnir <glephunter@gmail.com>
2025-02-21 08:25:11 +08:00
zeertzjq
b96c3d9a51 vim-patch:9.1.1125: cannot loop through pum menu with multiline items (#32543)
Problem:  cannot loop through pum menu with multiline items with
          fuzzy and noselect in 'completeopt' (Tomasz N)
Solution: remove unnecessary compl_no_select condition (glepnir)

fixes: vim/vim#16641
closes: vim/vim#16674

3af0a8d8f5

Co-authored-by: glepnir <glephunter@gmail.com>
2025-02-21 08:24:52 +08:00
zeertzjq
1fb606b2ff vim-patch:9.1.1126: patch 9.1.1121 used a wrong way to handle enter
Problem:  patch 9.1.1121 used a wrong way to handle enter
Solution: compl_enter_selects also needs to consider the selected item
          in ins_compl_new_leader() (glepnir)

closes: vim/vim#16673

4418041698

Co-authored-by: glepnir <glephunter@gmail.com>
2025-02-21 07:45:30 +08:00
zeertzjq
145c2e720c test(completion_spec): make Enter test descriptions more accurate 2025-02-21 07:45:30 +08:00
glepnir
07785ea9c5 vim-patch:9.1.1121: Enter does not insert newline with "noselect"
Problem:  Enter does not insert newline with "noselect" when the pum is
          visible (lifepillar)
Solution: When Enter is pressed and no complete-item is selected,
          ins_compl_prep returns false, and the edit function continues
          processing Enter to insert a new line. (glepnir)

fixes: vim/vim#1653
closes: vim/vim#16653

07f0dbe3aa

Co-authored-by: glepnir <glephunter@gmail.com>
2025-02-21 07:45:30 +08:00
zeertzjq
99a6cbe540 vim-patch:9.1.1124: No test for 'listchars' "precedes" with double-width char (#32541)
Problem:  No test for 'listchars' "precedes" with double-width char.
Solution: Add a test and fix a typo in code (zeertzjq).

closes: vim/vim#16675

08a83a033a

Cherry-pick test_listchars.vim changes from patch 9.0.0625.
Fix a regression from #30014 by moving the mb_schar assignment after the
double-width check.
2025-02-21 07:02:49 +08:00
luukvbaal
e16bec41b6 feat(messages): confirm kind for z=, :tselect, inputlist() #32521
Problem:  Messages preceding a `cmdline_show->prompt` event can not be
          distinguished as such when receiving the event. (But since
          `msg_show` handlers should be scheduled, one can already check
          whether a prompt is active when displaying the message.)

Solution: Rather than add a new kind again, use the `confirm` kind.
          Could be seen as slightly misleading where it is more of
          a choice rather than a confirmation, but that already applies
          to `confirm()` as well...
2025-02-20 14:04:27 -08:00
zeertzjq
51cf84daf9 feat(marks): virtual lines support horizontal scrolling (#32497)
Add a new field `virt_lines_overflow` that enables horizontal scrolling
for virtual lines when set to "scroll".
2025-02-20 21:47:12 +08:00
Mantas Mikulėnas
574ea6a191 fix(keycodes): recognize <Find>, <Select> #28431
PuTTY sets TERM=xterm, but sends ESC[1~ and ESC[4~ for Home/End keys,
which does not match what the 'xterm' terminfo has for khome/kend, so
libtermkeys instead reports them as the original DEC VT220 names.

The VT220 came with a DEC LK201 keyboard which had the following keys in
the area above arrow keys (where PCs now have Ins/Del/Home/End/etc):

  ┌────────┬────────┬────────┐
  │ Find   │ Insert │ Re-    │
  │        │ Here   │ move   │
  ├────────┼────────┼────────┤
  │ Select │ Prev   │ Next   │
  │        │ Screen │ Screen │
  └────────┴────────┴────────┘

These would send ESC[x~ sequences in the expected order:

  ┌────────┬────────┬────────┐
  │ ESC[1~ │ ESC[2~ │ ESC[3~ │
  ├────────┼────────┼────────┤
  │ ESC[4~ │ ESC[5~ │ ESC[6~ │
  └────────┴────────┴────────┘

Modern terminals continue to use the same sequences for Ins/Del as well
as PageUp/PageDn. But the VT220 keyboard apparently had no Home/End, and
PuTTY apparently chose to re-purpose the Find/Select key sequences for
Home/End (even though it claims to emulate Xterm and this doesn't match
what actual Xterm does).

So when Home/End are used in Neovim through PuTTY with TERM=xterm (the
default setting), libtermkey finds no match for the received sequences
in the terminfo database and defaults to reporting them as <Find> and
<Select> respectively.

PuTTY is not unique here -- tmux *also* sends ESC[1~ and ESC[4~ after
its internal translation -- but the difference is that 'tmux' terminfo
correctly maps them to Home/End so Neovim recognizes them as such, while
PuTTY defaults to using 'xterm' which uses a different mapping.

This initial patch only allows Neovim to recognize <Find> and <Select>
key codes as themselves, so that the user could manually map them e.g.
using ":imap <Find> <Home>".

Alternatives:

  - Using TERM=putty(-256color) would of course be the most correct
    solution, but in practice it leads to other minor issues, e.g. the
    need to have different PuTTY config profiles for older or non-Linux
    systems that lack that terminfo, or tmux's insistence on rendering
    italics as reverse.

  - Using Neovim through tmux avoids the problem (as tmux recognizes
    ESC[1~ on input), but is something that needs to be manually run
    every time.

The keycodes.h constants are slightly misnamed because K_SELECT was
already taken for a different purpose.
2025-02-20 05:26:46 -08:00
Luca Saccarola
4913b7895c vim-patch:c729d6d: runtime: decouple Open and Launch commands and gx mapping from netrw (#32506)
closes: vim/vim#16494
fixes: #vim/vim#16486

c729d6d154
2025-02-20 12:10:13 +00:00
Riley Bruins
b0bbe25c48 fix(treesitter): don't spam query errors in the highlighter
**Problem:** An erroneous query in the treesitter highlighter gives a
deluge of errors that makes the editor almost unusable.

**Solution:** Detach the highlighter after an error is detected, so that
it only gets displayed once (per highlighter instance).
2025-02-19 19:13:16 +01:00
Luuk van Baal
36f44b3121 fix(api): remove invalid assertions
Problem: `try_leave()` assertions moved in #31600 no longer hold.
Solution: Remove the assertions.
2025-02-19 19:11:55 +01:00
Luuk van Baal
bc1018a8d3 fix(treesitter): avoid computing fold levels for empty buffer
Problem:  Computing fold levels for an empty buffer (somehow) breaks the
          parser state, resulting in a broken highlighter and foldexpr.
          Cached foldexpr parser is invalid after filetype has changed.
Solution: Avoid computing fold levels for empty buffer.
          Clear cached foldinfos upon `FileType`.
2025-02-19 19:11:55 +01:00
Luuk van Baal
a0b52e7cb3 fix(treesitter)!: enforce buffer is loaded when creating parser
Problem: `vim.treesitter._create_parser()` silently loads the buffer,
          bypassing the swapfile prompt.
Solution: Error for an unloaded buffer, ensure buffer is loaded in
          `vim.treesitter.start()` instead.
2025-02-19 19:11:55 +01:00
Phạm Bình An
a422f3393e docs: Lua "bit" library #32492
Problem:
lua-bit is built-in, but there is no doc

Solution:
Upstream doc from https://bitop.luajit.org/
2025-02-19 10:09:09 -08:00
Sean Dewar
f3ce67549c fix(terminal): avoid more busy_start lacking busy_stop (#32509)
Problem: after #32458, it may still be possible for `busy_start` UI events to be
emitted without matching `busy_stop`s in the terminal.

Solution: do `terminal_enter`'s cursor visibility check immediately after
setting/restoring State so it occurs before events. This ensures that if pending
escape sequences are processed while in `terminal_enter`, the cursor's initial
visibility is set before `is_focused` is checked by `term_settermprop`.

As a result, we can move the call to `showmode` back to where it was originally.
2025-02-19 10:47:44 +00:00
zeertzjq
a3eb49f638 vim-patch:9.1.1122: too many strlen() calls in findfile.c (#32516)
Problem:  too many strlen() calls in findfile.c
Solution: refactor findfile.c and remove calls to strlen()
          (John Marriott)

closes: vim/vim#16595

d6e3c9048d

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-02-19 17:14:38 +08:00
zeertzjq
9005134cdc vim-patch:9.0.0532: edit test is flaky when run under valgrind (#32518)
Problem:    Edit test is flaky when run under valgrind.
Solution:   Send some text to the terminal to trigger a redraw.

14f91765c0

Cherry-pick Test_edit_shift_bs() from patch 8.2.4876.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-02-19 06:32:45 +00:00
zeertzjq
5d03060743 test(lua/hl_spec): fix hang on exit with ASAN (#32508) 2025-02-18 21:22:46 +08:00
Christian Clason
4c2d14a370 build(deps): bump tree-sitter to v0.25.2 2025-02-18 10:41:11 +01:00
zeertzjq
4a2a54f993 vim-patch:5647c91: runtime(doc): add reference to extendnew() at extend() (#32500)
related: vim/vim#16607

5647c91355

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-02-17 22:59:34 +00:00
Sören Tempel
639734bed4 fix(tests): remove the __extension__ keyword in filter_complex_blocks (#32483)
Problem: This keyword is used by GCC and Clang to prevent -Wpedantic
(and other options) from emitting warnings for many GNU C extensions.
This is used heavily in Alpine Linux through musl libc and
foritfy-headers. Without filtering the __extension__ keyword some type
definitions are duplicated. For example, timeval is defined once as

  struct timeval { time_t tv_sec; suseconds_t tv_usec; };

and once as:

  __extension__ struct timeval { time_t tv_sec; suseconds_t tv_usec; };

Without this patch, the LuaJIT C parser doesn't recognize that these
definitions are equivalent, causing unit test to fail on Alpine Linux.

Solution: Filter out the keyword in filter_complex_blocks.
2025-02-18 06:43:48 +08:00
Riley Bruins
1827ab7a1f fix(treesitter): separately track the number of valid regions
We need to add a separate variable to keep track of this information,
since we cannot read the length of the valid regions table itself, since
it has holes.
2025-02-17 15:13:26 +00:00
Justin M. Keyes
b360c06085 refactor(channel): eliminate special case in on_proc_exit() #32485
Problem:
on_proc_exit() has a special-case that assumes that the UI client will
never spawn more than 1 child process.

Solution:
If the Nvim server exits, the stream EOF will trigger `rpc_close()` in
the UI client, so we don't need the special case in `on_proc_exit`.
Pass `Channel.exit_status` from `rpc_close()` so that the correct exit
code is reflected.
2025-02-17 02:26:19 -08:00
dundargoc
bd0a65bc15 docs: misc (#32258)
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: Julian Visser <12615757+justmejulian@users.noreply.github.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-02-17 10:33:20 +08:00
zeertzjq
5e7801329f test(lua/hl_spec): reduce flakiness (#32489) 2025-02-17 10:32:35 +08:00
zeertzjq
bfd59c955f test: reduce flakiness in highlight tests (#32488) 2025-02-17 01:45:53 +00:00
zeertzjq
9d699e2005 vim-patch:68ba6c2: runtime(vim): Update base-syntax, improve performance (#32487)
Contain the vimNotation syntax group, matching this at top level is
unnecessary and very slow.

The removed vimString and vimNumber definitions are broken and/or never
match. They have long been replaced by newer definitions.

closes: vim/vim#16645

68ba6c2c6c

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-02-17 08:00:33 +08:00
phanium
a75b09019f docs: stdpath() type #32480 2025-02-16 13:33:56 -08:00
Maria José Solano
0e8e4a07f5 fix(diagnostic): don't include diagnostic code when using custom formatter #32464 2025-02-16 12:13:29 -08:00