Commit Graph

31540 Commits

Author SHA1 Message Date
zeertzjq
846a2019c0
vim-patch:9.1.0999: Vim9: leaking finished exception (#31939)
Problem:  leaking finished exception
          (after v9.1.0984)
Solution: use finish_exception to clean up caught exceptions
          (Yee Cheng Chin)

In Vimscript, v:exception/throwpoint/stacktrace are supposed to reflect
the currently caught exception, and be popped after the exception is
finished (via endtry, finally, or a thrown exception inside catch).
Vim9script does not handle this properly, and leaks them instead. This
is clearly visible when launching GVim with menu enabled.  A caught
exception inside the s:BMShow() in menu.vim would show up when querying
`v:stacktrace` even though the exception was already caught and handled.

To fix this, just use the same functionality as Vimscript by calling
`finish_exception` to properly restore the states. Note that this
assumes `current_exception` is always the same as `caught_stack` which
believe should be the case.

Added tests for this. Also fix up test_stacktrace to properly test the
stack restore behavior where we have nested exceptions in catch blocks
and to also test the vim9script functionality properly.

- Also, remove its dependency on explicitly checking a line number in
  runtest.vim which is a very fragile way to write tests as any minor
  change in runtest.vim (shared among all tests) would require changing
  test_stacktrace.vim. We don't actually need such granularity in the
  test.

closes: vim/vim#16413

2051af1642

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2025-01-10 08:03:44 +08:00
Justin M. Keyes
7c00e0efbb
docs: misc #31867 2025-01-09 09:26:45 -08:00
Riley Bruins
0c296ab224
feat(docs): "yxx" runs Lua/Vimscript code examples #31904
`yxx` in Normal mode over a Lua or Vimscript code block section will execute the code.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-01-09 08:36:16 -08:00
Famiu Haque
1e47aa677a
fix(api): deprecated API nvim_get_option does not validate option name #31919
Problem:
Deprecated API `nvim_get_option()` doesn't validate the option name,
which leads to an assertion failure.

Solution:
Validate option name in `nvim_get_option()`.

Ref: #31894
2025-01-09 07:32:27 -08:00
Justin M. Keyes
5135a23219
Merge #31900 from luukvbaal/nvim_echo 2025-01-09 06:36:29 -08:00
bfredl
dcaf8bef08
Merge pull request #31844 from bfredl/iter_crash
fix(decoration): fix crash when on_lines decor provider modifies marktree
2025-01-09 13:37:28 +01:00
Luuk van Baal
5c92b40b4b feat(api): deprecate nvim_out/err_write(ln) 2025-01-09 13:35:42 +01:00
Luuk van Baal
ead5683ff9 feat(api): add err field to nvim_echo() opts
Problem:  We want to deprecate `nvim_err_write(ln)()` but there is no
          obvious replacement (from Lua). Meanwhile we already have
          `nvim_echo()` with an `opts` argument.
Solution: Add `err` argument to `nvim_echo()` that directly maps to
          `:echoerr`.
2025-01-09 13:35:40 +01:00
bfredl
6dd7fcaafd
Merge pull request #31898 from bfredl/termbomb
fix(terminal): don't crash on unprintable chars
2025-01-09 13:35:25 +01:00
bfredl
f8c8a245aa fix(terminal): don't crash on unprintable chars
fixes #31897
2025-01-09 11:22:00 +01:00
bfredl
33ff546b50 fix(decoration): fix crash when on_lines decor provider modifies marktree
If a "on_lines" callback changes the structure of the marktree, the
iterator (which is used for an entire window viewport) might now
point to invalid memory. Restore the iterator to the beginning of the
line in this case.

fixes #29484
2025-01-09 11:17:42 +01:00
zeertzjq
3f0adf90de
vim-patch:9.1.0998: filetype: TI assembly files are not recognized (#31929)
Problem:  filetype: TI assembly files are not recognized
Solution: inspect '*.sa' and assembly files and detect TI assembly
          files, include filetype plugin and syntax script for TI
          assembly files (Wu, Zhenyu)

closes: vim/vim#15827

4f73c07abf

Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
2025-01-09 17:30:26 +08:00
Christian Clason
d740a4274d vim-patch:8ab1819: runtime(xf86conf): add section name OutputClass to syntax script
References:
https://man.archlinux.org/man/xorg.conf.5#DESCRIPTION

closes: vim/vim#16397

8ab1819df6

Co-authored-by: Jan-Arvid Harrach <jharrach@tutanota.com>
2025-01-09 08:07:30 +01:00
zeertzjq
5f85e78db3
vim-patch:9.1.0997: too many strlen() calls in drawscreen.c (#31927)
Problem:  too many strlen() calls in drawscreen.c
Solution: refactor drawscreen.c and remove calls to strlen(),
          make get_keymap_str() (in screen.c) return string length
          instead of TRUE/FALSE (John Marriott).

a21240b97d

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-01-09 12:49:45 +08:00
zeertzjq
19c9572d36
Revert "refactor(options): set option value for non-current context directly" (#31924)
Reverts #31112
2025-01-09 12:32:25 +08:00
zeertzjq
822313e42b
vim-patch:partial:9.1.0882: too many strlen() calls in insexpand.c (#31490)
Problem:  too many strlen() calls in insexpand.c
Solution: Refactor insexpand.c and reduce number of calls to STRLEN(),
          fix a warning get_next_filename_completion(), add new function
          ins_compl_leader_len() (John Marriott)

closes: vim/vim#16095

5e6ea92b2c

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-01-09 08:59:59 +08:00
zeertzjq
0d469b697e
vim-patch:1718e7d: runtime(vim): Update base-syntax, improve ex-bang matching (#31922)
Always match ex-bang explicitly rather than incidentally as the ! operator.

fixes: vim/vim#16221
closes: vim/vim#16410

1718e7d07e

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-01-09 00:40:50 +00:00
Lewis Russell
c4b658fed8
Merge pull request #31112 from famiu/refactor/options/set_option_for
refactor(options): set option value for non-current context directly
2025-01-08 17:56:21 +00:00
Guilherme Soares
17b46d01e2
test(treesitter): inspect_tree #31182
To prevent #30986 and #31198 regression update inspect_tree tests
2025-01-08 05:06:09 -08:00
notomo
5b9518b436
fix(api): nvim_set_decoration_provider callback return type #31912
Problem: incorrect return type doc causes luals `Annotations specify that at most 0 return value(s) are required, found 1 returned here instead.` diagnosis

Solution: correct return type doc
2025-01-08 04:37:29 -08:00
Christian Clason
561580aba5 vim-patch:9.1.0995: filetype: shaderslang files are not detected
Problem:  filetype: shaderslang files are not detected
Solution: detect '*.slang' files as shaderslang filetype,
          include a filetype and syntax script (mtvare6)

Reference:
https://shader-slang.com/

closes: vim/vim#16387

616219f684

Co-authored-by: mtvare6 <mtvare6@proton.me>
2025-01-08 10:32:45 +01:00
zeertzjq
141114c170
fix(api): crash on invalid buffer to nvim_buf_del_user_command (#31908) 2025-01-08 05:16:41 +00:00
Evgeni Chasnovski
6719276040
fix(highlight): make TablineSel more noticeable with 'notermguicolors' #31905
Problem: Linking `TablineSel` to `Normal` makes it more noticeable with
`notermguicolors` but less so with `termguicolors` (compared to using
bold text in both cases).

Solution: use bold text with `termguicolors` and regular with
`notermguicolors`.
2025-01-07 14:02:35 -08:00
glepnir
b12b91c274
feat(health): show :checkhealth in floating window #31086
Problem: health can not shown in a floating window
Solution: add g:health variable
2025-01-07 08:09:01 -08:00
Riley Bruins
d9ee0d2984 perf(treesitter): don't fetch parser for each fold line
**Problem:** The treesitter `foldexpr` calls `get_parser()` for each
line in the buffer when calculating folds. This can be incredibly slow
for buffers where a parser cannot be found (because the result is not
cached), and exponentially more so when the user has many
`runtimepath`s.

**Solution:** Only fetch the parser when it is needed; that is, only
when initializing fold data for a buffer.

Co-authored-by: Jongwook Choi <wookayin@gmail.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-01-07 16:43:45 +01:00
Jared Baur
b67fcd0488
fix(highlight): make TablineSel more noticeable #31896
The default `TablineSel` highlighting makes it subjectively difficult to
differentiate the selected tab from unselected ones.
2025-01-07 04:21:15 -08:00
dundargoc
d8bc08db7f refactor: adopt vterm
We have changed too much to consider it a mere bundled dependency (such
as unicode handling in e3bfcf2fd4), and
can consider it our own at this point.
2025-01-07 12:35:24 +01:00
Christian Clason
4d94059919 vim-patch:3159b64: runtime(sh): fix typo in Last Change header
related: vim/vim#16394

3159b6494e

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-01-07 08:03:13 +01:00
Christian Clason
b44a8ba1e7 vim-patch:cf1f555: runtime(sh): add PS0 to bashSpecialVariables in syntax script
PS0 is also a special prompt variable. (It is expanded and displayed
after it reads a command but before executing it.)

References:
https://www.gnu.org/software/bash/manual/html_node/Interactive-Shell-Behavior.html

closes: vim/vim#16394

cf1f55548d

Co-authored-by: Jon Parise <jon@indelible.org>
2025-01-07 08:03:13 +01:00
Christian Clason
a942dea157 vim-patch:7ceaa8f: runtime(vim): Remove trailing comma from match_words
fixes: vim/vim#16377 (`filetype plugin indent on` breaks matchit).
closes: vim/vim#16389

7ceaa8f3dd

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-01-07 08:03:13 +01:00
zeertzjq
e27f7125d6
Merge pull request #31893 from zeertzjq/vim-9.1.0984
vim-patch:9.1.{0984,0991}: getstacktrace(), v:stacktrace
2025-01-07 09:42:17 +08:00
zeertzjq
8fa4306eb9 vim-patch:9.1.0991: v:stacktrace has wrong type in Vim9 script
Problem:  v:stacktrace has wrong type in Vim9 script.
Solution: Change the type to t_list_dict_any.  Fix grammar in docs.
          (zeertzjq)

closes: vim/vim#16390

6655bef330
2025-01-07 09:15:10 +08:00
zeertzjq
d5308637bf vim-patch:9.1.0984: exception handling can be improved
Problem:  exception handling can be improved
Solution: add v:stacktrace and getstacktrace()

closes: vim/vim#16360

663d18d610

Co-authored-by: ichizok <gclient.gaap@gmail.com>
Co-authored-by: Naruhiko Nishino <naru123456789@gmail.com>
2025-01-07 09:15:10 +08:00
luukvbaal
06ff5480ce
vim-patch:9.1.0993: New 'cmdheight' behavior may be surprising #31892
Problem:  Although patch 9.1.0990 fixed a real problem/inconsistency,
          it also introduced new behavior that may break BWC and/or be
          unexpected. Before 9.1.0990, window commands could make the
          topframe smaller (without changing 'cmdheight'; quirk that is
          now fixed), but did not allow extending the topframe beyond
          the 'cmdheight' set by the user. After 9.1.0990, the user can
          reduce the 'cmdheight' below the value they set explicitly,
          through window commands, which may lead to confusion.
          (aftere v9.1.0990)
Solution: Store the value explicitly set by the user and clamp the
          'cmdheight' when resizing the topframe. This also applies to
          dragging laststatus, which in contrast to window commands
          _did_ allow reducing the 'cmdheight' to values below the one
          set by the user. So with this patch there is still new
          behavior, but I think in a way that is less surprising.
          While at it, also fix a Coverity warning, introduced in
          v9.1.0990 (Luuk van Baal)

c97e869535
2025-01-06 17:00:09 -08:00
Riley Bruins
30de00687b
refactor(treesitter): simplify condition #31889 2025-01-06 16:56:53 -08:00
dundargoc
b6ab294838 fix: fix incorrect search code 2025-01-06 20:03:17 +00:00
Justin M. Keyes
3d9fb975b9
Merge #31625 perf(decor): improve iter_captures() cache 2025-01-06 07:09:34 -08:00
luukvbaal
86770108e2
fix(lsp): open_floating_preview() zindex relative to current window #31886
Problem:  open_floating_preview() may be hidden behind current window if
          that is floating and has a higher zindex.
Solution: Open floating preview with zindex higher than current window.
2025-01-06 06:05:50 -08:00
vanaigr
dd234135ad refactor: split predicates and directives 2025-01-06 00:35:19 -06:00
vanaigr
8d2ee542a8 perf(decor): join predicates and matches cache 2025-01-06 00:34:48 -06:00
vanaigr
ef77845b97 test: benchmark treesitter highlighing 2025-01-06 00:34:19 -06:00
zeertzjq
9b7905df16
Merge pull request #31882 from zeertzjq/vim-0c3e57b
vim-patch: doc updates
2025-01-06 10:17:19 +08:00
zeertzjq
e8c0b87c1f vim-patch:fd77161: runtime(doc): update doc for :horizontal
Revert the documentation for :horizontal from commit
0c3e57b403e0e3a1fefc because :horizontal cannot be shortened to :ho

closes: vim/vim#16362

fd771613b3

Co-authored-by: h-east <h.east.727@gmail.com>
2025-01-06 09:54:55 +08:00
zeertzjq
22dadf4c33 vim-patch:0c3e57b: runtime(doc): update index.txt, windows.txt and version9.txt
closes: vim/vim#16357

0c3e57b403

Co-authored-by: h-east <h.east.727@gmail.com>
Co-authored-by: Aliaksei Budavei <32549825+zzzyxwvut@users.noreply.github.com>
2025-01-06 09:53:49 +08:00
zeertzjq
abb19e873b
Merge pull request #31881 from zeertzjq/vim-21c37d7
vim-patch: update Vim syntax
2025-01-06 09:43:47 +08:00
zeertzjq
53f5d528cf vim-patch:6139766: runtime(vim): fix failing vim syntax test
after v9.1.0985

related: vim/vim#16356

6139766e82

Co-authored-by: h-east <h.east.727@gmail.com>

N/A patch:
vim-patch:8a27d97: runtime(doc): Capitalise the mnemonic "Zero" for the 'z' flag of search()
2025-01-06 09:16:13 +08:00
zeertzjq
b23c28845f vim-patch:21c37d7: runtime(vim): update base-syntax after v9.1.0936
21c37d7f69

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-01-06 09:16:13 +08:00
Justin M. Keyes
5e02a2c470
"nvim -es": disable shada #21723
Problem:
`nvim -es` (and `nvim -Es`) is the recommended way to non-interactively
run commands/vimscript. But it enables shada by default, which is
usually not wanted.

Solution:
- Disable shada by default for `nvim -es/-Es`. This can be overridden by
  `-i foo` if needed.
- Do NOT change the 'loadplugins' default.
  - User config + packages _should_ be enabled by default, for both `nvim
    -es` and `nvim -l`. Else any Lua packages you have can't be accessed
    without `-u path/to/config`, which is clumsy.
      - Use-cases:
        ```
        nvim --headless "+Lazy! sync" +qa
            would become: nvim -es "+Lazy! sync"
        nvim --headless +PlugInstall +qall
            would become: nvim -es +PlugInstall
        ```
  - Opt-out (`--clean` or `-u NONE`) is much easier than opt-in (`-u
    path/to/config`).
  -  User config/packages are analogous to pip packages, which are
     expected when doing `python -c ...`.

related: 7c94bcd2d7
related: ddd0eb6f51
2025-01-05 17:10:16 -08:00
Justin M. Keyes
570a8da01b
fix(health): "q" should not close last window #31876 2025-01-05 11:31:39 -08:00
Daiki Noda
ac5a6d9ff5
build: fix RelWithDebInfo optimization flags #31802
Problem:
RelWithDebInfo generates redundant flags:

    Compilation: /usr/bin/cc -O2 -g -Og -g

The `CMAKE_C_FLAGS_RELWITHDEBINFO` variable is being modified in a way
that caused duplicate `-Og` and `-g` flags to be added. The resulting
flags were `-O2 -g -Og -g`.

- `-Og` (Optimize for debugging) and `-O2` (Optimize for performance)
  are different optimization levels. We can't use both at once.
- The duplicate `-g` flag is redundant and no effect.

multiple -O flags has no effect for code, just redundant.

> If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

Solution:
Adjust the flags to use the more appropriate `-O2 -g`.

    Compilation: /usr/bin/cc -O2 -g

BEFORE:

```
:verbose version
NVIM v0.11.0-dev-1443+ge00cd1ab40
Build type: RelWithDebInfo
LuaJIT 2.1.1734355927
Compilation: /usr/bin/cc -O2 -g -Og -g -flto -fno-fat-lto-ob
jects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict
...
```

AFTER:

```
:verbose version
NVIM v0.11.0-dev-e00cd1ab4-dirty
Build type: RelWithDebInfo
LuaJIT 2.1.1734355927
Compilation: /usr/bin/cc -O2 -g -flto -fno-fat-lto-objects -
Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-protot
...
```
2025-01-05 11:28:31 -08:00