Commit Graph

30788 Commits

Author SHA1 Message Date
Riley Bruins
64847fbdc9 perf(treesitter): use child_containing_descendant() in is_ancestor()
**Problem:** `is_ancestor()` uses a slow, bottom-up parent lookup which
has performance pitfalls detailed in #28512.

**Solution:** Take `is_ancestor()` from $O(n^2)$ to $O(n)$ by
incorporating the use of the `child_containing_descendant()` function
2024-09-25 23:01:08 +02:00
Nathan Smith
921dc22fc0
fix(diagnostic): correct severity type on setqflist, setloclist (#30506)
fix(diagnostic): correct severity type on setqflist, setloclist
2024-09-25 10:10:50 -05:00
dundargoc
046e0956ee build: fix or silence new clang-tidy warnings 2024-09-25 16:09:08 +02:00
Justin M. Keyes
f3b7444e66
refactor(lua): vim.keymap.set tests, docs #30511 2024-09-25 07:01:27 -07:00
Justin M. Keyes
069451bb21
fix(coverity): size_t overflow #30497
CID 497370: Overflowed constant (INTEGER_OVERFLOW)
    Expression `tsize - ret.has_type_key`, where tsize=0 and
    ret.has_type_key=1, underflows the type that
    receives it, an unsigned integer 64 bits wide.

    CID 509910: Overflowed constant (INTEGER_OVERFLOW)
    Expression stack.size++, which is equal to 0, where stack.size is
    known to be equal to 18446744073709551615, overflows the type that
    receives it, an unsigned integer 64 bits wide
2024-09-25 03:25:49 -07:00
Christian Clason
8ba9f0468d build(deps): bump wasmtime to v25.0.1 2024-09-25 11:39:11 +02:00
Justin M. Keyes
ce7017b850
docs: render @see, @note items in _meta/api.lua #30494 2024-09-25 02:34:13 -07:00
Christian Clason
6c77e840ae build(deps): bump libuv to v1.49.0 2024-09-25 11:24:03 +02:00
zeertzjq
052875b9dc
fix(paste): only record a paste when it's from RPC (#30491)
Problem:  When using nvim_paste in a mapping during a macro recording,
          both the mapping and the paste are recorded, causing the paste
          to be performed twice when replaying the macro.
Solution: Only record a paste when it is from RPC.

Unfortunately this means there is no way for a script to make a recorded
paste. A way to enable that can be discussed later if there is need.
2024-09-24 11:48:40 +00:00
Justin M. Keyes
3f6bc34e66
docs: lua error patterns #30240
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
Co-authored-by: Ananth Bhaskararaman <antsub@gmail.com>
2024-09-24 04:46:50 -07:00
Christian Clason
2276743cb8 vim-patch:a7229c8: runtime(rmd,rrst): 'fex' option not properly restored
Add 'fex' to b:undo_ftplugin variable

closes: vim/vim#15728

a7229c8a99

Co-authored-by: John M Devin <john.m.devin@gmail.com>
2024-09-24 09:55:43 +02:00
zeertzjq
d831392b15
feat(paste): unify cancel and error behavior (#30476)
Before this PR, the behavior of nvim_paste is:
- When vim.paste() returns false, return false to the client, but treat
  following chunks normally (i.e. rely on the client cancelling the
  paste as expected).
- When vim.paste() throws an error, still return true to the client, but
  drain the following chunks in the stream without calling vim.paste().

There are two problems with such behavior:
- When vim.paste() errors, the client is still supposed to send the
  remaining chunks of the stream, even though they do nothing.
- Having different code paths for two uncommon but similar situations
  complicates maintenance.

This PR makes both the cancel case and the error case return false to
the client and drain the remaining chunks of the stream, which, apart
from sharing the same code path, is beneficial whether the client checks
the return value of nvim_paste or not:
- If the client checks the return value, it can avoid sending the
  following chunks needlessly after an error.
- If the client doesn't check the return value, chunks following a
  cancelled chunk won't be pasted on the server regardless, which leads
  to less confusing behavior.
2024-09-24 07:14:14 +08:00
Tristan Knight
032e024f8a
fix(filetype): handle .in files with no filename (#30487)
Problem:
fnamemodify with the :r flag will not strip extensions if the filename
starts with a ".". This means that files named ".in" could cause an
infinite loop.

Solution:
Add early return if the filename was not changed
2024-09-24 06:42:16 +08:00
Justin M. Keyes
34a40d3a50
Merge #30435 refactor: rename "Dictionary" => "Dict" 2024-09-23 07:14:10 -07:00
Justin M. Keyes
47e6b2233f
fix(vim.fs): dirname() returns "." on mingw/msys2 #30480
Problem:
`vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on
mingw/msys2.

Solution:
- Check for "mingw" when deciding `iswin`.
- Use `has("win32")` where possible, it works in "fast" contexts since
  b02eeb6a72.
2024-09-23 06:05:58 -07:00
Justin M. Keyes
17027d6472 refactor(api): rename Dictionary => Dict
In the api_info() output:

    :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val')
    ...

    {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1}

The `ArrayOf(Integer, 2)` return type didn't break clients when we added
it, which is evidence that clients don't use the `return_type` field,
thus renaming Dictionary => Dict in api_info() is not a breaking change.
2024-09-23 14:42:57 +02:00
Justin M. Keyes
737f58e232 refactor(api)!: rename Dictionary => Dict
In the api_info() output:

    :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val')
    ...

    {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1}

The `ArrayOf(Integer, 2)` return type didn't break clients when we added
it, which is evidence that clients don't use the `return_type` field,
thus renaming Dictionary => Dict in api_info() is not (in practice)
a breaking change.
2024-09-23 14:42:57 +02:00
zeertzjq
5acdc4499e
test(tui_spec): prevent another case of race between paste and input (#30481)
Problem:  When input immediately follows end of bracketed paste, the
          nvim_input may be processed before the nvim_paste.
Solution: Ensure some waiting after the end of a bracketed paste.
2024-09-23 11:50:57 +00:00
Justin M. Keyes
cac86e9b4c
build: silence "po" noise #30469
Problem:
Noise in stderr from src/nvim/po/CMakeLists.txt during build:

    48 substitutions on 48 lines
    "optwin.js" "optwin.js" 1299L, 57582B written
    385 substitutions on 385 lines
    "nvim.pot" "nvim.pot" 9318L, 180177B written

Solution:
Run with `-c silent source` instead of `-S`.
2024-09-23 02:18:30 -07:00
zeertzjq
5057753431
fix(runtime): treat b:undo_ftplugin consistently in Lua ftplugins (#30473)
- Don't assume b:undo_ftplugin is set when first modifying it.
- Don't assume b:undo_ftplugin already contains some resetting.
2024-09-23 16:49:34 +08:00
Christian Clason
423176db56 vim-patch:be551da: runtime(netrw): remove extraneous closing bracket
fixes: vim/vim#15717
closes: vim/vim#15718

be551dacb8

Co-authored-by: Peter Aronoff <peter@aronoff.org>
2024-09-23 09:30:49 +02:00
zeertzjq
bfe0acaea1
vim-patch:9.1.0740: incorrect internal diff with empty file (#30471)
Problem:  incorrect internal diff with an empty file
Solution: Set pointer to NULL, instead of using an empty line file
          (Yukihiro Nakadaira)

When using internal diff, empty file is read as one empty line file.
So result differs from external diff.

closes: vim/vim#15719

f1694b439b

Co-authored-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
2024-09-23 12:04:07 +08:00
dundargoc
e83ce331da build: use treesitter's CMakeLists.txt 2024-09-22 19:58:03 +02:00
dundargoc
327110ff8c build(cmake): remove unnecessary policy code
Policy CMP0092 is by default on for minimum cmake versions above 3.15.
2024-09-22 17:21:10 +02:00
Lewis Russell
511b991e66 feat(fs.lua): add vim.fs.rm()
Analogous to the shell `rm` command.
2024-09-22 15:05:24 +01:00
Evgeni Chasnovski
29bceb4f75
docs(api): nvim_get_runtime_file preserves 'runtimepath' order #30454 2024-09-22 03:51:22 -07:00
zeertzjq
e697c1b43d
fix(paste): improve repeating of pasted text (#30438)
- Fixes 'autoindent' being applied during redo.
- Makes redoing a large paste significantly faster.
- Stores pasted text in the register being recorded.

Fix #28561
2024-09-22 06:02:48 +08:00
dundargoc
1d815acd78 build: bump minimum cmake version to 3.16 2024-09-21 23:42:03 +02:00
Christian Clason
4e4b1b6590 test(terminal): unskip wrap tests on windows
These should have been unskipped again when reflow was reenabled.
2024-09-21 19:00:52 +02:00
Lewis Russell
e5c174421d test: support upvalues in exec_lua 2024-09-21 16:04:09 +01:00
zeertzjq
a19e89022d
Merge pull request #30452 from zeertzjq/vim-9.1.0738
vim-patch: rapid files are not recognized
2024-09-21 20:50:09 +08:00
zeertzjq
ac65e0f04b vim-patch:a0c14ef: runtime(filetype): tests: Test_filetype_detection() fails
Problem:  tests: Test_filetype_detection() fails (after 9.1.0738)
Solution: Add missing filetype detect patterns for *.SYSx and *.MODx

a0c14ef310

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-09-21 20:25:07 +08:00
zeertzjq
d28be6fe69 vim-patch:9.1.0738: filetype: rapid files are not recognized
Problem:  filetype: rapid files are not recognized
Solution: detect '*.sysx' and '*.modx' as rapid filetype
          (KnoP-01)

closes: vim/vim#15669

fdcb08264d

Co-authored-by: KnoP-01 <knosowski@graeffrobotics.de>
2024-09-21 20:24:06 +08:00
zeertzjq
881a58787d
vim-patch:e6b01cf: runtime(dist): do not output a message if executable is not found (#30451)
closes: vim/vim#15705

e6b01cfe01

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-09-21 12:16:28 +00:00
zeertzjq
d8cd15e8d6
vim-patch:9.1.0739: [security]: use-after-free in ex_getln.c (#30448)
Problem:  [security]: use-after-free in ex_getln.c
Solution: free pointer p a bit later (John Marriott)

closes: vim/vim#15712

a6de28755e

Co-authored-by: John Marriott <basilisk@internode.on.net>
2024-09-21 18:26:44 +08:00
Christian Clason
059a9e6254 vim-patch:50423ab: runtime(java): Optionally recognise _module_ import declarations
Define "g:java_syntax_previews" and include number 476 in
its list to enable this recognition:
------------------------------------------------------------
        let g:java_syntax_previews = [476]
------------------------------------------------------------

Reference:
https://openjdk.org/jeps/476

closes: vim/vim#15709

50423ab808

Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
2024-09-21 11:25:41 +02:00
Christian Clason
cd230be918 vim-patch:597aadc: runtime(lyrics): support multiple timestamps in syntax script
Problem:  Multiple timestamps in the same line were not highlighted
Solution: Adapt the syntax to support multiple timestamps

fixes: vim/vim#15703
closes: vim/vim#15707

597aadcf21

Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2024-09-21 11:25:41 +02:00
Christian Clason
91b7a421ea vim-patch:87b6565: runtime(modconf): remove erroneous :endif in ftplugin
regression introduced in f86568f91848ece0c5da

closes: vim/vim#15704

87b65652e8

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-09-21 11:25:41 +02:00
Christian Clason
b40b22f426 vim-patch:f86568f: runtime(misc): simplify keywordprg in various ftplugins
closes: vim/vim#15696

f86568f918

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2024-09-21 11:25:41 +02:00
Christian Clason
f5883e0d45 vim-patch:2307945: runtime(java): Optionally recognise all primitive constants in _switch-case_ labels
Define "g:java_syntax_previews" and include number 455 in
its list to enable this recognition:
------------------------------------------------------------
	let g:java_syntax_previews = [455]
------------------------------------------------------------

Reference:
https://openjdk.org/jeps/455

closes: vim/vim#15698

23079450a8

Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
2024-09-21 11:25:41 +02:00
Christian Clason
674c1aac11 vim-patch:41c7bba: runtime(zsh,sh): set and unset compiler in ftplugin
closes: vim/vim#15699

41c7bbaf8f

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2024-09-21 11:25:41 +02:00
Christian Clason
82f329a41d vim-patch:c18a9d5: runtime(netrw): using inefficient highlight pattern for 'mf'
Fixes E872 too many '(' in highlight pattern for `mf` selection

fixup for vim/vim#15551
closes: vim/vim#15700

c18a9d5835

Co-authored-by: yasuda <yasuda@kyoto-sr.co.jp>
2024-09-21 11:25:41 +02:00
dundargoc
e268fcbdaa build: work around bug in make when PATH includes cmake as dir
There appears to be a bug in `make` where if a rule asks `make` to
invoke a command called `foo`, and `foo` exists somewhere in `$PATH` as
a directory (not an executable file), `make` will attempt to `execve`
that directory instead of continuing to search in later parts of the
`$PATH` for `foo` as a true executable.

The cause can be traced back to a bug in Make 4.3 which stems from their
use of the findprog function in Gnulib. This was reported to the Make
maintainers here:

https://savannah.gnu.org/bugs/index.php?57962

and then forwarded to the Gnulib maintainers here:

https://github.com/coreutils/gnulib/commit/7b1de4a

Make 4.4 does not have this bug, and I can confirm that I'm able to run
make in the Neovim repo with no further modifications to my system than
upgrading the version of make I'm using to 4.4 or 4.4.1.

As the change is small enough, and it's unlikely that make version
around the world is going to be updated in a timely manner, it makes
sense to just add a workaround for this. Using `command -v` to resolve
the `cmake` command, similar to what is already being done with
`cmake3`, makes it work correctly in all cases. Continuing to include
`... || echo cmake` at the end means that if neither `cmake3` nor
`cmake` are installed, the user will still see a message about CMake
being missing.

Co-authored-by: Jake Zimmerman <zimmerman.jake@gmail.com>
2024-09-20 22:16:34 +02:00
Justin M. Keyes
100bb15d18 docs: link to discussions instead of stackoverflow 2024-09-20 16:13:17 +02:00
Justin M. Keyes
a60700f3b1 docs: prefix LSP bug report title 2024-09-20 16:08:55 +02:00
Riley Bruins
052e048db6 fix(treesitter): lint top-level anonymous nodes
**Problem:** Top-level anonymous nodes are not being checked by the
query linter

**Solution:** Check them by adding them to the top-level query

This commit also moves a table construction out of the match iterator so
it is run less frequently.
2024-09-20 08:44:43 +02:00
zeertzjq
f01c764cc6
vim-patch:35699f1: runtime(vim): Update base-syntax, improve folding function matches (#30427)
- Allow function command modifiers.
- Match function bodies starting with empty lines.

Command modifiers reported by @Konfekt.

fixes vim/vim#15671
closes: vim/vim#15674

35699f1749

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2024-09-20 06:59:46 +08:00
Tristan Knight
adbaaa5225
docs(lsp): hover window controls #30347 2024-09-19 08:00:08 -07:00
Justin M. Keyes
84e85aeb10
fix(health): check more "old" files #30421
Problem:

    Node.js provider (optional) ~
    - ERROR Failed to run healthcheck for "provider.node" plugin. Exception:
      …/runtime/lua/provider/node/health.lua:9: attempt to call field 'provider_disabled' (a nil value)

    Perl provider (optional) ~
    - ERROR Failed to run healthcheck for "provider.perl" plugin. Exception:
      …/runtime/lua/provider/perl/health.lua:8: attempt to call field 'provider_disabled' (a nil value)

    Python 3 provider (optional) ~
    - ERROR Failed to run healthcheck for "provider.python" plugin. Exception:
      …/runtime/lua/provider/python/health.lua:226: attempt to call field 'provider_disabled' (a nil value)

    Ruby provider (optional) ~
    - ERROR Failed to run healthcheck for "provider.ruby" plugin. Exception:
      …/runtime/lua/provider/ruby/health.lua:9: attempt to call field 'provider_disabled' (a nil value)

Solution:
Add these files to the runtime sanity check.

fix #29302
2024-09-19 06:34:23 -07:00
zeertzjq
7dbbaaec3f
refactor!: rename 'jumpoptions' flag "unload" to "clean" (#30418)
Follow-up to #29347
2024-09-19 18:05:27 +08:00