Commit Graph

7744 Commits

Author SHA1 Message Date
Justin M. Keyes
76aa3e52be
feat(defaults): popupmenu "Open in browser", "Go to definition" #30261
- Use the popup to expose more features such as LSP and gx.
- Move the copy/paste items lower in the menu, they are lower priority.
2024-09-05 05:56:00 -07:00
Justin M. Keyes
975aeee537
test: avoid noise in CI logs #30264
Problem:
Since 96128a5076 the test logs have noise from tests that *expect*
failures:

    $NVIM_LOG_FILE: /tmp/cirrus-ci-build/build/.nvimlog
    (last 100 lines)
    ERR 2024-09-04T13:38:45.181 T949.28335.0/c terminfo_start:486: uv_pipe_open failed: no such device or address
    ERR 2024-09-04T13:38:45.181 T949.28335.0/c flush_buf:2527: uv_write failed: bad file descriptor
    ERR 2024-09-04T13:38:45.181 T949.28335.0/c flush_buf:2527: uv_write failed: bad file descriptor
    WRN 2024-09-04T13:43:43.294 ?.35904    server_start:173: Failed to start server: address already in use: /…/Xtest_tmpdir/…/T7159.35895.0
    WRN 2024-09-04T13:43:43.314 ?.35907    server_start:173: Failed to start server: illegal operation on a directory: /
    ERR 2024-09-04T13:43:43.332 ?.35909    socket_watcher_init:60: Host lookup failed: https://example.com

Solution:
Rewrite the test to use `vim.system()`. Set NVIM_LOG_FILE in the child
process to a "throwaway" logfile.
2024-09-05 02:39:58 -07:00
Tristan Knight
882a450a29
fix(lsp): handle locations exceeding line length #30253
Problem:
LSP spec [states](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position)
that "if the character value is greater than the line length it defaults
back to the line length", but `locations_to_items` fails in that case.

Solution:
Adjust locations_to_items to follow the spec.

closes #28281
2024-09-05 00:23:11 -07:00
Lewis Russell
b6e350a6b4 fix(lua): allows tables with integer keys to be merged in tbl_deep_extend
- The exclusion of lists was never justified in the commit history and is
  the wrong thing to do for a function that deals with tables.

- Move the error checks out of the recursive path.

Fixes #23654
2024-09-04 11:34:19 +01:00
zeertzjq
7b7c95dac9
vim-patch:9.1.0713: Newline causes E749 in Ex mode (#30254)
Problem:  Newline causes E749 in Ex mode (after 9.1.0573).
Solution: Don't execute empty command followed by a newline.

closes: vim/vim#15614

2432b4a753

Cherry-pick code change from patch 8.2.3405.
2024-09-04 06:35:26 +08:00
Tristan Knight
45e76acaa0
feat(lsp): support hostname in rpc.connect #30238
Updated the `rpc.connect` function to support connecting to LSP servers
using hostnames, not just IP addresses. This change includes updates to
the documentation and additional test cases to verify the new
functionality.

- Modified `connect` function to resolve hostnames.
- Updated documentation to reflect the change.
- Added test case for connecting using hostname.

Added a TCP echo server utility function to the LSP test suite. This
server echoes the first message it receives and is used in tests to
verify LSP server connections via both IP address and hostname.
Refactored existing tests to use the new utility function.
2024-09-03 08:10:39 -07:00
vanaigr
d1d7d54680
fix(api): nvim_buf_get_text() crashes with large negative column #28740
Problem:
crash when calling nvim_buf_get_text() with a large negative start_col:

    call nvim_buf_get_text(0, 0, -123456789, 0, 0, {})

Solution:
clamp start_col after subtracting it from the line length.
2024-09-03 06:01:42 -07:00
Justin M. Keyes
ea2d949351
test: tmpname(create:boolean) #30242
Problem:
137f98cf64 added the `create` parameter to `tmpname()` but didn't
fully implement it.

Solution:
- Update impl for the `os.tmpname()` codepath.
- Inspect all usages of `tmpname()`, update various tests.
2024-09-03 02:18:17 -07:00
Justin M. Keyes
96128a5076 feat(startup): validate --listen address
Problem:
`nvim --listen` does not error on EADDRINUSE. #30123

Solution:
Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead
of the old, ambiguous situation where it was both an input *and* an
output), we can be fail fast instead of trying to "recover". This
reverts the "recovery" behavior of
704ba4151e, but that was basically
a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
2024-09-02 22:41:41 +02:00
Justin M. Keyes
137f98cf64 test: tmpname() can skip file creation 2024-09-02 20:19:50 +02:00
Justin M. Keyes
61e9137394
docs: misc #28970 2024-09-01 13:01:24 -07:00
Gregory Anders
6913c5e1d9
feat(treesitter)!: default to correct behavior for quantified captures (#30193)
For context, see https://github.com/neovim/neovim/pull/24738. Before
that PR, Nvim did not correctly handle captures with quantifiers. That
PR made the correct behavior opt-in to minimize breaking changes, with
the intention that the correct behavior would eventually become the
default. Users can still opt-in to the old (incorrect) behavior for now,
but this option will eventually be removed completely.

BREAKING CHANGE: Any plugin which uses `Query:iter_matches()` must
update their call sites to expect an array of nodes in the `match`
table, rather than a single node.
2024-09-01 18:01:53 +00:00
luukvbaal
97f8d1de1c
vim-patch:9.1.0708: Recursive window update does not account for reset skipcol (#30217)
Problem:  Window is updated with potentially invalid skipcol in recursive
          window update path. I.e. cursor outside of visible range in
          large line that does not fit.
Solution: Make sure it is valid (Luuk van Baal).

3d5065fc75
2024-09-01 20:19:19 +08:00
zeertzjq
bfa365a872
fix(completion): don't include <Lua function> in -complete= (#30209) 2024-09-01 07:57:09 +08:00
zeertzjq
ea2998fec9
vim-patch:9.1.0704: inserting with a count is inefficient (#30206)
Problem:  inserting with a count is inefficient
Solution: Disable calculation of the cursor position and topline, if a
          count has been used (Ken Takata)

Optimize insertion when using :normal 10000ix.

This patch optimizes the insertion with a large count (e.g. `:normal
10000ix`).

It seems that calculation of the cursor position for a long line is slow
and it takes O(n^2). Disable the calculation if not needed.

Before:
```
$ time ./vim --clean -c 'normal 10000ix' -cq!
real    0m1.879s
user    0m1.328s
sys     0m0.139s

$ time ./vim --clean -c 'normal 20000ix' -cq!
real    0m5.574s
user    0m5.421s
sys     0m0.093s

$ time ./vim --clean -c 'normal 40000ix' -cq!
real    0m23.588s
user    0m23.187s
sys     0m0.140s
```

After:
```
$ time ./vim --clean -c 'normal 10000ix' -cq!
real    0m0.187s
user    0m0.046s
sys     0m0.093s

$ time ./vim --clean -c 'normal 20000ix' -cq!
real    0m0.217s
user    0m0.046s
sys     0m0.108s

$ time ./vim --clean -c 'normal 40000ix' -cq!
real    0m0.278s
user    0m0.093s
sys     0m0.140s

$ time ./vim --clean -c 'normal 80000ix' -cq!
real    0m0.494s
user    0m0.311s
sys     0m0.140s

$ time ./vim --clean -c 'normal 160000ix' -cq!
real    0m1.302s
user    0m1.140s
sys     0m0.094s
```

closes: vim/vim#15588

09b80d23cf

Co-authored-by: Ken Takata <kentkt@csc.jp>
2024-09-01 06:21:36 +08:00
glepnir
a6c4487e8b
vim-patch:9.1.0684: completion is inserted on Enter with "noselect" (#30111)
Problem:  completion is inserted on Enter with "noselect"
          (Carman Fu)
Solution: check noselect before update compl_shown_match
          (glepnir)

fixes: vim/vim#15526
closes: vim/vim#15530

753794bae8
2024-08-31 17:10:05 +08:00
zeertzjq
55dc482e75
fix(completion): fix inconsistent Enter behavior (#30196)
Problem:  Behavior of Enter in completion depends on typing speed.
Solution: Don't make whether Enter selects original text depend on
          whether completion has been interrupted, which can happen
          interactively with a slow completion function.
2024-08-31 04:03:30 +08:00
glepnir
42ed0ffad9
fix(lsp): when prefix is non word add all result into matches (#30044)
Problem: prefix can be a symbol like period, the fuzzy matching can't
handle it correctly.

Solution: when prefix is empty or a symbol add all lsp completion
result into matches.
2024-08-30 20:23:49 +02:00
bfredl
cfdf68a7ac feat(mbyte): support extended grapheme clusters including more emoji
Use the grapheme break algorithm from utf8proc to support grapheme
clusters from recent unicode versions.

Handle variant selector VS16 turning some codepoints into double-width
emoji. This means we need to use ptr2cells rather than char2cells when
possible.
2024-08-30 11:49:09 +02:00
Riley Bruins
59baa5e8a1
fix(tohtml): apply sp color if present #30110
Problem:
Things like underlines are always given a default foreground highlight
regardless of the value of `sp`.

Solution:
Check for `sp` first, and apply that color to the text decoration color if it
exists.

Limitations:
If there is no value of `sp`, vim applies a text decoration color that matches
the foreground of the text. This is still not implemented (and seems like a much
more complex problem): in TOhtml, the underline will still be given a default
foreground highlight.
2024-08-29 09:36:33 -07:00
zeertzjq
0346666f71
vim-patch:9.1.0699: "dvgo" is not always an inclusive motion (#30173)
Problem:  "dvgo" is not always an inclusive motion
          (Iain King-Speir)
Solution: initialize the inclusive flag to false

fixes: vim/vim#15580
closes: vim/vim#15582

f8702aeb8f

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-08-29 06:24:40 +08:00
Lewis Russell
688b961d13 feat(treesitter): add support for wasm parsers
Problem: Installing treesitter parser is hard (harder than
climbing to heaven).

Solution: Add optional support for wasm parsers with `wasmtime`.

Notes:

* Needs to be enabled by setting `ENABLE_WASMTIME` for tree-sitter and
  Neovim. Build with
  `make CMAKE_EXTRA_FLAGS=-DENABLE_WASMTIME=ON
  DEPS_CMAKE_FLAGS=-DENABLE_WASMTIME=ON`
* Adds optional Rust (obviously) and C11 dependencies.
* Wasmtime comes with a lot of features that can negatively affect
  Neovim performance due to library and symbol table size. Make sure to
  build with minimal features and full LTO.
* To reduce re-compilation times, install `sccache` and build with
  `RUSTC_WRAPPER=<path/to/sccache> make ...`
2024-08-26 16:44:03 +02:00
zeertzjq
cf44121f7f
vim-patch:9.1.0694: matchparen is slow on a long line (#30134)
Problem:  The matchparen plugin is slow on a long line.
Solution: Don't use a regexp to get char at and before cursor.
          (zeertzjq)

Example:

```vim
  call setline(1, repeat(' foobar', 100000))
  runtime plugin/matchparen.vim
  normal! $hhhhhhhh
```

closes: vim/vim#15568

81e7513c86
2024-08-25 06:07:43 +08:00
zeertzjq
91ce0c3ddd
vim-patch:9.1.0692: Wrong patlen value in ex_substitute() (#30131)
Problem:  Wrong patlen value in ex_substitute() (after 9.1.0426).
Solution: Compute patlen after finding end separator.
          (zeertzjq)

Add a more explicit test.  The test already passes as the only case
where a overlarge patlen value matters was fixed by patch 9.1.0689.

closes: vim/vim#15565

d1c8d2de4b
2024-08-24 10:19:24 +00:00
zeertzjq
bb4b6b427c
vim-patch:9.1.0690: cannot set special highlight kind in popupmenu (#30128)
Problem:  cannot set special highlight kind in popupmenu
Solution: add kind_hlgroup item to complete function
          (glepnir)

closes: vim/vim#15561

38f99a1f0d

Co-authored-by: glepnir <glephunter@gmail.com>
2024-08-24 08:38:05 +08:00
glepnir
1f5bcc7c4e
feat(lsp): completion opts support custom item conversion (#30060)
Problem: Some items of completion results include function signatures that can
cause the pum to be very long when a function has many params, because pum
scales with the longest word/abbr.

Solution: add custom covert function that can customise abbr to remove params.
2024-08-22 21:42:27 +02:00
zeertzjq
362389eb15
vim-patch:9.1.0683: mode() returns wrong value with <Cmd> mapping (#30109)
Problem:  mode() returns wrong value with <Cmd> mapping
Solution: Change decision priority of VIsual_active and move
          visual mode a bit further down (kuuote)

closes: vim/vim#15533

0fd1cb1b1f

Co-authored-by: kuuote <znmxodq1@gmail.com>
2024-08-22 05:30:21 +08:00
zeertzjq
6f7bb02e7f
vim-patch:9.1.0686: zip-plugin has problems with special characters (#30108)
Problem:  zip-plugin has problems with special characters
          (user202729)
Solution: escape '*?[\' on Unix and handle those chars
          a bit differently on MS-Windows, add a test, check
          before overwriting files

runtime(zip): small fixes for zip plugin

This does the following:
- verify the unzip plugin is executable when loading the autoload plugin
- handle extracting file names with '[*?\' in its name correctly by
  escaping those characters for the unzip command (and handle those
  characters a bit differently on MS-Windows, since the quoting is different)
- verify, that the extract plugin is not overwriting a file (could cause
  a hang, because unzip asking for confirmation)
- add a test zip file which contains those special file names

fixes: vim/vim#15505
closes: vim/vim#15519

7790ea0c68

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-08-20 23:35:27 +00:00
zeertzjq
a8fbe1d409
fix(decor): don't use separate DecorSignHighlight for url (#30096) 2024-08-20 08:20:19 +08:00
ibhagwan
1d11808bfd
fix(terminal): interrupt/got_int hangs terminal (#30056)
Upon `terminal_enter`, `mapped_ctrl_c` is set in order to avoid `CTRL-C`
interrupts (which is proxied to the terminal process instead), `os_inchar`
will then test `mapped_ctrl_c` against `State` and set `ctrl_c_interrupts=false`
which prevents `process_ctrl_c` from setting `got_int=true` in a terminal
state.

However, if `got_int` is set outside of `process_ctrl_c`, e.g. via
`interrupt()`, this will hang the neovim process as `terminal_execute` will
enter an endless loop as `got_int` will never be cleared causing `safe_vgetc`
to always return `Ctrl_C`.

A minimal example reproducing this bug:
```vim
:autocmd TermEnter * call timer_start(500, {-> interrupt()})
:terminal
:startinsert
```

To fix, we make sure `got_int` is cleared inside `terminal_execute` when
it detects `Ctrl_C`.

Closes #20726

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-08-20 06:23:56 +08:00
Gregory Anders
6d997f8068
fix(terminal): handle C0 characters in OSC terminator (#30090)
When a C0 character is present in an OSC terminator (i.e. after the ESC
but before a \ (0x5c) or printable character), vterm executes the
control character and resets the current string fragment. If the C0
character is the final byte in the sequence, the string fragment has a
zero length. However, because the VT parser is still in the "escape"
state, vterm attempts to subtract 1 from the string length (to account
for the escape character). When the string fragment is empty, this
causes an underflow in the unsigned size variable, resulting in a buffer
overflow.

The fix is simple: explicitly check if the string length is non-zero
before subtracting.
2024-08-19 06:43:06 -05:00
Gregory Anders
33464189bc
fix(vim.text): handle very long strings (#30075)
Lua's string.byte has a maximum (undocumented) allowable length, so
vim.text.hencode fails on large strings with the error "string slice too
long".

Instead of converting the string to an array of bytes up front, convert
each character to a byte one at a time.
2024-08-17 22:28:03 -05:00
zeertzjq
cce1eb0806
fix(api): error properly with invalid field in nvim_open_win (#30078) 2024-08-17 23:10:27 +00:00
zeertzjq
a25dbeee10 vim-patch:9.1.0677: :keepp does not retain the substitute pattern
Problem:  :keeppatterns does not retain the substitute pattern
          for a :s command
Solution: preserve the last substitute pattern when used with the
          :keeppatterns command modifier (Gregory Anders)

closes: vim/vim#15497

3b59be4ed8

Co-authored-by: Gregory Anders <greg@gpanders.com>
2024-08-17 06:34:59 +08:00
zeertzjq
b3d291c565 vim-patch:9.1.0678: [security]: use-after-free in alist_add()
Problem:  [security]: use-after-free in alist_add()
          (SuyueGuo)
Solution: Lock the current window, so that the reference to
          the argument list remains valid.

This fixes CVE-2024-43374

0a6e57b09b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-08-17 06:04:52 +08:00
zeertzjq
ee5aaba215
fix(man): avoid setting v:errmsg (#30052) 2024-08-15 22:02:20 +08:00
Gregory Anders
4199671047
feat(term): support OSC 8 hyperlinks in :terminal (#30050) 2024-08-15 06:09:14 -05:00
bfredl
ef4c9b136e refactor(tests): again yet more global highlight definitions 2024-08-14 14:03:34 +02:00
futsuuu
ab561302a3 test: remove internal assertions and simplify 2024-08-13 14:05:10 +01:00
futsuuu
b621921074 test: add a test to check the indentation 2024-08-13 14:05:10 +01:00
zeertzjq
37d97e771e
vim-patch:9.1.0672: marker folds may get corrupted on undo (#30026)
Problem:  marker folds may get corrupted on undo (Yousef Mohammed)
Solution: when adjusting folds, make sure that line1 is the lower limit
          and line2 is the upper line limit. In particular, line2 should
          not be able to get smaller than line1.

fixes: vim/vim#15455
closes: vim/vim#15466

8d02e5cf96

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-08-11 22:52:31 +00:00
Lewis Russell
9b5ab66678 test(lsp): refactor and tidy
- Merge all the top level 'LSP' describe blocks
- Refactor text edit tests
- Fix typing errors
- Add linebreaks between tests
2024-08-11 15:14:14 +01:00
Christian Clason
8df6736ca1 feat(term): enable reflow by default (#21124)
Problem: Contents of terminal buffer are not reflown when Nvim is
resized.

Solution: Enable reflow in libvterm by default. Now that libvterm is
vendored, also fix "TUI rapid resize" test failures there.

Note: Neovim's scrollback buffer does not support reflow (yet), so lines
vanishing into the buffer due to a too small window will be restored
without reflow.
2024-08-10 10:26:07 +02:00
zeertzjq
0ec43cb4b5
vim-patch:9.1.0667: Some other options reset curswant unnecessarily when set (#30020)
Problem:  Some other options reset curswant unnecessarily when set.
          (Andrew Haust)
Solution: Don't reset curswant when setting 'comments', 'commentstring'
          or 'define' (zeertzjq)

fixes: vim/vim#15462
closes: vim/vim#15467

b026a293b1
2024-08-10 08:05:30 +00:00
zeertzjq
4e8efe002e
vim-patch:9.1.0666: assert_equal() doesn't show multibyte string correctly (#30018)
Problem:  assert_equal() doesn't show multibyte string correctly
Solution: Properly advance over a multibyte char.
          (zeertzjq)

closes: vim/vim#15456

9c4b2462bb
2024-08-10 06:35:51 +08:00
zeertzjq
336ab2682e vim-patch:8.2.4860: MS-Windows: always uses current directory for executables
Problem:    MS-Windows: always uses current directory for executables.
Solution:   Check the NoDefaultCurrentDirectoryInExePath environment variable.
            (Yasuhiro Matsumoto, closes vim/vim#10341)

05cf63e9bd

Omit doc change: override in later doc update.

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2024-08-09 07:21:59 +08:00
zeertzjq
94cc293927 vim-patch:8.2.3477: startup test fails on MS-Windows
Problem:    Startup test fails on MS-Windows.
Solution:   Skip the test if not on Unix.

6d19798774

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-08-08 14:55:16 +08:00
zeertzjq
92186be428 vim-patch:8.2.3476: renaming a buffer on startup may cause using freed memory
Problem:    Renaming a buffer on startup may cause using freed memory.
Solution:   Check if the buffer is used in a window. (closes vim/vim#8955)

d3710cf01e

Cherry-pick Test_echo_true_in_cmd() from Vim.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-08-08 14:54:14 +08:00
zeertzjq
1937870114 vim-patch:9.1.0663: tests: zip test still resets 'shellslash' option
Problem:  tests: zip test still resets 'shellslash' option
Solution: Remove resetting the 'shellslash' option, the zip
          plugin should now be able to handle this options

closes: vim/vim#15434

91efcd115e

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-08-07 07:16:26 +08:00
zeertzjq
9307a53c7b
vim-patch:9.1.0661: the zip plugin is not tested. (#29993)
Problem:  the zip plugin is not tested.
Solution: include tests (Damien)

closes: vim/vim#15411

d7af21e746

Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com>
2024-08-06 22:53:05 +00:00