Compare commits

...

362 Commits

Author SHA1 Message Date
e96f75a4e6 NVIM 0.10.4
This is maintenance release, focusing on bug fixes. It also contains changes
to the available binary releases.

A Linux AArch64 binary has been added as part of the binary releases.
In addition, the previous "linux64" binary has been renamed to "linux-x86_64".
This is a BREAKING changes for scripts which consumes our binary releases.

FIXES
--------------------------------------------------------------------------------
- a8eddf1eb1 checkhealth: failed if 'lua' in plugin name
- 2bc5e1be0f decor: set invalid flag for end of invalidated paired marks
- d8149e5af9 inspect: use correct default highlight
- 357ee88606 jobs: do not block UI when jobwait() doesn't block (#31803)
- b0b383bff9 lsp: minimum height for floating popup #31990
- 4b25fe09cc lua: prevent SIGSEGV when lua error is NULL in libuv_worker (#32091)
- e477ac7c45 marks: revise metadata for start mark of revalidated pair #32017
- 22a327a20e mpack: remove invalid bool definition
- 87440e7bc5 runtime: let matchit and matchparen skips fallback on treesitter captures
- f132efaefb search: avoid quadratic time complexity when computing fuzzy score (#32153)
- ca10442e01 treesitter: don't open fold when o/O adds a line below #28709
- 323c43e1c4 treesitter: uv_dlclose after uv_dlerror
- a3cc513b67 treesitter.foldexpr: only refresh valid buffers
- a986048cb0 treesitter.foldexpr: refresh in the buffers affected by OptionSet
- d7ee06124d treesitter.foldexpr: robustness against ctrl-c
- 79030bf196 ui: ensure screen update before waiting for input #30576
- 3a50639331 9.1.0699: "dvgo" is not always an inclusive motion (#30173)
- 6a6c6b2658 9.1.0708: Recursive window update does not account for reset skipcol (#30217)
- 938a600847 9.1.1048: crash after scrolling and pasting in silent Ex mode (#32168)

BUILD
--------------------------------------------------------------------------------
- fdcdf560da release: add linux-arm64 appimage and tarball
- a7392c04d9 tests: add arm64 runner
2025-01-29 11:10:58 +01:00
8d420a32db ci(release)!: remove backwards compatible releases
Remove `nvim-linux64.tar.gz` and `nvim.appimage` as maintaining
these is too much work.

Also fix directory names to be consistent.

(cherry picked from commit 318676ad13)
2025-01-28 11:12:21 +01:00
fdcdf560da ci(release): add linux-arm64 appimage and tarball
Problem: No releases for ARM Linux.

Solution: Provide appimages and tarballs for `linux-arm64`. Rename
x86 releases to `linux-x86_64` for consistency.

(cherry picked from commit c1718d6863)
2025-01-28 11:12:21 +01:00
22a327a20e fix(mpack): remove invalid bool definition
This causes build failures with gcc 15.

Fixes #31723

(cherry picked from commit 83479b95ab)
2025-01-28 03:33:12 +00:00
d63848c918 Merge pull request #32197 from zeertzjq/backport
ci(tests): add arm64 runner
2025-01-28 11:16:55 +08:00
a6c54fdfc1 ci(tests): remove build-types jobs
Problem: Some CI jobs are redundant: `RelWithDebInfo` is already tested
on Linux-Arm64; `MinSizeRel` and Ninja Multi Config are not sufficiently
relevant in practice to spend CI cycles on.

Solution: Remove `build-types` job.
(cherry picked from commit 0fd4ef5da7)
2025-01-25 08:28:06 +08:00
a7392c04d9 ci(tests): add arm64 runner
Problem: Linux `aarch64`/`arm64` builds are not tested.

Solution: Add `ubuntu-arm` runners to test matrix (using
`RelWithDebInfo` build).

(cherry picked from commit 3702bcb139)
2025-01-25 08:27:55 +08:00
7908900859 docs(support): update tested macOS and FreeBSD versions (#32191) 2025-01-24 10:07:05 +00:00
a8eddf1eb1 fix(checkhealth): failed if 'lua' in plugin name
(cherry picked from commit 4c9f3689a1)
2025-01-23 08:25:31 +00:00
938a600847 vim-patch:9.1.1048: crash after scrolling and pasting in silent Ex mode (#32168)
Problem:  Crash after scrolling and pasting in silent Ex mode.
          (fizz-is-on-the-way)
Solution: Don't move cursor to line 0 when scrolling.
          (zeertzjq)

closes: vim/vim#16506

df098fedbc
(cherry picked from commit a9c12d4c29)
2025-01-23 00:36:43 +00:00
3a50639331 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>
(cherry picked from commit 0346666f71)
2025-01-22 07:17:20 +00:00
f132efaefb fix(search): avoid quadratic time complexity when computing fuzzy score (#32153)
(cherry picked from commit a8b6fa07c4)
2025-01-22 01:54:04 +00:00
46cc8a52b2 Merge pull request #32102 from tomtomjhj/cherrypick-ts-foldexpr
Backport treesitter foldexpr fixes
2025-01-19 11:31:47 -08:00
a3cc513b67 fix(treesitter.foldexpr): only refresh valid buffers
Problem: autocmd to refresh folds always uses the current buffer if the
option type is local. However, the current buffer may not have a parser,
and thus the assert that checks for a parser could fail.

Solution: check if the foldinfo contains the buffer, and only refresh if
so.
2025-01-20 00:27:42 +09:00
a986048cb0 fix(treesitter.foldexpr): refresh in the buffers affected by OptionSet 2025-01-20 00:27:39 +09:00
d7ee06124d fix(treesitter.foldexpr): robustness against ctrl-c
Problem:
Exiting the insert mode with ctrl-c does not trigger InsertLeave
autocmd. This may lead to nil error in treesitter foldexpr.

Solution:
Check nil. Folds still can be stale after exiting the insert mode with
ctrl-c, but it will be eventually updated correctly.

An alternative solution would be to ensure that exiting the insert mode
always triggers do_foldupdate. This can be done either by "fixing"
ctrl-c or with on_key callback that checks ctrl-c (nvim-cmp does this).
2025-01-20 00:26:52 +09:00
ca10442e01 fix(treesitter): don't open fold when o/O adds a line below #28709
Problem:
`o`-ing on a folded line opens the fold, because the new line gets the
fold level from the above line (level '='), which extends the fold to
the new line. `O` has a similar problem when run on the line below a
fold.

Solution:
Use -1 for the added line to get the lower level from the above/below
line.
2025-01-20 00:26:03 +09:00
4b25fe09cc fix(lua): prevent SIGSEGV when lua error is NULL in libuv_worker (#32091)
Problem:
Calling `xstrdup` with a NULL pointer causes a SIGSEGV if `lua_tostring` returns
NULL in `nlua_luv_thread_common_cfpcall`.

Crash stack trace:
- `_platform_strlen` → `xstrdup` (memory.c:469)
- `nlua_luv_thread_common_cfpcall` (executor.c:281)

Solution:
Check if `lua_tostring` returns NULL and pass NULL to `event_create` to avoid the crash.

(cherry picked from commit a5b1b83a26)

Co-authored-by: 林玮 (Jade Lin) <linw1995@icloud.com>
2025-01-19 01:00:18 +00:00
baaaf6a9e7 build: fix install 2025-01-15 21:27:02 +01:00
e477ac7c45 fix(marks): revise metadata for start mark of revalidated pair #32017
Problem:  Metadata may be revised for end mark of a revalidated pair.
Solution: Revise metadata for start mark of a revalidated pair.
(cherry picked from commit 5cc93ef472)
2025-01-15 10:56:52 +00:00
3b5c2213fd build: fix make install on cmake 3.13 and 3.14
Closes https://github.com/neovim/neovim/issues/30756.
2025-01-15 09:33:30 +01:00
5aabe5695f Update test/functional/plugin/lsp_spec.lua 2025-01-14 12:36:42 +00:00
b0b383bff9 fix(lsp): minimum height for floating popup #31990
Problem:
The floating window for hover and signature help always cuts off a few lines,
because the `_make_floating_popup_size` function counts empty lines as having
zero height.

Solution:
Ensure the height is at least 1.

(cherry picked from commit a4f575abd8)
2025-01-14 12:36:42 +00:00
323c43e1c4 fix(treesitter): uv_dlclose after uv_dlerror
(cherry picked from commit 5a54681025)
2025-01-14 09:48:10 +00:00
2bc5e1be0f fix(decor): set invalid flag for end of invalidated paired marks
(cherry picked from commit 87610d82db)
2025-01-10 07:41:32 +00:00
87440e7bc5 fix(runtime): let matchit and matchparen skips fallback on treesitter captures
When treesitter is enabled, by default syntax groups are not defined, but these
groups are used to identify where to skip matches in matchit and matchparen.

This patch does three things:
1. If syntax is enabled regardless of treesitter (`vim.bo.syntax='on'`):
   Use original implementation.
2. If treesitter is enabled and syntax is not:
   Match the syntax groups (i.e. `comment\|string`) against treesitter captures
   to check for skipped groups.
3. Add an explicit treesitter syntax for marking captures to skip:
   matchit uses `b:match_skip` to determine what counts as skippable
   Where 's:comment\|string' uses a match of the named syntax groups against
   a regex match of comment\|string, 't:comment\|string' now uses vim regex
   to match against the names of the treesitter capture groups.

(cherry picked from commit 69aa33d890)
2025-01-04 19:48:25 +00:00
357ee88606 fix(jobs): do not block UI when jobwait() doesn't block (#31803)
(cherry picked from commit efe1732c6f)
2025-01-03 17:16:40 +00:00
6a6c6b2658 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-12-28 17:16:37 +00:00
79030bf196 fix(ui): ensure screen update before waiting for input #30576
Ensure the screen is fully updated before blocking for input. This did
not always happen before, for example when setting `cursorline
scrolloff=9999`, which lead to jerky movement when using some GUI
applications.

Because of the duality of redraw_later, this can't be done in
command-line or when waiting for "Press ENTER". In many of those cases
the redraw is expected AFTER the key press, while normally it should
update the screen immediately. So, those special cases are excluded.

(cherry picked from commit 7eba016c86)
2024-12-28 17:16:37 +00:00
aa2b69b178 ci(build.yml): disable security restriction
A new security restriction in Ubuntu 24.04 prevents users from using
`unshare`, so we need to disable it in order for the test to work
properly.
2024-12-26 22:35:35 +01:00
b36cadcb8e build: specify POST_BUILD when using add_custom_command
This is needed specifically for the second signature of
add_custom_command, which appends an operation to an existing target.
This will prevent the cmake warning CMP0175.

Reference: https://cmake.org/cmake/help/latest/policy/CMP0175.html
(cherry picked from commit 07b14c8e2e)
2024-12-26 15:22:07 +01:00
d8149e5af9 fix(inspect): use correct default highlight
Problem: `vim.highlight` was renamed on `master`, breaking the
backported fix.

Solution: Use old name.

Fixup for 650dcbbafe
2024-12-23 11:23:41 +01:00
4e1b1b6fd7 version bump 2024-12-21 18:16:24 +01:00
9b5ee7df4e NVIM 0.10.3
Christmas edition. This is a maintenance release, focusing on fixes.

FEATURES
--------------------------------------------------------------------------------
- 085f1cc99d main: expand file ~\ or ~/ prefix on Windows

FIXES
--------------------------------------------------------------------------------
- f8ee92feec deps build for ARM64 MSVC
- 163a532cfa api: make `nvim_set_hl()` respect all `cterm` attributes (#31390)
- 6a63034b51 completion: avoid deleting text when completion leader changes #31448
- c257fe5582 coverity/510275: linematch out of bounds access (#30687)
- 7ca0408a1f defaults: don't replace keycodes in Visual search mappings (#31460)
- 71faa2be88 events: don't expand `args.file` for Lua callback (#31473)
- e80e8a0980 extmark: builtin completion can still affect nearby extmarks #31387
- 7abc58349e filetype: make filetype detection work with :doautocmd (#31470)
- 98ec48eefb inccommand: ensure cursor is where it belongs
- 650dcbbafe inspect: always show priority
- b5b84b806a inspect: show priority for treesitter highlights
- bf66871113 lsp: cancel pending requests before refreshing (#31500)
- 308e9719cf lsp: retrigger diagnostics request on server cancellation (#31345) (#31427)
- 84bbbd9fbe lsp: str_byteindex_enc bounds checking #30747
- 01fe4fc589 marks: skip right_gravity marks when deleting text
- 57b0fecd47 startup: report --startuptime error to stderr (#31131)
- 3c0e1a89d9 treesitter: show proper node name error messages
- bbefbc995e tui: avoid flushing buffer halfway an OSC 2 sequence (#30793)
- 424a452401 uri: uri_encode encodes brackets incorrectly for RFC2732 #31284
- 1a030f6e04 vim.system: invalid MAX_TIMEOUT for 32-bit systems #31638
- ee7885aa21 9.1.0759: screenpos() may return invalid position (#30681)

REFACTOR
--------------------------------------------------------------------------------
- b286ba419a fix incorrect use of enum (#30924)
- fb5a0e28db sort various Lua tables in src/ alphabetically (#30978)

DOCUMENTATION
--------------------------------------------------------------------------------
- 9455686b6f misc (#29410)
- 5480c0bd75 lua: "vim.bo" is always equivalent to :setlocal (#30733)
- 27fca9c7d2 lua: clarify when on_key "typed" will be empty (#30774)
2024-12-21 18:15:18 +01:00
1a030f6e04 fix(vim.system): invalid MAX_TIMEOUT for 32-bit systems #31638
The maximum signed value on 32-bit systems is 2 ^ 31 - 1. When using 2 ^ 31 for
the default timeout, the value would overflow on such systems resulting in
a negative value, which caused a stack trace when calling wait() without
a timeout.

(cherry picked from commit 4e130c1ee4)
2024-12-20 14:06:53 +00:00
bf66871113 fix(lsp): cancel pending requests before refreshing (#31500)
Problem:
Diagnostics and inlay hints can be expensive to calculate, and we
shouldn't stack them as this can cause noticeable lag.

Solution:
Check for duplicate inflight requests and cancel them before issuing a new one.
This ensures that only the latest request is processed, improving
performance and preventing potential conflicts.
2024-12-16 03:17:40 -08:00
424a452401 fix(uri): uri_encode encodes brackets incorrectly for RFC2732 #31284
**Problem:**
The brackets in the RFC2732 regular expression are currently unescaped,
causing them to be misinterpreted as special characters denoting
character groups rather than as literal characters.

**Solution:**
Escape the brackets.
Fix #31270

(cherry picked from commit 442d338cb5)
2024-12-11 14:14:33 +00:00
01fe4fc589 fix(marks): skip right_gravity marks when deleting text
Problem:  Marks that are properly restored by the splice associated with
          an undo edit, are unnecessarily pushed to the undo header. This
          results in incorrect mark tracking in the "copy_only"
          save/restore completion path.
Solution: Avoid pushing left gravity marks at the beginning of the range,
          and right gravity marks at the end of the range to the undo
          header.
(cherry picked from commit c4f76299f0)
2024-12-10 12:50:54 +00:00
7abc58349e fix(filetype): make filetype detection work with :doautocmd (#31470)
(cherry picked from commit 1077843b9b)
2024-12-10 03:17:12 +00:00
8fbe3e3941 Merge pull request #31532 from zeertzjq/backport
fix(events): don't expand `args.file` for Lua callback (#31473)
2024-12-10 10:51:40 +08:00
71faa2be88 fix(events): don't expand args.file for Lua callback (#31473)
Problem:  In an autocommand Lua callback whether `args.file` is expanded
          depends on whether `expand('<afile>')` has been called.
Solution: Always use the unexpanded file name for `args.file`.

Related to #31306 and vim/vim#16106. This doesn't provide `sfname`, but
at least makes `args.file` have a consistent value.
2024-12-10 10:19:01 +08:00
650dcbbafe fix(inspect): always show priority
Problem: It is not obvious if a treesitter highlight priority shown in
`:Inspect` is higher or lower than the default.

Solution: Also print default priority (`vim.hl.priorities.treesitter`).
Add padding for better readability.

(cherry picked from commit b52ffd0a59)
2024-12-07 16:51:17 +00:00
6a63034b51 fix(completion): avoid deleting text when completion leader changes #31448
Problem:  When completion leader changes, text that might be reinserted
          immediately after is deleted. This unnecessarily affects
          extmarks. #31387 restored the original extmarks but that
          prevents end_right_gravity marks from growing.
Solution: Avoid deleting leader text that will be reinserted.
(cherry picked from commit e788d1a3a9)
2024-12-07 14:54:33 +00:00
b5b84b806a fix(inspect): show priority for treesitter highlights
Problem: `:Inspect` does not show priority for treesitter highlights,
leading to confusion why sometimes earlier highlights override later
highlights.

Solution: Also print priority metadata if set.
(cherry picked from commit 9c278af7cc)
2024-12-07 09:51:46 +00:00
950048b206 Merge pull request #31461 from zeertzjq/backport
fix(defaults): don't replace keycodes in Visual search mappings (#31460)
2024-12-05 19:52:55 +08:00
7ca0408a1f fix(defaults): don't replace keycodes in Visual search mappings (#31460)
Also remove "silent" to be more consistent with Normal mode search.
2024-12-05 19:33:33 +08:00
78a36cdd55 Merge pull request #31452 from jamessan/backport-31358
Backport release build test fixes
2024-12-04 19:51:39 -07:00
694c3992ea test(marktree): expose test functions in release builds
In order to run the marktree unit test in release mode, the test functions need to be available even when NDEBUG is defined.

Keep the body of marktree_check a nop during release builds, which limits the usefulness of the testing, but at least lets the tests run.
2024-12-04 21:30:53 -05:00
9695650c0c ci: run tests directly rather than via the Makefile
Since the Makefile is not used to build, running the tests via the Makefile causes cmake to reconfigure and revert the release build back to debug.
2024-12-04 21:30:52 -05:00
7781111fef test(main_spec): make "nvim -v" test agnostic to build type
In release builds, the Compilation: line is omitted so the build is reproducible. Since the "fall-back for $VIM" line is always present, check for that instead.
2024-12-04 21:30:52 -05:00
4007c42b77 test(version_spec): expect vim.NIL, not nil, for "build" if not in a git clone 2024-12-04 21:30:52 -05:00
584b811aee test(main_spec): use CMakePresets.json instead of .git for root marker 2024-12-04 21:30:51 -05:00
a930b2666e ci(test): remove the .git directory for Linux
Tests should not rely on being run inside a git clone, so the Linux
builds cover this use case. The macOS builds will continue running with
the .git directory so there's still unix-ish coverage within a git
clone.
2024-12-04 21:30:51 -05:00
c36c4ddae2 ci: run one set of tests with a release build
This ensures that no tests fail due to differences between release and debug builds.

The release build-type check is now unnecessary, too, so remove it.
2024-12-04 21:30:43 -05:00
308e9719cf fix(lsp): retrigger diagnostics request on server cancellation (#31345) (#31427)
Co-authored-by: Jesse <github@jessebakker.com>
(cherry picked from commit 29c72cdf4a)
2024-12-02 12:13:23 -06:00
e80e8a0980 fix(extmark): builtin completion can still affect nearby extmarks #31387
Problem:
Built-in completion can still affect nearby extmarks. #31384

Solution:
Restore extmarks when completion leader changes.

(cherry picked from commit c7ec010ade)
2024-12-02 15:28:38 +00:00
163a532cfa fix(api): make nvim_set_hl() respect all cterm attributes (#31390)
(cherry picked from commit 8de1dc6923)
2024-12-02 00:51:14 +00:00
1a12dea191 test(filetype): symlink detection works after expand('<afile>') (#31307)
Also add a test for #31306, which currently fails.

(cherry picked from commit c697c49a76)
2024-11-22 11:44:04 +00:00
6f2786433d test(autocmd/termxx_spec): fix TextChangedT test flakiness (#31296)
Problem:  The E937 error appears for too short in TextChangedT test.
Solution: Only feed an Enter key after seeing the error.
(cherry picked from commit 3597633075)
2024-11-22 00:32:36 +00:00
085f1cc99d feat(main): expand file ~\ or ~/ prefix on Windows
In command_line_scan() for MSWIN, expand "~\" or "~/" prefixed paths to
the USERPROFILE environment variable for the user's profile directory.

Rename the static os_homedir() to os_uv_homedir() to emphasize that it
is a wrapper around a libuv function.

Add the function os_get_homedir() to os/env.c to return the cached
homedir value as a const. Must be called after homedir is initialized or
it fails.

The difference between this function and the static os_uv_homedir() is
that the latter gets the homedir from libuv and is used to initialize
homedir in init_homedir(), while os_get_homedir() just returns homedir
as a const if it's initialized and is public.

Use the os_get_homedir() accessor for ~/ expansion on Windows to make
the code more concise.

Add a Windows section to main_spec.lua with tests for expanding ~/ and
~\ prefixes for files passed in on the command-line.

Fix #23901

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-11-19 07:26:37 +08:00
3c0e1a89d9 fix(treesitter): show proper node name error messages
**Problem:** Currently node names with non-alphanumeric, non
underscore/hyphen characters (only possible with anonymous nodes) are
not given a proper error message. See tree-sitter issue 3892 for more
details.

**Solution:** Apply a different scanning logic to anonymous nodes to
correctly identify the entire node name (i.e., up until the final double
quote)

(cherry picked from commit 36990f324d)
2024-11-13 13:03:00 +00:00
57b0fecd47 fix(startup): report --startuptime error to stderr (#31131)
Problem:  Crash when initializing for --startuptime errors.
Solution: Report the error to stderr, as neither logging nor messages
          have been initialized yet.
(cherry picked from commit 17e00d0cc6)
2024-11-13 05:47:28 +00:00
f8ee92feec fix: deps build for ARM64 MSVC
Problem:

Neovim will not build for ARM64 using MSVC due to misconfigured
gettext dependency build settings.

Solution:

Fix the dependency build settings for gettext when building with MSVC.

(cherry picked from commit 7737f89206)
2024-11-09 15:48:00 +00:00
98ec48eefb fix(inccommand): ensure cursor is where it belongs
Problem:  Inccommand preview callback may flush inaccurate cmdline cursor position.
Solution: Ensure cursor is where it belongs when doing command preview.
(cherry picked from commit 59e130b6ca)
2024-11-09 15:26:32 +00:00
34a976ec2b ci: downgrade to clang 19
Clang 20 is still in development at the time of this commit and is
unsuitable for CI.

(cherry picked from commit 7d8dd8234a)
2024-11-09 15:09:52 +00:00
6a07b199ff vim-patch:9.1.0003: Cannot build against Ruby 33 dynamically (#30683)
Problem:  Cannot build against Ruby 33 dynamically
Solution: Ruby 33 removed transient heap, so do not use
          rb_ary_transient anymore, NoMethodError format changed,
          so update test for expected error message
          (Isao Sato)

- ruby-3.3 removed transient heap for ruby/dyn

when +ruby/dyn with ruby-3.3 do command :ruby, E448 occur.
ruby-3.3 has no transient heap anymore, so disable rb_ary_transient etc.

$ LC_ALL=C VIMRUNTIME=runtime ./src/vim -u NONE -c 'ruby puts RUBY_VERSION'
"=> Error detected while processing command line:
"=> E448: Could not load library function rb_ary_detransient
"=> E266: Sorry, this command is disabled, the Ruby library could not be
    loaded.

- ruby-3.3 changed NoMethodError format:

$ rvm 3.2.2, 3.3.0-rc1 do ruby -e 'begin; nil.name; rescue => e; puts "%s : %s"%[RUBY_VERSION, e.message]; end '
=> 3.2.2 : undefined method `name' for nil:NilClass
=> 3.3.0 : undefined method `name' for nil

so loose pattern in Test_ruby_Vim_buffer_get()

closes: vim/vim#13741

443657b32b

Co-authored-by: Isao Sato <svardew@gmail.com>
2024-11-09 13:11:47 +01:00
6550227110 ci: bump Intel macOS runners to 13
Problem: macos-12 GH runners are deprecated and will be removed soon.

Solution: use macos-13 runners instead.
2024-11-09 13:11:47 +01:00
b7f025e45b ci: adjust reviewers 2024-11-09 13:11:47 +01:00
6c12cfe18c ci: work around flaky python tests (#31063)
It's the same workaround as 88ed9ffcd1,
which was later removed in f707ce76ac
after it turned out to be stable after a while.
2024-11-09 13:11:47 +01:00
7774ca9107 ci: bump macos runner version to macos-15 2024-11-09 13:11:47 +01:00
348a939168 tests: skip watch.watchdirs test on macos 14 CI
Problem:
Strange failure only in macos 14 CI

    FAILED   test/functional/lua/watch_spec.lua @ 82: vim._watch watchdirs() detects file changes
    test/functional/lua/watch_spec.lua:149: Expected objects to be the same.
    Passed in:
    (table: 0x0116023758) {
     *[1] = {
        [change_type] = 3
       *[path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/nvim_KFMvPbXk9a' }
      [2] = {
        [change_type] = 3
        [path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/file' } }
    Expected:
    (table: 0x010d9d6548) {
     *[1] = {
        [change_type] = 1
       *[path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/file' }
      [2] = {
        [change_type] = 3
        [path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/file' } }

    stack traceback:
            test/functional/lua/watch_spec.lua:149: in function <test/functional/lua/watch_spec.lua:82>

Solution:
Skip test for that exact version.
2024-11-09 13:11:47 +01:00
9455686b6f docs: misc (#29410)
Co-authored-by: Michael Härtl <haertl.mike@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-11-09 13:11:47 +01:00
1a4e78832f ci: bump ubuntu runner version to ubuntu-24.04
Also bump clang to version 20.
2024-11-09 13:11:47 +01:00
fb5a0e28db refactor: sort various Lua tables in src/ alphabetically (#30978)
refactor: sort various Lua tables in src/ alphabetically (#30977)

(cherry picked from commit 42fa3d080e)

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-10-29 08:14:08 +08:00
b286ba419a refactor: fix incorrect use of enum (#30924)
refactor: fix incorrect use of enum (#30631)

(cherry picked from commit 184d5e7543)

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-10-24 12:43:15 +08:00
94f44122ad test(012_directory_spec): fix flakiness on Windows (#30921)
test(012_directory_spec): fix flakiness on Windows (#30920)

Problem:  012_directory_spec is flaky on Windows.
Solution: Use :%bwipe! instead :qall!.
(cherry picked from commit fffcb88ad6)

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-10-24 11:57:40 +08:00
0b0385ea6a test(rpc): retry flaky 'vim.rpcrequest and vim.rpcnotify' test (#30922)
Problem: 'vim.rpcrequest and vim.rpcnotify' is flaky on Windows.

Solution: retry it.
(cherry picked from commit 6fd13eedda)

Co-authored-by: Christian Clason <c.clason@uni-graz.at>
2024-10-24 11:45:24 +08:00
84bbbd9fbe fix(lsp): str_byteindex_enc bounds checking #30747
Problem:
Previously the index was only checked against the UTF8 length. This
could cause unexpected behaviours for strings containing multibyte chars

Solution:
Check indicies correctly against their max value before returning the
fallback length

(cherry picked from commit 80e37aa533)
2024-10-16 17:25:37 +00:00
bbefbc995e fix(tui): avoid flushing buffer halfway an OSC 2 sequence (#30793)
Problem:  Setting title while TUI buffer is almost full may cause the
          end of a flush to be treated as a part of an OSC 2 or OSC 0
          sequence, leading to problems like invisible cursor.
Solution: Make the whole sequence to set title a unibi_ext string.
(cherry picked from commit 4846bf05dc)
2024-10-15 00:18:12 +00:00
97aaea3478 test(tui_spec): use Unicode in cursor_address test (#30807)
Now that #16425 is fixed, use Unicode again to reduce screen height.
Unfortunately composing chars still can't be used, as it turns out that
composing chars may be missing when sent separately from the base char
at the last char a screen line.

(cherry picked from commit 1189c5ce59)
2024-10-14 08:20:44 +00:00
1a02f1835f test(autocmd/termxx_spec): properly setup TextChangedT tests (#30788) 2024-10-13 11:29:29 +08:00
2d1a13bdf5 vim-patch:9.1.0776: test_strftime may fail because of missing TZ data (#30780)
Problem:  test_strftime may fail because of missing TZ data
Solution: Use GMT offsets to validate timezone differences (James McCoy)

Some systems only provide timezones that follow the geographical region
naming (e.g. America/New_York) by default and require an additional
install for other names (like EST).

The GMT+<offset> format must always be honored, so use that to generate
distinct data for the test.

closes: vim/vim#15848

ea997edc7a

Co-authored-by: James McCoy <jamessan@jamessan.com>
(cherry picked from commit b0ddc1783a)
2024-10-12 22:54:59 +00:00
27fca9c7d2 docs(lua): clarify when on_key "typed" will be empty (#30774)
(cherry picked from commit 45f8f957c0)
2024-10-12 04:42:41 +00:00
5480c0bd75 docs(lua): "vim.bo" is always equivalent to :setlocal (#30733)
vim.bo

    :lua vim.bo.textwidth = 80
    :setglobal textwidth?
      textwidth=0

:setlocal

    :setlocal textwidth=80
    :setglobal textwidth?
      textwidth=0

:set

    :set textwidth=80
    :setglobal textwidth?
      textwidth=80

(cherry picked from commit 8ef3dd3afa)
2024-10-09 12:00:53 +00:00
c257fe5582 fix(coverity/510275): linematch out of bounds access (#30687)
Problem:
Int pointer cast to unsigned long pointer causes potential memory
corruption.

Solution:
Cast and store value first, then pass the new pointer.

(cherry picked from commit 60e1862ccb)
2024-10-07 23:45:57 +00:00
ee7885aa21 vim-patch:9.1.0759: screenpos() may return invalid position (#30681)
Problem:  screenpos() may return invalid position
          after switching buffers (Greg Hurrell)
Solution: reset w_leftcol if wrapping has been set
          after copying wrap option

fixes: vim/vim#15792
closes: vim/vim#15803

b065a10e24

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 9f26bdc416)
2024-10-05 23:14:33 +00:00
82ea8a7c3f version bump 2024-10-03 10:52:41 +02:00
8b98642002 NVIM 0.10.2
This is a maintainance release.

FEATURES
--------------------------------------------------------------------------------
- a3f9bd7f79 jumplist: allow opting out of removing unloaded buffers (#30419)

FIXES
--------------------------------------------------------------------------------
- be831a725d api: error properly with invalid field in nvim_open_win (#30078)
- 9b4e7c9a0d api: fix crash/leak with float title/footer on error (#30543)
- 26b72b0f91 api: nvim_buf_get_text() crashes with large negative column #28740
- e537379641 channel: handle writing to file instead of pipe (#30520)
- 1fc09b0738 column: set signcolumn width after splitting window (#30556)
- 5cb3505ab8 completion: don't include <Lua function> in -complete= (#30209)
- 40671f18f7 decor: don't use separate DecorSignHighlight for url (#30096)
- 95c3fd4dc0 decor: exclude invalid marks from meta total
- 21157459fe diagnostics: don't apply extmarks to invalid lines #29321
- f31e29fce4 diff: use mmfile_t in linematch
- 3a23149cfc filetype: handle .in files with no filename (#30487)
- 045afa9e8a float: properly find last window of tabpage (#30571)
- 006fd0304c health: fix pyenv root and python exepath detect issue
- 1e1e4066b1 health: return correct name from 'path2name()'
- 339067ab7e lsp: avoid reusing diagnostics from different servers in actions (#30002)
- 5955ef0ba8 lsp: don't send foreign diagnostics to servers in buf.code_action (#29501)
- e13564b9f4 lsp: handle encoding bounds in str_utfindex_enc
- f3675337f0 lsp: handle nil bytes in strings
- b55435f438 lsp: handle out-of-bounds character positions #30288
- d593b20017 lsp: return call hierarchy item, not the index (#30145)
- fa4bd6994d lua: ignore stdout and stderr for xdg-open
- 7284400a34 man: avoid setting v:errmsg (#30052)
- d000c56373 man: check if buffer is valid before restoring 'tagfunc' (#30180)
- b18538527e regexp: fix typo in E888 error message (#30161)
- ef05c514aa runtime: add remaining missing commentstrings (#30252)
- 7e15526dd2 runtime: sync bundled treesitter queries
- ad393c1fc1 runtime: sync bundled treesitter queries
- 316fa168a1 terminal: interrupt/got_int hangs terminal (#30094)
- c9d7ad4a34 treesitter: EditQuery shows swapfile ATTENTION #30536
- a6b2233c3e treesitter: escape things like `"` in omnifunc results
- 68a2259804 treesitter: indent size for inspect_tree #28727
- ba47b440fd treesitter: lint top-level anonymous nodes
- ee57bb5a8e tui: reset active attr ID when OSC 8 sequence is terminated (#29960)
- bce2364f60 tui: set id parameter in OSC 8 sequences (#29847)
- 4ad864dd09 version: return nil with empty string
- d63d379eec vim.ui.open: prefer xdg-open on WSL #30302
- 1f58e27600 win-msi: set installer scope to machine #29895
- 28fba3bf27 window: making float with title/footer non-float leaks memory (#30551)
- 2f3c447605 window: respect hide flag of float windows when switching (#30507)
- 6a44055a71 fix(vim.fs): dirname() returns "." on mingw/msys2 (#30484)

VIM PATCHES
--------------------------------------------------------------------------------
- 797f524337 7c8bbc6: runtime(doc): use mkdir -p to save a command
- 7550947157 9.0.2149: [security]: use-after-free in exec_instructions()
- 771b3a52c5 9.0.2158: [security]: use-after-free in check_argument_type
- a0a95edb2d 9.1.0638: E1510 may happen when formatting a message for smsg() (#29907)
- 1fda01fa55 9.1.0647: [security] use-after-free in tagstack_clear_entry
- 05e72488b9 9.1.0648: [security] double-free in dialog_changed()
- 2e1f656eb7 9.1.0653: Patch v9.1.0648 not completely right
- eec37b6e6b 9.1.0666: assert_equal() doesn't show multibyte string correctly (#30018)
- 9f8a5cd022 9.1.0667: Some other options reset curswant unnecessarily when set (#30020)
- 1ed493cc96 9.1.0694: matchparen is slow on a long line (#30134)
- 974447bfc3 9.1.0707: [security]: invalid cursor position may cause a crash (#30204)
- 886a8b62c5 9.1.0716: resetting setcellwidth() doesn't update the screen (#30274)
- 260ac4b3a2 9.1.0728: [security]: heap-use-after-free in garbage collection with location list user data
- b4824edac1 9.1.0729: Wrong cursor-screenline when resizing window
- 4abd480e8f 9.1.0730: Crash with cursor-screenline and narrow window
- 687c0078c2 9.1.0753: Wrong display when typing in diff mode with 'smoothscroll' (#30614)
- 8611f4dcf0 b584117: runtime(doc): buffers can be re-used (#30300)
- b5a2d52a36 e2c4e07: runtime(doc): Update :help :command-complete list
- ca6f8ee267 ecd642a: runtime(doc): clarify, that register 1-9 will always be shifted (#29476)

REFACTOR
--------------------------------------------------------------------------------
- 6aba2f3944 move some functions out of eval.c (#29964)

BUILD SYSTEM
--------------------------------------------------------------------------------
- 8d842a301c add quotes around `CMAKE_GENERATOR` variable
- e63e0a2e06 make makefile work on windows
- 1db8824fbc remove nix flakes (#28863)
- 53e37391e8 silence "po" noise #30469
- 983482626d work around bug in make when PATH includes cmake as dir
- 50a021e653 "Makefile: use pattern rules for build/.deps (#10366)"

CI
--------------------------------------------------------------------------------
- b020b66005 add `needs:backport` label on backport PRs with conflict
- 9d7711a732 don't add reviewers for PRs created by a bot
- 6f34f07a31 enable automerge by default when backporting
- 2c95d48083 remove "skip ci" tag
- d585f3103d skip automerge step if backport failed
- b65e978a23 update labeler configuration and add reviewers

TESTING
--------------------------------------------------------------------------------
- d535482ab2 api/buffer_updates_spec: prevent flakiness (#30521)
- 6a0d1eee46 api/window_spec: remove duplicate test (#30538)
- 61b0816790 health: "test_plug/health/init.lua" completes as "test_plug"
- 2a8d80a442 tui_spec: prevent another case of race between paste and input (#30481)

DOCUMENTATION
--------------------------------------------------------------------------------
- b380a8fe21 remove mention of removed parsers
- c7e943a181 eval: fix wrong return type of getcharsearch() (#30176)
- c2625b6fad treesitter: don't quote metadata
2024-10-03 10:48:34 +02:00
687c0078c2 vim-patch:9.1.0753: Wrong display when typing in diff mode with 'smoothscroll' (#30614)
Problem:  Wrong display when typing in diff mode with 'smoothscroll'.
Solution: Use adjust_plines_for_skipcol() (zeertzjq).

closes: vim/vim#15776

47f8584a80
(cherry picked from commit 0e484c2041)
2024-10-01 23:34:17 +00:00
68a2259804 fix(treesitter): indent size for inspect_tree #28727
Problem: For :InspectTree, indent size (`&shiftwidth`) for the tree
viewer may be incorrect.

This is because the tree viewer buffer with the filetype `query` does
not explicitly configures the tab size, which can mismatch with the
default indent size (2) assumed by TSTreeView's implementation.

Solution: Set shiftwidth to be the same as TSTreeViewOpts specifies,
which defaults to 2.

(cherry picked from commit 5331f87f61)
2024-10-01 16:30:12 +00:00
aa83d866c1 Merge pull request #30591 from lewis6991/backport-30526-to-release-0.10 2024-09-30 12:50:27 +01:00
f31e29fce4 fix(diff): use mmfile_t in linematch
Problem:

Linematch used to use strchr to navigate a string, however strchr does
not supoprt embedded NULs.

Solution:

Use `mmfile_t` instead of `char *` in linematch and introduce `strnchr()`.

Also remove heap allocations from `matching_char_iwhite()`

Fixes: #30505
(cherry picked from commit c65646c247)
2024-09-30 12:34:01 +01:00
045afa9e8a fix(float): properly find last window of tabpage (#30571)
(cherry picked from commit df915f3afc)
2024-09-29 10:55:55 +00:00
1fc09b0738 fix(column): set signcolumn width after splitting window (#30556)
(cherry picked from commit d5f6f61879)
2024-09-28 09:38:08 +00:00
28fba3bf27 fix(window): making float with title/footer non-float leaks memory (#30551)
(cherry picked from commit 4f9311b759)
2024-09-28 02:44:46 +00:00
2f3c447605 fix(window): respect hide flag of float windows when switching (#30507)
(cherry picked from commit 7b71fdbc1e)
2024-09-27 22:26:41 +00:00
9b4e7c9a0d fix(api): fix crash/leak with float title/footer on error (#30543)
(cherry picked from commit f55213ce0e)
2024-09-27 15:01:24 +00:00
6a0d1eee46 test(api/window_spec): remove duplicate test (#30538)
(cherry picked from commit eea6b84a87)
2024-09-27 11:47:55 +00:00
c9d7ad4a34 fix(treesitter): EditQuery shows swapfile ATTENTION #30536
Problem:
EditQuery shows swapfile ATTENTION, but this buffer is not intended for
preservation (and the dialog breaks the UX).

Solution:
Set 'noswapfile' on the buffer before renaming it.

(cherry picked from commit b63cd8cbae)
2024-09-27 10:55:11 +00:00
d535482ab2 test(api/buffer_updates_spec): prevent flakiness (#30521)
Use poke_eventloop() to wait for Nvim to finish processing input.

(cherry picked from commit 66197dde70)
2024-09-26 10:57:12 +00:00
e537379641 fix(channel): handle writing to file instead of pipe (#30520) 2024-09-26 08:43:51 +00:00
3a23149cfc 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

(cherry picked from commit 032e024f8a)
2024-09-23 23:04:34 +00:00
b380a8fe21 docs: remove mention of removed parsers
Partial backport of https://github.com/neovim/neovim/pull/29719.
2024-09-23 15:46:22 +02:00
6a44055a71 backport: fix(vim.fs): dirname() returns "." on mingw/msys2 (#30484)
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 13:41:47 +00:00
2a8d80a442 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.
(cherry picked from commit 5acdc4499e)
2024-09-23 12:14:20 +00:00
53e37391e8 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`.

(cherry picked from commit cac86e9b4c)
2024-09-23 09:43:37 +00:00
b65e978a23 ci: update labeler configuration and add reviewers
(cherry picked from commit 783f6079b8)
2024-09-21 11:39:42 +00:00
1db8824fbc build: remove nix flakes (#28863)
It does not work and we don't plan on maintaining these anymore.

The flake files are being moved to
https://github.com/nix-community/neovim-nightly-overlay/pull/516
instead.

(cherry picked from commit 0e9c92a900)
2024-09-20 21:51:13 +00:00
d5a0e4ec5b fix(build): issues with s390x CI
Does not fix everything, but at least let's test run to finish before
timeout

(cherry picked from commit 176bfea135)
2024-09-20 21:44:30 +00:00
983482626d 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>
(cherry picked from commit e268fcbdaa)
2024-09-20 20:53:02 +00:00
8d842a301c build: add quotes around CMAKE_GENERATOR variable
This will fix the following error when using generators that have a
space in them, e.g. "Unix Makefiles":

"CMake Error: Could not create named generator Unix".

Closes https://github.com/neovim/neovim/issues/30218.

(cherry picked from commit ef8067a19d)
2024-09-20 20:31:39 +00:00
e63e0a2e06 build: make makefile work on windows
Using powershell as the default windows shell as using cmd alters $PATH
in a way that makes building neovim fail (powershell prioritizes visual
studio tools which is arguably more correct).

This was tested with gnu make for windows, which can be installed with
e.g. scoop. It does not work with nmake and it is extremely unlikely we
want to add nmake support as the makefile is merely supposed to be
syntactic sugar for the most common case. For similar reasons, the only
supported generator is ninja.

(cherry picked from commit 4ee65484b1)
2024-09-20 20:09:17 +00:00
50a021e653 revert: "Makefile: use pattern rules for build/.deps (#10366)"
This reverts commit 7f6ff829aa.

The given reasoning and usecase is unsatisfactory. While it is true that
it allows to run `make build/bin/nvim`, it can easily be recreated with
`ninja -C build bin/nvim` which does the exact same thing. This minor
convenience is not worth adding the extra code given how rare this
usecase should be.

(cherry picked from commit 3085c9d9da)
2024-09-20 19:26:25 +00:00
2c95d48083 ci: remove "skip ci" tag
We can't skip CI runs as there are required checks that needs to always
be run.

(cherry picked from commit dafd944a46)
2024-09-20 15:28:41 +00:00
ba47b440fd 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 17:15:43 +02:00
9d7711a732 ci: don't add reviewers for PRs created by a bot
This will ensure automatic backports created by the backport action does
not request reviewers (since the commit in question has already been
vetted and merged), but manual backports created by users does request
reviewers as these commits has not been vetted previously.

(cherry picked from commit 755512ed60)
2024-09-20 14:51:55 +00:00
a3f9bd7f79 feat(jumplist): allow opting out of removing unloaded buffers (#30419)
Problem:  Cannot opt out of removing unloaded buffers from the jumplist.
Solution: Only enable that with "clean" flag in 'jumpoptions'.
2024-09-19 10:32:50 +00:00
017a054e82 Merge pull request #30393 from justinmk/release
backport: vim.ui.open fixes
2024-09-16 03:27:47 -07:00
d63d379eec fix(vim.ui.open): prefer xdg-open on WSL #30302
xdg-open is usually not installed in WSL. But if the user deliberately
installs it, presumably they want to prioritize it.
2024-09-16 12:04:01 +02:00
fa4bd6994d fix(lua): ignore stdout and stderr for xdg-open
Ref #19724
Fix #29932
2024-09-16 12:03:49 +02:00
4abd480e8f vim-patch:9.1.0730: Crash with cursor-screenline and narrow window
Problem:  Crash with cursor-screenline and narrow window
          (elig0n)
Solution: Don't set right_col when width2 is 0 (zeertzjq).

fixes: vim/vim#15677
closes: vim/vim#15678

59149f0269
(cherry picked from commit 5191a11d66)
2024-09-14 12:17:48 +00:00
b4824edac1 vim-patch:9.1.0729: Wrong cursor-screenline when resizing window
Problem:  Wrong cursor-screenline when resizing window
Solution: Invalidate saved left_col and right_col when width1 or width2
          change.

closes: vim/vim#15679

86dc4f8b43
(cherry picked from commit 90585e47fe)
2024-09-14 12:17:48 +00:00
e464b8c90d Merge pull request #30380 from zeertzjq/backport
Manual backport of #30377 to release-0.10
2024-09-14 20:04:10 +08:00
260ac4b3a2 vim-patch:9.1.0728: [security]: heap-use-after-free in garbage collection with location list user data
Problem:  heap-use-after-free in garbage collection with location list
          user data.
Solution: Mark user data as in use when no other window is referencing
          the location list (zeertzjq)

fixes: neovim/neovim#30371
closes: vim/vim#15683

be4bd189d2
2024-09-14 19:35:17 +08:00
d585f3103d ci: skip automerge step if backport failed
(cherry picked from commit 67d6b6f27e)
2024-09-14 00:18:58 +00:00
f3675337f0 fix(lsp): handle nil bytes in strings
Problem:

The LSP omnifunc can insert nil bytes, which when read in other places
(like semantic token) could cause an error:

    semantic_tokens.lua:304: Vim:E976: Using a Blob as a String

Solution:

Use `#line` instead of `vim.fn.strlen(line)`. Both return UTF-8 bytes
but the latter can't handle nil bytes.

Completion candidates can currently insert nil bytes, if other parts of
Alternative fix to https://github.com/neovim/neovim/pull/30359

Note that https://github.com/neovim/neovim/pull/30315 will avoid the
insertion of nil bytes from the LSP omnifunc, but the change of this PR
can more easily be backported.

(cherry picked from commit 8512f669f0)
2024-09-13 20:59:13 +00:00
b020b66005 ci: add needs:backport label on backport PRs with conflict
This makes it easy to keep track of which backport PRs have failed and
need manual intervention to fix.

(cherry picked from commit 4c23b83456)
2024-09-13 15:16:35 +00:00
6f34f07a31 ci: enable automerge by default when backporting
This will automatically merge backported PRs without human intervention
if the tests pass.

(cherry picked from commit 057314345a)
2024-09-13 10:57:22 +00:00
23a9c67f1b Merge pull request #30344 from tris203/backport-30342-to-release-0.10
fix(health): "test_plug/health/init.lua" completes "test_plug"
2024-09-12 10:31:43 +08:00
61b0816790 test(health): "test_plug/health/init.lua" completes as "test_plug"
(cherry picked from commit 7b680e0ca9)
2024-09-11 16:07:29 +01:00
1e1e4066b1 fix(health): return correct name from 'path2name()'
`path2name()` function doesn't process `'pluginname/health/init.lua'` correctly. Instead of retruning `'pluginname'` it returns `'pluginname.health'`

(cherry picked from commit 237d2aef4d)
2024-09-11 14:36:22 +01:00
ef05c514aa fix(runtime): add remaining missing commentstrings (#30252)
(cherry picked from commit 9ddfcb64bf)
2024-09-10 09:51:05 +02:00
e13564b9f4 fix(lsp): handle encoding bounds in str_utfindex_enc
Problem:
str_utfindex_enc could return an error if the index was longer than the
line length. This was handled in each of the calls to it individually

Solution:
* Fix the call at the source level so that if the index is higher than
  the line length, utf length is returned

(cherry picked from commit f279d1ae33)
2024-09-10 09:49:25 +02:00
b55435f438 fix(lsp): handle out-of-bounds character positions #30288
Problem:
str_byteindex_enc could return an error if the index was longer than the
lline length. This was handled in each of the calls to it individually

Solution:
* Fix the call at the source level so that if the index is higher than
  the line length, line length is returned as per LSP specification
* Remove pcalls on str_byteindex_enc calls. No longer needed now that
  str_byteindex_enc has a bounds check.
2024-09-08 21:01:58 +02:00
461ed5e6bd Merge pull request #30303 from neovim/backport-30300-to-release-0.10
vim-patch:b584117: runtime(doc): buffers can be re-used
2024-09-08 06:03:38 +08:00
8611f4dcf0 vim-patch:b584117: runtime(doc): buffers can be re-used (#30300)
while at it, also move the note about :wincmd
directly to :h :wincmd, it doesn't seem to belong to the buffer section.

closes: vim/vim#15636

b584117b05

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit b40ec083ae)
2024-09-07 21:42:02 +00:00
95c3fd4dc0 fix(decor): exclude invalid marks from meta total
Problem:  Marktree meta count still includes invalidated marks, making
          guards that check the meta total ineffective.
Solution: Revise marktree metadata when in/revalidating a mark.
2024-09-06 14:20:46 +02:00
59d3d76b79 Merge pull request #30276 from neovim/backport-30274-to-release-0.10
vim-patch:9.1.0716: resetting setcellwidth() doesn't update the screen
2024-09-06 07:32:52 +08:00
886a8b62c5 vim-patch:9.1.0716: resetting setcellwidth() doesn't update the screen (#30274)
Problem:  resetting setcellwidth() doesn't update the screen
Solution: Redraw after clearing the cellwidth table (Ken Takata)

closes: vim/vim#15628

539e9b571a

Co-authored-by: Ken Takata <kentkt@csc.jp>
(cherry picked from commit d60c753cff)
2024-09-05 22:52:31 +00:00
26b72b0f91 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.

(cherry picked from commit d1d7d54680)
2024-09-03 15:30:37 +02:00
1fe8dc4d2c Merge pull request #30211 from neovim/backport-30209-to-release-0.10
fix(completion): don't include <Lua function> in -complete=
2024-09-01 08:26:33 +08:00
5cb3505ab8 fix(completion): don't include <Lua function> in -complete= (#30209)
(cherry picked from commit bfa365a872)
2024-08-31 23:58:51 +00:00
0f6f5c4682 Merge pull request #30210 from neovim/backport-30207-to-release-0.10
vim-patch: doc updates
2024-09-01 07:56:44 +08:00
b5a2d52a36 vim-patch:e2c4e07: runtime(doc): Update :help :command-complete list
closes: vim/vim#15602

e2c4e07795

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
(cherry picked from commit 751ab0e4ca)
2024-08-31 22:56:45 +00:00
797f524337 vim-patch:7c8bbc6: runtime(doc): use mkdir -p to save a command
closes: vim/vim#15599

7c8bbc6d28

Co-authored-by: Ughur Alakbarov <58857108+ugur-a@users.noreply.github.com>
(cherry picked from commit 5f81c36934)
2024-08-31 22:56:45 +00:00
8aea03f7b2 Merge pull request #30205 from neovim/backport-30204-to-release-0.10
vim-patch:9.1.0707: [security]: invalid cursor position may cause a crash
2024-09-01 05:29:20 +08:00
974447bfc3 vim-patch:9.1.0707: [security]: invalid cursor position may cause a crash (#30204)
Problem:  [security]: invalid cursor position may cause a crash
          (after v9.1.0038)
Solution: Set cursor to the last character in a line, if it would
          otherwise point to beyond the line; no tests added, as it
          is unclear how to reproduce this.

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-4ghr-c62x-cqfh

396fd1ec29

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 6f167fcae9)
2024-08-31 21:08:30 +00:00
6ed530baa5 Merge pull request #30182 from neovim/backport-30180-to-release-0.10
fix(man): check if buffer is valid before restoring 'tagfunc'
2024-08-29 20:21:47 +08:00
d000c56373 fix(man): check if buffer is valid before restoring 'tagfunc' (#30180)
(cherry picked from commit 7588ff2d89)
2024-08-29 11:54:09 +00:00
2a32ec784c Merge pull request #30178 from neovim/backport-30176-to-release-0.10
docs(eval): wrong return type of getcharsearch
2024-08-29 18:30:46 +08:00
c7e943a181 docs(eval): fix wrong return type of getcharsearch() (#30176)
(cherry picked from commit 6c2186a998)
2024-08-29 10:02:42 +00:00
d874ba319d Merge pull request #30163 from neovim/backport-30161-to-release-0.10
fix(regexp): fix typo in E888 error message
2024-08-28 11:00:30 +08:00
b18538527e fix(regexp): fix typo in E888 error message (#30161)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
(cherry picked from commit 3bcd5624be)
2024-08-28 02:40:19 +00:00
a6b2233c3e fix(treesitter): escape things like " in omnifunc results
(cherry picked from commit f8e1ebd6f6)
2024-08-27 09:52:11 +02:00
d593b20017 fix(lsp): return call hierarchy item, not the index (#30145)
(cherry picked from commit d9ccd828b0)
2024-08-26 18:19:40 +02:00
7834d80b81 Merge pull request #30137 from neovim/backport-30134-to-release-0.10
vim-patch:9.1.0694: matchparen is slow on a long line
2024-08-25 06:30:50 +08:00
1ed493cc96 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
(cherry picked from commit cf44121f7f)
2024-08-24 22:08:04 +00:00
dca6c4e92c Merge pull request #30097 from neovim/backport-30096-to-release-0.10
fix(decor): don't use separate DecorSignHighlight for url
2024-08-20 09:26:46 +08:00
40671f18f7 fix(decor): don't use separate DecorSignHighlight for url (#30096)
(cherry picked from commit a8fbe1d409)
2024-08-20 00:20:41 +00:00
316fa168a1 fix(terminal): interrupt/got_int hangs terminal (#30094)
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>
Co-authored-by: ibhagwan <59988195+ibhagwan@users.noreply.github.com>
2024-08-20 06:48:13 +08:00
be831a725d fix(api): error properly with invalid field in nvim_open_win (#30078)
(cherry picked from commit cce1eb0806)
2024-08-18 01:33:50 +02:00
1fd86be15c Merge pull request #30063 from neovim/backport-30052-to-release-0.10
fix(man): avoid setting v:errmsg
2024-08-15 22:28:10 +08:00
7284400a34 fix(man): avoid setting v:errmsg (#30052)
(cherry picked from commit ee5aaba215)
2024-08-15 14:02:55 +00:00
3ca127063b Merge pull request #30054 from neovim/backport-29476-to-release-0.10
vim-patch:ecd642a: runtime(doc): clarify, that register 1-9 will always be shifted
2024-08-15 11:50:38 +08:00
ca6f8ee267 vim-patch:ecd642a: runtime(doc): clarify, that register 1-9 will always be shifted (#29476)
related: vim/vim#15077

ecd642af43

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 1922f7e32b)
2024-08-15 03:24:31 +00:00
e4492677ee Merge pull request #30031 from neovim/backport-29895-to-release-0.10
fix(win-msi): set installer scope to machine
2024-08-13 07:08:26 +08:00
1f58e27600 fix(win-msi): set installer scope to machine #29895
Problem:
The windows installer did not have the AllUsers property which leads to
the installer being misidentified as per user installer.
Currently the installer already requires administrative privileges and
installs into the system-wide ProgramFiles directory, but the start menu
entry and uninstaller registration are created only for the current user.
Issue: #29885

https://cmake.org/cmake/help/latest/cpack_gen/wix.html#variable:CPACK_WIX_INSTALL_SCOPE

Solution:
With setting CPACK_WIX_INSTALL_SCOPE to "perMachine" the generated msi
installer includes the Property ALLUSERS=1.
Additionally the start menu entries and uninstaller registration will be
created for all users.

(cherry picked from commit 88f07d6ca4)
2024-08-12 22:48:24 +00:00
b0bac2a339 Merge pull request #30021 from neovim/backport-30020-to-release-0.10
vim-patch:9.1.0667: Some other options reset curswant unnecessarily when set
2024-08-10 16:28:03 +08:00
9f8a5cd022 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
(cherry picked from commit 0ec43cb4b5)
2024-08-10 08:05:47 +00:00
4552a9629a Merge pull request #30019 from neovim/backport-30018-to-release-0.10
vim-patch:9.1.0666: assert_equal() doesn't show multibyte string correctly
2024-08-10 06:59:18 +08:00
eec37b6e6b 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
(cherry picked from commit 4e8efe002e)
2024-08-09 22:36:10 +00:00
339067ab7e fix(lsp): avoid reusing diagnostics from different servers in actions (#30002)
Problem: When preparing the parameters for a code actions LSP request,
the code set `context.diagnostics` when processing the first LSP client,
and then reused those `context.diagnostics` for subsequent LSP clients.

This meant that the second and next LSP clients got diagnostics that
did not originate from them, and they did not get the diagnostics that
they sent.

Solution: Avoid setting `context.diagnostics` (which is referenced by
all clients). Instead, set `params.context.diagnostics` directly, which
is specific to a single client.

Fixes #30001
Caused by #29501

(cherry picked from commit 7031949be0)
2024-08-07 18:09:27 +02:00
ee57bb5a8e fix(tui): reset active attr ID when OSC 8 sequence is terminated (#29960)
When the cursor is moved we terminate any active OSC 8 sequences to
prevent the sequence from inadvertently spanning regions it is not meant
to span. However, if we do not also reset the TUI's active attr id
(print_attr_id) then the TUI does not "know" that it's current attribute
set has changed. When cursor_goto is called to wrap a line, the TUI does
not recompute the attributes so the OSC 8 sequence is not restarted
again.

When we terminate an OSC 8 sequence before moving the cursor, also reset
the active attr id so that the attributes are recomputed for URLs.

(cherry picked from commit f32557ca67)
2024-08-03 16:02:48 +02:00
dd0f6afa00 Merge pull request #29968 from neovim/backport-29967-to-release-0.10
vim-patch:9.1.{0648,0653}
2024-08-03 09:10:04 +08:00
2e1f656eb7 vim-patch:9.1.0653: Patch v9.1.0648 not completely right
Problem:  Patch v9.1.0648 not completely right
          (zeertzjq)
Solution: Remove always true condition

closes: vim/vim#15415

a0b5bc1285

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 4c886d0e73)
2024-08-03 00:46:14 +00:00
05e72488b9 vim-patch:9.1.0648: [security] double-free in dialog_changed()
Problem:  [security] double-free in dialog_changed()
          (SuyueGuo)
Solution: Only clear pointer b_sfname pointer, if it is different
          than the b_ffname pointer.  Don't try to free b_fname,
          set it to NULL instead.

fixes: vim/vim#15403

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-46pw-v7qw-xc2f

b29f4abcd4

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 6967c08840)
2024-08-03 00:46:14 +00:00
187c93d7e5 Merge pull request #29965 from neovim/backport-29964-to-release-0.10
refactor: move some functions out of eval.c
2024-08-03 08:05:29 +08:00
6aba2f3944 refactor: move some functions out of eval.c (#29964)
- common_function() has always been in evalfunc.c in Vim
- return_register() has always been in evalfunc.c in Vim
- get_user_input() was moved to ex_getln.c in Vim 8.1.1957
- tv_get_lnum_buf() was moved to typval.c in Vim 8.2.0847

(cherry picked from commit 383f693472)
2024-08-02 23:43:10 +00:00
21157459fe fix(diagnostics): don't apply extmarks to invalid lines #29321
Problem:
If there are errors in the last line of a buffer, something like `Gdk` or
`G2k3J` will produce an error (at least with `lua_ls`):

    Error executing vim.schedule lua callback:
    .../neovim/share/nvim/runtime/lua/vim/diagnostic.lua:1446: Invalid 'line': out of range

Solution:
Only set extmarks if the target buffer line still exists

(cherry picked from commit e5e81262af)
2024-08-02 16:04:35 +02:00
5955ef0ba8 fix(lsp): don't send foreign diagnostics to servers in buf.code_action (#29501)
`buf.code_action` always included diagnostics on a given line from all
clients. Servers should only receive diagnostics they published, and in
the exact same format they sent it.

Should fix https://github.com/neovim/neovim/issues/29500

(cherry picked from commit 720b309c78)
2024-08-02 12:59:41 +02:00
3af1495af0 Merge pull request #29947 from neovim/backport-29945-to-release-0.10
vim-patch:9.0.{2149,2158},9.1.0647
2024-08-02 08:39:30 +08:00
1fda01fa55 vim-patch:9.1.0647: [security] use-after-free in tagstack_clear_entry
Problem:  [security] use-after-free in tagstack_clear_entry
          (Suyue Guo )
Solution: Instead of manually calling vim_free() on each of the tagstack
          entries, let's use tagstack_clear_entry(), which will
          also free the stack, but using the VIM_CLEAR macro,
          which prevents a use-after-free by setting those pointers
          to NULL

This addresses CVE-2024-41957

Github advisory:
https://github.com/vim/vim/security/advisories/GHSA-f9cr-gv85-hcr4

8a0bbe7b8a

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 6af359ef4c)
2024-08-02 08:16:53 +08:00
771b3a52c5 vim-patch:9.0.2158: [security]: use-after-free in check_argument_type
Problem:  [security]: use-after-free in check_argument_type
Solution: Reset function type pointer when freeing the function type
          list

function pointer fp->uf_func_type may point to the same memory, that was
allocated for fp->uf_type_list. However, when cleaning up a function
definition (e.g. because it was invalid), fp->uf_type_list will be
freed, but fp->uf_func_type may still point to the same (now) invalid
memory address.

So when freeing the fp->uf_type_list, check if fp->func_type points to
any of those types and if it does, reset the fp->uf_func_type pointer to
the t_func_any (default) type pointer

closes: vim/vim#13652

0f28791b21

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit a4bec30b7b)
2024-08-01 23:36:57 +00:00
7550947157 vim-patch:9.0.2149: [security]: use-after-free in exec_instructions()
Problem:  [security]: use-after-free in exec_instructions()
Solution: get tv pointer again

[security]: use-after-free in exec_instructions()

exec_instructions may access freed memory, if the GA_GROWS_FAILS()
re-allocates memory. When this happens, the typval tv may still point to
now already freed memory. So let's get that pointer again and compare it
with tv. If those two pointers differ, tv is now invalid and we have to
refresh the tv pointer.

closes: vim/vim#13621

5dd41d4b63

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 9f2d793068)
2024-08-01 23:36:57 +00:00
c43dd3ef6f Merge pull request #29908 from neovim/backport-29907-to-release-0.10
vim-patch:9.1.0638: E1510 may happen when formatting a message for smsg()
2024-07-30 06:49:21 +08:00
a0a95edb2d vim-patch:9.1.0638: E1510 may happen when formatting a message for smsg() (#29907)
Problem:  E1510 may happen when formatting a message
          (after 9.1.0181).
Solution: Only give E1510 when using typval. (zeertzjq)

closes: vim/vim#15391

0dff31576a
(cherry picked from commit d131c48c82)
2024-07-29 22:26:31 +00:00
c2625b6fad docs(treesitter): don't quote metadata
(cherry picked from commit 5aa1a9532c)
2024-07-28 16:36:22 +02:00
ad393c1fc1 fix(runtime): sync bundled treesitter queries
(cherry picked from commit 9e80738f30)
2024-07-28 16:36:22 +02:00
4ad864dd09 fix(version): return nil with empty string
(cherry picked from commit 8bdfc2ab2b)
2024-07-27 15:30:53 +02:00
bce2364f60 fix(tui): set id parameter in OSC 8 sequences (#29847)
The id parameter is used to communicate to the terminal that two URLs
are the same. Without an id, the terminal must rely on heuristics to
determine which cells belong together to make a single hyperlink.

See the relevant section in the spec [1] for more details.

[1]: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter

(cherry picked from commit b02c839414)
2024-07-24 15:18:47 -05:00
006fd0304c fix(health): fix pyenv root and python exepath detect issue
Fix the following two issues:

- pyenv root detection issue

When `PYENV_ROOT` environment variable is not set, neovim will detect
pyenv's root via `pyenv root` command, but which will be always fail
because `vim.fn.system()` returns result with additional `\n`. Using
`vim.system` instead prevents this problem. to trim it before check
whether it is exists

- python executable path detection issue

Filter unrelated `python-config` in cases where multiple python versions
are installed, e.g. `python-config`, `python3.10-config`,
`python3.11-config` etc.

(cherry picked from commit b4b4cf46a7)
2024-07-24 17:15:09 +02:00
7e15526dd2 fix(runtime): sync bundled treesitter queries
(cherry picked from commit 862338255d)
2024-07-24 17:02:12 +02:00
85ac560947 version bump 2024-07-24 09:23:38 +02:00
7e194f0d0c NVIM 0.10.1
This is a maintenance release.

FEATURES
--------------------------------------------------------------------------------
- ebc6c38cde lsp: update LSP healthcheck format (#28988)

BUILD
--------------------------------------------------------------------------------
- ba90b54301 deps: drop unused bundled bash, python parsers and queries
- 803cc08c17 deps: bump tree-sitter-c to v0.21.3
- 91e337a477 deps: bump tree-sitter-query to v0.4.0
- 978b63a9f1 deps: bump tree-sitter-vimdoc to v3.0.0
- b322c3560b "popcount" name conflict on NetBSD #28983
- b397b5672c remove -O2 from gen_cflags
- f77db12995 reuse code for deps.txt for both deps and main build
- 46d2906332 macos: disable deduplication in link step

FIXES
--------------------------------------------------------------------------------
- 70f7708cdf assert failure in VimL expression parser
- 28f03205be show swapfile warning as a warning (#28972)
- 0d293e4315 api: alloc and draw cursor window in nvim__redraw
- e1b6187801 colorscheme: underline StatusLineNC with 'notermguicolors' #28810
- aa1321801d column: clamp line number for legacy signs
- df6ce8377f column: crash with 'signcolumn' set to "number" (#29003)
- 97be9d8563 column: modifying a sign should update placed signs (#29750)
- 21b21b94e6 comment: fall back to using trimmed comment markers (#28950)
- 0827279ff5 defaults: default @/Q broken when 'ignorecase' is set (#29343)
- 5d9f2d7ecc drawline: don't draw beyond end of window (#29035)
- eadc4e03a2 drawline: don't draw beyond end of window with 'rnu' (#29406)
- bec397edda extmarks: issues with revalidating marks #28961
- 1fe1f8556e filetype: fix typos in filetype detection
- ad55ec350c float: handle error in win_float_create() (#29742)
- bf16fe3f01 fs: make vim.fs.root work for relative paths and unnamed buffers (#28973)
- 5eaae797af health: broken ruby detect #28804
- 24ee2e7c74 health: fix fetching url with python in provider health (#29594)
- 7582d4a7b5 input: handle vim.on_key() properly with ALT and K_SPECIAL (#29677)
- 4f0c4c3921 lsp: add textDocument/documentLink to capability map (#28838)
- 2d7aab623e lsp: avoid vim.keymap.del error when stopping a client (#29478)
- bdd5871dc5 lsp: check if buffer was detached in on_init callback (#28942)
- d8ff216040 lsp: clear lsp client diagnostics (#29091)
- 3a727beafd lsp: detach all clients on_reload to force buf_state reload (#28898)
- e98637e8c0 lsp: do not detach from buffer if there are uninitialized clients (#29043)
- 0ee3147bc7 lsp: do not reset buf version when detaching client (#29273)
- 24fa65a500 lsp: don't show codelens for buffers that don't support it (#29690)
- 4efca7cda5 lsp: handle nil root_dir in health check (#29010)
- efe8a0a520 lsp: hide layout in codelenses in virtual text (#28794) (#28895)
- 2fb69ccaf7 lsp: inlay hints are rendered in the correct order (#29707)
- dfff482efe lsp: remove superfluous on_detach callback from semantic tokens module (#29188)
- 10a16c1311 lsp: trigger LspDetach on buffer delete
- 33121f1eae lua: change some vim.fn.expand() to vim.fs.normalize() (#29583)
- ffc457a1dc marks: revalidate marks whose position did not change
- f82d7b8200 mouse: early return when clicking in padded 'statuscolumn' (#29394)
- d6756fc0a5 move: half-page scrolling with resized grid at eob (#28821)
- 0cf7e2570c path: avoid chdir() when resolving path (#28799)
- 63ff7338ea quickfix: make shortmess+=O work with cmdheight=0 (#29609)
- 46c2962b3a runtime: add commentstring for glsl ftplugin
- b98aa783f3 runtime: source c ftplugin properly for cpp on Windows (#29053)
- 039121f5a3 snippet: cancel snippet session when leaving the buffer (#29044)
- 84d7bfcf16 snippet: don't override unnamed register on tabstop select (#29008)
- e13f03af85 snippet: modify base indentation when there's actually whitespace (#29670)
- 9fd6664ba7 tohtml: extmark text may be out of bounds
- 8c88f402e1 tohtml: ignore lsp inlay hints
- 5cdf0c22bd tohtml: properly handle multiple hl groups #29012
- 3d319092d5 tohtml: replace ipairs with pairs
- 4150e5e6fd tohtml: show how many warnings are hidden
- 0389472961 tohtml: support ranges again
- ab2d243fd0 treesitter: display fields for anonymous nodes in :InspectTree
- 35f6425207 treesitter: do not modify highlight state for _on_spell_nav
- 356ddb1305 treesitter: ensure syntaxset augroup exists (#29542)
- eb53aba5af treesitter: recognize aliased parsers in omnifunc, query linter
- b6b2272573 tui: move $COLORTERM check to _defaults.lua (#29206)
- 89f29fcc92 tui: remove duplicate disabling of synchronized output (#28884)
- a784b901be tui: skip TUI in ui_rgb_attached (#29096)
- 19787d6057 ui: avoid ambiguity about last chunk when flushing halfway (#29718)
- 89fa1ee822 ui: flush ext_cmdline events before doing cmdpreview (#29062)
- 7055cd1238 ui: superfluous showmode / excessive grid_cursor_goto #29089
- 6802db7aa1 version: fix vim.version().prerelease
- 728f6c7c83 vim.text: remove assert from vim.text.hexdecode
- c3aef56199 win-msi: add bin to PATH per-machine after installation (#29099)

VIM PATCHES
--------------------------------------------------------------------------------
- fdf769fa86 0b74eec: runtime(stylus): remove remaining css code (vim/vim#14866)
- 29fd7432fd 74703f1: runtime(doc): remove obsolete Ex insert behavior (#29702)
- 891cc78179 7a85e34: runtime(doc): fix inconsistencies in :h file-searching (#29652)
- 704d33634e 8.2.0083: text properties wrong when tabs and spaces are exchanged
- 571e54e12c 8.2.0109: corrupted text properties when expanding spaces
- 7c055bd74b 8.2.3388: fnamemodify('path/..', ':p') differs from using 'path/../' (#29667)
- 9c91233a38 9.1.0414: Unable to leave long line with 'smoothscroll' and 'scrolloff'
- 34cc49bd72 9.1.0498: getcmdcompltype() interferes with cmdline completion (#29397)
- 259a620eb8 9.1.0512: Mode message for spell completion doesn't match allowed keys (#29437)
- f89d4ee6ce 9.1.0526: Unwanted cursor movement with pagescroll at start of buffer (#29569)
- 4ce293c2c3 9.1.0565: Stop directory doesn't work properly in 'tags'
- c467bfeb93 9.1.0566: Stop dir in findfile() doesn't work properly w/o trailing slash
- 576363a0fb 9.1.0567: Cannot use relative paths as findfile() stop directories
- ceb82a9396 9.1.0569: fnamemodify() treats ".." and "../" differently (#29673)
- 07de890de6 9.1.0580: :lmap mapping for keypad key not applied when typed in Select mode (#29693)
- b01202df15 9.1.0594: Unnecessary redraw when setting 'winfixbuf' (#29775)
- 804a94d300 9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fit (#29793)
- a03cc83bfb df62c62: runtime(doc): grammar fixes in options.txt (#29729)
- fde5718e62 partial:9.0.0323: using common name in tests leads to flaky tests

REDACTOR
--------------------------------------------------------------------------------
- c35e040b7e replace deprecated vim.loop with vim.uv
- 3a354bfcaa lsp: reuse buf_detach_client logic in on_detach (#28939) (#29024)
- dffadc392e path.c: add nonnull attributes (#28829)
- db65017e60 tests: more global highlight definitions
- 3725db69ef tests: use more global highlight definitions

CI
--------------------------------------------------------------------------------
- 7400f9dfe5 adjust workflows to enable required checks
- 575136c178 always add `target:release` label when backporting
- 410f43c0ae bump backport action to version 3
- 9a2760a01f change label `backport` to `target:release`
- b94b341ef2 run workflows on release branches
- 0e81c62405 skip lintcommit workflow on release branches

TESTING
--------------------------------------------------------------------------------
- f03348472d add a test for #29119
- 18a36d3d9f do not set termguicolors in test runner
- 68513c2a89 fix reporting "no flush received" too early (#29735)
- 981548b7f7 remove checks for failed tests on Windows
- 65776124b1 starting and stopping treesitter highlight (#29546)

DOCUMENTATION
--------------------------------------------------------------------------------
- 891b235df0 document 'list' behavior when 'listchars' excludes "tab" (#29360)
- 8c00651131 fix more treesitter parsing errors
- 777e15fa61 update LSP quickstart (#28989)
- 6136326d63 lpeg: merge upstream changes
- f7d8650616 lsp: format the handwritten part #29295
2024-07-24 09:20:05 +02:00
70f7708cdf fix: assert failure in VimL expression parser
(cherry picked from commit 6720bd440f)
2024-07-21 16:49:52 +02:00
0d293e4315 fix(api): alloc and draw cursor window in nvim__redraw
Problem:  Unable to move cursor to recently opened window.
Solution: Make sure uninitialized window is drawn before trying to move
          the cursor to it.
(cherry picked from commit 89f9f168a5)
2024-07-21 16:37:50 +02:00
ffc457a1dc fix(marks): revalidate marks whose position did not change
Problem:  Marks whose position did not change with the action that
          invalidated them (right_gravity = false) are not revalidated
          upon undo.
Solution: Remove early return when restoring a marks saved position so
          that it is still revalidated. Add "move" guards instead.
(cherry picked from commit 012db2b0f5)
2024-07-21 16:31:33 +02:00
575136c178 ci: always add target:release label when backporting
Previously the label was not added if the backport PR was created
manually. The new code is also easier to maintain as it's close to other
label-related code.

(cherry picked from commit 4c788b1757)
2024-07-21 16:03:10 +02:00
f77db12995 build: reuse code for deps.txt for both deps and main build
(cherry picked from commit f09f5c45fa)
2024-07-21 14:56:57 +02:00
18a9ae169e Merge pull request #29797 from neovim/backport-29793-to-release-0.10
vim-patch:9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fit
2024-07-19 12:14:33 +08:00
804a94d300 vim-patch:9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fit (#29793)
Problem:  Wrong cursor position with 'breakindent' when a double-width
          character doesn't fit in a screen line (mikoto2000)
Solution: Include the width of the 'breakindent' properly.
          (zeertzjq)

fixes: vim/vim#15289
closes: vim/vim#15290

b5d6b5caac
(cherry picked from commit 35b35cb93c)
2024-07-19 03:55:46 +00:00
0389472961 fix(tohtml): support ranges again 2024-07-18 09:44:52 +02:00
9fd6664ba7 fix(tohtml): extmark text may be out of bounds 2024-07-18 09:44:52 +02:00
5cdf0c22bd fix(tohtml): properly handle multiple hl groups #29012
Problem: :TOhtml doesn't properly handle virtual text when it has
multiple highlight groups. It also improperly calculates position offset
for multi-byte virt_text characters.

Solution: Apply the `vim.api.nvim_strwidth` broadly to properly
calculate character offset, and handle the cases where the `hl` argument
can be a table of multiple hl groups.
2024-07-18 09:44:52 +02:00
4150e5e6fd fix(tohtml): show how many warnings are hidden 2024-07-18 09:44:52 +02:00
8c88f402e1 fix(tohtml): ignore lsp inlay hints 2024-07-18 09:44:52 +02:00
3d319092d5 fix(tohtml): replace ipairs with pairs 2024-07-18 09:44:52 +02:00
6527f5e2d2 Merge pull request #29783 from neovim/backport-29742-to-release-0.10
fix(winfloat): error handle in float create
2024-07-18 13:24:09 +08:00
ad55ec350c fix(float): handle error in win_float_create() (#29742)
Problem: Missing error handling in win_float_create() function.
Solution: Add an inline function for error handling.
(cherry picked from commit 8ddcf9d939)
2024-07-18 05:00:31 +00:00
125b253e7b Merge pull request #29782 from neovim/backport-29775-to-release-0.10
vim-patch:9.1.0594: Unnecessary redraw when setting 'winfixbuf'
2024-07-18 12:46:13 +08:00
b01202df15 vim-patch:9.1.0594: Unnecessary redraw when setting 'winfixbuf' (#29775)
Problem:  Unnecessary redraw when setting 'winfixbuf'.
Solution: Remove P_RWIN flag. (zeertzjq)

closes: vim/vim#15283

ac4ce9e15b
(cherry picked from commit bbe51ef016)
2024-07-18 04:26:17 +00:00
d6437e2ca5 Merge pull request #29781 from neovim/backport-29750-to-release-0.10
fix(column): modifying a sign should update placed signs
2024-07-18 12:24:10 +08:00
97be9d8563 fix(column): modifying a sign should update placed signs (#29750)
Problem:  Modifying a sign no longer updates already placed signs.
Solution: Loop over (newly-exposed) placed decorations when modifying a
          sign definition. Update placed decor if it belongs to the sign
          that is modified.
(cherry picked from commit f9a49fab0c)
2024-07-18 04:09:26 +00:00
2fb69ccaf7 fix(lsp): inlay hints are rendered in the correct order (#29707)
Problem:
When there are multiple inlay hints present at the same position, they
should be rendered in the order they are received in the response from
LSP as per the LSP spec. Currently, this is not respected.

Solution:
Gather all hints for a given position, and then set it in a single
extmark call instead of multiple set_extmark calls. This leads to fewer
extmark calls and correct inlay hints being rendered.
2024-07-17 17:56:04 +02:00
0e81c62405 ci: skip lintcommit workflow on release branches
Since lintcommit is a required check, it will always need to be run.
However, the lintcommit script is not designed to work on PRs that
doesn't target master branch (and it's not clear whether it's even
desirable).

To circumvent this we create a "dummy" lintcommit check that is run on
release branches that always passes, thus fulfilling the condition of
the required check.

(cherry picked from commit 0500804df5)
2024-07-17 17:29:18 +02:00
68513c2a89 test: fix reporting "no flush received" too early (#29735)
(cherry picked from commit bc2bd25f8e)
2024-07-17 23:06:02 +08:00
eb53aba5af fix(treesitter): recognize aliased parsers in omnifunc, query linter
**Problem:** A query file for something like `html_tags` will not be
given html node completion

**Solution:** Check for parser aliases before offering completions

Co-authored-by: Lewis Russell <me@lewisr.dev>
(cherry picked from commit 05dcda8f9b)
2024-07-17 12:37:42 +02:00
e13f03af85 fix(snippet): modify base indentation when there's actually whitespace (#29670)
(cherry picked from commit 5fe4ce6678)
2024-07-17 11:42:03 +02:00
24fa65a500 fix(lsp): don't show codelens for buffers that don't support it (#29690)
(cherry picked from commit 1f2f460b4a)
2024-07-17 11:41:53 +02:00
b94b341ef2 ci: run workflows on release branches
Github doesn't allow workflows to be run from the `github-actions`
account, which is the default account. This caused the CI on backport
PRs to not be run. The way to circumvent this is to use a token that
essentially "pretends" to be another user, which in turn triggers the CI
as desired.

Also run lintcommit on release branches as that is now a required check,
meaning it must always be run.
2024-07-16 20:12:13 +02:00
410f43c0ae ci: bump backport action to version 3 2024-07-16 20:12:13 +02:00
677eb23c38 Merge pull request #29731 from neovim/backport-29729-to-release-0.10
vim-patch:df62c62: runtime(doc): grammar fixes in options.txt
2024-07-16 06:47:16 +08:00
a03cc83bfb vim-patch:df62c62: runtime(doc): grammar fixes in options.txt (#29729)
closes: vim/vim#15265

df62c62177

Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
(cherry picked from commit c2b51e6c41)
2024-07-15 22:32:55 +00:00
a333847f6b Merge pull request #29730 from neovim/backport-29727-to-release-0.10
docs(lpeg): merge upstream changes
2024-07-16 06:30:15 +08:00
6136326d63 docs(lpeg): merge upstream changes
(cherry picked from commit 8703e7bd12)
2024-07-15 22:16:53 +00:00
7400f9dfe5 ci: adjust workflows to enable required checks
Auto-merging is a useful feature by github, but it requires required
checks which requires a few adjustments. The primary change is that
required checks can't use `paths` or `paths-ignore` as that risks not
running the job, and required checks must always be run.

A workaround for this is to introduce a dummy workflow which is used for
every path not used in the real workflow. That way the required job is
"always" run as far as github is concerned. The workaround is unweildly
so it's only useful to do it for costly workflows where the potential
benefits are big. If not it's better to simply remove any `paths` or
`paths-ignore` from a workflow instead.

(cherry picked from commit 3c803483ac)
2024-07-15 18:16:57 +02:00
2ae8bb7b96 Merge pull request #29720 from neovim/backport-29718-to-release-0.10
fix(ui): avoid ambiguity about last chunk when flushing halfway
2024-07-15 18:49:07 +08:00
19787d6057 fix(ui): avoid ambiguity about last chunk when flushing halfway (#29718)
(cherry picked from commit 594c7f3d77)
2024-07-15 10:35:38 +00:00
f654a30093 docs: misc (#29714)
Co-authored-by: Christian Clason <c.clason@uni-graz.at>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: dundargoc <33953936+dundargoc@users.noreply.github.com>
2024-07-15 07:09:47 +08:00
29fd7432fd vim-patch:74703f1: runtime(doc): remove obsolete Ex insert behavior (#29702)
related: vim/vim#15120
closes: vim/vim#15228

74703f1086

Nvim only supports Vim Ex mode, so this is long obsolete in Nvim.

Co-authored-by: Mohamed Akram <mohd.akram@outlook.com>
2024-07-14 15:08:13 +08:00
b2587a0665 Merge pull request #29701 from neovim/backport-29652-to-release-0.10
vim-patch:7a85e34: runtime(doc): fix inconsistencies in :h file-searching
2024-07-14 15:02:51 +08:00
891cc78179 vim-patch:7a85e34: runtime(doc): fix inconsistencies in :h file-searching (#29652)
closes: vim/vim#15201

7a85e343d2
(cherry picked from commit 15f6cf0c8f)
2024-07-14 06:46:36 +00:00
94aacc2695 Merge pull request #29700 from neovim/backport-29673-to-release-0.10
vim-patch:9.1.0569: fnamemodify() treats ".." and "../" differently
2024-07-14 14:45:36 +08:00
ceb82a9396 vim-patch:9.1.0569: fnamemodify() treats ".." and "../" differently (#29673)
Problem:  fnamemodify() treats ".." and "../" differently.
Solution: Expand ".." properly like how "/.." is treated in 8.2.3388.
          (zeertzjq)

closes: vim/vim#15218

1ee7420460
(cherry picked from commit 028dd3c5c4)
2024-07-14 06:33:01 +00:00
bddbbd874c Merge pull request #29699 from neovim/backport-29668-to-release-0.10
vim-patch:9.1.{0562,0565,0566,0567}: file search fixes
2024-07-14 14:31:02 +08:00
576363a0fb vim-patch:9.1.0567: Cannot use relative paths as findfile() stop directories
Problem:  Cannot use relative paths as findfile() stop directories.
Solution: Change a relative path to an absolute path.
          (zeertzjq)

related: vim/vim#15200
closes: vim/vim#15202

764526e279
(cherry picked from commit 80818641f3)
2024-07-14 06:14:50 +00:00
c467bfeb93 vim-patch:9.1.0566: Stop dir in findfile() doesn't work properly w/o trailing slash
Problem:  Stop directory in findfile() doesn't work properly without a
          trailing slash.
Solution: Always use fnamencmp(), not fnamecmp().

related: vim/vim#15200
related: vim/vim#15202

e6ab23bd4a
(cherry picked from commit 091a130804)
2024-07-14 06:14:50 +00:00
4ce293c2c3 vim-patch:9.1.0565: Stop directory doesn't work properly in 'tags'
Problem:  Stop directory doesn't work properly in 'tags'.
          (Jesse Pavel)
Solution: Also move the stop directory forward by one byte.
          (zeertzjq)

This doesn't support relative stop directories yet, as they are not
supported in other places like findfile() either.

fixes: vim/vim#15200
related: vim/vim#15202

68819afb2c
(cherry picked from commit 50feb85b0c)
2024-07-14 06:14:50 +00:00
fde5718e62 vim-patch:partial:9.0.0323: using common name in tests leads to flaky tests
Problem:    Using common name in tests leads to flaky tests.
Solution:   Rename files and directories to be more specific.

3b0d70f4ff

This only includes test_findfile.vim changes.

vim-patch:9.1.0562: tests: inconsistency in test_findfile.vim

Problem:  tests: inconsistency in test_findfile.vim, it saves and
          restores 'shellslash', but doesn't actually set it
Solution: Set shellslash explicitly (zeertzjq)

closes: vim/vim#15217

e7b98ab96e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
(cherry picked from commit 2c9e82e193)
2024-07-14 06:14:50 +00:00
a430944ea7 Merge pull request #29698 from neovim/backport-29667-to-release-0.10
vim-patch:8.2.3388: fnamemodify('path/..', ':p') differs from using 'path/../'
2024-07-14 14:12:30 +08:00
7c055bd74b vim-patch:8.2.3388: fnamemodify('path/..', ':p') differs from using 'path/../' (#29667)
Problem:    fnamemodify('path/..', ':p') differs from using 'path/../'.
Solution:   Include the "/.." in the directory name. (closes vim/vim#8808)

4eaef9979f

Co-authored-by: Bram Moolenaar <Bram@vim.org>
(cherry picked from commit 31d53cbb0f)
2024-07-14 05:59:59 +00:00
113e5a91de Merge pull request #29694 from neovim/backport-29693-to-release-0.10
vim-patch:9.1.0580: :lmap mapping for keypad key not applied when typed in Select mode
2024-07-14 07:09:29 +08:00
07de890de6 vim-patch:9.1.0580: :lmap mapping for keypad key not applied when typed in Select mode (#29693)
Problem:  An :lmap mapping for a printable keypad key is not applied
          when typing it in Select mode.
Solution: Change keypad key to ASCII after setting vgetc_char.
          (zeertzjq)

closes: vim/vim#15245

90a800274d
(cherry picked from commit 49ba36becd)
2024-07-13 22:53:52 +00:00
ae9aa58f9c Merge pull request #29679 from neovim/backport-29677-to-release-0.10
fix(input): handle vim.on_key() properly with ALT and K_SPECIAL
2024-07-13 04:38:07 +08:00
7582d4a7b5 fix(input): handle vim.on_key() properly with ALT and K_SPECIAL (#29677)
(cherry picked from commit 16f63b964f)
2024-07-12 20:14:45 +00:00
8c00651131 docs: fix more treesitter parsing errors 2024-07-09 16:13:26 +02:00
ba90b54301 build(deps): drop unused bundled bash, python parsers and queries
Problem: Neovim bundles treesitter parsers for bash and python but does
not use them by default. This dilutes the messaging about the bundled
parsers being required for functionality or reasonable out-of-the-box
experience. It also increases the risk of query incompatibilities for no
gain.

Solution: Stop bundling bash and python parser and queries.
(cherry picked from commit 51d85f7ea5)
2024-07-09 16:13:26 +02:00
46d2906332 build(macos): disable deduplication in link step
Problem: Apple Clang 16 comes with a new deduplication algorithm that is
enabled by default in release builds (https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes#New-Features-in-Xcode-16-Beta) which breaks the built
nvim binary (locks and spins at 100% CPU).

Solution: Disable deduplication on macOS. Tested on Clang 15 as well and
seems to make no difference to binary size anyway.

(cherry picked from commit 7e099cf3eb)
2024-07-09 14:29:59 +02:00
978b63a9f1 build(deps): bump tree-sitter-vimdoc to v3.0.0 2024-07-09 13:49:12 +02:00
cb9ccedf04 Merge pull request #29625 from zeertzjq/backport
Backport to release-0.10
2024-07-09 19:45:31 +08:00
33121f1eae fix(lua): change some vim.fn.expand() to vim.fs.normalize() (#29583)
Unlike vim.fn.expand(), vim.fs.normalize() doesn't expand wildcards.
2024-07-09 19:27:10 +08:00
24ee2e7c74 fix(health): fix fetching url with python in provider health (#29594) 2024-07-09 19:25:27 +08:00
8fe17036ba Merge pull request #29610 from neovim/backport-29609-to-release-0.10
fix(quickfix): make shortmess+=O work with cmdheight=0
2024-07-08 10:51:38 +08:00
63ff7338ea fix(quickfix): make shortmess+=O work with cmdheight=0 (#29609)
(cherry picked from commit 73ae7d44a2)
2024-07-08 02:36:58 +00:00
f39fb4c11e Merge pull request #29600 from neovim/backport-29599-to-release-0.10
build: remove -O2 from gen_cflags
2024-07-08 06:14:55 +08:00
b397b5672c build: remove -O2 from gen_cflags
Problem:
zig cc implicitly defines NDEBUG with -O2. This breaks debug builds
which does not include -O2 or NDEBUG.

Solution:
Do not add -O2 when generating header files.

(cherry picked from commit e5ff302033)
2024-07-07 18:59:09 +00:00
bc1e168e49 Merge pull request #29595 from neovim/backport-28966-to-release-0.10
refactor: replace deprecated vim.loop with vim.uv
2024-07-07 16:54:16 +08:00
c35e040b7e refactor: replace deprecated vim.loop with vim.uv
(cherry picked from commit 1a2e6ebc59)
2024-07-07 08:41:56 +00:00
ab2d243fd0 fix(treesitter): display fields for anonymous nodes in :InspectTree
(cherry picked from commit 9217e0d671)
2024-07-05 10:15:14 +02:00
5cad641848 Merge pull request #29570 from neovim/backport-29569-to-release-0.10
vim-patch:9.1.0526: Unwanted cursor movement with pagescroll at start of buffer
2024-07-05 08:14:39 +08:00
f89d4ee6ce vim-patch:9.1.0526: Unwanted cursor movement with pagescroll at start of buffer (#29569)
Problem:  Cursor is moved to bottom of window trying to pagescroll when
          already at the start of the buffer (Asheq Imran, after v9.1.0357)
Solution: Don't move cursor when buffer content did not move.
          (Luuk van Baal)

8ccb89016e
(cherry picked from commit 3e6cec0bef)
2024-07-04 23:51:51 +00:00
d6a73d7314 Merge pull request #29551 from neovim/backport-29478-to-release-0.10
fix(lsp): :LspStop vim.keymap.del error
2024-07-04 05:36:27 +08:00
2d7aab623e fix(lsp): avoid vim.keymap.del error when stopping a client (#29478)
(cherry picked from commit fc9b70826e)
2024-07-03 20:59:14 +00:00
28a5923aea Merge pull request #29547 from neovim/backport-29546-to-release-0.10
test: starting and stopping treesitter highlight
2024-07-03 09:25:07 +08:00
65776124b1 test: starting and stopping treesitter highlight (#29546)
(cherry picked from commit 599fc7cee4)
2024-07-03 00:41:10 +00:00
2845d05569 Merge pull request #29545 from neovim/backport-29542-to-release-0.10
fix(treesitter): ensure syntaxset augroup exists
2024-07-03 07:56:32 +08:00
356ddb1305 fix(treesitter): ensure syntaxset augroup exists (#29542)
Problem:
Error when calling vim.treesitter.start() and vim.treesitter.stop() in
init.lua.

Solution:
Ensure syntaxset augroup exists after loading synload.vim.

(cherry picked from commit d413038b4f)
2024-07-02 23:40:57 +00:00
803cc08c17 build(deps): bump tree-sitter-c to v0.21.3
(cherry picked from commit 98536dd78e)
2024-06-25 10:04:44 +02:00
91e337a477 build(deps): bump tree-sitter-query to v0.4.0
(cherry picked from commit 61b3a26e5b)
2024-06-25 10:04:44 +02:00
f76d0dc91e Merge pull request #29469 from neovim/backport-29460-to-release-0.10
fix(treesitter): do not modify highlight state for _on_spell_nav
2024-06-24 20:03:36 +08:00
35f6425207 fix(treesitter): do not modify highlight state for _on_spell_nav
Problem:  Treesitter highlighter clears the already populated highlight
          state when performing spell checking while drawing a
          smoothscrolled topline.
Solution: Save and restore the highlight state in the highlighter's
          _on_spell_nav callback.
(cherry picked from commit da4e8dc5b0)
2024-06-24 11:40:30 +00:00
9c6efd0a65 Merge pull request #29438 from neovim/backport-29437-to-release-0.10
vim-patch:9.1.0512: Mode message for spell completion doesn't match allowed keys
2024-06-21 14:53:22 +08:00
259a620eb8 vim-patch:9.1.0512: Mode message for spell completion doesn't match allowed keys (#29437)
Problem:  Mode message for spell completion doesn't match allowed keys
          (Kyle Kovacs)
Solution: Show "^S" instead of "s".
          (zeertzjq)

This matches the code in vim_is_ctrl_x_key():

	case CTRL_X_SPELL:
	    return (c == Ctrl_S || c == Ctrl_P || c == Ctrl_N);

fixes: neovim/neovim#29431
closes: vim/vim#15065

7002c055d5
(cherry picked from commit 1db1476fd9)
2024-06-21 06:40:43 +00:00
3b8d0721af Merge pull request #29407 from neovim/backport-29406-to-release-0.10
fix(drawline): don't draw beyond end of window with 'rnu'
2024-06-19 09:33:17 +08:00
eadc4e03a2 fix(drawline): don't draw beyond end of window with 'rnu' (#29406)
(cherry picked from commit b1c439cef6)
2024-06-19 01:20:42 +00:00
17fe405adc Merge pull request #29399 from neovim/backport-29394-to-release-0.10
fix(mouse): early return when clicking in padded 'statuscolumn'
2024-06-19 06:16:50 +08:00
f82d7b8200 fix(mouse): early return when clicking in padded 'statuscolumn' (#29394)
Problem:  Hit assert when clicking inside a padded 'statuscolumn' that
          is padded beyond the length of the allocated click_defs.
Solution: Still consider this a "in_statuscol" click, but return early
          when about to execute the click func.
(cherry picked from commit 102971a396)
2024-06-18 22:03:11 +00:00
b16fe558ae Merge pull request #29398 from neovim/backport-29397-to-release-0.10
vim-patch:9.1.0498: getcmdcompltype() interferes with cmdline completion
2024-06-19 06:00:15 +08:00
34cc49bd72 vim-patch:9.1.0498: getcmdcompltype() interferes with cmdline completion (#29397)
Problem:  getcmdcompltype() interferes with cmdline completion.
Solution: Don't set expand context when it's already set.
          (zeertzjq)

closes: vim/vim#15036

a821b609f9
(cherry picked from commit 4e8ec4900e)
2024-06-18 21:47:42 +00:00
ad82e11eb7 Merge pull request #29386 from neovim/backport-29014-to-release-0.10
refactor(tests): more global highlight definitions
2024-06-18 10:33:17 +08:00
db65017e60 refactor(tests): more global highlight definitions
(cherry picked from commit b90d7c36cf)
2024-06-18 02:18:49 +00:00
2eafe248c4 Merge pull request #29385 from neovim/backport-29006-to-release-0.10
refactor(tests): use more global highlight definitions
2024-06-18 10:10:39 +08:00
3725db69ef refactor(tests): use more global highlight definitions
(cherry picked from commit fb43741f80)
2024-06-18 01:52:58 +00:00
9f2aec2629 Merge pull request #29383 from neovim/backport-29295-to-release-0.10
docs(lsp): format the handwritten part
2024-06-18 07:25:30 +08:00
f7d8650616 docs(lsp): format the handwritten part #29295
(cherry picked from commit 7ce261c064)
2024-06-17 23:06:15 +00:00
446b05f85a Merge pull request #29362 from neovim/backport-29360-to-release-0.10
docs: document 'list' behavior when 'listchars' excludes "tab"
2024-06-16 06:25:05 +08:00
891b235df0 docs: document 'list' behavior when 'listchars' excludes "tab" (#29360)
(cherry picked from commit 7e65f3757b)
2024-06-15 22:11:15 +00:00
1ab52dff9a Merge pull request #29346 from neovim/backport-29343-to-release-0.10
fix(defaults): default @/Q broken when 'ignorecase' is set
2024-06-15 10:51:36 +08:00
0827279ff5 fix(defaults): default @/Q broken when 'ignorecase' is set (#29343)
Problem:
When 'ignorecase' is set, the default keymap Q and Q would exit visual
mode.

This issue was raised in #28287 and a fix was applied in #28289.

However, `==` operator is subject to user `ignorecase` setting.

Solution:
Switching to `==#` operator would guarantee case sensitive comparison
between visual mode and linewise visual mode.

Co-authored-by: Kuanju Chen <kuanju.chen@mksinst.com>
(cherry picked from commit 61aabe0730)
2024-06-15 02:21:35 +00:00
77b0970cda Merge pull request #29342 from neovim/backport-29229-to-release-0.10
docs: misc
2024-06-15 07:24:26 +08:00
643d6af451 docs: misc (#29229)
Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
Co-authored-by: Jose Pedro Oliveira <jose.p.oliveira.oss@gmail.com>
Co-authored-by: Maria José Solano <majosolano99@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
(cherry picked from commit 6e28589e00)
2024-06-14 23:06:11 +00:00
4d9114d3ab Merge pull request #29309 from neovim/backport-29096-to-release-0.10
fix(tui): skip TUI in ui_rgb_attached
2024-06-13 11:13:24 +08:00
a784b901be fix(tui): skip TUI in ui_rgb_attached (#29096)
The ui_rgb_attached function determines if any UI is attached which
supports RGB (truecolor). We determine if the TUI supports RGB via the
'termguicolors' option which is checked at the beginning of this
function. If the TUI does not support RGB ('termguicolors' is unset), we
check to see if any _other_ UI is attached which supports RGB.

Normally, the TUI's "rgb" flag and the 'termguicolors' option are the
same. However, they may differ during startup when the "rgb" flag is set
by tui/tui.c to indicate to the core that the terminal emulator supports
truecolor. The 'termguicolors' option is not actually set until
_defaults.lua runs.

(cherry picked from commit 0231265c8c)
2024-06-13 01:27:14 +00:00
0608444447 Merge pull request #29308 from neovim/backport-29103-to-release-0.10
test: do not set termguicolors in test runner
2024-06-13 09:25:42 +08:00
981548b7f7 test: remove checks for failed tests on Windows
(cherry picked from commit 5493fcd52f)
2024-06-13 01:09:49 +00:00
728f6c7c83 fix(vim.text): remove assert from vim.text.hexdecode
Instead, return nil plus an error message if the input is invalid.

(cherry picked from commit 4cff418564)
2024-06-13 01:09:49 +00:00
18a36d3d9f test: do not set termguicolors in test runner
It's not clear why this is needed and it has adverse side effects on
other tests.

(cherry picked from commit d24f3d055a)
2024-06-13 01:09:49 +00:00
8a8c3ed4dc Merge pull request #29279 from luukvbaal/backport-29272-to-release-0.10
fix(column): clamp line number for legacy signs
2024-06-12 10:19:20 +08:00
aa1321801d fix(column): clamp line number for legacy signs
Problem:  Legacy :sign API still allows placing signs beyond the end of
          the buffer. This is unaccounted for by the signcolumn tracking
          logic and is disallowed in general for the extmark API which
          implements it now.
Solution: Clamp legacy sign line number to the length of the buffer.
(cherry picked from commit 1dcda86559
extmark_set() namespace scope and screen test reverse sign order conflict)
2024-06-11 11:02:16 +02:00
0ee3147bc7 fix(lsp): do not reset buf version when detaching client (#29273)
(cherry picked from commit 37bf4c572a)

Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
2024-06-10 22:22:26 +02:00
46c2962b3a fix(runtime): add commentstring for glsl ftplugin
(cherry picked from commit b6c1ce8a95)
2024-06-09 14:56:21 +02:00
b6b2272573 fix(tui): move $COLORTERM check to _defaults.lua (#29206)
fix(tui): move $COLORTERM check to _defaults.lua (#29197)

We currently check $COLORTERM in the TUI process to determine if the
terminal supports 24 bit color (truecolor). If $COLORTERM is "truecolor"
or "24bit" then we automatically assume that the terminal supports
truecolor, but if $COLORTERM is set to any other value we still query
the terminal.

The `rgb` flag of the UI struct is a boolean which only indicates
whether the UI supports truecolor, but does not have a 3rd state that we
can use to represent "we don't know if the UI supports truecolor". We
currently use `rgb=false` to represent this "we don't know" state, and
we use XTGETTCAP and DECRQSS queries to determine at runtime if the
terminal supports truecolor. However, if $COLORTERM is set to a value
besides "truecolor" or "24bit" (e.g. "256" or "16) that is a clear
indication that the terminal _does not_ support truecolor, so it is
incorrect to treat `rgb=false` as "we don't know" in that case.

Instead, in the TUI process we only check for the terminfo capabilities.
This must be done in the TUI process because we do not have access to
this information in the core Neovim process when `_defaults.lua` runs.
If the TUI cannot determine truecolor support from terminfo alone, we
set `rgb=false` to indicate "we don't know if the terminal supports
truecolor yet, keep checking". When we get to `_defaults.lua`, we can
then check $COLORTERM and only query the terminal if it is unset.

This means that users can explicitly opt out of truecolor determination
by setting `COLORTERM=256` (or similar) in their environment.

(cherry picked from commit d7651b27d5)

Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2024-06-05 08:52:48 -05:00
dfff482efe fix(lsp): remove superfluous on_detach callback from semantic tokens module (#29188)
LspDetach is now triggered by the main on_detach callback that is added
when an LSP client is attached to a buffer. The semantic_tokens module
already includes a LspDetach handler that does the right thing. When the
LspDetach trigger was added to the main LSP on_detach, it created a race
condition in semantic tokens when a buffer was deleted that would
trigger both its own on_detach and the LspDetach handlers. If the former
came last, an error was thrown trying to delete a non-existent augroup
(destroy() was being called twice).

(cherry picked from commit 43581011e4)

Co-authored-by: jdrouhard <john@drouhard.dev>
2024-06-04 19:00:51 +02:00
8dece36427 Merge pull request #29187 from neovim/backport-29089-to-release-0.10
fix(ui): superfluous showmode due to unset globals
2024-06-04 21:48:57 +08:00
7055cd1238 fix(ui): superfluous showmode / excessive grid_cursor_goto #29089
Problem:  Unsetting global variables earlier in #28578 to avoid
          recursiveness, caused superfluous or even unlimited
          showmode().
Solution: Partly revert #28578 so that the globals are unset at the end
          of showmode(), and avoid recursiveness for ext UI by adding a
          recursive function guard to each generated UI call that may
          call a Lua callback.
(cherry picked from commit b66106a46c)
2024-06-04 13:10:45 +00:00
f1fba12803 Merge pull request #29182 from neovim/backport-29181-to-release-0.10
fix(filetype): fix typos in filetype detection
2024-06-04 17:39:29 +08:00
1fe1f8556e fix(filetype): fix typos in filetype detection
(cherry picked from commit aa9f21ee95)
2024-06-04 09:26:54 +00:00
94d8f6bde8 Merge pull request #29139 from neovim/backport-29136-to-release-0.10
vim-patch:8.2.{0083,0109}
2024-06-02 15:50:32 +08:00
f03348472d test: add a test for #29119
(cherry picked from commit 56337310ef)
2024-06-02 07:37:27 +00:00
571e54e12c vim-patch:8.2.0109: corrupted text properties when expanding spaces
Problem:    Corrupted text properties when expanding spaces.
Solution:   Reallocate the line. (Nobuhiro Takasaki, closes vim/vim#5457)

ac15fd8c67

Co-authored-by: Bram Moolenaar <Bram@vim.org>
(cherry picked from commit 97d9d71bf3)
2024-06-02 07:37:27 +00:00
704d33634e vim-patch:8.2.0083: text properties wrong when tabs and spaces are exchanged
Problem:    Text properties wrong when tabs and spaces are exchanged.
Solution:   Take text properties into account. (Nobuhiro Takasaki,
            closes vim/vim#5427)

5cb0b93d52

Co-authored-by: Bram Moolenaar <Bram@vim.org>
(cherry picked from commit 4374ec83cd)
2024-06-02 07:37:27 +00:00
4c53b9c0a1 Merge pull request #29125 from neovim/backport-29003-to-release-0.10
fix(column): crash with 'signcolumn' set to "number"
2024-06-01 18:29:23 +08:00
df6ce8377f fix(column): crash with 'signcolumn' set to "number" (#29003)
Problem:  Numberwidth may depend on number of signs with text in the
          buffer and is not handled correctly for extmark signs.
Solution: Move legacy sign code for changed numberwidth so that it is
          handled properly for legacy and extmark signs alike.
(cherry picked from commit f2083bd55c)
2024-06-01 10:10:52 +00:00
58e1ef2f65 Merge pull request #29105 from neovim/backport-29099-to-release-0.10
fix(win-msi): add bin to PATH per-machine after installation
2024-05-31 13:39:38 +08:00
c3aef56199 fix(win-msi): add bin to PATH per-machine after installation (#29099)
#22856 made it possible for the msi installer to perform per-user
installations, which caused problems for users that already had
per-machine installations trying to update (the Windows Installer does
not support major upgrades across installation context, see #22933 and
https://stackoverflow.com/a/15498911). It was then reverted in #22949,
but the scope of the modification to the PATH environment variable was
not reverted.

(cherry picked from commit a18652ed61)
2024-05-31 04:45:46 +00:00
d8ff216040 fix(lsp): clear lsp client diagnostics (#29091)
Problem: When an lsp client is stopped, the client will
only clear the diagnostics for the attached buffers but
not the unattached buffers.
Solution: Reset the diagnostics for the whole namespace rather than
for only the attached buffers.

(cherry picked from commit 025c874415)

Co-authored-by: crwebb85 <51029315+crwebb85@users.noreply.github.com>
2024-05-30 09:23:04 +02:00
89fa1ee822 fix(ui): flush ext_cmdline events before doing cmdpreview (#29062)
Problem:  Unable to update the screen for external cmdline during cmdpreview.
Solution: Flush the cmdline UI before cmdpreview state.
(cherry picked from commit 5b6477be45)

Co-authored-by: luukvbaal <luukvbaal@gmail.com>
2024-05-28 03:06:20 -07:00
88cd7a6cdd Merge pull request #29058 from neovim/backport-29057-to-release-0.10
vim-patch:0b74eec: runtime(stylus): remove remaining css code (vim/vim#14866)
2024-05-28 15:15:24 +08:00
fdf769fa86 vim-patch:0b74eec: runtime(stylus): remove remaining css code (vim/vim#14866)
This seems to be a forgotten fixup in 2d919d2744 (r141568461)

0b74eeceb8
(cherry picked from commit 4e2c8dc374)
2024-05-28 07:00:03 +00:00
b36458b363 Merge pull request #29054 from neovim/backport-29053-to-release-0.10
fix(runtime): source c ftplugin properly for cpp on Windows
2024-05-28 06:51:36 +08:00
b98aa783f3 fix(runtime): source c ftplugin properly for cpp on Windows (#29053)
On Windows, '{' is currently not treated as a wildcard char, so another
wildcard char is needed for the pattern to be treated as a wildcard.

It may be worth trying to make '{' always a wildcard char in the future,
but that'll be a bit harder as it'll be necessary to make sure '{' is
escaped at various places.

(cherry picked from commit 7b16c1fa84)
2024-05-27 22:39:22 +00:00
039121f5a3 fix(snippet): cancel snippet session when leaving the buffer (#29044)
(cherry picked from commit 608543f8a9)

Co-authored-by: Maria José Solano <majosolano99@gmail.com>
2024-05-27 17:56:05 +02:00
e98637e8c0 fix(lsp): do not detach from buffer if there are uninitialized clients (#29043)
Problem: if on_lines is called before the LSP is initialized, the buffer
is detached.
Solution: check for uninitialized clients before detaching.

(cherry picked from commit 292365fa1b)

Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
2024-05-27 17:26:42 +02:00
b9e540cc70 Merge pull request #29038 from neovim/backport-28983-to-release-0.10
fix: "popcount" name conflict on NetBSD
2024-05-27 19:28:31 +08:00
b322c3560b build: "popcount" name conflict on NetBSD #28983
Problem:
    NetBSD's libc already has a function by the same name.

Solution:
    Rename popcount to xpopcount and add #if defined(__NetBSD__) to
prefer NetBSD's own implementation.  This fixes #28983.

(cherry picked from commit 104800ce2e)
2024-05-27 11:15:13 +00:00
8d1467ce9a Merge pull request #29036 from neovim/backport-29035-to-release-0.10
fix(drawline): don't draw beyond end of window
2024-05-27 14:51:14 +08:00
5d9f2d7ecc fix(drawline): don't draw beyond end of window (#29035)
(cherry picked from commit 9a0239fdc8)
2024-05-27 06:37:38 +00:00
565fccbeeb Merge pull request #29027 from neovim/backport-28961-to-release-0.10
fix(extmarks): issues with revalidating marks
2024-05-27 05:36:25 +08:00
3a354bfcaa refactor(lsp): reuse buf_detach_client logic in on_detach (#28939) (#29024)
(cherry picked from commit 2908f71dc9)
2024-05-26 20:47:59 +02:00
bec397edda fix(extmarks): issues with revalidating marks #28961
Problem:  Invalid marks appear to be revalidated multiple times, and
          decor is added at the old position for unpaired marks.
Solution: Avoid revalidating already valid marks, and don't use old
          position to add to decor for unpaired marks.
(cherry picked from commit 43a2019f09)
2024-05-26 17:56:50 +00:00
4efca7cda5 fix(lsp): handle nil root_dir in health check (#29010)
fix(lsp): handle nil root_dir in health check (#29007)

The root directory could show up as something like:

    Root directory: ~/path/to/cwd/v:null

Despite being `nil`

(cherry picked from commit f03b1622ad)

Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2024-05-25 17:30:27 -05:00
84d7bfcf16 fix(snippet): don't override unnamed register on tabstop select (#29008)
(cherry picked from commit 7994fdba6a)

Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2024-05-25 22:05:23 +02:00
777e15fa61 docs: update LSP quickstart (#28989)
docs: update LSP quickstart (#28954)

The LSP quickstart can act as our true "entrypoint" for answering the
question "How do I use LSP in Neovim?" As such, it can be a little more
beginniner-friendly than other sections of our help docs by including
explanatory comments and a more fleshed out example (including a
`FileType` autocommand).

This also includes some other minor wording updates and points users
toward `:checkhealth lsp`.

(cherry picked from commit 28c04948a1)

Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2024-05-24 18:47:36 -05:00
ebc6c38cde feat(lsp): update LSP healthcheck format (#28988)
feat(lsp): update LSP healthcheck format (#28980)

This is mostly an aesthetic change, although there are a few new pieces
of information included. Originally I wanted to investigate including
server capabilities in the healthcheck, but until we have the ability to
fold/unfold text in health checks that would be too much information.

(cherry picked from commit 5d26934c7c)

Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2024-05-24 18:47:13 -05:00
bf16fe3f01 fix(fs): make vim.fs.root work for relative paths and unnamed buffers (#28973)
If a buffer does not have a backing file then fall back to the current
working directory.

(cherry picked from commit 206f8f24a2)
2024-05-24 10:57:21 -05:00
28f03205be fix: show swapfile warning as a warning (#28972)
The new default SwapExists autocommand displays warning text (W325) but
does not use the WarningMsg highlight group as other warnings do. Use
the WARN log level when displaying this warning.

(cherry picked from commit e71713ba2b)
2024-05-24 10:48:07 -05:00
7e878da7dd Merge pull request #28953 from neovim/backport-28810-to-release-0.10
fix(colorscheme): update `StatusLineNC` to have underline with 'notgc'
2024-05-24 05:42:46 +08:00
21b21b94e6 fix(comment): fall back to using trimmed comment markers (#28950)
fix(comment): fall back to using trimmed comment markers (#28938)

Problem: Currently comment detection, addition, and removal are done
  by matching 'commentstring' exactly. This has the downside when users
  want to add comment markers with space (like with `-- %s`
  commentstring) but also be able to uncomment lines that do not contain
  space (like `--aaa`).

Solution: Use the following approach:
  - Line is commented if it matches 'commentstring' with trimmed parts.
  - Adding comment is 100% relying on 'commentstring' parts (as is now).
  - Removing comment is first trying exact 'commentstring' parts with
    fallback on trying its trimmed parts.
(cherry picked from commit 0a2218f965)

Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
2024-05-23 16:02:13 -05:00
e1b6187801 fix(colorscheme): underline StatusLineNC with 'notermguicolors' #28810
Problem: statusline for non-active window can be hard to distinguish
  from normal text with 'notermguicolors'. It was set to use only bold
  text to find a balance between being not too similar to active
  statusline and normal text, and be supported in enough terminal
  emulators (if it does not support 'termguicolors' there is higher
  chance that it also does not support underline).

Solution: reconsider balance by placing more emphasis on making
  non-active statusline more distinguishable.
  This also results into tabline being shown with underline which
  aligns with "make more distinguishable" shift.
(cherry picked from commit 9b9f54e2c1)
2024-05-23 21:01:15 +00:00
bdd5871dc5 fix(lsp): check if buffer was detached in on_init callback (#28942)
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
(cherry picked from commit af200c10cf)

Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
2024-05-23 16:27:27 +02:00
10a16c1311 fix(lsp): trigger LspDetach on buffer delete
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
(cherry picked from commit 5ac8db10f0)

Co-authored-by: Andre Toerien <49614525+AThePeanut4@users.noreply.github.com>
2024-05-23 13:30:39 +02:00
3a727beafd fix(lsp): detach all clients on_reload to force buf_state reload (#28898)
Problem:  The changetracking state can de-sync when reloading a buffer
          with more than one LSP client attached.
Solution: Fully detach all clients from the buffer to force buf_state to
          be re-created.
(cherry picked from commit 879d17ea8d)

Co-authored-by: Ilia Choly <ilia.choly@gmail.com>
2024-05-21 20:18:48 +02:00
efe8a0a520 fix(lsp): hide layout in codelenses in virtual text (#28794) (#28895)
Problem: layout i.e. whitespace that is part of codelenses is currently
displayed as weird symbols and large amounts of spaces

Solution: replace all consecutive whitespace symbols with a single space
character when trying to display codelenses as virtual text

(cherry picked from commit d9a2acdab3)

Co-authored-by: Mango The Fourth <40720523+MangoIV@users.noreply.github.com>
2024-05-21 18:41:55 +02:00
4f0c4c3921 fix(lsp): add textDocument/documentLink to capability map (#28838)
(cherry picked from commit 8263ed4670)
2024-05-21 18:41:22 +02:00
4e9864147a Merge pull request #28891 from neovim/backport-28884-to-release-0.10
fix(tui): remove duplicate disabling of synchronized output
2024-05-21 21:09:05 +08:00
89f29fcc92 fix(tui): remove duplicate disabling of synchronized output (#28884)
Synchronized output is enabled and disabled inside flush_buf().

(cherry picked from commit 47c741e30c)
2024-05-21 12:54:38 +00:00
671073e714 Merge pull request #28842 from neovim/backport-28829-to-release-0.10
refactor(path.c): add nonnull attributes
2024-05-19 05:59:54 +08:00
dffadc392e refactor(path.c): add nonnull attributes (#28829)
This possibly fixes the coverity warning.

(cherry picked from commit 63e3a63d2f)
2024-05-18 21:38:49 +00:00
1e62f8e15c Merge pull request #28833 from neovim/backport-28831-to-release-0.10
vim-patch:94043780196c
2024-05-18 16:17:11 +08:00
8e239ed9ea vim-patch:94043780196c (#28831)
runtime(matchparen): fix :NoMatchParen not working (vim/vim#14797)

fixes: neovim/neovim#28828

9404378019
(cherry picked from commit 48c2ad5d2d)
2024-05-18 07:53:42 +00:00
6a1c0e9574 Merge pull request #28823 from neovim/backport-28821-to-release-0.10
fix(move): half-page scrolling with resized grid at eob
2024-05-18 07:13:47 +08:00
d6756fc0a5 fix(move): half-page scrolling with resized grid at eob (#28821)
(cherry picked from commit 5947f249f8)
2024-05-17 23:00:44 +00:00
c6ebb931d9 Merge pull request #28820 from neovim/backport-28790-to-release-0.10
vim-patch:9.1.{0414,0416}
2024-05-18 06:35:24 +08:00
9c91233a38 vim-patch:9.1.0414: Unable to leave long line with 'smoothscroll' and 'scrolloff'
Problem:  Unable to leave long line with 'smoothscroll' and 'scrolloff'.
          Corrupted screen near the end of a long line with 'scrolloff'.
          (Ernie Rael, after 9.1.0280)
Solution: Only correct cursor in case scroll_cursor_bot() was not itself
          called to make the cursor visible. Avoid adjusting for
          'scrolloff' beyond the text line height (Luuk van Baal)

b32055e504

vim-patch:9.1.0416: some screen dump tests can be improved

Problem:  some screen dump tests can be improved (after 9.1.0414)
Solution: Make sure screen state changes properly and is captured in the
          screen dumps (Luuk van Baal)

2e642734f4
(cherry picked from commit f178b8ba49)
2024-05-17 22:14:03 +00:00
81560bbdbf Merge pull request #28814 from neovim/backport-28804-to-release-0.10
fix(health): incorrect checkhealth of ruby
2024-05-18 05:44:16 +08:00
9a2760a01f ci: change label backport to target:release
`backport` is too similar `ci:backport release-x.y` and causes
confusion.
2024-05-17 22:52:56 +02:00
5eaae797af fix(health): broken ruby detect #28804
(cherry picked from commit 10f9173519)
2024-05-17 15:58:56 +00:00
ea6b2b78bd Merge pull request #28808 from neovim/backport-28799-to-release-0.10
fix(path): avoid chdir() when resolving path
2024-05-17 18:52:38 +08:00
0cf7e2570c fix(path): avoid chdir() when resolving path (#28799)
Use uv_fs_realpath() instead.

It seems that uv_fs_realpath() has some problems on non-Linux platforms:
- macOS and other BSDs: this function will fail with UV_ELOOP if more
  than 32 symlinks are found while resolving the given path.  This limit
  is hardcoded and cannot be sidestepped.
- Windows: while this function works in the common case, there are a
  number of corner cases where it doesn't:
  - Paths in ramdisk volumes created by tools which sidestep the Volume
    Manager (such as ImDisk) cannot be resolved.
  - Inconsistent casing when using drive letters.
  - Resolved path bypasses subst'd drives.

Ref: https://docs.libuv.org/en/v1.x/fs.html#c.uv_fs_realpath

I don't know if the old implementation that uses uv_chdir() and uv_cwd()
also suffers from the same problems.
- For the ELOOP case, chdir() seems to have the same limitations.
- On Windows, Vim doesn't use anything like chdir() either. It uses
  _wfullpath(), while libuv uses GetFinalPathNameByHandleW().

(cherry picked from commit 42aa69b076)
2024-05-17 10:39:17 +00:00
902980edb9 Merge pull request #28787 from neovim/backport-28785-to-release-0.10
fix(version): fix vim.version().prerelease
2024-05-17 06:26:52 +08:00
6802db7aa1 fix(version): fix vim.version().prerelease
fixes #28782 (when backported)

(cherry picked from commit d049752e45)
2024-05-16 20:04:20 +00:00
d90ee70897 version bump 2024-05-16 20:17:00 +02:00
303 changed files with 6554 additions and 4259 deletions

View File

@ -16,7 +16,7 @@ if [[ $os == Linux ]]; then
if [[ $CC == clang ]]; then
DEFAULT_CLANG_VERSION=$(echo | clang -dM -E - | grep __clang_major | awk '{print $3}')
CLANG_VERSION=18
CLANG_VERSION=19
if ((DEFAULT_CLANG_VERSION >= CLANG_VERSION)); then
echo "Default clang version is $DEFAULT_CLANG_VERSION, which equal or larger than wanted version $CLANG_VERSION. Aborting!"
exit 1
@ -30,10 +30,10 @@ if [[ $os == Linux ]]; then
fi
if [[ -n $TEST ]]; then
sudo apt-get install -y locales-all cpanminus attr libattr1-dev gdb fswatch
sudo apt-get install -y locales-all cpanminus attr libattr1-dev gdb fswatch xdg-utils
# Use default CC to avoid compilation problems when installing Python modules
CC=cc python3 -m pip -q install --user --upgrade pynvim
CC=cc python3 -m pip -q install --user --upgrade --break-system-packages pynvim
fi
elif [[ $os == Darwin ]]; then
brew update --quiet

View File

@ -2,6 +2,10 @@ build:
- changed-files:
- any-glob-to-any-file: [ CMakeLists.txt, "**/CMakeLists.txt", "**/Makefile", "**/*.cmake", cmake.deps/**/* ]
checkhealth:
- changed-files:
- any-glob-to-any-file: [ "**/health.lua" ]
ci:
- changed-files:
- any-glob-to-any-file: [ .github/actions/**, .github/workflows/**, .github/scripts/** ]
@ -14,6 +18,14 @@ column:
- changed-files:
- any-glob-to-any-file: [ src/nvim/sign* ]
comment:
- changed-files:
- any-glob-to-any-file: [ runtime/lua/vim/_comment.lua ]
defaults:
- changed-files:
- any-glob-to-any-file: [ runtime/lua/vim/_defaults.lua ]
diagnostic:
- changed-files:
- any-glob-to-any-file: [ runtime/lua/vim/diagnostic.lua ]
@ -34,6 +46,10 @@ filetype:
- changed-files:
- any-glob-to-any-file: [ runtime/lua/vim/filetype.lua, runtime/lua/vim/filetype/detect.lua ]
filesystem:
- changed-files:
- any-glob-to-any-file: [ runtime/lua/vim/fs.lua ]
folds:
- changed-files:
- any-glob-to-any-file: [ src/nvim/fold* ]
@ -46,9 +62,9 @@ mouse:
- changed-files:
- any-glob-to-any-file: [ src/nvim/mouse* ]
platform:nix:
netrw:
- changed-files:
- any-glob-to-any-file: [ contrib/flake.lock, contrib/flake.nix ]
- any-glob-to-any-file: [ runtime/autoload/netrw.vim, runtime/plugin/netrwPlugin.vim ]
snippet:
- changed-files:

View File

@ -23,6 +23,10 @@ module.exports = async ({ github, context }) => {
reviewers.add("lewis6991");
}
if (labels.includes("comment")) {
reviewers.add("echasnovski");
}
if (labels.includes("defaults")) {
reviewers.add("gpanders");
}
@ -35,21 +39,20 @@ module.exports = async ({ github, context }) => {
reviewers.add("lewis6991");
}
if (labels.includes("documentation")) {
reviewers.add("clason");
}
if (labels.includes("editorconfig")) {
reviewers.add("gpanders");
}
if (labels.includes("extmarks")) {
if (labels.includes("marks")) {
reviewers.add("bfredl");
}
if (labels.includes("filetype")) {
reviewers.add("clason");
reviewers.add("gpanders");
}
if (labels.includes("inccommand")) {
reviewers.add("famiu");
}
if (labels.includes("lsp")) {
@ -57,6 +60,10 @@ module.exports = async ({ github, context }) => {
reviewers.add("mfussenegger");
}
if (labels.includes("netrw")) {
reviewers.add("justinmk");
}
if (labels.includes("options")) {
reviewers.add("famiu");
}
@ -78,10 +85,6 @@ module.exports = async ({ github, context }) => {
reviewers.add("famiu");
}
if (labels.includes("test")) {
reviewers.add("justinmk");
}
if (labels.includes("treesitter")) {
reviewers.add("bfredl");
reviewers.add("clason");
@ -98,7 +101,6 @@ module.exports = async ({ github, context }) => {
}
if (labels.includes("vim-patch")) {
reviewers.add("seandewar");
reviewers.add("zeertzjq");
}

View File

@ -12,25 +12,35 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.BACKPORT_APP }}
private-key: ${{ secrets.BACKPORT_KEY }}
- name: Create backport PR
id: backport
uses: korthout/backport-action@v2
uses: korthout/backport-action@v3
with:
pull_title: "${pull_title}"
label_pattern: "^ci:backport ([^ ]+)$"
# https://github.com/korthout/backport-action/pull/399
experimental: >
{
"detect_merge_method": true
}
github_token: ${{ steps.app-token.outputs.token }}
- if: ${{steps.backport.outputs.was_successful == 'true'}}
- name: Create failed backport label
if: ${{ steps.backport.outputs.was_successful == 'false' }}
uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: ${{steps.backport.outputs.created_pull_numbers}},
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['backport']
labels: ['needs:backport']
})
- name: Enable automerge
if: ${{ steps.backport.outputs.was_successful == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --rebase --auto ${{ steps.backport.outputs.created_pull_numbers }}

View File

@ -74,7 +74,9 @@ jobs:
for d in *; do (cd "$d"; rm -rf ./autom4te.cache; make clean || true; make distclean || true); done
- name: Re-build bundled dependencies with no network access
run: unshare --map-root-user --net make deps DEPS_CMAKE_FLAGS=-DUSE_EXISTING_SRC_DIR=ON
run: |
sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0
unshare --map-root-user --net make deps DEPS_CMAKE_FLAGS=-DUSE_EXISTING_SRC_DIR=ON
- name: Build
run: make CMAKE_FLAGS="-D CI_BUILD=ON"

33
.github/workflows/build_dummy.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: build_dummy
on:
pull_request:
branches:
- 'master'
- 'release-[0-9]+.[0-9]+'
# This needs to be an exact complement of `paths` in the build.yml workflow.
# This is required to bypass required checks since a required job is always
# needed to run.
paths-ignore:
- '**.cmake'
- '**/CMakeLists.txt'
- '**/CMakePresets.json'
- 'cmake.*/**'
- '.github/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
old-cmake:
name: Test oldest supported cmake
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- run: echo "success"
use-existing-src:
name: Test USE_EXISTING_SRC_DIR=ON builds with no network access
runs-on: ubuntu-latest
steps:
- run: echo "success"

View File

@ -2,13 +2,6 @@ name: docs
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'src/nvim/api/*.[ch]'
- 'src/nvim/eval.lua'
- 'runtime/lua/**.lua'
- 'runtime/doc/**'
- 'scripts/gen_vimdoc.py'
- 'scripts/gen_help_html.lua'
jobs:
docs:
runs-on: ubuntu-latest

View File

@ -33,8 +33,25 @@ jobs:
- name: "Extract if the PR is a breaking change and add it as label"
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true
request-reviewer:
target-release:
needs: ["changed-files", "type-scope"]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- if: startsWith(github.base_ref, 'release')
uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['target:release']
})
request-reviewer:
needs: ["changed-files", "type-scope", "target-release"]
permissions:
pull-requests: write
uses: ./.github/workflows/reviewers_add.yml

View File

@ -1,4 +1,4 @@
name: "lintcommit"
name: lintcommit
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

16
.github/workflows/lintcommit_dummy.yml vendored Normal file
View File

@ -0,0 +1,16 @@
# Dummy workflow of lintcommit.yml. lintcommit is a required check, but it's
# only designed to work on master. Since required checks are always required to
# run, we can essentially "skip" the lintcommit on release branches with this
# dummy check that automatically passes.
name: lintcommit_dummy
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- 'release-[0-9]+.[0-9]+'
jobs:
lint-commits:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- run: echo "success"

View File

@ -32,26 +32,45 @@ ${NVIM_VERSION}
3. Extract: `tar xzvf nvim-macos-arm64.tar.gz`
4. Run `./nvim-macos-arm64/bin/nvim`
### Linux (x64)
### Linux (x86_64)
Minimum glibc version to run these releases is 2.31. People requiring releases
that work on older glibc versions can find them at
https://github.com/neovim/neovim-releases.
#### AppImage
1. Download **nvim.appimage**
2. Run `chmod u+x nvim.appimage && ./nvim.appimage`
1. Download **nvim-linux-x86_64.appimage**
2. Run `chmod u+x nvim-linux-x86_64.appimage && ./nvim-linux-x86_64.appimage`
- If your system does not have FUSE you can [extract the appimage](https://github.com/AppImage/AppImageKit/wiki/FUSE#type-2-appimage):
```
./nvim.appimage --appimage-extract
./nvim-linux-x86_64.appimage --appimage-extract
./squashfs-root/usr/bin/nvim
```
#### Tarball
1. Download **nvim-linux64.tar.gz**
2. Extract: `tar xzvf nvim-linux64.tar.gz`
3. Run `./nvim-linux64/bin/nvim`
1. Download **nvim-linux-x86_64.tar.gz**
2. Extract: `tar xzvf nvim-linux-x86_64.tar.gz`
3. Run `./nvim-linux-x86_64/bin/nvim`
### Linux (arm64)
#### AppImage
1. Download **nvim-linux-arm64.appimage**
2. Run `chmod u+x nvim-linux-arm64.appimage && ./nvim-linux-arm64.appimage`
- If your system does not have FUSE you can [extract the appimage](https://github.com/AppImage/AppImageKit/wiki/FUSE#type-2-appimage):
```
./nvim-linux-arm64.appimage --appimage-extract
./squashfs-root/usr/bin/nvim
```
#### Tarball
1. Download **nvim-linux-arm64.tar.gz**
2. Extract: `tar xzvf nvim-linux-arm64.tar.gz`
3. Run `./nvim-linux-arm64/bin/nvim`
### Other
@ -60,11 +79,14 @@ https://github.com/neovim/neovim-releases.
## SHA256 Checksums
```
${SHA_LINUX_64_TAR}
${SHA_APP_IMAGE}
${SHA_APP_IMAGE_ZSYNC}
${SHA_MACOS_X86_64}
${SHA_APPIMAGE_ARM64}
${SHA_APPIMAGE_ARM64_ZSYNC}
${SHA_LINUX_ARM64_TAR}
${SHA_APPIMAGE_X86_64}
${SHA_APPIMAGE_X86_64_ZSYNC}
${SHA_LINUX_X86_64_TAR}
${SHA_MACOS_ARM64}
${SHA_WIN_64_ZIP}
${SHA_MACOS_X86_64}
${SHA_WIN_64_MSI}
${SHA_WIN_64_ZIP}
```

View File

@ -11,7 +11,7 @@ concurrency:
env:
INSTALL_PREFIX: ${{ github.workspace }}/nvim-install
# Double test timeout since it's running via qemu
TEST_TIMEOUT: 2400
TEST_TIMEOUT: 3600
# TEST_FILE: test/functional/shada
# TEST_FILTER: foo
@ -23,7 +23,7 @@ jobs:
matrix:
test: [functionaltest, oldtest]
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 90
steps:
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: docker://multiarch/ubuntu-core:s390x-focal
@ -34,7 +34,7 @@ jobs:
bash -c
"
apt-get -y update &&
DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake curl gettext ninja-build locales-all cpanminus git attr libattr1-dev &&
time DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential cmake curl gettext ninja-build locales-all cpanminus git attr libattr1-dev xdg-utils &&
useradd --create-home qemuci &&
chown -R qemuci. . &&
runuser -u qemuci -- git clone --depth=1 https://github.com/neovim/neovim.git &&

View File

@ -39,10 +39,21 @@ jobs:
printf "appimage_tag=${APPIMAGE_TAG}\n" >> $GITHUB_OUTPUT
linux:
runs-on: ubuntu-20.04
needs: setup
strategy:
fail-fast: false
matrix:
runner: [ ubuntu-20.04, ubuntu-24.04-arm ]
include:
- runner: ubuntu-20.04
arch: x86_64
cc: gcc-10
- runner: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.runner }}
env:
CC: gcc-10
CC: ${{ matrix.cc }}
LDAI_NO_APPSTREAM: 1 # skip checking (broken) AppStream metadata for issues
outputs:
version: ${{ steps.build.outputs.version }}
steps:
@ -52,22 +63,25 @@ jobs:
fetch-depth: 0
- run: ./.github/scripts/install_deps.sh
- run: echo "CMAKE_BUILD_TYPE=${{ needs.setup.outputs.build_type }}" >> $GITHUB_ENV
- if: matrix.arch == 'arm64'
run: sudo apt-get update && sudo apt-get install -y libfuse2t64
- name: appimage
run: ./scripts/genappimage.sh ${{ needs.setup.outputs.appimage_tag }}
run: |
./scripts/genappimage.sh ${{ needs.setup.outputs.appimage_tag }}
- name: tar.gz
run: cpack --config build/CPackConfig.cmake -G TGZ
- uses: actions/upload-artifact@v4
with:
name: appimage
name: appimage-${{ matrix.arch }}
path: |
build/bin/nvim.appimage
build/bin/nvim.appimage.zsync
build/bin/nvim-linux-${{ matrix.arch }}.appimage
build/bin/nvim-linux-${{ matrix.arch }}.appimage.zsync
retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: nvim-linux64
name: nvim-linux-${{ matrix.arch }}
path: |
build/nvim-linux64.tar.gz
build/nvim-linux-${{ matrix.arch }}.tar.gz
retention-days: 1
- name: Export version
id: build
@ -75,15 +89,14 @@ jobs:
printf 'version<<END\n' >> $GITHUB_OUTPUT
./build/bin/nvim --version | head -n 3 >> $GITHUB_OUTPUT
printf 'END\n' >> $GITHUB_OUTPUT
macos:
needs: setup
strategy:
fail-fast: false
matrix:
runner: [ macos-12, macos-14 ]
runner: [ macos-13, macos-14 ]
include:
- runner: macos-12
- runner: macos-13
arch: x86_64
- runner: macos-14
arch: arm64
@ -104,7 +117,6 @@ jobs:
-D CMAKE_BUILD_TYPE=${{ needs.setup.outputs.build_type }} \
-D CMAKE_FIND_FRAMEWORK=NEVER
cmake --build .deps
- name: Build neovim
run: |
cmake -B build -G Ninja \
@ -112,7 +124,6 @@ jobs:
-D ENABLE_LIBINTL=OFF \
-D CMAKE_FIND_FRAMEWORK=NEVER
cmake --build build
- name: Package
run: cpack --config build/CPackConfig.cmake
@ -187,21 +198,36 @@ jobs:
git push origin :stable || true
# `sha256sum` outputs <sha> <path>, so we cd into each dir to drop the
# containing folder from the output.
- name: Generate Linux64 SHA256 checksums
- name: Generate Linux x86_64 SHA256 checksums
run: |
cd ./nvim-linux64
sha256sum nvim-linux64.tar.gz > nvim-linux64.tar.gz.sha256sum
echo "SHA_LINUX_64_TAR=$(cat nvim-linux64.tar.gz.sha256sum)" >> $GITHUB_ENV
- name: Generate App Image SHA256 checksums
cd ./nvim-linux-x86_64
sha256sum nvim-linux-x86_64.tar.gz > nvim-linux-x86_64.tar.gz.sha256sum
echo "SHA_LINUX_X86_64_TAR=$(cat nvim-linux-x86_64.tar.gz.sha256sum)" >> $GITHUB_ENV
- name: Generate Linux arm64 SHA256 checksums
run: |
cd ./appimage
sha256sum nvim.appimage > nvim.appimage.sha256sum
echo "SHA_APP_IMAGE=$(cat nvim.appimage.sha256sum)" >> $GITHUB_ENV
- name: Generate App Image Zsync SHA256 checksums
cd ./nvim-linux-arm64
sha256sum nvim-linux-arm64.tar.gz > nvim-linux-arm64.tar.gz.sha256sum
echo "SHA_LINUX_ARM64_TAR=$(cat nvim-linux-arm64.tar.gz.sha256sum)" >> $GITHUB_ENV
- name: Generate AppImage x64_64 SHA256 checksums
run: |
cd ./appimage
sha256sum nvim.appimage.zsync > nvim.appimage.zsync.sha256sum
echo "SHA_APP_IMAGE_ZSYNC=$(cat nvim.appimage.zsync.sha256sum)" >> $GITHUB_ENV
cd ./appimage-x86_64
sha256sum nvim-linux-x86_64.appimage > nvim-linux-x86_64.appimage.sha256sum
echo "SHA_APPIMAGE_X86_64=$(cat nvim-linux-x86_64.appimage.sha256sum)" >> $GITHUB_ENV
- name: Generate AppImage x86_64 Zsync SHA256 checksums
run: |
cd ./appimage-x86_64
sha256sum nvim-linux-x86_64.appimage.zsync > nvim-linux-x86_64.appimage.zsync.sha256sum
echo "SHA_APPIMAGE_X86_64_ZSYNC=$(cat nvim-linux-x86_64.appimage.zsync.sha256sum)" >> $GITHUB_ENV
- name: Generate AppImage x64_64 SHA256 checksums
run: |
cd ./appimage-arm64
sha256sum nvim-linux-arm64.appimage > nvim-linux-arm64.appimage.sha256sum
echo "SHA_APPIMAGE_ARM64=$(cat nvim-linux-arm64.appimage.sha256sum)" >> $GITHUB_ENV
- name: Generate AppImage arm64 Zsync SHA256 checksums
run: |
cd ./appimage-arm64
sha256sum nvim-linux-arm64.appimage.zsync > nvim-linux-arm64.appimage.zsync.sha256sum
echo "SHA_APPIMAGE_ARM64_ZSYNC=$(cat nvim-linux-arm64.appimage.zsync.sha256sum)" >> $GITHUB_ENV
- name: Generate macos x86_64 SHA256 checksums
run: |
cd ./nvim-macos-x86_64
@ -226,6 +252,6 @@ jobs:
run: |
envsubst < "$GITHUB_WORKSPACE/.github/workflows/notes.md" > "$RUNNER_TEMP/notes.md"
if [ "$TAG_NAME" != "nightly" ]; then
gh release create stable $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA nvim-macos-x86_64/* nvim-macos-arm64/* nvim-linux64/* appimage/* nvim-win64/*
gh release create stable $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA nvim-macos-x86_64/* nvim-macos-arm64/* nvim-linux-x86_64/* nvim-linux-arm64/* appimage-x86_64/* appimage-arm64/* nvim-win64/*
fi
gh release create $TAG_NAME $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA nvim-macos-x86_64/* nvim-macos-arm64/* nvim-linux64/* appimage/* nvim-win64/*
gh release create $TAG_NAME $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA nvim-macos-x86_64/* nvim-macos-arm64/* nvim-linux-x86_64/* nvim-linux-arm64/* appimage-x86_64/* appimage-arm64/* nvim-win64/*

View File

@ -5,7 +5,7 @@ on:
workflow_call:
jobs:
request-reviewer:
if: github.event.pull_request.state == 'open' && github.event.pull_request.draft == false
if: github.event.pull_request.state == 'open' && github.event.pull_request.draft == false && !endsWith(github.actor, '[bot]')
runs-on: ubuntu-latest
permissions:
pull-requests: write

View File

@ -8,8 +8,6 @@ on:
branches:
- 'master'
- 'release-[0-9]+.[0-9]+'
paths-ignore:
- 'contrib/**'
workflow_dispatch:
concurrency:
@ -30,7 +28,7 @@ env:
jobs:
lint:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 10
env:
CC: clang
@ -80,7 +78,7 @@ jobs:
run: cmake --build build --target lintc-uncrustify
clang-analyzer:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 20
env:
CC: clang
@ -95,18 +93,24 @@ jobs:
- run: cmake --build build --target clang-analyzer
posix:
name: ${{ matrix.build.runner }} ${{ matrix.build.flavor }} ${{ matrix.build.cc }} ${{ matrix.test }}
name: ${{ matrix.build.os }} ${{ matrix.build.flavor }} ${{ matrix.build.cc }} ${{ matrix.test }}
strategy:
fail-fast: false
matrix:
# The `os` field is not needed to differentiate between the different
# matrix builds. It is needed to not change the required checks (which
# uses jobs names) each time we bump the runner version. It may be
# possible to remove if we e.g. start using `-latest` runner versions
# or if github introduces a wildcard for required checks in the future.
build:
[
{ runner: ubuntu-22.04, flavor: asan, cc: clang, flags: -D ENABLE_ASAN_UBSAN=ON },
{ runner: ubuntu-22.04, flavor: tsan, cc: clang, flags: -D ENABLE_TSAN=ON },
{ runner: ubuntu-22.04, cc: gcc },
{ runner: macos-12, cc: clang, flags: -D CMAKE_FIND_FRAMEWORK=NEVER, deps_flags: -D CMAKE_FIND_FRAMEWORK=NEVER },
{ runner: macos-14, cc: clang, flags: -D CMAKE_FIND_FRAMEWORK=NEVER, deps_flags: -D CMAKE_FIND_FRAMEWORK=NEVER },
{ runner: ubuntu-22.04, flavor: puc-lua, cc: gcc, deps_flags: -D USE_BUNDLED_LUAJIT=OFF -D USE_BUNDLED_LUA=ON, flags: -D PREFER_LUA=ON },
{ runner: ubuntu-24.04, os: ubuntu, flavor: asan, cc: clang, flags: -D ENABLE_ASAN_UBSAN=ON },
{ runner: ubuntu-24.04, os: ubuntu, flavor: tsan, cc: clang, flags: -D ENABLE_TSAN=ON },
{ runner: ubuntu-24.04, os: ubuntu, flavor: release, cc: gcc, flags: -D CMAKE_BUILD_TYPE=Release },
{ runner: ubuntu-24.04-arm, os: ubuntu, flavor: arm, cc: gcc, flags: -D CMAKE_BUILD_TYPE=RelWithDebInfo },
{ runner: macos-13, os: macos, flavor: intel, cc: clang, flags: -D CMAKE_FIND_FRAMEWORK=NEVER, deps_flags: -D CMAKE_FIND_FRAMEWORK=NEVER },
{ runner: macos-15, os: macos, flavor: arm, cc: clang, flags: -D CMAKE_FIND_FRAMEWORK=NEVER, deps_flags: -D CMAKE_FIND_FRAMEWORK=NEVER },
{ runner: ubuntu-24.04, os: ubuntu, flavor: puc-lua, cc: gcc, deps_flags: -D USE_BUNDLED_LUAJIT=OFF -D USE_BUNDLED_LUA=ON, flags: -D PREFER_LUA=ON },
]
test: [unittest, functionaltest, oldtest]
exclude:
@ -142,6 +146,10 @@ jobs:
sudo cpanm -n Neovim::Ext || cat "$HOME/.cpanm/build.log"
perl -W -e 'use Neovim::Ext; print $Neovim::Ext::VERSION'
- name: Remove .git directory
if: ${{ matrix.build.os == 'ubuntu' }}
run: cmake -E rm -rf -- .git
- name: Build third-party deps
run: |
cmake -S cmake.deps --preset ci -D CMAKE_BUILD_TYPE=Debug ${{ matrix.build.deps_flags }}
@ -152,9 +160,15 @@ jobs:
cmake --preset ci -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX ${{ matrix.build.flags }}
cmake --build build
- name: ${{ matrix.test }}
- if: ${{ matrix.test == 'oldtest' }}
name: ${{ matrix.test }}
timeout-minutes: 20
run: make ${{ matrix.test }}
run: make -C test/old/testdir NVIM_PRG=$(realpath build)/bin/nvim
- if: ${{ matrix.test != 'oldtest' }}
name: ${{ matrix.test }}
timeout-minutes: 20
run: cmake --build build --target ${{ matrix.test }}
- name: Install
run: |
@ -190,42 +204,8 @@ jobs:
windows:
uses: ./.github/workflows/test_windows.yml
# This job tests the following things:
# - Check if Release, MinSizeRel and RelWithDebInfo compiles correctly.
# - Test the above build types with the GCC compiler specifically.
# Empirically the difference in warning levels between GCC and other
# compilers is particularly big.
# - Test if the build works with multi-config generators. We mostly use
# single-config generators so it's nice to have a small sanity check for
# multi-config.
build-types:
runs-on: ubuntu-22.04
timeout-minutes: 10
env:
CC: gcc
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Build third-party deps
run: |
cmake -S cmake.deps -B .deps -G "Ninja Multi-Config"
cmake --build .deps
- name: Configure
run: cmake --preset ci -G "Ninja Multi-Config"
- name: Release
run: cmake --build build --config Release
- name: RelWithDebInfo
run: cmake --build build --config RelWithDebInfo
- name: MinSizeRel
run: cmake --build build --config MinSizeRel
with-external-deps:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 10
env:
CC: gcc

View File

@ -31,6 +31,13 @@ jobs:
cmake --preset ci -D CMAKE_BUILD_TYPE='RelWithDebInfo' ${{ inputs.build_flags }}
cmake --build build
# FIXME(dundargoc): this workaround is needed as the python3 provider
# tests suddenly started to become extremely flaky, and this removes the
# flakiness for some reason.
- uses: actions/setup-python@v4
with:
python-version: '3.13'
- name: Install test deps
run: |
$PSNativeCommandArgumentPassing = 'Legacy'

View File

@ -50,6 +50,6 @@ jobs:
if: ${{ steps.update-version.outputs.NEW_PATCHES != 0 }}
run: |
git add -u
git commit -m 'docs: update version.c [skip ci]'
git commit -m 'docs: update version.c'
git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${VERSION_BRANCH}
gh pr create --draft --fill --label vim-patch --base ${GITHUB_REF#refs/heads/} --head ${VERSION_BRANCH} || true

View File

@ -12,7 +12,7 @@
- To build on Windows, see the [Building on Windows](#building-on-windows) section. _MSVC (Visual Studio) is recommended._
4. `sudo make install`
- Default install location is `/usr/local`
- On Debian/Ubuntu, instead of installing files directly with `sudo make install`, you can run `cd build && cpack -G DEB && sudo dpkg -i nvim-linux64.deb` to build DEB-package and install it. This should help ensuring the clean removal of installed files.
- On Debian/Ubuntu, instead of `sudo make install`, you can try `cd build && cpack -G DEB && sudo dpkg -i nvim-linux-<arch>.deb` (with `<arch>` either `x86_64` or `arm64`) to build DEB-package and install it. This helps ensure clean removal of installed files. Note: This is an unsupported, "best-effort" feature of the Nvim build.
**Notes**:
- From the repository's root directory, running `make` will download and build all the needed dependencies and put the `nvim` executable in `build/bin`.
@ -240,7 +240,7 @@ cmake --build build
### How to build without "bundled" dependencies
1. Manually install the dependencies:
- libuv libluv libvterm luajit lua-lpeg lua-mpack msgpack-c tree-sitter tree-sitter-bash tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-python tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium
- libuv libluv libvterm luajit lua-lpeg lua-mpack msgpack-c tree-sitter tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-query tree-sitter-vim tree-sitter-vimdoc unibilium
2. Run CMake:
```sh
cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo

View File

@ -39,6 +39,12 @@ include(InstallHelpers)
include(PreventInTreeBuilds)
include(Util)
#-------------------------------------------------------------------------------
# User settings
#-------------------------------------------------------------------------------
set(DEPS_IGNORE_SHA FALSE)
#-------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------
@ -47,9 +53,6 @@ set(TOUCHES_DIR ${PROJECT_BINARY_DIR}/touches)
file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
set_directory_properties(PROPERTIES
EP_PREFIX "${DEPS_BUILD_DIR}")
if(NOT CI_BUILD)
set(CMAKE_INSTALL_MESSAGE NEVER)
endif()
@ -142,7 +145,7 @@ endif()
# version string, else they are combined with the result of `git describe`.
set(NVIM_VERSION_MAJOR 0)
set(NVIM_VERSION_MINOR 10)
set(NVIM_VERSION_PATCH 0)
set(NVIM_VERSION_PATCH 4)
set(NVIM_VERSION_PRERELEASE "") # for package maintainers
# API level
@ -241,7 +244,7 @@ add_glob_target(
GLOB_DIRS runtime scripts src test
GLOB_PAT *.lua
TOUCH_STRATEGY PER_DIR)
add_dependencies(lintlua-luacheck lua-dev-deps)
add_dependencies(lintlua-luacheck lua_dev_deps)
add_glob_target(
TARGET lintlua-stylua
@ -300,26 +303,24 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(cmake.packaging)
endif()
get_externalproject_options(uncrustify ${DEPS_IGNORE_SHA})
ExternalProject_Add(uncrustify
URL https://github.com/uncrustify/uncrustify/archive/uncrustify-0.79.0.tar.gz
URL_HASH SHA256=e7afaeabf636b7f0ce4e3e9747b95f7bd939613a8db49579755dddf44fedca5f
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/uncrustify
CMAKE_ARGS ${DEPS_CMAKE_ARGS}
EXCLUDE_FROM_ALL TRUE
DOWNLOAD_NO_PROGRESS TRUE)
${EXTERNALPROJECT_OPTIONS})
option(USE_BUNDLED_BUSTED "Use bundled busted" ON)
if(USE_BUNDLED_BUSTED)
ExternalProject_Add(lua-dev-deps
URL https://github.com/neovim/deps/raw/5a1f71cceb24990a0b15fd9a472a5f549f019248/opt/lua-dev-deps.tar.gz
URL_HASH SHA256=27db2495f5eddc7fc191701ec9b291486853530c6125609d3197d03481e8d5a2
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/lua-dev-deps
get_externalproject_options(lua_dev_deps ${DEPS_IGNORE_SHA})
ExternalProject_Add(lua_dev_deps
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/lua_dev_deps
SOURCE_DIR ${DEPS_SHARE_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL TRUE
DOWNLOAD_NO_PROGRESS TRUE)
${EXTERNALPROJECT_OPTIONS})
else()
add_custom_target(lua-dev-deps)
add_custom_target(lua_dev_deps)
endif()

View File

@ -15,9 +15,10 @@ Install from download
Downloads are available on the [Releases](https://github.com/neovim/neovim/releases) page.
* Latest [stable release](https://github.com/neovim/neovim/releases/latest)
* [macOS x86](https://github.com/neovim/neovim/releases/latest/download/nvim-macos-x86_64.tar.gz)
* [macOS arm](https://github.com/neovim/neovim/releases/latest/download/nvim-macos-arm64.tar.gz)
* [Linux](https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz)
* [macOS x86_64](https://github.com/neovim/neovim/releases/latest/download/nvim-macos-x86_64.tar.gz)
* [macOS arm64](https://github.com/neovim/neovim/releases/latest/download/nvim-macos-arm64.tar.gz)
* [Linux x86_64](https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz)
* [Linux arm64](https://github.com/neovim/neovim/releases/latest/download/nvim-linux-arm64.tar.gz)
* [Windows](https://github.com/neovim/neovim/releases/latest/download/nvim-win64.msi)
* Latest [development prerelease](https://github.com/neovim/neovim/releases/nightly)
@ -55,12 +56,12 @@ Several Neovim GUIs are available from scoop (extras): [scoop.sh/#/apps?q=neovim
1. Choose a package (**nvim-winXX.zip**) from the [releases page](https://github.com/neovim/neovim/releases).
2. Unzip the package. Any location is fine, administrator privileges are _not_ required.
- `$VIMRUNTIME` will be set to that location automatically.
3. Double-click `nvim-qt.exe`.
3. Run `nvim.exe` from a terminal.
**Optional** steps:
- Add the `bin` folder (e.g. `C:\Program Files\nvim\bin`) to your PATH.
- This makes it easy to run `nvim` and `nvim-qt` from anywhere.
- This makes it easy to run `nvim` from anywhere.
- If `:set spell` does not work, create the `C:/Users/foo/AppData/Local/nvim/site/spell` folder.
You can then copy your spell files over (for English, located
[here](https://github.com/vim/vim/blob/master/runtime/spell/en.utf-8.spl) and
@ -118,24 +119,24 @@ After this step add this to `~/.bashrc`:
### AppImage ("universal" Linux package)
The [Releases](https://github.com/neovim/neovim/releases) page provides an [AppImage](https://appimage.org) that runs on most Linux systems. No installation is needed, just download `nvim.appimage` and run it. (It might not work if your Linux distribution is more than 4 years old.)
The [Releases](https://github.com/neovim/neovim/releases) page provides an [AppImage](https://appimage.org) that runs on most Linux systems. No installation is needed, just download `nvim-linux-x86_64.appimage` and run it. (It might not work if your Linux distribution is more than 4 years old.) The following instructions assume an `x86_64` architecture; on ARM Linux replace with `arm64`.
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-86_64.appimage
chmod u+x nvim-linux-x86_64.appimage
./nvim-linux-x86_64.appimage
To expose nvim globally:
mkdir -p /opt/nvim
mv nvim.appimage /opt/nvim/nvim
mv nvim-linux-x86_64.appimage /opt/nvim/nvim
And the following line to `~/.bashrc`:
export PATH="$PATH:/opt/nvim/"
If the `./nvim.appimage` command fails, try:
If the `./nvim-linux-x86_64.appimage` command fails, try:
```sh
./nvim.appimage --appimage-extract
./nvim-linux-x86_64.appimage --appimage-extract
./squashfs-root/AppRun --version
# Optional: exposing nvim globally.

View File

@ -211,12 +211,12 @@ https://github.com/neovim/neovim-backup
* For special-purpose jobs where the runner version doesn't really matter,
prefer `-latest` tags so we don't need to manually bump the versions. An
example of a special-purpose workflow is `labeler_pr.yml`.
* For our testing job `test.yml`, prefer to use the latest stable (i.e.
non-beta) version explicitly. Avoid using the `-latest` tags here as it
makes it difficult to determine from an unrelated PR if a failure is due
to the PR itself or due to GitHub bumping the `-latest` tag without our
knowledge. There's also a high risk that automatically bumping the CI
versions will fail due to manual work being required from experience.
* For our testing job `test.yml`, prefer to use the latest version
explicitly. Avoid using the `-latest` tags here as it makes it difficult
to determine from an unrelated PR if a failure is due to the PR itself or
due to GitHub bumping the `-latest` tag without our knowledge. There's
also a high risk that automatically bumping the CI versions will fail due
to manual work being required from experience.
* For our release job, which is `release.yml`, prefer to use the oldest
stable (i.e. non-deprecated) versions available. The reason is that we're
trying to produce images that work in the broadest number of environments,

View File

@ -1,3 +1,26 @@
ifeq ($(OS),Windows_NT)
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -NoLogo
MKDIR := @$$null = new-item -itemtype directory -force
TOUCH := @$$null = new-item -force
RM := remove-item -force
CMAKE := cmake
CMAKE_GENERATOR := Ninja
define rmdir
if (Test-Path $1) { remove-item -recurse $1 }
endef
else
MKDIR := mkdir -p
TOUCH := touch
RM := rm -rf
CMAKE := $(shell (command -v cmake3 || command -v cmake || echo cmake))
CMAKE_GENERATOR ?= "$(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || echo "Unix Makefiles")"
GENERATOR_CMD ?= "$(shell (command -v ninja > /dev/null 2>&1 && echo "ninja") || echo "make")"
define rmdir
rm -rf $1
endef
endif
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))
@ -9,7 +32,6 @@ filter-true = $(strip $(filter-out 1 on ON true TRUE,$1))
all: nvim
CMAKE ?= $(shell (command -v cmake3 || echo cmake))
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
# Extra CMake flags which extend the default set
CMAKE_EXTRA_FLAGS ?=
@ -37,21 +59,11 @@ else
checkprefix: ;
endif
CMAKE_GENERATOR ?= $(shell (command -v ninja > /dev/null 2>&1 && echo "Ninja") || \
echo "Unix Makefiles")
DEPS_BUILD_DIR ?= .deps
DEPS_BUILD_DIR ?= ".deps"
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
$(error DEPS_BUILD_DIR must not contain whitespace)
endif
ifeq (,$(BUILD_TOOL))
ifeq (Ninja,$(CMAKE_GENERATOR))
BUILD_TOOL = ninja
else
BUILD_TOOL = $(MAKE)
endif
endif
DEPS_CMAKE_FLAGS ?=
USE_BUNDLED ?=
@ -61,7 +73,7 @@ endif
ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS)))
BUNDLED_LUA_CMAKE_FLAG := -DUSE_BUNDLED_LUA=ON
$(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || rm build/.ran-*)
$(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || $(RM) build/.ran-*)
endif
# For use where we want to make sure only a single job is run. This does issue
@ -69,34 +81,33 @@ endif
SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
nvim: build/.ran-cmake deps
$(BUILD_TOOL) -C build
$(CMAKE) --build build
libnvim: build/.ran-cmake deps
$(BUILD_TOOL) -C build libnvim
$(CMAKE) --build build --target libnvim
cmake:
touch CMakeLists.txt
$(TOUCH) CMakeLists.txt
$(MAKE) build/.ran-cmake
build/.ran-cmake: | deps
$(CMAKE) -B build -G '$(CMAKE_GENERATOR)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(MAKEFILE_DIR)
touch $@
$(CMAKE) -B build -G $(CMAKE_GENERATOR) $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(MAKEFILE_DIR)
$(TOUCH) $@
deps: | build/.ran-deps-cmake
ifeq ($(call filter-true,$(USE_BUNDLED)),)
$(BUILD_TOOL) -C $(DEPS_BUILD_DIR)
$(CMAKE) --build $(DEPS_BUILD_DIR)
endif
ifeq ($(call filter-true,$(USE_BUNDLED)),)
$(DEPS_BUILD_DIR):
mkdir -p "$@"
$(MKDIR) $@
build/.ran-deps-cmake:: $(DEPS_BUILD_DIR)
$(CMAKE) -S $(MAKEFILE_DIR)/cmake.deps -B $(DEPS_BUILD_DIR) -G '$(CMAKE_GENERATOR)' \
$(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) $(DEPS_CMAKE_FLAGS)
$(CMAKE) -S $(MAKEFILE_DIR)/cmake.deps -B $(DEPS_BUILD_DIR) -G $(CMAKE_GENERATOR) $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) $(DEPS_CMAKE_FLAGS)
endif
build/.ran-deps-cmake::
mkdir -p build
touch $@
$(MKDIR) build
$(TOUCH) "$@"
# TODO: cmake 3.2+ add_custom_target() has a USES_TERMINAL flag.
oldtest: | nvim
@ -113,7 +124,7 @@ test/old/testdir/%.vim: phony_force nvim
$(SINGLE_MAKE) -C test/old/testdir NVIM_PRG=$(NVIM_PRG) SCRIPTS= $(MAKEOVERRIDES) $(patsubst test/old/testdir/%.vim,%,$@)
functionaltest-lua: | nvim
$(BUILD_TOOL) -C build functionaltest
$(CMAKE) --build build --target functionaltest
FORMAT=formatc formatlua format
LINT=lintlua lintsh lintc clang-analyzer lintcommit lintdoc lint
@ -135,16 +146,19 @@ iwyu: build/.ran-cmake
$(CMAKE) --build build
clean:
test -d build && $(BUILD_TOOL) -C build clean || true
ifneq ($(wildcard build),)
$(CMAKE) --build build --target clean
endif
$(MAKE) -C test/old/testdir clean
$(MAKE) -C runtime/indent clean
distclean:
rm -rf $(DEPS_BUILD_DIR) build
$(call rmdir, $(DEPS_BUILD_DIR))
$(call rmdir, build)
$(MAKE) clean
install: checkprefix nvim
$(BUILD_TOOL) -C build install
$(GENERATOR_CMD) -C build install
appimage:
bash scripts/genappimage.sh
@ -155,14 +169,4 @@ appimage:
appimage-%:
bash scripts/genappimage.sh $*
# Generic pattern rules, allowing for `make build/bin/nvim` etc.
# Does not work with "Unix Makefiles".
ifeq ($(CMAKE_GENERATOR),Ninja)
build/%: phony_force
$(BUILD_TOOL) -C build $(patsubst build/%,%,$@)
$(DEPS_BUILD_DIR)/%: phony_force
$(BUILD_TOOL) -C $(DEPS_BUILD_DIR) $(patsubst $(DEPS_BUILD_DIR)/%,%,$@)
endif
.PHONY: test clean distclean nvim libnvim cmake deps install appimage checkprefix benchmark $(FORMAT) $(LINT) $(TEST)

View File

@ -74,25 +74,6 @@ if(APPLE)
message(STATUS "Using deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
set_directory_properties(PROPERTIES
EP_PREFIX "${DEPS_BUILD_DIR}"
CMAKE_CONFIGURE_DEPENDS deps.txt)
file(READ deps.txt DEPENDENCIES)
STRING(REGEX REPLACE "\n" ";" DEPENDENCIES "${DEPENDENCIES}")
foreach(dep ${DEPENDENCIES})
STRING(REGEX REPLACE " " ";" dep "${dep}")
list(GET dep 0 name)
list(GET dep 1 value)
if(NOT ${name})
# _URL variables must NOT be set when USE_EXISTING_SRC_DIR is set,
# otherwise ExternalProject will try to re-download the sources.
if(NOT USE_EXISTING_SRC_DIR)
set(${name} ${value})
endif()
endif()
endforeach()
if(USE_BUNDLED_LUAJIT)
set(LUA_ENGINE LuaJit)
elseif(USE_BUNDLED_LUA)

View File

@ -28,7 +28,7 @@ function(BuildTSParser)
${EXTERNALPROJECT_OPTIONS})
endfunction()
foreach(lang c lua vim vimdoc query python bash)
foreach(lang c lua vim vimdoc query)
BuildTSParser(LANG ${lang})
endforeach()
BuildTSParser(LANG markdown CMAKE_FILE MarkdownParserCMakeLists.txt)

View File

@ -15,15 +15,20 @@ string(REPLACE "#undef HAVE_LONG_LONG_INT" "#define HAVE_LONG_LONG_INT 1" CONFIG
string(REPLACE "#undef HAVE_ICONV_H" "#define HAVE_ICONV_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_ICONV" "#define HAVE_ICONV 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef ICONV_CONST" "#define ICONV_CONST const" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef uintmax_t" "
#if _WIN64
# define intmax_t long long
# define uintmax_t unsigned long long
#elif _WIN32
# define intmax_t long
# define uintmax_t unsigned long
#endif"
CONFIG_CONTENT ${CONFIG_CONTENT})
if(MSVC)
string(REPLACE "#undef HAVE_STDINT_H_WITH_UINTMAX" "#define HAVE_STDINT_H_WITH_UINTMAX 1" CONFIG_CONTENT ${CONFIG_CONTENT})
string(REPLACE "#undef HAVE_STDINT_H" "#define HAVE_STDINT_H 1" CONFIG_CONTENT ${CONFIG_CONTENT})
else()
string(REPLACE "#undef uintmax_t" "
#if _WIN64
# define intmax_t long long
# define uintmax_t unsigned long long
#elif _WIN32
# define intmax_t long
# define uintmax_t unsigned long
#endif"
CONFIG_CONTENT ${CONFIG_CONTENT})
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gettext-runtime/config.h ${CONFIG_CONTENT})
set(HAVE_NEWLOCALE 0)

View File

@ -41,21 +41,22 @@ GETTEXT_SHA256 66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47f5c
LIBICONV_URL https://github.com/neovim/deps/raw/b9bf36eb31f27e8136d907da38fa23518927737e/opt/libiconv-1.17.tar.gz
LIBICONV_SHA256 8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313
TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/v0.21.0.tar.gz
TREESITTER_C_SHA256 6f0f5d1b71cf8ffd8a37fb638c6022fa1245bd630150b538547d52128ce0ea7e
TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/v0.21.3.tar.gz
TREESITTER_C_SHA256 75a3780df6114cd37496761c4a7c9fd900c78bee3a2707f590d78c0ca3a24368
TREESITTER_LUA_URL https://github.com/tree-sitter-grammars/tree-sitter-lua/archive/v0.1.0.tar.gz
TREESITTER_LUA_SHA256 230cfcbfa74ed1f7b8149e9a1f34c2efc4c589a71fe0f5dc8560622f8020d722
TREESITTER_VIM_URL https://github.com/neovim/tree-sitter-vim/archive/v0.4.0.tar.gz
TREESITTER_VIM_SHA256 9f856f8b4a10ab43348550fa2d3cb2846ae3d8e60f45887200549c051c66f9d5
TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v2.5.1.tar.gz
TREESITTER_VIMDOC_SHA256 063645096504b21603585507c41c6d8718ff3c11b2150c5bfc31e8f3ee9afea3
TREESITTER_QUERY_URL https://github.com/tree-sitter-grammars/tree-sitter-query/archive/v0.3.0.tar.gz
TREESITTER_QUERY_SHA256 f878ff37abcb83250e31a6569e997546f3dbab74dcb26683cb2d613f7568cfc0
TREESITTER_PYTHON_URL https://github.com/tree-sitter/tree-sitter-python/archive/v0.21.0.tar.gz
TREESITTER_PYTHON_SHA256 720304a603271fa89e4430a14d6a81a023d6d7d1171b1533e49c0ab44f1e1c13
TREESITTER_BASH_URL https://github.com/tree-sitter/tree-sitter-bash/archive/v0.21.0.tar.gz
TREESITTER_BASH_SHA256 f0515efda839cfede851adb24ac154227fbc0dfb60c6c11595ecfa9087d43ceb
TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v3.0.0.tar.gz
TREESITTER_VIMDOC_SHA256 a639bf92bf57bfa1cdc90ca16af27bfaf26a9779064776dd4be34c1ef1453f6c
TREESITTER_QUERY_URL https://github.com/tree-sitter-grammars/tree-sitter-query/archive/v0.4.0.tar.gz
TREESITTER_QUERY_SHA256 d3a423ab66dc62b2969625e280116678a8a22582b5ff087795222108db2f6a6e
TREESITTER_MARKDOWN_URL https://github.com/MDeiml/tree-sitter-markdown/archive/v0.2.3.tar.gz
TREESITTER_MARKDOWN_SHA256 4909d6023643f1afc3ab219585d4035b7403f3a17849782ab803c5f73c8a31d5
TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.22.6.tar.gz
TREESITTER_SHA256 e2b687f74358ab6404730b7fb1a1ced7ddb3780202d37595ecd7b20a8f41861f
UNCRUSTIFY_URL https://github.com/uncrustify/uncrustify/archive/uncrustify-0.79.0.tar.gz
UNCRUSTIFY_SHA256 e7afaeabf636b7f0ce4e3e9747b95f7bd939613a8db49579755dddf44fedca5f
LUA_DEV_DEPS_URL https://github.com/neovim/deps/raw/5a1f71cceb24990a0b15fd9a472a5f549f019248/opt/lua-dev-deps.tar.gz
LUA_DEV_DEPS_SHA256 27db2495f5eddc7fc191701ec9b291486853530c6125609d3197d03481e8d5a2

View File

@ -1,3 +1,7 @@
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(CMAKE_SYSTEM_PROCESSOR arm64)
endif()
set(CPACK_PACKAGE_NAME "Neovim")
set(CPACK_PACKAGE_VENDOR "neovim.io")
set(CPACK_PACKAGE_FILE_NAME "nvim")
@ -38,6 +42,7 @@ if(WIN32)
# Create start menu and desktop shortcuts
set(CPACK_WIX_PROGRAM_MENU_FOLDER "${CPACK_PACKAGE_NAME}")
set(CPACK_PACKAGE_EXECUTABLES "nvim" "Neovim")
set(CPACK_WIX_INSTALL_SCOPE "perMachine")
# We use a wix patch to add further options to the installer.
# See: https://cmake.org/cmake/help/v3.7/module/CPackWIX.html#variable:CPACK_WIX_PATCH_FILE
@ -48,7 +53,7 @@ elseif(APPLE)
set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_LIST_DIR}/neovim.icns)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CPACK_PACKAGE_FILE_NAME "nvim-linux64")
set(CPACK_PACKAGE_FILE_NAME "nvim-linux-${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_GENERATOR TGZ DEB)
set(CPACK_DEBIAN_PACKAGE_NAME "Neovim") # required
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Neovim.io") # required

View File

@ -6,7 +6,7 @@
Name='PATH'
Action='set'
Permanent='no'
System='no'
System='yes'
Part='last'
Value='[INSTALL_ROOT]bin'
/>

View File

@ -58,6 +58,32 @@ if(CMAKE_OSX_SYSROOT)
set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -isysroot${CMAKE_OSX_SYSROOT}")
endif()
get_filename_component(rootdir ${PROJECT_SOURCE_DIR} NAME)
if(${rootdir} MATCHES "cmake.deps")
set(depsfile ${PROJECT_SOURCE_DIR}/deps.txt)
else()
set(depsfile ${PROJECT_SOURCE_DIR}/cmake.deps/deps.txt)
endif()
set_directory_properties(PROPERTIES
EP_PREFIX "${DEPS_BUILD_DIR}"
CMAKE_CONFIGURE_DEPENDS ${depsfile})
file(READ ${depsfile} DEPENDENCIES)
STRING(REGEX REPLACE "\n" ";" DEPENDENCIES "${DEPENDENCIES}")
foreach(dep ${DEPENDENCIES})
STRING(REGEX REPLACE " " ";" dep "${dep}")
list(GET dep 0 name)
list(GET dep 1 value)
if(NOT ${name})
# _URL variables must NOT be set when USE_EXISTING_SRC_DIR is set,
# otherwise ExternalProject will try to re-download the sources.
if(NOT USE_EXISTING_SRC_DIR)
set(${name} ${value})
endif()
endif()
endforeach()
function(get_externalproject_options name DEPS_IGNORE_SHA)
string(TOUPPER ${name} name_allcaps)
set(url ${${name_allcaps}_URL})

View File

@ -61,6 +61,7 @@ function(add_glob_target)
if(NOT ARG_COMMAND)
add_custom_target(${ARG_TARGET})
add_custom_command(TARGET ${ARG_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "${ARG_TARGET} SKIP: ${ARG_COMMAND} not found")
return()
endif()

61
contrib/flake.lock generated
View File

@ -1,61 +0,0 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1713248628,
"narHash": "sha256-NLznXB5AOnniUtZsyy/aPWOk8ussTuePp2acb9U+ISA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5672bc9dbf9d88246ddab5ac454e82318d094bb8",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,164 +0,0 @@
{
description = "Neovim flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
inherit (builtins)
elemAt
foldl'
mapAttrs
match
readFile
;
inherit (nixpkgs.lib)
const
flip
pipe
remove
splitString
toLower
;
in
{
overlay = final: prev: {
neovim = (final.neovim-unwrapped.override {
treesitter-parsers = pipe ../cmake.deps/deps.txt [
readFile
(splitString "\n")
(map (match "TREESITTER_([A-Z_]+)_(URL|SHA256)[[:space:]]+([^[:space:]]+)[[:space:]]*"))
(remove null)
(flip foldl' { }
(acc: matches:
let
lang = toLower (elemAt matches 0);
type = toLower (elemAt matches 1);
value = elemAt matches 2;
in
acc // {
${lang} = acc.${lang} or { } // {
${type} = value;
};
}))
(mapAttrs (const final.fetchurl))
(self: self // {
markdown = final.stdenv.mkDerivation {
inherit (self.markdown) name;
src = self.markdown;
installPhase = ''
mv tree-sitter-markdown $out
'';
};
})
];
}).overrideAttrs (oa: rec {
version = self.shortRev or "dirty";
src = ../.;
preConfigure = oa.preConfigure or "" + ''
sed -i cmake.config/versiondef.h.in -e 's/@NVIM_VERSION_PRERELEASE@/-dev-${version}/'
'';
nativeBuildInputs = oa.nativeBuildInputs ++ [
final.libiconv
];
});
# a development binary to help debug issues
neovim-debug = let
stdenv = if final.stdenv.isLinux then
final.llvmPackages_latest.stdenv
else
final.stdenv;
in (final.neovim.override {
lua = final.luajit;
inherit stdenv;
}).overrideAttrs (oa: {
dontStrip = true;
NIX_CFLAGS_COMPILE = " -ggdb -Og";
cmakeBuildType = "Debug";
disallowedReferences = [ ];
});
# for neovim developers, beware of the slow binary
neovim-developer = let inherit (final.luaPackages) luacheck;
in final.neovim-debug.overrideAttrs (oa: {
cmakeFlags = oa.cmakeFlags ++ [
"-DLUACHECK_PRG=${luacheck}/bin/luacheck"
"-DENABLE_LTO=OFF"
] ++ final.lib.optionals final.stdenv.isLinux [
# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
# https://clang.llvm.org/docs/AddressSanitizer.html#symbolizing-the-reports
"-DENABLE_ASAN_UBSAN=ON"
];
doCheck = final.stdenv.isLinux;
});
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
overlays = [ self.overlay ];
inherit system;
};
lua = pkgs.lua5_1;
pythonEnv = pkgs.python3.withPackages (ps: [
ps.msgpack
]);
in {
packages = with pkgs; {
default = neovim;
inherit neovim neovim-debug neovim-developer;
};
checks = {
shlint = pkgs.runCommand "shlint" {
nativeBuildInputs = [ pkgs.shellcheck ];
preferLocalBuild = true;
} "make -C ${./..} shlint > $out";
};
# kept for backwards-compatibility
defaultPackage = pkgs.neovim;
devShells = {
default = pkgs.neovim-developer.overrideAttrs (oa: {
buildInputs = with pkgs;
oa.buildInputs ++ [
lua.pkgs.luacheck
sumneko-lua-language-server
pythonEnv
include-what-you-use # for scripts/check-includes.py
jq # jq for scripts/vim-patch.sh -r
shellcheck # for `make shlint`
];
nativeBuildInputs = with pkgs;
oa.nativeBuildInputs ++ [
clang-tools # for clangd to find the correct headers
];
shellHook = oa.shellHook + ''
export NVIM_PYTHON_LOG_LEVEL=DEBUG
export NVIM_LOG_FILE=/tmp/nvim.log
export ASAN_SYMBOLIZER_PATH=${pkgs.llvm_18}/bin/llvm-symbolizer
# ASAN_OPTIONS=detect_leaks=1
export ASAN_OPTIONS="log_path=./test.log:abort_on_error=1"
# for treesitter functionaltests
mkdir -p runtime/parser
cp -f ${pkgs.vimPlugins.nvim-treesitter.builtGrammars.c}/parser runtime/parser/c.so
'';
});
};
});
}

View File

@ -2820,7 +2820,7 @@ nvim_set_decoration_provider({ns_id}, {opts})
Note: this function should not be called often. Rather, the callbacks
themselves can be used to throttle unneeded callbacks. the `on_start`
callback can return `false` to disable the provider until the next redraw.
Similarly, return `false` in `on_win` will skip the `on_lines` calls for
Similarly, return `false` in `on_win` will skip the `on_line` calls for
that window (but any extmarks set in `on_win` will still be used). A
plugin managing multiple sources of decoration should ideally only set one
provider, and merge the sources internally. You can use multiple `ns_id`
@ -2829,10 +2829,10 @@ nvim_set_decoration_provider({ns_id}, {opts})
Note: doing anything other than setting extmarks is considered
experimental. Doing things like changing options are not explicitly
forbidden, but is likely to have unexpected consequences (such as 100% CPU
consumption). doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is
consumption). Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is
quite dubious for the moment.
Note: It is not allowed to remove or update extmarks in 'on_line'
Note: It is not allowed to remove or update extmarks in `on_line`
callbacks.
Attributes: ~
@ -3496,9 +3496,9 @@ nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()*
• event: (string) name of the triggered event
|autocmd-events|
• group: (number|nil) autocommand group id, if any
match: (string) expanded value of <amatch>
buf: (number) expanded value of <abuf>
file: (string) expanded value of <afile>
file: (string) <afile> (not expanded to a full path)
match: (string) <amatch> (expanded to a full path)
buf: (number) <abuf>
• data: (any) arbitrary data passed from
|nvim_exec_autocmds()| *event-data*
• command (string) optional: Vim command to execute on event.

View File

@ -2963,8 +2963,8 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()*
difference if the buffer is displayed in a window with
different 'virtualedit' or 'list' values.
Examples: >
:xnoremap <CR>
Examples: >vim
xnoremap <CR>
\ <Cmd>echom getregion(
\ getpos('v'), getpos('.'), #{ type: mode() })<CR>
<
@ -3507,7 +3507,7 @@ id({expr}) *id()*
Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
`v:_null_blob` have the same `id()` with different types
because they are internally represented as NULL pointers.
`id()` returns a hexadecimal representanion of the pointers to
`id()` returns a hexadecimal representation of the pointers to
the containers (i.e. like `0x994a40`), same as `printf("%p",
{expr})`, but it is advised against counting on the exact
format of the return value.
@ -4597,19 +4597,19 @@ matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()*
Examples: >vim
" Assuming line 3 in buffer 5 contains "a"
:echo matchbufline(5, '\<\k\+\>', 3, 3)
[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]
echo matchbufline(5, '\<\k\+\>', 3, 3)
< `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
" Assuming line 4 in buffer 10 contains "tik tok"
:echo matchbufline(10, '\<\k\+\>', 1, 4)
[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]
<
echo matchbufline(10, '\<\k\+\>', 1, 4)
< `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
If {submatch} is present and is v:true, then submatches like
"\1", "\2", etc. are also returned. Example: >vim
" Assuming line 2 in buffer 2 contains "acd"
:echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
\ {'submatches': v:true})
[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]
< The "submatches" List always contains 9 items. If a submatch
< `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
The "submatches" List always contains 9 items. If a submatch
is not found, then an empty string is returned for that
submatch.
@ -4769,17 +4769,17 @@ matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()*
option settings on the pattern.
Example: >vim
:echo matchstrlist(['tik tok'], '\<\k\+\>')
[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]
:echo matchstrlist(['a', 'b'], '\<\k\+\>')
[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]
<
echo matchstrlist(['tik tok'], '\<\k\+\>')
< `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
echo matchstrlist(['a', 'b'], '\<\k\+\>')
< `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
If "submatches" is present and is v:true, then submatches like
"\1", "\2", etc. are also returned. Example: >vim
:echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
\ #{submatches: v:true})
[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]
< The "submatches" List always contains 9 items. If a submatch
< `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
The "submatches" List always contains 9 items. If a submatch
is not found, then an empty string is returned for that
submatch.
@ -6007,7 +6007,7 @@ screencol() *screencol()*
the following mappings: >vim
nnoremap <expr> GG ":echom " .. screencol() .. "\n"
nnoremap <silent> GG :echom screencol()<CR>
noremap GG <Cmd>echom screencol()<Cr>
noremap GG <Cmd>echom screencol()<CR>
<
screenpos({winid}, {lnum}, {col}) *screenpos()*

View File

@ -1220,13 +1220,13 @@ Vim fills these registers with text from yank and delete commands.
Numbered register 0 contains the text from the most recent yank command,
unless the command specified another register with ["x].
Numbered register 1 contains the text deleted by the most recent delete or
change command, unless the command specified another register or the text is
less than one line (the small delete register is used then). An exception is
made for the delete operator with these movement commands: |%|, |(|, |)|, |`|,
|/|, |?|, |n|, |N|, |{| and |}|. Register "1 is always used then (this is Vi
compatible). The "- register is used as well if the delete is within a line.
Note that these characters may be mapped. E.g. |%| is mapped by the matchit
plugin.
change command (even when the command specified another register), unless the
text is less than one line (the small delete register is used then). An
exception is made for the delete operator with these movement commands: |%|,
|(|, |)|, |`|, |/|, |?|, |n|, |N|, |{| and |}|.
Register "1 is always used then (this is Vi compatible). The "- register is
used as well if the delete is within a line. Note that these characters may be
mapped. E.g. |%| is mapped by the matchit plugin.
With each successive deletion or change, Vim shifts the previous contents
of register 1 into register 2, 2 into 3, and so forth, losing the previous
contents of register 9.

View File

@ -1623,7 +1623,7 @@ There are three different types of searching:
stop-directories are appended to the path (for the 'path' option) or to
the filename (for the 'tags' option) with a ';'. If you want several
stop-directories separate them with ';'. If you want no stop-directory
("search upward till the root directory) just use ';'. >
("search upward till the root directory") just use ';'. >
/usr/include/sys;/usr
< will search in: >
/usr/include/sys
@ -1636,7 +1636,7 @@ There are three different types of searching:
If Vim's current path is /u/user_x/work/release and you do >
:set path=include;/u/user_x
< and then search for a file with |gf| the file is searched in: >
< and then search for a file with |gf| the file is searched in: >
/u/user_x/work/release/include
/u/user_x/work/include
/u/user_x/include
@ -1648,7 +1648,7 @@ There are three different types of searching:
3) Combined up/downward search:
If Vim's current path is /u/user_x/work/release and you do >
set path=**;/u/user_x
< and then search for a file with |gf| the file is searched in: >
< and then search for a file with |gf| the file is searched in: >
/u/user_x/work/release/**
/u/user_x/work/**
/u/user_x/**
@ -1660,10 +1660,10 @@ There are three different types of searching:
In the above example you might want to set path to: >
:set path=**,/u/user_x/**
< This searches:
/u/user_x/work/release/** ~
/u/user_x/** ~
This searches the same directories, but in a different order.
< This searches: >
/u/user_x/work/release/**
/u/user_x/**
< This searches the same directories, but in a different order.
Note that completion for ":find", ":sfind", and ":tabfind" commands do not
currently work with 'path' items that contain a URL or use the double star

View File

@ -293,7 +293,7 @@ loaded by Vim: >
ftplugin/sql.vim
syntax/sqlinformix.vim
indent/sql.vim
>
<
Notice indent/sqlinformix.sql was not loaded. There is no indent file
for Informix, Vim loads the default files if the specified files does not
exist.
@ -349,7 +349,7 @@ The defaults static maps are: >
The use of "<C-C>" can be user chosen by using the following in your |init.vim|
as it may not work properly on all platforms: >
let g:ftplugin_sql_omni_key = '<C-C>'
>
<
The static maps (which are based on the syntax highlight groups) follow this
format: >
imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>
@ -664,7 +664,7 @@ your |init.vim|: >
filetype is changed temporarily to SQL, the sqlcompletion plugin
will cache the syntax groups listed in the List specified in this
option.
>
------------------------------------------------------------------------------
4.5 SQL Maps *sql-completion-maps*

View File

@ -366,7 +366,7 @@ tag char note action in Normal mode ~
or start of putted text
|`]| `] 1 cursor to the end of last operated text or
end of putted text
|``| `` 1 cursor to the position before latest jump
|``| "``" 1 cursor to the position before latest jump
|`{| `{ 1 cursor to the start of the current paragraph
|`}| `} 1 cursor to the end of the current paragraph
|a| a 2 append text after the cursor N times
@ -397,7 +397,7 @@ tag char note action in Normal mode ~
|q| q{0-9a-zA-Z"} record typed characters into named register
{0-9a-zA-Z"} (uppercase to append)
|q| q (while recording) stops recording
|Q| Q replay last recorded macro
|Q| Q 2 replay last recorded register
|q:| q: edit : command-line in command-line window
|q/| q/ edit / command-line in command-line window
|q?| q? edit ? command-line in command-line window
@ -736,7 +736,7 @@ tag char note action in Normal mode ~
search pattern and Visually select it
|gP| ["x]gP 2 put the text [from register x] before the
cursor N times, leave the cursor after it
|gQ| gQ switch to "Ex" mode with Vim editing
|gQ| gQ switch to "Ex" mode with Vim editing
|gR| gR 2 enter Virtual Replace mode
|gT| gT go to the previous tab page
|gU| gU{motion} 2 make Nmove text uppercase
@ -923,7 +923,6 @@ tag command note action in Visual mode ~
|v_O| O move horizontally to other corner of area
|v_P| P replace highlighted area with register
contents; registers are unchanged
Q does not start Ex mode
|v_R| R 2 delete the highlighted lines and start
insert
|v_S| S 2 delete the highlighted lines and start
@ -1136,7 +1135,7 @@ tag command action ~
|:!!| :!! repeat last ":!" command
|:#| :# same as ":number"
|:&| :& repeat last ":substitute"
|:star| :* use the last Visual area, like :'<,'>
|:star| :* use the last Visual area, like ":'<,'>"
|:<| :< shift lines one 'shiftwidth' left
|:=| := print the last line number
|:>| :> shift lines one 'shiftwidth' right

View File

@ -1927,11 +1927,6 @@ These two commands will keep on asking for lines, until you type a line
containing only a ".". Watch out for lines starting with a backslash, see
|line-continuation|.
When in Ex mode (see |-e|) a backslash at the end of the line can be used to
insert a NUL character. To be able to have a line ending in a backslash use
two backslashes. This means that the number of backslashes is halved, but
only at the end of the line.
NOTE: These commands cannot be used with |:global| or |:vglobal|.
":append" and ":insert" don't work properly in between ":if" and
":endif", ":for" and ":endfor", ":while" and ":endwhile".

View File

@ -12,7 +12,7 @@ enhanced LSP tools.
https://microsoft.github.io/language-server-protocol/
LSP facilitates features like go-to-definition, find-references, hover,
LSP facilitates features like go-to-definition, find references, hover,
completion, rename, format, refactor, etc., using semantic whole-project
analysis (unlike |ctags|).
@ -25,26 +25,36 @@ Nvim provides an LSP client, but the servers are provided by third parties.
Follow these steps to get LSP features:
1. Install language servers using your package manager or by following the
upstream installation instruction. You can find language servers here:
upstream installation instructions. You can find language servers here:
https://microsoft.github.io/language-server-protocol/implementors/servers/
2. Configure the LSP client per language server. See |vim.lsp.start()| or use
this minimal example as a guide: >lua
2. Use |vim.lsp.start()| to start the LSP server (or attach to an existing
one) when a file is opened. Example: >lua
-- Create an event handler for the FileType autocommand
vim.api.nvim_create_autocmd('FileType', {
-- This handler will fire when the buffer's 'filetype' is "python"
pattern = 'python',
callback = function(ev)
vim.lsp.start({
name = 'my-server-name',
cmd = {'name-of-language-server-executable', '--option', 'arg1', 'arg2'},
vim.lsp.start({
name = 'my-server-name',
cmd = {'name-of-language-server-executable'},
root_dir = vim.fs.root(0, {'setup.py', 'pyproject.toml'}),
-- Set the "root directory" to the parent directory of the file in the
-- current buffer (`ev.buf`) that contains either a "setup.py" or a
-- "pyproject.toml" file. Files that share a root directory will reuse
-- the connection to the same LSP server.
root_dir = vim.fs.root(ev.buf, {'setup.py', 'pyproject.toml'}),
})
end,
})
<
3. Check that the server attached to the buffer: >
:lua =vim.lsp.get_clients()
3. Check that the buffer is attached to the server: >vim
:checkhealth lsp
4. Configure keymaps and autocmds to use LSP features. See |lsp-config|.
4. (Optional) Configure keymaps and autocommands to use LSP features. |lsp-config|
*lsp-config*
*lsp-defaults*
When the LSP client starts it enables diagnostics |vim.diagnostic| (see
When the Nvim LSP client starts it enables diagnostics |vim.diagnostic| (see
|vim.diagnostic.config()| to customize). It also sets various default options,
listed below, if (1) the language server supports the functionality and (2)
the options are empty or were set by the builtin runtime (ftplugin) files. The
@ -57,12 +67,13 @@ options are not restored when the LSP client is stopped or detached.
|CTRL-W_}| to utilize the language server.
- 'formatexpr' is set to |vim.lsp.formatexpr()|, so you can format lines via
|gq| if the language server supports it.
- To opt out of this use |gw| instead of gq, or set 'formatexpr' on LspAttach.
- To opt out of this use |gw| instead of gq, or clear 'formatexpr' on |LspAttach|.
- |K| is mapped to |vim.lsp.buf.hover()| unless |'keywordprg'| is customized or
a custom keymap for `K` exists.
*lsp-defaults-disable*
To override the above defaults, set or unset the options on |LspAttach|: >lua
To override or delete any of the above defaults, set or unset the options on
|LspAttach|: >lua
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(ev)
@ -71,7 +82,8 @@ To override the above defaults, set or unset the options on |LspAttach|: >lua
vim.keymap.del('n', 'K', { buffer = ev.buf })
end,
})
<
*lsp-config*
To use other LSP features, set keymaps on |LspAttach|. Not all language
servers provide the same capabilities. To ensure you only set keymaps if the
language server supports a feature, guard keymaps behind capability checks.
@ -201,26 +213,26 @@ Each response handler has this signature: >
function(err, result, ctx, config)
<
Parameters: ~
- {err} (table|nil) Error info dict, or `nil` if the request
completed.
- {result} (Result | Params | nil) `result` key of the |lsp-response| or
`nil` if the request failed.
- {ctx} (table) Table of calling state associated with the
handler, with these keys:
- {method} (string) |lsp-method| name.
- {client_id} (number) |vim.lsp.Client| identifier.
- {bufnr} (Buffer) Buffer handle.
- {params} (table|nil) Request parameters table.
- {version} (number) Document version at time of
request. Handlers can compare this to the
current document version to check if the
response is "stale". See also |b:changedtick|.
- {config} (table) Handler-defined configuration table, which allows
users to customize handler behavior.
For an example, see:
|vim.lsp.diagnostic.on_publish_diagnostics()|
To configure a particular |lsp-handler|, see:
|lsp-handler-configuration|
{err} (`table|nil`) Error info dict, or `nil` if the request
completed.
{result} (`Result|Params|nil`) `result` key of the |lsp-response| or
`nil` if the request failed.
{ctx} (`table`) Table of calling state associated with the
handler, with these keys:
{method} (`string`) |lsp-method| name.
{client_id} (`number`) |vim.lsp.Client| identifier.
{bufnr} (`Buffer`) Buffer handle.
{params} (`table|nil`) Request parameters table.
{version} (`number`) Document version at time of
request. Handlers can compare this to the
current document version to check if the
response is "stale". See also |b:changedtick|.
{config} (`table`) Handler-defined configuration table, which allows
users to customize handler behavior.
For an example, see:
|vim.lsp.diagnostic.on_publish_diagnostics()|
To configure a particular |lsp-handler|, see:
|lsp-handler-configuration|
Returns: ~
Two values `result, err` where `err` is shaped like an RPC error: >
@ -977,7 +989,7 @@ Lua module: vim.lsp.client *lsp-client*
if the client supports workspace folders. It
can be `null` if the client supports workspace
folders but none are configured.
• {root_dir} (`string`)
• {root_dir} (`string?`)
• {attached_buffers} (`table<integer,true>`)
• {commands} (`table<string,fun(command: lsp.Command, ctx: table)>`)
Table of command name to function which is
@ -1460,7 +1472,7 @@ get_namespace({client_id}, {is_pull})
client. Defaults to push
*vim.lsp.diagnostic.on_diagnostic()*
on_diagnostic({_}, {result}, {ctx}, {config})
on_diagnostic({error}, {result}, {ctx}, {config})
|lsp-handler| for the method "textDocument/diagnostic"
See |vim.diagnostic.config()| for configuration options. Handler-specific
@ -1485,6 +1497,7 @@ on_diagnostic({_}, {result}, {ctx}, {config})
<
Parameters: ~
• {error} (`lsp.ResponseError?`)
• {result} (`lsp.DocumentDiagnosticReport`)
• {ctx} (`lsp.HandlerContext`)
• {config} (`vim.diagnostic.Opts`) Configuration table (see
@ -1634,7 +1647,7 @@ is_enabled({filter}) *vim.lsp.inlay_hint.is_enabled()*
Query whether inlay hint is enabled in the {filter}ed scope
Parameters: ~
• {filter} (`table`) Optional filters |kwargs|, or `nil` for all.
• {filter} (`table?`) Optional filters |kwargs|, or `nil` for all.
• {bufnr} (`integer?`) Buffer number, or 0 for current
buffer, or nil for all.

View File

@ -680,8 +680,8 @@ vim.diff({a}, {b}, {opts}) *vim.diff()*
Parameters: ~
• {a} (`string`) First string to compare
• {b} (`string`) Second string to compare
• {opts} (`table`) Optional parameters:
• {on_hunk}
• {opts} (`table?`) Optional parameters:
• {on_hunk}?
(`fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer`)
Invoked for each hunk in the diff. Return a negative number
to cancel the callback for any remaining hunks. Arguments:
@ -689,33 +689,33 @@ vim.diff({a}, {b}, {opts}) *vim.diff()*
• `count_a` (`integer`): Hunk size in {a}.
• `start_b` (`integer`): Start line of hunk in {b}.
• `count_b` (`integer`): Hunk size in {b}.
• {result_type} (`'unified'|'indices'`, default: `'unified'`)
• {result_type}? (`'unified'|'indices'`, default: `'unified'`)
Form of the returned diff:
• `unified`: String in unified format.
• `indices`: Array of hunk locations. Note: This option is
ignored if `on_hunk` is used.
• {linematch} (`boolean|integer`) Run linematch on the
• {linematch}? (`boolean|integer`) Run linematch on the
resulting hunks from xdiff. When integer, only hunks upto
this size in lines are run through linematch. Requires
`result_type = indices`, ignored otherwise.
• {algorithm} (`'myers'|'minimal'|'patience'|'histogram'`,
• {algorithm}? (`'myers'|'minimal'|'patience'|'histogram'`,
default: `'myers'`) Diff algorithm to use. Values:
• `myers`: the default algorithm
• `minimal`: spend extra time to generate the smallest
possible diff
• `patience`: patience diff algorithm
• `histogram`: histogram diff algorithm
• {ctxlen} (`integer`) Context length
• {interhunkctxlen} (`integer`) Inter hunk context length
• {ignore_whitespace} (`boolean`) Ignore whitespace
• {ignore_whitespace_change} (`boolean`) Ignore whitespace
• {ctxlen}? (`integer`) Context length
• {interhunkctxlen}? (`integer`) Inter hunk context length
• {ignore_whitespace}? (`boolean`) Ignore whitespace
• {ignore_whitespace_change}? (`boolean`) Ignore whitespace
change
• {ignore_whitespace_change_at_eol} (`boolean`) Ignore
• {ignore_whitespace_change_at_eol}? (`boolean`) Ignore
whitespace change at end-of-line.
• {ignore_cr_at_eol} (`boolean`) Ignore carriage return at
• {ignore_cr_at_eol}? (`boolean`) Ignore carriage return at
end-of-line
• {ignore_blank_lines} (`boolean`) Ignore blank lines
• {indent_heuristic} (`boolean`) Use the indent heuristic for
• {ignore_blank_lines}? (`boolean`) Ignore blank lines
• {indent_heuristic}? (`boolean`) Use the indent heuristic for
the internal diff library.
Return: ~
@ -1426,12 +1426,9 @@ Option:remove({value}) *vim.opt:remove()*
• {value} (`string`) Value to remove
vim.bo[{bufnr}] *vim.bo*
Get or set buffer-scoped |options| for the buffer with number {bufnr}. If
{bufnr} is omitted then the current buffer is used. Invalid {bufnr} or key
is an error.
Note: this is equivalent to `:setlocal` for |global-local| options and
`:set` otherwise.
Get or set buffer-scoped |options| for the buffer with number {bufnr}.
Like `:setlocal`. If {bufnr} is omitted then the current buffer is used.
Invalid {bufnr} or key is an error.
Example: >lua
local bufnr = vim.api.nvim_get_current_buf()
@ -1646,12 +1643,15 @@ vim.on_key({fn}, {ns_id}) *vim.on_key()*
• {fn} will not be cleared by |nvim_buf_clear_namespace()|
Parameters: ~
• {fn} (`fun(key: string, typed: string)?`) Function invoked on
every key press. |i_CTRL-V| {key} is the key after mappings
have been applied, and {typed} is the key(s) before mappings
are applied, which may be empty if {key} is produced by
non-typed keys. When {fn} is nil and {ns_id} is specified,
the callback associated with namespace {ns_id} is removed.
• {fn} (`fun(key: string, typed: string)?`) Function invoked for
every input key, after mappings have been applied but before
further processing. Arguments {key} and {typed} are raw
keycodes, where {key} is the key after mappings are applied,
and {typed} is the key(s) before mappings are applied.
{typed} may be empty if {key} is produced by non-typed key(s)
or by the same typed key(s) that produced a previous {key}.
When {fn} is `nil` and {ns_id} is specified, the callback
associated with namespace {ns_id} is removed.
• {ns_id} (`integer?`) Namespace ID. If nil or 0, generates and returns
a new |nvim_create_namespace()| id.
@ -1659,6 +1659,9 @@ vim.on_key({fn}, {ns_id}) *vim.on_key()*
(`integer`) Namespace id associated with {fn}. Or count of all
callbacks if on_key() is called without arguments.
See also: ~
• |keytrans()|
vim.paste({lines}, {phase}) *vim.paste()*
Paste handler, invoked by |nvim_paste()| when a conforming UI (such as the
|TUI|) pastes text into the editor.
@ -3012,7 +3015,10 @@ vim.fs.parents({start}) *vim.fs.parents()*
vim.fs.root({source}, {marker}) *vim.fs.root()*
Find the first parent directory containing a specific "marker", relative
to a buffer's directory.
to a file path or buffer.
If the buffer is unnamed (has no backing file) or has a non-empty
'buftype' then the search begins from Nvim's |current-directory|.
Example: >lua
-- Find the root of a Python project, starting from file 'main.py'
@ -3029,7 +3035,8 @@ vim.fs.root({source}, {marker}) *vim.fs.root()*
Parameters: ~
• {source} (`integer|string`) Buffer number (0 for current buffer) or
file path to begin the search from.
file path (absolute or relative to the |current-directory|)
to begin the search from.
• {marker} (`string|string[]|fun(name: string, path: string): boolean`)
A marker, or list of markers, to search for. If a function,
the function is called for each evaluated item and should
@ -3085,7 +3092,7 @@ In addition, its regex-like interface is available as |vim.re|
Pattern:match({subject}, {init}) *Pattern:match()*
Pattern:match({subject}, {init}, {...}) *Pattern:match()*
Matches the given `pattern` against the `subject` string. If the match
succeeds, returns the index in the subject of the first character after
the match, or the captured values (if the pattern captured any value). An
@ -3108,9 +3115,10 @@ Pattern:match({subject}, {init}) *Pattern:match()*
Parameters: ~
• {subject} (`string`)
• {init} (`integer?`)
• {...} (`any`)
Return: ~
(`integer|vim.lpeg.Capture?`)
(`any`) ...
vim.lpeg.B({pattern}) *vim.lpeg.B()*
Returns a pattern that matches only if the input string at the current
@ -3120,7 +3128,7 @@ vim.lpeg.B({pattern}) *vim.lpeg.B()*
or failure.
Parameters: ~
• {pattern} (`vim.lpeg.Pattern`)
• {pattern} (`vim.lpeg.Pattern|string|integer|boolean|table`)
Return: ~
(`vim.lpeg.Pattern`)
@ -3144,7 +3152,7 @@ vim.lpeg.C({patt}) *vim.lpeg.C()*
<
Parameters: ~
• {patt} (`vim.lpeg.Pattern`)
• {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
Return: ~
(`vim.lpeg.Capture`)
@ -3195,11 +3203,11 @@ vim.lpeg.Cf({patt}, {func}) *vim.lpeg.Cf()*
This capture assumes that `patt` should produce at least one capture with
at least one value (of any type), which becomes the initial value of an
accumulator. (If you need a specific initial value, you may prefix a
constant captureto `patt`.) For each subsequent capture, LPeg calls `func`
with this accumulator as the first argument and all values produced by the
capture as extra arguments; the first result from this call becomes the
new value for the accumulator. The final value of the accumulator becomes
the captured value.
constant capture to `patt`.) For each subsequent capture, LPeg calls
`func` with this accumulator as the first argument and all values produced
by the capture as extra arguments; the first result from this call becomes
the new value for the accumulator. The final value of the accumulator
becomes the captured value.
Example: >lua
local number = lpeg.R('09') ^ 1 / tonumber
@ -3210,7 +3218,7 @@ vim.lpeg.Cf({patt}, {func}) *vim.lpeg.Cf()*
<
Parameters: ~
• {patt} (`vim.lpeg.Pattern`)
• {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
• {func} (`fun(acc, newvalue)`)
Return: ~
@ -3222,7 +3230,7 @@ vim.lpeg.Cg({patt}, {name}) *vim.lpeg.Cg()*
with the given name (which can be any non-nil Lua value).
Parameters: ~
• {patt} (`vim.lpeg.Pattern`)
• {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
• {name} (`string?`)
Return: ~
@ -3245,8 +3253,9 @@ vim.lpeg.Cmt({patt}, {fn}) *vim.lpeg.Cmt()*
function become the values produced by the capture.
Parameters: ~
• {patt} (`vim.lpeg.Pattern`)
• {fn} (`function`)
• {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
• {fn} (`fun(s: string, i: integer, ...: any)`) (position:
boolean|integer, ...: any)
Return: ~
(`vim.lpeg.Capture`)
@ -3285,7 +3294,7 @@ vim.lpeg.Cs({patt}) *vim.lpeg.Cs()*
<
Parameters: ~
• {patt} (`vim.lpeg.Pattern`)
• {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
Return: ~
(`vim.lpeg.Capture`)
@ -3298,7 +3307,7 @@ vim.lpeg.Ct({patt}) *vim.lpeg.Ct()*
the group name as its key. The captured value is only the table.
Parameters: ~
• {patt} (`vim.lpeg.Pattern|''`)
• {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
Return: ~
(`vim.lpeg.Capture`)
@ -3333,7 +3342,7 @@ vim.lpeg.locale({tab}) *vim.lpeg.locale()*
Return: ~
(`vim.lpeg.Locale`)
vim.lpeg.match({pattern}, {subject}, {init}) *vim.lpeg.match()*
vim.lpeg.match({pattern}, {subject}, {init}, {...}) *vim.lpeg.match()*
Matches the given `pattern` against the `subject` string. If the match
succeeds, returns the index in the subject of the first character after
the match, or the captured values (if the pattern captured any value). An
@ -3354,12 +3363,13 @@ vim.lpeg.match({pattern}, {subject}, {init}) *vim.lpeg.match()*
<
Parameters: ~
• {pattern} (`vim.lpeg.Pattern`)
• {pattern} (`vim.lpeg.Pattern|string|integer|boolean|table|function`)
• {subject} (`string`)
• {init} (`integer?`)
• {...} (`any`)
Return: ~
(`integer|vim.lpeg.Capture?`)
(`any`) ...
vim.lpeg.P({value}) *vim.lpeg.P()*
Converts the given value into a proper pattern. The following rules are
@ -3453,7 +3463,7 @@ vim.lpeg.V({v}) *vim.lpeg.V()*
<
Parameters: ~
• {v} (`string|integer`)
• {v} (`boolean|string|number|function|table|thread|userdata|lightuserdata`)
Return: ~
(`vim.lpeg.Pattern`)
@ -4385,8 +4395,9 @@ vim.text.hexdecode({enc}) *vim.text.hexdecode()*
Parameters: ~
• {enc} (`string`) String to decode
Return: ~
(`string`) Decoded string
Return (multiple): ~
(`string?`) Decoded string
(`string?`) Error message, if any
vim.text.hexencode({str}) *vim.text.hexencode()*
Hex encode a string.
@ -4402,7 +4413,7 @@ vim.text.hexencode({str}) *vim.text.hexencode()*
Lua module: tohtml *vim.tohtml*
:TOhtml {file} *:TOhtml*
:[range]TOhtml {file} *:TOhtml*
Converts the buffer shown in the current window to HTML, opens the generated
HTML in a new split window, and saves its contents to {file}. If {file} is not
given, a temporary file (created by |tempname()|) is used.
@ -4424,6 +4435,8 @@ tohtml.tohtml({winid}, {opt}) *tohtml.tohtml.tohtml()*
• {width}? (`integer`, default: 'textwidth' if non-zero or
window width otherwise) Width used for items which are
either right aligned or repeat a character infinitely.
• {range}? (`integer[]`, default: entire buffer) Range of
rows to use.
Return: ~
(`string[]`)

View File

@ -1380,11 +1380,13 @@ completion can be enabled:
-complete=arglist file names in argument list
-complete=augroup autocmd groups
-complete=breakpoint |:breakadd| suboptions
-complete=buffer buffer names
-complete=behave :behave suboptions
-complete=color color schemes
-complete=command Ex command (and arguments)
-complete=compiler compilers
-complete=diff_buffer diff buffer names
-complete=dir directory names
-complete=environment environment variable names
-complete=event autocommand events
@ -1395,7 +1397,7 @@ completion can be enabled:
-complete=function function name
-complete=help help subjects
-complete=highlight highlight groups
-complete=history :history suboptions
-complete=history |:history| suboptions
-complete=keymap keyboard mappings
-complete=locale locale names (as output of locale -a)
-complete=lua Lua expression |:lua|
@ -1405,6 +1407,8 @@ completion can be enabled:
-complete=messages |:messages| suboptions
-complete=option options
-complete=packadd optional package |pack-add| names
-complete=runtime file and directory names in |'runtimepath'|
-complete=scriptnames sourced script names
-complete=shellcmd Shell command
-complete=sign |:sign| suboptions
-complete=syntax syntax file names |'syntax'|

View File

@ -354,11 +354,11 @@ gg Goto line [count], default first line, on the first
See also 'startofline' option.
:[range]go[to] [count] *:go* *:goto* *go*
[count]go Go to [count] byte in the buffer. Default [count] is
one, start of the file. When giving [range], the
last number in it used as the byte count. End-of-line
characters are counted depending on the current
'fileformat' setting.
[count]go Go to [count] byte in the buffer. |exclusive| motion.
Default [count] is one, start of the file. When
giving [range], the last number in it used as the byte
count. End-of-line characters are counted depending
on the current 'fileformat' setting.
Also see the |line2byte()| function, and the 'o'
option in 'statusline'.

View File

@ -349,8 +349,8 @@ The following new features were added.
|default-autocmds|
• Treesitter:
• Bundled parsers and queries (highlight, folds) for Markdown, Python, and
Bash.
• Bundled parsers and queries (highlight, folds) for Markdown (used for LSP
hover).
• |:InspectTree| shows root nodes.
• |:InspectTree| now supports |folding|.
• |:InspectTree| shows node ranges in 0-based instead of 1-based indexing.

View File

@ -1092,7 +1092,7 @@ A jump table for the options with a short description can be found at |Q_op|.
applying 'breakindent', even if the resulting
text should normally be narrower. This prevents
text indented almost to the right window border
occupying lot of vertical space when broken.
occupying lots of vertical space when broken.
(default: 20)
shift:{n} After applying 'breakindent', the wrapped line's
beginning will be shifted by the given number of
@ -3439,7 +3439,7 @@ A jump table for the options with a short description can be found at |Q_op|.
in Insert mode as specified with the 'indentkeys' option.
When this option is not empty, it overrules the 'cindent' and
'smartindent' indenting. When 'lisp' is set, this option is
is only used when 'lispoptions' contains "expr:1".
only used when 'lispoptions' contains "expr:1".
The expression is evaluated with |v:lnum| set to the line number for
which the indent is to be computed. The cursor is also in this line
when the expression is evaluated (but it may be moved around).
@ -3611,7 +3611,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Otherwise only one space is inserted.
*'jumpoptions'* *'jop'*
'jumpoptions' 'jop' string (default "")
'jumpoptions' 'jop' string (default "clean")
global
List of words that change the behavior of the |jumplist|.
stack Make the jumplist behave like the tagstack.
@ -3624,6 +3624,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|alternate-file| or using |mark-motions| try to
restore the |mark-view| in which the action occurred.
clean Remove unloaded buffers from the jumplist.
EXPERIMENTAL: this flag may change in the future.
*'keymap'* *'kmp'*
'keymap' 'kmp' string (default "")
local to buffer
@ -3688,7 +3691,7 @@ A jump table for the options with a short description can be found at |Q_op|.
part can be in one of two forms:
1. A list of pairs. Each pair is a "from" character immediately
followed by the "to" character. Examples: "aA", "aAbBcC".
2. A list of "from" characters, a semi-colon and a list of "to"
2. A list of "from" characters, a semicolon and a list of "to"
characters. Example: "abc;ABC"
Example: "aA,fgh;FGH,cCdDeE"
Special characters need to be preceded with a backslash. These are
@ -3756,7 +3759,7 @@ A jump table for the options with a short description can be found at |Q_op|.
update use |:redraw|.
This may occasionally cause display errors. It is only meant to be set
temporarily when performing an operation where redrawing may cause
flickering or cause a slow down.
flickering or cause a slowdown.
*'linebreak'* *'lbr'* *'nolinebreak'* *'nolbr'*
'linebreak' 'lbr' boolean (default off)
@ -3834,6 +3837,9 @@ A jump table for the options with a short description can be found at |Q_op|.
between tabs and spaces and for trailing blanks. Further changed by
the 'listchars' option.
When 'listchars' does not contain "tab" field, tabs are shown as "^I"
or "<09>", like how unprintable characters are displayed.
The cursor is displayed at the start of the space a Tab character
occupies, not at the end as usual in Normal mode. To get this cursor
position while displaying Tabs with spaces, use: >vim
@ -4582,7 +4588,7 @@ A jump table for the options with a short description can be found at |Q_op|.
set path+=
< To use an environment variable, you probably need to replace the
separator. Here is an example to append $INCL, in which directory
names are separated with a semi-colon: >vim
names are separated with a semicolon: >vim
let &path = &path .. "," .. substitute($INCL, ';', ',', 'g')
< Replace the ';' with a ':' or whatever separator is used. Note that
this doesn't work when $INCL contains a comma or white space.
@ -5442,7 +5448,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'shortmess' 'shm' string (default "ltToOCF")
global
This option helps to avoid all the |hit-enter| prompts caused by file
messages, for example with CTRL-G, and to avoid some other messages.
messages, for example with CTRL-G, and to avoid some other messages.
It is a list of flags:
flag meaning when present ~
l use "999L, 888B" instead of "999 lines, 888 bytes" *shm-l*
@ -5847,7 +5853,7 @@ A jump table for the options with a short description can be found at |Q_op|.
minus two.
timeout:{millisec} Limit the time searching for suggestions to
{millisec} milli seconds. Applies to the following
{millisec} milliseconds. Applies to the following
methods. When omitted the limit is 5000. When
negative there is no limit.

View File

@ -12,11 +12,12 @@ Support *support*
Supported platforms *supported-platforms*
`System` `Tier` `Versions` `Tested versions`
Linux 1 >= 2.6.32, glibc >= 2.12 Ubuntu 22.04
macOS (Intel) 1 >= 11 macOS 12
macOS (M1) 2 >= 11 macOS 14
Linux (x86_64) 1 >= 2.6.32, glibc >= 2.12 Ubuntu 24.04
Linux (arm64) 1 >= 2.6.32, glibc >= 2.12 Ubuntu 24.04
macOS (x86_64) 1 >= 11 macOS 13
macOS (arm64) 1 >= 11 macOS 15
Windows 64-bit 1 >= Windows 10 Version 1809 Windows Server 2022
FreeBSD 1 >= 10 FreeBSD 13
FreeBSD 1 >= 10 FreeBSD 14
OpenBSD 2 >= 7
MinGW 2 MinGW-w64
Windows 64-bit 3 < Windows 10 Version 1809
@ -28,10 +29,10 @@ your Windows version, run the "winver" command and look for "Version xxxx"
Support types ~
* Tier 1: Officially supported and tested with CI. Any contributed patch
MUST NOT break such systems.
MUST NOT break support for such platforms.
* Tier 2: Officially supported, but not necessarily tested with CI. These
systems are maintained to the best of our ability, without being a top
* Tier 2: Officially supported, but not necessarily tested with CI. Support
for these platforms are maintained by best effort, without being a top
priority.
* Tier 3: Not tested and no guarantees, and not all features may work.
@ -47,7 +48,8 @@ Common
Some common notes when adding support for new platforms:
Cmake is the only supported build system. The platform must be buildable with cmake.
CMake is the only supported build system. Nvim must be buildable on the
platform with CMake.
All functionality related to the new platform must be implemented in its own
file inside `src/nvim/os` unless it's already done in a common file, in which

View File

@ -152,8 +152,7 @@ add a few items or change the highlighting, follow these steps:
1. Create your user directory from 'runtimepath', see above.
2. Create a directory in there called "after/syntax". For Unix: >
mkdir ~/.config/nvim/after
mkdir ~/.config/nvim/after/syntax
mkdir -p ~/.config/nvim/after/syntax
3. Write a Vim script that contains the commands you want to use. For
example, to change the colors for the C syntax: >
@ -4986,7 +4985,6 @@ IncSearch 'incsearch' highlighting; also used for the text replaced with
":s///c".
*hl-Substitute*
Substitute |:substitute| replacement text highlighting.
*hl-LineNr*
LineNr Line number for ":number" and ":#" commands, and when 'number'
or 'relativenumber' option is set.
@ -5006,7 +5004,6 @@ CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line.
*hl-MatchParen*
MatchParen Character under the cursor or just before it, if it
is a paired bracket, and its match. |pi_paren.txt|
*hl-ModeMsg*
ModeMsg 'showmode' message (e.g., "-- INSERT --").
*hl-MsgArea*
@ -5052,7 +5049,7 @@ PmenuThumb Popup menu: Thumb of the scrollbar.
Question |hit-enter| prompt and yes/no questions.
*hl-QuickFixLine*
QuickFixLine Current |quickfix| item in the quickfix window. Combined with
|hl-CursorLine| when the cursor is there.
|hl-CursorLine| when the cursor is there.
*hl-Search*
Search Last search pattern highlighting (see 'hlsearch').
Also used for similar items that need to stand out.

View File

@ -330,7 +330,7 @@ TREESITTER QUERY DIRECTIVES *treesitter-directives*
Treesitter directives store metadata for a node or match and perform side
effects. For example, the `set!` directive sets metadata on the match or node: >query
((identifier) @foo (#set! "type" "parameter"))
((identifier) @foo (#set! type "parameter"))
<
The following directives are built in:
@ -345,9 +345,9 @@ The following directives are built in:
{value}
Examples: >query
((identifier) @foo (#set! @foo "kind" "parameter"))
((node1) @left (node2) @right (#set! "type" "pair"))
((codeblock) @markup.raw.block (#set! "priority" 90))
((identifier) @foo (#set! @foo kind "parameter"))
((node1) @left (node2) @right (#set! type "pair"))
((codeblock) @markup.raw.block (#set! priority 90))
<
`offset!` *treesitter-directive-offset!*
Takes the range of the captured node and applies an offset. This will
@ -631,7 +631,7 @@ higher than treesitter. It is also possible to change the priority of an
individual query pattern manually by setting its `"priority"` metadata
attribute: >query
((super_important_node) @superimportant (#set! "priority" 105))
((super_important_node) @superimportant (#set! priority 105))
<
==============================================================================

View File

@ -87,7 +87,7 @@ The ":tags" command shows the list of tags that you traversed through:
1 1 write_line 8 write_block.c ~
2 1 write_char 7 write_line.c ~
> ~
>
<
Now to go back. The CTRL-T command goes to the preceding tag. In the example
above you get back to the "write_line" function, in the call to "write_char".
This command takes a count argument that indicates how many tags to jump

View File

@ -209,7 +209,7 @@ gx Opens the current filepath or URL (decided by
This implies that an insert command must be completed
(to start Insert mode, see |:startinsert|). A ":"
command must be completed as well. And you can't use
"Q" or "gQ" to start Ex mode.
"gQ" to start Ex mode.
The display is not updated while ":normal" is busy.
@ -579,6 +579,10 @@ Acting on multiple lines behaves as follows:
transformed to empty comments (e.g. `/**/`). Comment markers are aligned to
the least indented line.
Matching 'commentstring' does not account for whitespace in comment markers.
Removing comment markers is first attempted exactly, with fallback to using
markers trimmed from whitespace.
If the filetype of the buffer is associated with a language for which a
|treesitter| parser is installed, then |vim.filetype.get_option()| is called
to look up the value of 'commentstring' corresponding to the cursor position.

View File

@ -62,6 +62,7 @@ Defaults *nvim-defaults*
- 'isfname' does not include ":" (on Windows). Drive letters are handled
correctly without it. (Use |gF| for filepaths suffixed with ":line:col").
- 'joinspaces' is disabled
- 'jumpoptions' defaults to "clean"
- 'langnoremap' is enabled
- 'langremap' is disabled
- 'laststatus' defaults to 2 (statusline is always shown)
@ -326,6 +327,7 @@ string options work.
- 'inccommand' shows interactive results for |:substitute|-like commands
and |:command-preview| commands
- 'jumpoptions' "view" tries to restore the |mark-view| when moving through
"clean" removes unloaded buffer from the jumplist
- the |jumplist|, |changelist|, |alternate-file| or using |mark-motions|.
- 'laststatus' global statusline support
- 'mousescroll' amount to scroll by when scrolling with a mouse

View File

@ -53,11 +53,17 @@ active yes yes 'a'
hidden no yes 'h'
inactive no no ' '
Note: All CTRL-W commands can also be executed with |:wincmd|, for those
places where a Normal mode command can't be used or is inconvenient.
*buffer-reuse*
Each buffer has a unique number and the number will not change within a Vim
session. The |bufnr()| and |bufname()| functions can be used to convert
between a buffer name and the buffer number. There is one exception: if a new
empty buffer is created and it is not modified, the buffer will be re-used
when loading another file into that buffer. This also means the buffer number
will not change.
The main Vim window can hold several split windows. There are also tab pages
|tab-page|, each of which can hold multiple windows.
*window-ID* *winid* *windowid*
Each window has a unique identifier called the window ID. This identifier
will not change within a Vim session. The |win_getid()| and |win_id2tabwin()|
@ -69,9 +75,6 @@ across tabs. For most functions that take a window ID or a window number, the
window number only applies to the current tab, while the window ID can refer
to a window in any tab.
Each buffer has a unique number and the number will not change within a Vim
session. The |bufnr()| and |bufname()| functions can be used to convert
between a buffer name and the buffer number.
==============================================================================
2. Starting Vim *windows-starting*
@ -468,6 +471,10 @@ These commands can also be executed with ":wincmd":
:exe nr .. "wincmd w"
< This goes to window "nr".
Note: All CTRL-W commands can also be executed with |:wincmd|, for those
places where a Normal mode command can't be used or is inconvenient (e.g.
in a browser-based terminal).
==============================================================================
5. Moving windows around *window-moving*

View File

@ -13,8 +13,8 @@ vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, {
end
local ft, on_detect = vim.filetype.match({
-- The unexpanded file name is needed here. #27914
-- Neither args.file nor args.match are guaranteed to be unexpanded.
filename = vim.fn.bufname(args.buf),
-- However, bufname() can't be used, as it doesn't work with :doautocmd. #31306
filename = args.file,
buf = args.buf,
})
if not ft then

View File

@ -10,7 +10,8 @@ if exists("b:did_ftplugin")
endif
" Behaves mostly just like C
runtime! ftplugin/c.{vim,lua} ftplugin/c_*.{vim,lua} ftplugin/c/*.{vim,lua}
" XXX: "[.]" in the first pattern makes it a wildcard on Windows
runtime! ftplugin/c[.]{vim,lua} ftplugin/c_*.{vim,lua} ftplugin/c/*.{vim,lua}
" C++ uses templates with <things>
" Disabled, because it gives an error for typing an unmatched ">".

3
runtime/ftplugin/dot.lua Normal file
View File

@ -0,0 +1,3 @@
vim.bo.commentstring = '// %s'
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl commentstring<'

View File

@ -0,0 +1,3 @@
vim.bo.commentstring = '// %s'
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl commentstring<'

View File

@ -0,0 +1 @@
vim.bo.commentstring = '// %s'

View File

@ -0,0 +1,3 @@
vim.bo.commentstring = '// %s'
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl commentstring<'

View File

@ -0,0 +1,3 @@
vim.bo.commentstring = '// %s'
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl commentstring<'

View File

@ -0,0 +1,3 @@
vim.bo.commentstring = '// %s'
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | setl commentstring<'

View File

@ -470,7 +470,13 @@ local function put_page(page)
-- XXX: nroff justifies text by filling it with whitespace. That interacts
-- badly with our use of $MANWIDTH=999. Hack around this by using a fixed
-- size for those whitespace regions.
vim.cmd([[silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g]])
-- Use try/catch to avoid setting v:errmsg.
vim.cmd([[
try
keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g
catch
endtry
]])
vim.cmd('1') -- Move cursor to first line
highlight_man_page()
set_options()
@ -708,7 +714,7 @@ function M.open_page(count, smods, args)
end
sect, name = extract_sect_and_name_path(path)
local buf = fn.bufnr()
local buf = api.nvim_get_current_buf()
local save_tfu = vim.bo[buf].tagfunc
vim.bo[buf].tagfunc = "v:lua.require'man'.goto_tag"
@ -724,7 +730,9 @@ function M.open_page(count, smods, args)
end
end)
vim.bo[buf].tagfunc = save_tfu
if api.nvim_buf_is_valid(buf) then
vim.bo[buf].tagfunc = save_tfu
end
if not ok then
error(ret)

View File

@ -50,11 +50,11 @@ local function check_config()
local init_lua = vim.fn.stdpath('config') .. '/init.lua'
local init_vim = vim.fn.stdpath('config') .. '/init.vim'
local vimrc = vim.env.MYVIMRC and vim.fn.expand(vim.env.MYVIMRC) or init_lua
local vimrc = vim.env.MYVIMRC and vim.fs.normalize(vim.env.MYVIMRC) or init_lua
if vim.fn.filereadable(vimrc) == 0 and vim.fn.filereadable(init_vim) == 0 then
ok = false
local has_vim = vim.fn.filereadable(vim.fn.expand('~/.vimrc')) == 1
local has_vim = vim.fn.filereadable(vim.fs.normalize('~/.vimrc')) == 1
health.warn(
('%s user config file: %s'):format(
-1 == vim.fn.getfsize(vimrc) and 'Missing' or 'Unreadable',
@ -114,7 +114,7 @@ local function check_config()
)
shadafile = (
vim.o.shadafile == ''
and (shadafile == '' and vim.fn.stdpath('state') .. '/shada/main.shada' or vim.fn.expand(
and (shadafile == '' and vim.fn.stdpath('state') .. '/shada/main.shada' or vim.fs.normalize(
shadafile
))
or (vim.o.shadafile == 'NONE' and '' or vim.o.shadafile)

View File

@ -1,5 +1,5 @@
local health = vim.health
local iswin = vim.loop.os_uname().sysname == 'Windows_NT'
local iswin = vim.fn.has('win32') == 1
local M = {}
@ -7,7 +7,7 @@ local function is(path, ty)
if not path then
return false
end
local stat = vim.loop.fs_stat(path)
local stat = vim.uv.fs_stat(path)
if not stat then
return false
end
@ -36,7 +36,17 @@ local function check_for_pyenv()
local pyenv_root = vim.fn.resolve(os.getenv('PYENV_ROOT') or '')
if pyenv_root == '' then
pyenv_root = vim.fn.system({ pyenv_path, 'root' })
local p = vim.system({ pyenv_path, 'root' }):wait()
if p.code ~= 0 then
local message = string.format(
'pyenv: Failed to infer the root of pyenv by running `%s root` : %s. Ignoring pyenv for all following checks.',
pyenv_path,
p.stderr
)
health.warn(message)
return { '', '' }
end
pyenv_root = vim.trim(p.stdout)
health.info('pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.')
end
@ -77,12 +87,14 @@ local function download(url)
return out
end
elseif vim.fn.executable('python') == 1 then
local script = "try:\n\
from urllib.request import urlopen\n\
except ImportError:\n\
from urllib2 import urlopen\n\
response = urlopen('" .. url .. "')\n\
print(response.read().decode('utf8'))\n"
local script = ([[
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
response = urlopen('%s')
print(response.read().decode('utf8'))
]]):format(url)
local out, rc = health.system({ 'python', '-c', script })
if out == '' and rc ~= 0 then
return 'python urllib.request error: ' .. rc
@ -425,7 +437,7 @@ function M.check()
local venv_bins = vim.fn.glob(string.format('%s/%s/python*', virtual_env, bin_dir), true, true)
venv_bins = vim.tbl_filter(function(v)
-- XXX: Remove irrelevant executables found in bin/.
return not v:match('python%-config')
return not v:match('python.*%-config')
end, venv_bins)
if vim.tbl_count(venv_bins) > 0 then
for _, venv_bin in pairs(venv_bins) do

View File

@ -19,8 +19,7 @@ function M.check()
end
health.info('Ruby: ' .. health.system({ 'ruby', '-v' }))
local ruby_detect_table = vim.provider.ruby.detect()
local host = ruby_detect_table[1]
local host, _ = vim.provider.ruby.detect()
if (not host) or host:find('^%s*$') then
health.warn('`neovim-ruby-host` not found.', {
'Run `gem install neovim` to ensure the neovim RubyGem is installed.',

View File

@ -1,6 +1,6 @@
--- @brief
---<pre>help
---:TOhtml {file} *:TOhtml*
---:[range]TOhtml {file} *:TOhtml*
---Converts the buffer shown in the current window to HTML, opens the generated
---HTML in a new split window, and saves its contents to {file}. If {file} is not
---given, a temporary file (created by |tempname()|) is used.
@ -40,7 +40,8 @@
--- @field winid integer
--- @field bufnr integer
--- @field width integer
--- @field buflen integer
--- @field start integer
--- @field end_ integer
--- @class (private) vim.tohtml.styletable
--- @field [integer] vim.tohtml.line (integer: (1-index, exclusive))
@ -57,6 +58,26 @@
--- @field [3] any[][] virt_text
--- @field [4] any[][] overlay_text
--- @type string[]
local notifications = {}
---@param msg string
local function notify(msg)
if #notifications == 0 then
vim.schedule(function()
if #notifications > 1 then
vim.notify(
('TOhtml: %s (+ %d more warnings)'):format(notifications[1], tostring(#notifications - 1))
)
elseif #notifications == 1 then
vim.notify('TOhtml: ' .. notifications[1])
end
notifications = {}
end)
end
table.insert(notifications, msg)
end
local HIDE_ID = -1
-- stylua: ignore start
local cterm_8_to_hex={
@ -168,6 +189,8 @@ local background_color_cache = nil
--- @type string?
local foreground_color_cache = nil
local len = vim.api.nvim_strwidth
--- @see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
--- @param color "background"|"foreground"|integer
--- @return string?
@ -215,7 +238,7 @@ local function cterm_to_hex(colorstr)
if hex then
cterm_color_cache[color] = hex
else
vim.notify_once("Info(TOhtml): Couldn't get terminal colors, using fallback")
notify("Couldn't get terminal colors, using fallback")
local t_Co = tonumber(vim.api.nvim_eval('&t_Co'))
if t_Co <= 8 then
cterm_color_cache = cterm_8_to_hex
@ -241,7 +264,7 @@ local function get_background_color()
end
local hex = try_query_terminal_color('background')
if not hex or not hex:match('#%x%x%x%x%x%x') then
vim.notify_once("Info(TOhtml): Couldn't get terminal background colors, using fallback")
notify("Couldn't get terminal background colors, using fallback")
hex = vim.o.background == 'light' and '#ffffff' or '#000000'
end
background_color_cache = hex
@ -259,7 +282,7 @@ local function get_foreground_color()
end
local hex = try_query_terminal_color('foreground')
if not hex or not hex:match('#%x%x%x%x%x%x') then
vim.notify_once("Info(TOhtml): Couldn't get terminal foreground colors, using fallback")
notify("Couldn't get terminal foreground colors, using fallback")
hex = vim.o.background == 'light' and '#000000' or '#ffffff'
end
foreground_color_cache = hex
@ -292,9 +315,12 @@ local function style_line_insert_virt_text(style_line, col, val)
end
--- @param state vim.tohtml.state
--- @param hl string|integer|nil
--- @param hl string|integer|string[]|integer[]?
--- @return nil|integer
local function register_hl(state, hl)
if type(hl) == 'table' then
hl = hl[#hl]
end
if type(hl) == 'nil' then
return
elseif type(hl) == 'string' then
@ -370,7 +396,7 @@ end
--- @param state vim.tohtml.state
local function styletable_syntax(state)
for row = 1, state.buflen do
for row = state.start, state.end_ do
local prev_id = 0
local prev_col = nil
for col = 1, #vim.fn.getline(row) + 1 do
@ -390,7 +416,7 @@ end
--- @param state vim.tohtml.state
local function styletable_diff(state)
local styletable = state.style
for row = 1, state.buflen do
for row = state.start, state.end_ do
local style_line = styletable[row]
local filler = vim.fn.diff_filler(row)
if filler ~= 0 then
@ -400,7 +426,7 @@ local function styletable_diff(state)
{ { fill:rep(state.width), register_hl(state, 'DiffDelete') } }
)
end
if row == state.buflen + 1 then
if row == state.end_ + 1 then
break
end
local prev_id = 0
@ -442,7 +468,9 @@ local function styletable_treesitter(state)
if not query then
return
end
for capture, node, metadata in query:iter_captures(root, buf_highlighter.bufnr, 0, state.buflen) do
for capture, node, metadata in
query:iter_captures(root, buf_highlighter.bufnr, state.start - 1, state.end_)
do
local srow, scol, erow, ecol = node:range()
--- @diagnostic disable-next-line: invisible
local c = q._query.captures[capture]
@ -467,7 +495,7 @@ local function _styletable_extmarks_highlight(state, extmark, namespaces)
---TODO(altermo) LSP semantic tokens (and some other extmarks) are only
---generated in visible lines, and not in the whole buffer.
if (namespaces[extmark[4].ns_id] or ''):find('vim_lsp_semantic_tokens') then
vim.notify_once('Info(TOhtml): lsp semantic tokens are not supported, HTML may be incorrect')
notify('lsp semantic tokens are not supported, HTML may be incorrect')
return
end
local srow, scol, erow, ecol =
@ -481,17 +509,27 @@ end
--- @param state vim.tohtml.state
--- @param extmark {[1]:integer,[2]:integer,[3]:integer,[4]:vim.api.keyset.set_extmark|any}
local function _styletable_extmarks_virt_text(state, extmark)
--- @param namespaces table<integer,string>
local function _styletable_extmarks_virt_text(state, extmark, namespaces)
if not extmark[4].virt_text then
return
end
---TODO(altermo) LSP semantic tokens (and some other extmarks) are only
---generated in visible lines, and not in the whole buffer.
if (namespaces[extmark[4].ns_id] or ''):find('vim_lsp_inlayhint') then
notify('lsp inlay hints are not supported, HTML may be incorrect')
return
end
local styletable = state.style
--- @type integer,integer
local row, col = extmark[2], extmark[3]
if
extmark[4].virt_text_pos == 'inline'
or extmark[4].virt_text_pos == 'eol'
or extmark[4].virt_text_pos == 'overlay'
row < vim.api.nvim_buf_line_count(state.bufnr)
and (
extmark[4].virt_text_pos == 'inline'
or extmark[4].virt_text_pos == 'eol'
or extmark[4].virt_text_pos == 'overlay'
)
then
if extmark[4].virt_text_pos == 'eol' then
style_line_insert_virt_text(styletable[row + 1], #vim.fn.getline(row + 1) + 1, { ' ' })
@ -510,7 +548,7 @@ local function _styletable_extmarks_virt_text(state, extmark)
else
style_line_insert_virt_text(styletable[row + 1], col + 1, { i[1], hlid })
end
virt_text_len = virt_text_len + #i[1]
virt_text_len = virt_text_len + len(i[1])
end
if extmark[4].virt_text_pos == 'overlay' then
styletable_insert_range(state, row + 1, col + 1, row + 1, col + virt_text_len + 1, HIDE_ID)
@ -521,11 +559,9 @@ local function _styletable_extmarks_virt_text(state, extmark)
hl_mode = 'blend',
hl_group = 'combine',
}
for opt, val in ipairs(not_supported) do
for opt, val in pairs(not_supported) do
if extmark[4][opt] == val then
vim.notify_once(
('Info(TOhtml): extmark.%s="%s" is not supported, HTML may be incorrect'):format(opt, val)
)
notify(('extmark.%s="%s" is not supported, HTML may be incorrect'):format(opt, val))
end
end
end
@ -586,7 +622,7 @@ local function styletable_extmarks(state)
_styletable_extmarks_conceal(state, v)
end
for _, v in ipairs(extmarks) do
_styletable_extmarks_virt_text(state, v)
_styletable_extmarks_virt_text(state, v, namespaces)
end
for _, v in ipairs(extmarks) do
_styletable_extmarks_virt_lines(state, v)
@ -597,7 +633,7 @@ end
local function styletable_folds(state)
local styletable = state.style
local has_folded = false
for row = 1, state.buflen do
for row = state.start, state.end_ do
if vim.fn.foldclosed(row) > 0 then
has_folded = true
styletable[row].hide = true
@ -611,9 +647,7 @@ local function styletable_folds(state)
end
end
if has_folded and type(({ pcall(vim.api.nvim_eval, vim.o.foldtext) })[2]) == 'table' then
vim.notify_once(
'Info(TOhtml): foldtext returning a table is half supported, HTML may be incorrect'
)
notify('foldtext returning a table with highlights is not supported, HTML may be incorrect')
end
end
@ -621,7 +655,7 @@ end
local function styletable_conceal(state)
local bufnr = state.bufnr
vim.api.nvim_buf_call(bufnr, function()
for row = 1, state.buflen do
for row = state.start, state.end_ do
--- @type table<integer,{[1]:integer,[2]:integer,[3]:string}>
local conceals = {}
local line_len_exclusive = #vim.fn.getline(row) + 1
@ -739,7 +773,7 @@ local function styletable_statuscolumn(state)
local max = tonumber(foldcolumn:match('^%w-:(%d)')) or 1
local maxfold = 0
vim.api.nvim_buf_call(state.bufnr, function()
for row = 1, vim.api.nvim_buf_line_count(state.bufnr) do
for row = state.start, state.end_ do
local foldlevel = vim.fn.foldlevel(row)
if foldlevel > maxfold then
maxfold = foldlevel
@ -754,12 +788,12 @@ local function styletable_statuscolumn(state)
--- @type table<integer,any>
local statuses = {}
for row = 1, state.buflen do
for row = state.start, state.end_ do
local status = vim.api.nvim_eval_statusline(
statuscolumn,
{ winid = state.winid, use_statuscol_lnum = row, highlights = true }
)
local width = vim.api.nvim_strwidth(status.str)
local width = len(status.str)
if width > minwidth then
minwidth = width
end
@ -774,7 +808,7 @@ local function styletable_statuscolumn(state)
for k, v in ipairs(hls) do
local text = str:sub(v.start + 1, hls[k + 1] and hls[k + 1].start or nil)
if k == #hls then
text = text .. (' '):rep(minwidth - vim.api.nvim_strwidth(str))
text = text .. (' '):rep(minwidth - len(str))
end
if text ~= '' then
local hlid = register_hl(state, v.group)
@ -794,7 +828,6 @@ local function styletable_listchars(state)
local function utf8_sub(str, i, j)
return vim.fn.strcharpart(str, i - 1, j and j - i + 1 or nil)
end
local len = vim.api.nvim_strwidth
--- @type table<string,string>
local listchars = vim.opt_local.listchars:get()
local ids = setmetatable({}, {
@ -805,7 +838,7 @@ local function styletable_listchars(state)
})
if listchars.eol then
for row = 1, state.buflen do
for row = state.start, state.end_ do
local style_line = state.style[row]
style_line_insert_overlay_char(
style_line,
@ -1099,16 +1132,22 @@ end
local function extend_pre(out, state)
local styletable = state.style
table.insert(out, '<pre>')
local out_start = #out
local hide_count = 0
--- @type integer[]
local stack = {}
local before = ''
local after = ''
local function loop(row)
local inside = row <= state.end_ and row >= state.start
local style_line = styletable[row]
if style_line.hide and (styletable[row - 1] or {}).hide then
return
end
_extend_virt_lines(out, state, row)
if inside then
_extend_virt_lines(out, state, row)
end
--Possible improvement (altermo):
--Instead of looping over all the buffer characters per line,
--why not loop over all the style_line cells,
@ -1118,8 +1157,16 @@ local function extend_pre(out, state)
end
local line = vim.api.nvim_buf_get_lines(state.bufnr, row - 1, row, false)[1] or ''
local s = ''
s = s .. _pre_text_to_html(state, row)
for col = 1, #line + 1 do
if inside then
s = s .. _pre_text_to_html(state, row)
end
local true_line_len = #line + 1
for k in pairs(style_line) do
if type(k) == 'number' and k > true_line_len then
true_line_len = k
end
end
for col = 1, true_line_len do
local cell = style_line[col]
--- @type table?
local char
@ -1159,18 +1206,18 @@ local function extend_pre(out, state)
end
end
if cell[3] then
if cell[3] and inside then
s = s .. _virt_text_to_html(state, cell)
end
char = cell[4][#cell[4]]
end
if col == #line + 1 and not char then
if col == true_line_len and not char then
break
end
if hide_count == 0 then
if hide_count == 0 and inside then
s = s
.. _char_to_html(
state,
@ -1179,12 +1226,20 @@ local function extend_pre(out, state)
)
end
end
table.insert(out, s)
if row > state.end_ + 1 then
after = after .. s
elseif row < state.start then
before = s .. before
else
table.insert(out, s)
end
end
for row = 1, state.buflen + 1 do
for row = 1, vim.api.nvim_buf_line_count(state.bufnr) + 1 do
loop(row)
end
out[out_start] = out[out_start] .. before
out[#out] = out[#out] .. after
assert(#stack == 0, 'an open HTML tag was never closed')
table.insert(out, '</pre>')
end
@ -1216,6 +1271,7 @@ local function global_state_to_state(winid, global_state)
if not width or width < 1 then
width = vim.api.nvim_win_get_width(winid)
end
local range = opt.range or { 1, vim.api.nvim_buf_line_count(bufnr) }
local state = setmetatable({
winid = winid == 0 and vim.api.nvim_get_current_win() or winid,
opt = vim.wo[winid],
@ -1223,7 +1279,8 @@ local function global_state_to_state(winid, global_state)
bufnr = bufnr,
tabstop = (' '):rep(vim.bo[bufnr].tabstop),
width = width,
buflen = vim.api.nvim_buf_line_count(bufnr),
start = range[1],
end_ = range[2],
}, { __index = global_state })
return state --[[@as vim.tohtml.state]]
end
@ -1282,35 +1339,22 @@ local function state_generate_style(state)
end)
end
--- @param winid integer[]|integer
--- @param winid integer
--- @param opt? vim.tohtml.opt
--- @return string[]
local function win_to_html(winid, opt)
if type(winid) == 'number' then
winid = { winid }
end
--- @cast winid integer[]
assert(#winid > 0, 'no window specified')
opt = opt or {}
local title = table.concat(
vim.tbl_map(vim.api.nvim_buf_get_name, vim.tbl_map(vim.api.nvim_win_get_buf, winid)),
','
)
local title = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(winid))
local global_state = opt_to_global_state(opt, title)
--- @type vim.tohtml.state[]
local states = {}
for _, i in ipairs(winid) do
local state = global_state_to_state(i, global_state)
state_generate_style(state)
table.insert(states, state)
end
local state = global_state_to_state(winid, global_state)
state_generate_style(state)
local html = {}
extend_html(html, function()
extend_head(html, global_state)
extend_body(html, function()
for _, state in ipairs(states) do
extend_pre(html, state)
end
extend_pre(html, state)
end)
end)
return html
@ -1337,6 +1381,10 @@ local M = {}
--- infinitely.
--- (default: 'textwidth' if non-zero or window width otherwise)
--- @field width? integer
---
--- Range of rows to use.
--- (default: entire buffer)
--- @field range? integer[]
--- Converts the buffer shown in the window {winid} to HTML and returns the output as a list of string.
--- @param winid? integer Window to convert (defaults to current window)

View File

@ -77,14 +77,11 @@ local function make_comment_check(parts)
local l_esc, r_esc = vim.pesc(parts.left), vim.pesc(parts.right)
-- Commented line has the following structure:
-- <possible whitespace> <left> <anything> <right> <possible whitespace>
local nonblank_regex = '^%s-' .. l_esc .. '.*' .. r_esc .. '%s-$'
-- Commented blank line can have any amount of whitespace around parts
local blank_regex = '^%s-' .. vim.trim(l_esc) .. '%s*' .. vim.trim(r_esc) .. '%s-$'
-- <whitespace> <trimmed left> <anything> <trimmed right> <whitespace>
local regex = '^%s-' .. vim.trim(l_esc) .. '.*' .. vim.trim(r_esc) .. '%s-$'
return function(line)
return line:find(nonblank_regex) ~= nil or line:find(blank_regex) ~= nil
return line:find(regex) ~= nil
end
end
@ -153,14 +150,14 @@ end
---@return fun(line: string): string
local function make_uncomment_function(parts)
local l_esc, r_esc = vim.pesc(parts.left), vim.pesc(parts.right)
local nonblank_regex = '^(%s*)' .. l_esc .. '(.*)' .. r_esc .. '(%s-)$'
local blank_regex = '^(%s*)' .. vim.trim(l_esc) .. '(%s*)' .. vim.trim(r_esc) .. '(%s-)$'
local regex = '^(%s*)' .. l_esc .. '(.*)' .. r_esc .. '(%s-)$'
local regex_trimmed = '^(%s*)' .. vim.trim(l_esc) .. '(.*)' .. vim.trim(r_esc) .. '(%s-)$'
return function(line)
-- Try both non-blank and blank regexes
local indent, new_line, trail = line:match(nonblank_regex)
-- Try regex with exact comment parts first, fall back to trimmed parts
local indent, new_line, trail = line:match(regex)
if new_line == nil then
indent, new_line, trail = line:match(blank_regex)
indent, new_line, trail = line:match(regex_trimmed)
end
-- Return original if line is not commented

View File

@ -49,10 +49,10 @@ do
vim.keymap.set('x', '*', function()
return _visual_search('/')
end, { desc = ':help v_star-default', expr = true, silent = true })
end, { desc = ':help v_star-default', expr = true, replace_keycodes = false })
vim.keymap.set('x', '#', function()
return _visual_search('?')
end, { desc = ':help v_#-default', expr = true, silent = true })
end, { desc = ':help v_#-default', expr = true, replace_keycodes = false })
end
--- Map Y to y$. This mimics the behavior of D and C. See |Y-default|
@ -85,13 +85,13 @@ do
vim.keymap.set(
'x',
'Q',
"mode() == 'V' ? ':normal! @<C-R>=reg_recorded()<CR><CR>' : 'Q'",
"mode() ==# 'V' ? ':normal! @<C-R>=reg_recorded()<CR><CR>' : 'Q'",
{ silent = true, expr = true, desc = ':help v_Q-default' }
)
vim.keymap.set(
'x',
'@',
"mode() == 'V' ? ':normal! @'.getcharstr().'<CR>' : '@'",
"mode() ==# 'V' ? ':normal! @'.getcharstr().'<CR>' : '@'",
{ silent = true, expr = true, desc = ':help v_@-default' }
)
@ -266,7 +266,10 @@ do
return
end
vim.v.swapchoice = 'e' -- Choose "(E)dit".
vim.notify(('W325: Ignoring swapfile from Nvim process %d'):format(info.pid))
vim.notify(
('W325: Ignoring swapfile from Nvim process %d'):format(info.pid),
vim.log.levels.WARN
)
end,
})
@ -431,10 +434,14 @@ do
--- response indicates that it does support truecolor enable 'termguicolors',
--- but only if the user has not already disabled it.
do
if tty.rgb then
-- The TUI was able to determine truecolor support
local colorterm = os.getenv('COLORTERM')
if tty.rgb or colorterm == 'truecolor' or colorterm == '24bit' then
-- The TUI was able to determine truecolor support or $COLORTERM explicitly indicates
-- truecolor support
setoption('termguicolors', true)
else
elseif colorterm == nil or colorterm == '' then
-- Neither the TUI nor $COLORTERM indicate that truecolor is supported, so query the
-- terminal
local caps = {} ---@type table<string, boolean>
require('vim.termcap').query({ 'Tc', 'RGB', 'setrgbf', 'setrgbb' }, function(cap, found)
if not found then

View File

@ -656,15 +656,18 @@ local on_key_cbs = {} --- @type table<integer,function>
---@note {fn} will be removed on error.
---@note {fn} will not be cleared by |nvim_buf_clear_namespace()|
---
---@param fn fun(key: string, typed: string)?
--- Function invoked on every key press. |i_CTRL-V|
--- {key} is the key after mappings have been applied, and
--- {typed} is the key(s) before mappings are applied, which
--- may be empty if {key} is produced by non-typed keys.
--- When {fn} is nil and {ns_id} is specified, the callback
--- associated with namespace {ns_id} is removed.
---@param fn fun(key: string, typed: string)? Function invoked for every input key,
--- after mappings have been applied but before further processing. Arguments
--- {key} and {typed} are raw keycodes, where {key} is the key after mappings
--- are applied, and {typed} is the key(s) before mappings are applied.
--- {typed} may be empty if {key} is produced by non-typed key(s) or by the
--- same typed key(s) that produced a previous {key}.
--- When {fn} is `nil` and {ns_id} is specified, the callback associated with
--- namespace {ns_id} is removed.
---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a
--- new |nvim_create_namespace()| id.
--- new |nvim_create_namespace()| id.
---
---@see |keytrans()|
---
---@return integer Namespace id associated with {fn}. Or count of all callbacks
---if on_key() is called without arguments.

View File

@ -169,7 +169,7 @@ function vim.show_pos(bufnr, row, col, filter)
if data.hl_group ~= data.hl_group_link then
append('links to ', 'MoreMsg')
append(data.hl_group_link, data.hl_group_link)
append(' ')
append(' ')
end
if comment then
append(comment, 'Comment')
@ -182,7 +182,14 @@ function vim.show_pos(bufnr, row, col, filter)
append('Treesitter', 'Title')
nl()
for _, capture in ipairs(items.treesitter) do
item(capture, capture.lang)
item(
capture,
string.format(
'priority: %d language: %s',
capture.metadata.priority or vim.highlight.priorities.treesitter,
capture.lang
)
)
end
nl()
end

View File

@ -956,9 +956,9 @@ function vim.api.nvim_create_augroup(name, opts) end
--- • event: (string) name of the triggered event
--- `autocmd-events`
--- • group: (number|nil) autocommand group id, if any
--- • match: (string) expanded value of <amatch>
--- • buf: (number) expanded value of <abuf>
--- • file: (string) expanded value of <afile>
--- • file: (string) <afile> (not expanded to a full path)
--- • match: (string) <amatch> (expanded to a full path)
--- • buf: (number) <abuf>
--- • data: (any) arbitrary data passed from
--- `nvim_exec_autocmds()` *event-data*
--- • command (string) optional: Vim command to execute on event.
@ -1921,7 +1921,7 @@ function vim.api.nvim_set_current_win(window) end
--- Note: this function should not be called often. Rather, the callbacks
--- themselves can be used to throttle unneeded callbacks. the `on_start`
--- callback can return `false` to disable the provider until the next redraw.
--- Similarly, return `false` in `on_win` will skip the `on_lines` calls for
--- Similarly, return `false` in `on_win` will skip the `on_line` calls for
--- that window (but any extmarks set in `on_win` will still be used). A
--- plugin managing multiple sources of decoration should ideally only set one
--- provider, and merge the sources internally. You can use multiple `ns_id`
@ -1930,10 +1930,10 @@ function vim.api.nvim_set_current_win(window) end
--- Note: doing anything other than setting extmarks is considered
--- experimental. Doing things like changing options are not explicitly
--- forbidden, but is likely to have unexpected consequences (such as 100% CPU
--- consumption). doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is
--- consumption). Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is
--- quite dubious for the moment.
---
--- Note: It is not allowed to remove or update extmarks in 'on_line'
--- Note: It is not allowed to remove or update extmarks in `on_line`
--- callbacks.
---
--- @param ns_id integer Namespace id from `nvim_create_namespace()`

View File

@ -11,19 +11,19 @@
--- - `count_a` (`integer`): Hunk size in {a}.
--- - `start_b` (`integer`): Start line of hunk in {b}.
--- - `count_b` (`integer`): Hunk size in {b}.
--- @field on_hunk fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer
--- @field on_hunk? fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer
---
--- Form of the returned diff:
--- - `unified`: String in unified format.
--- - `indices`: Array of hunk locations.
--- Note: This option is ignored if `on_hunk` is used.
--- (default: `'unified'`)
--- @field result_type 'unified'|'indices'
--- @field result_type? 'unified'|'indices'
---
--- Run linematch on the resulting hunks from xdiff. When integer, only hunks
--- upto this size in lines are run through linematch.
--- Requires `result_type = indices`, ignored otherwise.
--- @field linematch boolean|integer
--- @field linematch? boolean|integer
---
--- Diff algorithm to use. Values:
--- - `myers`: the default algorithm
@ -31,15 +31,15 @@
--- - `patience`: patience diff algorithm
--- - `histogram`: histogram diff algorithm
--- (default: `'myers'`)
--- @field algorithm 'myers'|'minimal'|'patience'|'histogram'
--- @field ctxlen integer Context length
--- @field interhunkctxlen integer Inter hunk context length
--- @field ignore_whitespace boolean Ignore whitespace
--- @field ignore_whitespace_change boolean Ignore whitespace change
--- @field ignore_whitespace_change_at_eol boolean Ignore whitespace change at end-of-line.
--- @field ignore_cr_at_eol boolean Ignore carriage return at end-of-line
--- @field ignore_blank_lines boolean Ignore blank lines
--- @field indent_heuristic boolean Use the indent heuristic for the internal diff library.
--- @field algorithm? 'myers'|'minimal'|'patience'|'histogram'
--- @field ctxlen? integer Context length
--- @field interhunkctxlen? integer Inter hunk context length
--- @field ignore_whitespace? boolean Ignore whitespace
--- @field ignore_whitespace_change? boolean Ignore whitespace change
--- @field ignore_whitespace_change_at_eol? boolean Ignore whitespace change at end-of-line.
--- @field ignore_cr_at_eol? boolean Ignore carriage return at end-of-line
--- @field ignore_blank_lines? boolean Ignore blank lines
--- @field indent_heuristic? boolean Use the indent heuristic for the internal diff library.
-- luacheck: no unused args
@ -65,7 +65,7 @@
---
---@param a string First string to compare
---@param b string Second string to compare
---@param opts vim.diff.Opts
---@param opts? vim.diff.Opts
---@return string|integer[][]?
--- See {opts.result_type}. `nil` if {opts.on_hunk} is given.
function vim.diff(a, b, opts) end

View File

@ -2,7 +2,7 @@
error('Cannot require a meta file')
-- These types were taken from https://github.com/LuaCATS/lpeg
-- (based on revision e6789e28e5b91a4a277a2a03081d708c403a3e34)
-- (based on revision 33f4ff5343a64cf613a0634d70092fbc2b64291b)
-- with types being renamed to include the vim namespace and with some descriptions made less verbose.
--- @brief <pre>help
@ -22,17 +22,18 @@ vim.lpeg = {}
--- @nodoc
--- @class vim.lpeg.Pattern
--- @operator len: vim.lpeg.Pattern
--- @operator unm: vim.lpeg.Pattern
--- @operator add(vim.lpeg.Pattern): vim.lpeg.Pattern
--- @operator sub(vim.lpeg.Pattern): vim.lpeg.Pattern
--- @operator mul(vim.lpeg.Pattern): vim.lpeg.Pattern
--- @operator mul(vim.lpeg.Capture): vim.lpeg.Pattern
--- @operator div(string): vim.lpeg.Capture
--- @operator div(number): vim.lpeg.Capture
--- @operator div(integer): vim.lpeg.Capture
--- @operator div(table): vim.lpeg.Capture
--- @operator div(function): vim.lpeg.Capture
--- @operator pow(number): vim.lpeg.Pattern
--- @operator mod(function): nil
--- @operator pow(integer): vim.lpeg.Pattern
--- @operator mod(function): vim.lpeg.Capture
local Pattern = {}
--- @alias vim.lpeg.Capture vim.lpeg.Pattern
@ -55,11 +56,12 @@ local Pattern = {}
--- assert(pattern:match('1 hello') == nil)
--- ```
---
--- @param pattern vim.lpeg.Pattern
--- @param pattern vim.lpeg.Pattern|string|integer|boolean|table|function
--- @param subject string
--- @param init? integer
--- @return integer|vim.lpeg.Capture|nil
function vim.lpeg.match(pattern, subject, init) end
--- @param ... any
--- @return any ...
function vim.lpeg.match(pattern, subject, init, ...) end
--- Matches the given `pattern` against the `subject` string. If the match succeeds, returns the
--- index in the subject of the first character after the match, or the captured values (if the
@ -81,8 +83,9 @@ function vim.lpeg.match(pattern, subject, init) end
---
--- @param subject string
--- @param init? integer
--- @return integer|vim.lpeg.Capture|nil
function Pattern:match(subject, init) end
--- @param ... any
--- @return any ...
function Pattern:match(subject, init, ...) end
--- Returns the string `"pattern"` if the given value is a pattern, otherwise `nil`.
---
@ -123,7 +126,7 @@ function vim.lpeg.P(value) end
--- Pattern `patt` must match only strings with some fixed length, and it cannot contain captures.
--- Like the `and` predicate, this pattern never consumes any input, independently of success or failure.
---
--- @param pattern vim.lpeg.Pattern
--- @param pattern vim.lpeg.Pattern|string|integer|boolean|table
--- @return vim.lpeg.Pattern
function vim.lpeg.B(pattern) end
@ -163,7 +166,7 @@ function vim.lpeg.S(string) end
--- assert(b:match('(') == nil)
--- ```
---
--- @param v string|integer
--- @param v boolean|string|number|function|table|thread|userdata|lightuserdata
--- @return vim.lpeg.Pattern
function vim.lpeg.V(v) end
@ -227,7 +230,7 @@ function vim.lpeg.locale(tab) end
--- assert(c == 'c')
--- ```
---
--- @param patt vim.lpeg.Pattern
--- @param patt vim.lpeg.Pattern|string|integer|boolean|table|function
--- @return vim.lpeg.Capture
function vim.lpeg.C(patt) end
@ -258,7 +261,7 @@ function vim.lpeg.Cc(...) end
--- `func(...func(func(C1, C2), C3)...,Cn)`, that is, it will fold (or accumulate, or reduce) the captures from
--- `patt` using function `func`. This capture assumes that `patt` should produce at least one capture with at
--- least one value (of any type), which becomes the initial value of an accumulator. (If you need a specific
--- initial value, you may prefix a constant captureto `patt`.) For each subsequent capture, LPeg calls `func`
--- initial value, you may prefix a constant capture to `patt`.) For each subsequent capture, LPeg calls `func`
--- with this accumulator as the first argument and all values produced by the capture as extra arguments;
--- the first result from this call becomes the new value for the accumulator. The final value of the accumulator
--- becomes the captured value.
@ -273,7 +276,7 @@ function vim.lpeg.Cc(...) end
--- assert(sum:match('10,30,43') == 83)
--- ```
---
--- @param patt vim.lpeg.Pattern
--- @param patt vim.lpeg.Pattern|string|integer|boolean|table|function
--- @param func fun(acc, newvalue)
--- @return vim.lpeg.Capture
function vim.lpeg.Cf(patt, func) end
@ -282,7 +285,7 @@ function vim.lpeg.Cf(patt, func) end
--- The group may be anonymous (if no name is given) or named with the given name (which
--- can be any non-nil Lua value).
---
--- @param patt vim.lpeg.Pattern
--- @param patt vim.lpeg.Pattern|string|integer|boolean|table|function
--- @param name? string
--- @return vim.lpeg.Capture
function vim.lpeg.Cg(patt, name) end
@ -320,7 +323,7 @@ function vim.lpeg.Cp() end
--- assert(gsub('Hello, xxx!', 'xxx', 'World') == 'Hello, World!')
--- ```
---
--- @param patt vim.lpeg.Pattern
--- @param patt vim.lpeg.Pattern|string|integer|boolean|table|function
--- @return vim.lpeg.Capture
function vim.lpeg.Cs(patt) end
@ -329,7 +332,7 @@ function vim.lpeg.Cs(patt) end
--- Moreover, for each named capture group created by `patt`, the first value of the group is put into
--- the table with the group name as its key. The captured value is only the table.
---
--- @param patt vim.lpeg.Pattern|''
--- @param patt vim.lpeg.Pattern|string|integer|boolean|table|function
--- @return vim.lpeg.Capture
function vim.lpeg.Ct(patt) end
@ -343,7 +346,7 @@ function vim.lpeg.Ct(patt) end
--- (so, to return true is equivalent to return `i`). If the call returns `false`, `nil`, or no value, the match fails.
--- Any extra values returned by the function become the values produced by the capture.
---
--- @param patt vim.lpeg.Pattern
--- @param fn function
--- @param patt vim.lpeg.Pattern|string|integer|boolean|table|function
--- @param fn fun(s: string, i: integer, ...: any): (position: boolean|integer, ...: any)
--- @return vim.lpeg.Capture
function vim.lpeg.Cmt(patt, fn) end

View File

@ -544,7 +544,7 @@ vim.wo.bri = vim.wo.breakindent
--- applying 'breakindent', even if the resulting
--- text should normally be narrower. This prevents
--- text indented almost to the right window border
--- occupying lot of vertical space when broken.
--- occupying lots of vertical space when broken.
--- (default: 20)
--- shift:{n} After applying 'breakindent', the wrapped line's
--- beginning will be shifted by the given number of
@ -3330,7 +3330,7 @@ vim.go.is = vim.go.incsearch
--- in Insert mode as specified with the 'indentkeys' option.
--- When this option is not empty, it overrules the 'cindent' and
--- 'smartindent' indenting. When 'lisp' is set, this option is
--- is only used when 'lispoptions' contains "expr:1".
--- only used when 'lispoptions' contains "expr:1".
--- The expression is evaluated with `v:lnum` set to the line number for
--- which the indent is to be computed. The cursor is also in this line
--- when the expression is evaluated (but it may be moved around).
@ -3541,8 +3541,11 @@ vim.go.js = vim.go.joinspaces
--- |alternate-file` or using `mark-motions` try to
--- restore the `mark-view` in which the action occurred.
---
--- clean Remove unloaded buffers from the jumplist.
--- EXPERIMENTAL: this flag may change in the future.
---
--- @type string
vim.o.jumpoptions = ""
vim.o.jumpoptions = "clean"
vim.o.jop = vim.o.jumpoptions
vim.go.jumpoptions = vim.o.jumpoptions
vim.go.jop = vim.go.jumpoptions
@ -3628,7 +3631,7 @@ vim.go.kp = vim.go.keywordprg
--- part can be in one of two forms:
--- 1. A list of pairs. Each pair is a "from" character immediately
--- followed by the "to" character. Examples: "aA", "aAbBcC".
--- 2. A list of "from" characters, a semi-colon and a list of "to"
--- 2. A list of "from" characters, a semicolon and a list of "to"
--- characters. Example: "abc;ABC"
--- Example: "aA,fgh;FGH,cCdDeE"
--- Special characters need to be preceded with a backslash. These are
@ -3720,7 +3723,7 @@ vim.go.ls = vim.go.laststatus
--- update use `:redraw`.
--- This may occasionally cause display errors. It is only meant to be set
--- temporarily when performing an operation where redrawing may cause
--- flickering or cause a slow down.
--- flickering or cause a slowdown.
---
--- @type boolean
vim.o.lazyredraw = false
@ -3820,6 +3823,9 @@ vim.go.lw = vim.go.lispwords
--- between tabs and spaces and for trailing blanks. Further changed by
--- the 'listchars' option.
---
--- When 'listchars' does not contain "tab" field, tabs are shown as "^I"
--- or "<09>", like how unprintable characters are displayed.
---
--- The cursor is displayed at the start of the space a Tab character
--- occupies, not at the end as usual in Normal mode. To get this cursor
--- position while displaying Tabs with spaces, use:
@ -4757,7 +4763,7 @@ vim.go.pm = vim.go.patchmode
--- ```
--- To use an environment variable, you probably need to replace the
--- separator. Here is an example to append $INCL, in which directory
--- names are separated with a semi-colon:
--- names are separated with a semicolon:
---
--- ```vim
--- let &path = &path .. "," .. substitute($INCL, ';', ',', 'g')
@ -5764,7 +5770,7 @@ vim.bo.shiftwidth = vim.o.shiftwidth
vim.bo.sw = vim.bo.shiftwidth
--- This option helps to avoid all the `hit-enter` prompts caused by file
--- messages, for example with CTRL-G, and to avoid some other messages.
--- messages, for example with CTRL-G, and to avoid some other messages.
--- It is a list of flags:
--- flag meaning when present ~
--- l use "999L, 888B" instead of "999 lines, 888 bytes" *shm-l*
@ -6249,7 +6255,7 @@ vim.bo.spo = vim.bo.spelloptions
--- minus two.
---
--- timeout:{millisec} Limit the time searching for suggestions to
--- {millisec} milli seconds. Applies to the following
--- {millisec} milliseconds. Applies to the following
--- methods. When omitted the limit is 5000. When
--- negative there is no limit.
---

View File

@ -2823,7 +2823,7 @@ function vim.fn.getcharpos(expr) end
--- nnoremap <expr> , getcharsearch().forward ? ',' : ';'
--- <Also see |setcharsearch()|.
---
--- @return table[]
--- @return table
function vim.fn.getcharsearch() end
--- Get a single character from the user or input stream as a
@ -3569,8 +3569,8 @@ function vim.fn.getreginfo(regname) end
--- difference if the buffer is displayed in a window with
--- different 'virtualedit' or 'list' values.
---
--- Examples: >
--- :xnoremap <CR>
--- Examples: >vim
--- xnoremap <CR>
--- \ <Cmd>echom getregion(
--- \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
--- <
@ -4233,7 +4233,7 @@ function vim.fn.iconv(string, from, to) end
--- Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
--- `v:_null_blob` have the same `id()` with different types
--- because they are internally represented as NULL pointers.
--- `id()` returns a hexadecimal representanion of the pointers to
--- `id()` returns a hexadecimal representation of the pointers to
--- the containers (i.e. like `0x994a40`), same as `printf("%p",
--- {expr})`, but it is advised against counting on the exact
--- format of the return value.
@ -5538,19 +5538,19 @@ function vim.fn.matcharg(nr) end
---
--- Examples: >vim
--- " Assuming line 3 in buffer 5 contains "a"
--- :echo matchbufline(5, '\<\k\+\>', 3, 3)
--- [{'lnum': 3, 'byteidx': 0, 'text': 'a'}]
--- echo matchbufline(5, '\<\k\+\>', 3, 3)
--- < `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
--- " Assuming line 4 in buffer 10 contains "tik tok"
--- :echo matchbufline(10, '\<\k\+\>', 1, 4)
--- [{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]
--- <
--- echo matchbufline(10, '\<\k\+\>', 1, 4)
--- < `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
---
--- If {submatch} is present and is v:true, then submatches like
--- "\1", "\2", etc. are also returned. Example: >vim
--- " Assuming line 2 in buffer 2 contains "acd"
--- :echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
--- echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
--- \ {'submatches': v:true})
--- [{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]
--- <The "submatches" List always contains 9 items. If a submatch
--- < `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
--- The "submatches" List always contains 9 items. If a submatch
--- is not found, then an empty string is returned for that
--- submatch.
---
@ -5749,17 +5749,17 @@ function vim.fn.matchstr(expr, pat, start, count) end
--- option settings on the pattern.
---
--- Example: >vim
--- :echo matchstrlist(['tik tok'], '\<\k\+\>')
--- [{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]
--- :echo matchstrlist(['a', 'b'], '\<\k\+\>')
--- [{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]
--- <
--- echo matchstrlist(['tik tok'], '\<\k\+\>')
--- < `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
--- echo matchstrlist(['a', 'b'], '\<\k\+\>')
--- < `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
---
--- If "submatches" is present and is v:true, then submatches like
--- "\1", "\2", etc. are also returned. Example: >vim
--- :echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
--- echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
--- \ #{submatches: v:true})
--- [{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]
--- <The "submatches" List always contains 9 items. If a submatch
--- < `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
--- The "submatches" List always contains 9 items. If a submatch
--- is not found, then an empty string is returned for that
--- submatch.
---
@ -7199,7 +7199,7 @@ function vim.fn.screenchars(row, col) end
--- the following mappings: >vim
--- nnoremap <expr> GG ":echom " .. screencol() .. "\n"
--- nnoremap <silent> GG :echom screencol()<CR>
--- noremap GG <Cmd>echom screencol()<Cr>
--- noremap GG <Cmd>echom screencol()<CR>
--- <
---
--- @return any

View File

@ -276,11 +276,9 @@ vim.go = setmetatable({}, {
})
--- Get or set buffer-scoped |options| for the buffer with number {bufnr}.
--- If {bufnr} is omitted then the current buffer is used.
--- Like `:setlocal`. If {bufnr} is omitted then the current buffer is used.
--- Invalid {bufnr} or key is an error.
---
--- Note: this is equivalent to `:setlocal` for |global-local| options and `:set` otherwise.
---
--- Example:
---
--- ```lua

View File

@ -88,7 +88,8 @@ function SystemObj:_timeout(signal)
self:kill(signal or SIG.TERM)
end
local MAX_TIMEOUT = 2 ^ 31
-- Use max 32-bit signed int value to avoid overflow on 32-bit systems. #31633
local MAX_TIMEOUT = 2 ^ 31 - 1
--- @param timeout? integer
--- @return vim.SystemCompleted

View File

@ -1239,6 +1239,10 @@ M.handlers.signs = {
bufnr = get_bufnr(bufnr)
opts = opts or {}
if not api.nvim_buf_is_loaded(bufnr) then
return
end
if opts.signs and opts.signs.severity then
diagnostics = filter_by_severity(opts.signs.severity, diagnostics)
end
@ -1323,8 +1327,10 @@ M.handlers.signs = {
local numhl = opts.signs.numhl or {}
local linehl = opts.signs.linehl or {}
local line_count = api.nvim_buf_line_count(bufnr)
for _, diagnostic in ipairs(diagnostics) do
if api.nvim_buf_is_loaded(diagnostic.bufnr) then
if diagnostic.lnum <= line_count then
api.nvim_buf_set_extmark(bufnr, ns.user_data.sign_ns, diagnostic.lnum, 0, {
sign_text = text[diagnostic.severity] or text[M.severity[diagnostic.severity]] or 'U',
sign_hl_group = sign_highlight_map[diagnostic.severity],

View File

@ -144,6 +144,9 @@ end
local function detect_noext(path, bufnr)
local root = fn.fnamemodify(path, ':r')
if root == path then
return
end
return M.match({ buf = bufnr, filename = root })
end
@ -1258,8 +1261,7 @@ local extension = {
['dpkg-new'] = detect_noext,
['in'] = function(path, bufnr)
if vim.fs.basename(path) ~= 'configure.in' then
local root = fn.fnamemodify(path, ':r')
return M.match({ buf = bufnr, filename = root })
return detect_noext(path, bufnr)
end
end,
new = detect_noext,

View File

@ -594,7 +594,7 @@ function M.frm(_, bufnr)
end
--- @type vim.filetype.mapfn
function M.fvwm_1(_, _)
function M.fvwm_v1(_, _)
return 'fvwm', function(bufnr)
vim.b[bufnr].fvwm_version = 1
end
@ -1331,7 +1331,7 @@ end
function M.sgml(_, bufnr)
local lines = table.concat(getlines(bufnr, 1, 5))
if lines:find('linuxdoc') then
return 'smgllnx'
return 'sgmllnx'
elseif lines:find('<!DOCTYPE.*DocBook') then
return 'docbk',
function(b)

View File

@ -1,6 +1,8 @@
local M = {}
local iswin = vim.uv.os_uname().sysname == 'Windows_NT'
-- Can't use `has('win32')` because the `nvim -ll` test runner doesn't support `vim.fn` yet.
local sysname = vim.uv.os_uname().sysname:lower()
local iswin = not not (sysname:find('windows') or sysname:find('mingw'))
local os_sep = iswin and '\\' or '/'
--- Iterate over all the parents of the given path.
@ -328,8 +330,11 @@ function M.find(names, opts)
return matches
end
--- Find the first parent directory containing a specific "marker", relative to a buffer's
--- directory.
--- Find the first parent directory containing a specific "marker", relative to a file path or
--- buffer.
---
--- If the buffer is unnamed (has no backing file) or has a non-empty 'buftype' then the search
--- begins from Nvim's |current-directory|.
---
--- Example:
---
@ -346,13 +351,13 @@ end
--- end)
--- ```
---
--- @param source integer|string Buffer number (0 for current buffer) or file path to begin the
--- search from.
--- @param source integer|string Buffer number (0 for current buffer) or file path (absolute or
--- relative to the |current-directory|) to begin the search from.
--- @param marker (string|string[]|fun(name: string, path: string): boolean) A marker, or list
--- of markers, to search for. If a function, the function is called for each
--- evaluated item and should return true if {name} and {path} are a match.
--- @return string? # Directory path containing one of the given markers, or nil if no directory was
--- found.
--- found.
function M.root(source, marker)
assert(source, 'missing required argument: source')
assert(marker, 'missing required argument: marker')
@ -361,14 +366,18 @@ function M.root(source, marker)
if type(source) == 'string' then
path = source
elseif type(source) == 'number' then
path = vim.api.nvim_buf_get_name(source)
if vim.bo[source].buftype ~= '' then
path = assert(vim.uv.cwd())
else
path = vim.api.nvim_buf_get_name(source)
end
else
error('invalid type for argument "source": expected string or buffer number')
end
local paths = M.find(marker, {
upward = true,
path = path,
path = vim.fn.fnamemodify(path, ':p:h'),
})
if #paths == 0 then

View File

@ -13,7 +13,7 @@ local function filepath_to_healthcheck(path)
func = 'health#' .. name .. '#check'
filetype = 'v'
else
local subpath = path:gsub('.*lua/', '')
local subpath = path:gsub('.*/lua/', '')
if vim.fs.basename(subpath) == 'health.lua' then
-- */health.lua
name = assert(vim.fs.dirname(subpath))
@ -306,7 +306,7 @@ function M.system(cmd, args)
if jobid < 1 then
local message =
string.format('Command error (job=%d): %s (in %s)', jobid, shellify(cmd), vim.loop.cwd())
string.format('Command error (job=%d): %s (in %s)', jobid, shellify(cmd), vim.uv.cwd())
error(message)
return opts.output, 1
end
@ -325,7 +325,7 @@ function M.system(cmd, args)
jobid,
shell_error_code,
shellify(cmd),
vim.loop.cwd()
vim.uv.cwd()
)
if opts.output:find('%S') then
emsg = string.format('%s\noutput: %s', emsg, opts.output)
@ -350,8 +350,8 @@ local path2name = function(path)
-- Remove everything up to the last /lua/ folder
path = path:gsub('^.*/lua/', '')
-- Remove the filename (health.lua)
path = vim.fs.dirname(path)
-- Remove the filename (health.lua) or (health/init.lua)
path = vim.fs.dirname(path:gsub('/init%.lua$', ''))
-- Change slashes to dots
path = path:gsub('/', '.')

View File

@ -208,8 +208,7 @@ end
---@return string|function
---@private
function Loader.loader_lib(modname)
local sysname = uv.os_uname().sysname:lower() or ''
local is_win = sysname:find('win', 1, true) and not sysname:find('darwin', 1, true)
local is_win = vim.fn.has('win32') == 1
local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1]
if ret then
-- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is

View File

@ -64,6 +64,8 @@ lsp._request_name_to_capability = {
[ms.textDocument_inlayHint] = { 'inlayHintProvider' },
[ms.textDocument_diagnostic] = { 'diagnosticProvider' },
[ms.inlayHint_resolve] = { 'inlayHintProvider', 'resolveProvider' },
[ms.textDocument_documentLink] = { 'documentLinkProvider' },
[ms.documentLink_resolve] = { 'documentLinkProvider', 'resolveProvider' },
}
-- TODO improve handling of scratch buffers with LSP attached.
@ -373,7 +375,7 @@ local function reset_defaults(bufnr)
end
api.nvim_buf_call(bufnr, function()
local keymap = vim.fn.maparg('K', 'n', false, true)
if keymap and keymap.callback == vim.lsp.buf.hover then
if keymap and keymap.callback == vim.lsp.buf.hover and keymap.buffer == 1 then
vim.keymap.del('n', 'K', { buffer = bufnr })
end
end)
@ -385,8 +387,8 @@ end
local function on_client_exit(code, signal, client_id)
local client = all_clients[client_id]
for bufnr in pairs(client.attached_buffers) do
vim.schedule(function()
vim.schedule(function()
for bufnr in pairs(client.attached_buffers) do
if client and client.attached_buffers[bufnr] then
api.nvim_exec_autocmds('LspDetach', {
buffer = bufnr,
@ -395,15 +397,16 @@ local function on_client_exit(code, signal, client_id)
})
end
local namespace = vim.lsp.diagnostic.get_namespace(client_id)
vim.diagnostic.reset(namespace, bufnr)
client.attached_buffers[bufnr] = nil
if #lsp.get_clients({ bufnr = bufnr, _uninitialized = true }) == 0 then
reset_defaults(bufnr)
end
end)
end
end
local namespace = vim.lsp.diagnostic.get_namespace(client_id)
vim.diagnostic.reset(namespace)
end)
local name = client.name or 'unknown'
@ -495,6 +498,29 @@ local function text_document_did_save_handler(bufnr)
end
end
---@param bufnr integer resolved buffer
---@param client vim.lsp.Client
local function buf_detach_client(bufnr, client)
api.nvim_exec_autocmds('LspDetach', {
buffer = bufnr,
modeline = false,
data = { client_id = client.id },
})
changetracking.reset_buf(client, bufnr)
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
local uri = vim.uri_from_bufnr(bufnr)
local params = { textDocument = { uri = uri } }
client.notify(ms.textDocument_didClose, params)
end
client.attached_buffers[bufnr] = nil
local namespace = lsp.diagnostic.get_namespace(client.id)
vim.diagnostic.reset(namespace, bufnr)
end
--- @type table<integer,true>
local attached_buffers = {}
@ -547,36 +573,34 @@ local function buf_attach(bufnr)
api.nvim_buf_attach(bufnr, false, {
on_lines = function(_, _, changedtick, firstline, lastline, new_lastline)
if #lsp.get_clients({ bufnr = bufnr }) == 0 then
return true -- detach
-- detach if there are no clients
return #lsp.get_clients({ bufnr = bufnr, _uninitialized = true }) == 0
end
util.buf_versions[bufnr] = changedtick
changetracking.send_changes(bufnr, firstline, lastline, new_lastline)
end,
on_reload = function()
local clients = lsp.get_clients({ bufnr = bufnr })
local params = { textDocument = { uri = uri } }
for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do
for _, client in ipairs(clients) do
changetracking.reset_buf(client, bufnr)
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
client.notify(ms.textDocument_didClose, params)
end
end
for _, client in ipairs(clients) do
client:_text_document_did_open_handler(bufnr)
end
end,
on_detach = function()
local params = { textDocument = { uri = uri } }
for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do
changetracking.reset_buf(client, bufnr)
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
client.notify(ms.textDocument_didClose, params)
end
local clients = lsp.get_clients({ bufnr = bufnr, _uninitialized = true })
for _, client in ipairs(clients) do
buf_detach_client(bufnr, client)
end
for _, client in ipairs(all_clients) do
client.attached_buffers[bufnr] = nil
end
util.buf_versions[bufnr] = nil
attached_buffers[bufnr] = nil
util.buf_versions[bufnr] = nil
end,
-- TODO if we know all of the potential clients ahead of time, then we
@ -650,27 +674,9 @@ function lsp.buf_detach_client(bufnr, client_id)
)
)
return
else
buf_detach_client(bufnr, client)
end
api.nvim_exec_autocmds('LspDetach', {
buffer = bufnr,
modeline = false,
data = { client_id = client_id },
})
changetracking.reset_buf(client, bufnr)
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
local uri = vim.uri_from_bufnr(bufnr)
local params = { textDocument = { uri = uri } }
client.notify(ms.textDocument_didClose, params)
end
client.attached_buffers[bufnr] = nil
util.buf_versions[bufnr] = nil
local namespace = lsp.diagnostic.get_namespace(client_id)
vim.diagnostic.reset(namespace, bufnr)
end
--- Checks if a buffer is attached for a particular client.
@ -844,17 +850,20 @@ api.nvim_create_autocmd('VimLeavePre', {
---@param params table|nil Parameters to send to the server
---@param handler? lsp.Handler See |lsp-handler|
--- If nil, follows resolution strategy defined in |lsp-handler-configuration|
---
---@param on_unsupported? fun()
--- The function to call when the buffer has no clients that support the given method.
--- Defaults to an `ERROR` level notification.
---@return table<integer, integer> client_request_ids Map of client-id:request-id pairs
---for all successful requests.
---@return function _cancel_all_requests Function which can be used to
---cancel all the requests. You could instead
---iterate all clients and call their `cancel_request()` methods.
function lsp.buf_request(bufnr, method, params, handler)
function lsp.buf_request(bufnr, method, params, handler, on_unsupported)
validate({
bufnr = { bufnr, 'n', true },
method = { method, 's' },
handler = { handler, 'f', true },
on_unsupported = { on_unsupported, 'f', true },
})
bufnr = resolve_bufnr(bufnr)
@ -876,7 +885,11 @@ function lsp.buf_request(bufnr, method, params, handler)
-- if has client but no clients support the given method, notify the user
if next(clients) and not method_supported then
vim.notify(lsp._unsupported_method(method), vim.log.levels.ERROR)
if on_unsupported == nil then
vim.notify(lsp._unsupported_method(method), vim.log.levels.ERROR)
else
on_unsupported()
end
vim.cmd.redraw()
return {}, function() end
end

View File

@ -448,7 +448,7 @@ local function pick_call_hierarchy_item(call_hierarchy_items)
if choice < 1 or choice > #items then
return
end
return choice
return call_hierarchy_items[choice]
end
--- @param method string
@ -836,14 +836,10 @@ function M.code_action(opts)
if opts.diagnostics or opts.only then
opts = { options = opts }
end
local context = opts.context or {}
local context = opts.context and vim.deepcopy(opts.context) or {}
if not context.triggerKind then
context.triggerKind = vim.lsp.protocol.CodeActionTriggerKind.Invoked
end
if not context.diagnostics then
local bufnr = api.nvim_get_current_buf()
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics(bufnr)
end
local mode = api.nvim_get_mode().mode
local bufnr = api.nvim_get_current_buf()
local win = api.nvim_get_current_win()
@ -885,7 +881,23 @@ function M.code_action(opts)
else
params = util.make_range_params(win, client.offset_encoding)
end
params.context = context
if context.diagnostics then
params.context = context
else
local ns_push = vim.lsp.diagnostic.get_namespace(client.id, false)
local ns_pull = vim.lsp.diagnostic.get_namespace(client.id, true)
local diagnostics = {}
local lnum = api.nvim_win_get_cursor(0)[1] - 1
vim.list_extend(diagnostics, vim.diagnostic.get(bufnr, { namespace = ns_pull, lnum = lnum }))
vim.list_extend(diagnostics, vim.diagnostic.get(bufnr, { namespace = ns_push, lnum = lnum }))
params.context = vim.tbl_extend('force', context, {
---@diagnostic disable-next-line: no-unknown
diagnostics = vim.tbl_map(function(d)
return d.user_data.lsp
end, diagnostics),
})
end
client.request(ms.textDocument_codeAction, params, on_result, bufnr)
end
end

View File

@ -182,7 +182,7 @@ local validate = vim.validate
--- It can be `null` if the client supports workspace folders but none are
--- configured.
--- @field workspace_folders lsp.WorkspaceFolder[]?
--- @field root_dir string
--- @field root_dir string?
---
--- @field attached_buffers table<integer,true>
---
@ -470,7 +470,6 @@ function Client.create(config)
_on_exit_cbs = ensure_list(config.on_exit),
_on_attach_cbs = ensure_list(config.on_attach),
_on_error_cb = config.on_error,
_root_dir = config.root_dir,
_trace = get_trace(config.trace),
--- Contains $/progress report messages.
@ -612,7 +611,10 @@ function Client:initialize()
self:_run_callbacks(self._on_init_cbs, lsp.client_errors.ON_INIT_CALLBACK_ERROR, self, result)
for buf in pairs(reattach_bufs) do
self:_on_attach(buf)
-- The buffer may have been detached in the on_init callback.
if self.attached_buffers[buf] then
self:_on_attach(buf)
end
end
log.info(

View File

@ -164,7 +164,7 @@ function M.display(lenses, bufnr, client_id)
return a.range.start.character < b.range.start.character
end)
for j, lens in ipairs(line_lenses) do
local text = lens.command and lens.command.title or 'Unresolved lens ...'
local text = (lens.command and lens.command.title or 'Unresolved lens ...'):gsub('%s+', ' ')
table.insert(chunks, { text, 'LspCodeLens' })
if j < num_line_lenses then
table.insert(chunks, { ' | ', 'LspCodeLensSeparator' })
@ -307,7 +307,13 @@ function M.refresh(opts)
}
active_refreshes[buf] = true
local request_ids = vim.lsp.buf_request(buf, ms.textDocument_codeLens, params, M.on_codelens)
local request_ids = vim.lsp.buf_request(
buf,
ms.textDocument_codeLens,
params,
M.on_codelens,
function() end
)
if vim.tbl_isempty(request_ids) then
active_refreshes[buf] = nil
end

View File

@ -122,13 +122,7 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
code = diagnostic.code,
_tags = tags_lsp_to_vim(diagnostic, client_id),
user_data = {
lsp = {
-- usage of user_data.lsp.code is deprecated in favor of the top-level code field
code = diagnostic.code,
codeDescription = diagnostic.codeDescription,
relatedInformation = diagnostic.relatedInformation,
data = diagnostic.data,
},
lsp = diagnostic,
},
}
end, diagnostics)
@ -157,8 +151,11 @@ local function diagnostic_vim_to_lsp(diagnostics)
---@param diagnostic vim.Diagnostic
---@return lsp.Diagnostic
return vim.tbl_map(function(diagnostic)
return vim.tbl_extend('keep', {
-- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp
local user_data = diagnostic.user_data or {}
if user_data.lsp then
return user_data.lsp
end
return {
range = {
start = {
line = diagnostic.lnum,
@ -174,7 +171,7 @@ local function diagnostic_vim_to_lsp(diagnostics)
source = diagnostic.source,
code = diagnostic.code,
tags = tags_vim_to_lsp(diagnostic),
}, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {})
}
end, diagnostics)
end
@ -318,11 +315,19 @@ end
--- )
--- ```
---
---@param _ lsp.ResponseError?
---@param error lsp.ResponseError?
---@param result lsp.DocumentDiagnosticReport
---@param ctx lsp.HandlerContext
---@param config vim.diagnostic.Opts Configuration table (see |vim.diagnostic.config()|).
function M.on_diagnostic(_, result, ctx, config)
function M.on_diagnostic(error, result, ctx, config)
if error ~= nil and error.code == protocol.ErrorCodes.ServerCancelled then
if error.data == nil or error.data.retriggerRequest ~= false then
local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
client.request(ctx.method, ctx.params)
end
return
end
if result == nil or result.kind == 'unchanged' then
return
end
@ -366,6 +371,7 @@ end
--- Structured: { [1] = {...}, [5] = {.... } }
---@private
function M.get_line_diagnostics(bufnr, line_nr, opts, client_id)
vim.deprecate('vim.lsp.diagnostic.get_line_diagnostics', 'vim.diagnostic.get', '0.12')
convert_severity(opts)
local diag_opts = {} --- @type vim.diagnostic.GetOpts

View File

@ -716,7 +716,8 @@ for k, fn in pairs(M) do
})
end
if err then
-- ServerCancelled errors should be propagated to the request handler
if err and err.code ~= protocol.ErrorCodes.ServerCancelled then
-- LSP spec:
-- interface ResponseError:
-- code: integer;

View File

@ -33,16 +33,25 @@ local function check_active_clients()
local clients = vim.lsp.get_clients()
if next(clients) then
for _, client in pairs(clients) do
local attached_to = table.concat(vim.tbl_keys(client.attached_buffers or {}), ',')
report_info(
local cmd ---@type string
if type(client.config.cmd) == 'table' then
cmd = table.concat(client.config.cmd --[[@as table]], ' ')
elseif type(client.config.cmd) == 'function' then
cmd = tostring(client.config.cmd)
end
report_info(table.concat({
string.format('%s (id: %d)', client.name, client.id),
string.format(
'%s (id=%s, root_dir=%s, attached_to=[%s])',
client.name,
client.id,
vim.fn.fnamemodify(client.root_dir, ':~'),
attached_to
)
)
' Root directory: %s',
client.root_dir and vim.fn.fnamemodify(client.root_dir, ':~') or nil
),
string.format(' Command: %s', cmd),
string.format(' Settings: %s', vim.inspect(client.settings, { newline = '\n ' })),
string.format(
' Attached buffers: %s',
vim.iter(pairs(client.attached_buffers)):map(tostring):join(', ')
),
}, '\n'))
end
else
report_info('No active clients')
@ -50,7 +59,7 @@ local function check_active_clients()
end
local function check_watcher()
vim.health.start('vim.lsp: File watcher')
vim.health.start('vim.lsp: File Watcher')
-- Only run the check if file watching has been enabled by a client.
local clients = vim.lsp.get_clients()
@ -94,11 +103,68 @@ local function check_watcher()
end
end
local function check_position_encodings()
vim.health.start('vim.lsp: Position Encodings')
local clients = vim.lsp.get_clients()
if next(clients) then
local position_encodings = {} ---@type table<integer, table<string, integer[]>>
for _, client in pairs(clients) do
for bufnr in pairs(client.attached_buffers) do
if not position_encodings[bufnr] then
position_encodings[bufnr] = {}
end
if not position_encodings[bufnr][client.offset_encoding] then
position_encodings[bufnr][client.offset_encoding] = {}
end
table.insert(position_encodings[bufnr][client.offset_encoding], client.id)
end
end
-- Check if any buffers are attached to multiple clients with different position encodings
local buffers = {} ---@type integer[]
for bufnr, encodings in pairs(position_encodings) do
local list = {} ---@type string[]
for k in pairs(encodings) do
list[#list + 1] = k
end
if #list > 1 then
buffers[#buffers + 1] = bufnr
end
end
if #buffers > 0 then
local lines =
{ 'Found buffers attached to multiple clients with different position encodings.' }
for _, bufnr in ipairs(buffers) do
local encodings = position_encodings[bufnr]
local parts = {}
for encoding, client_ids in pairs(encodings) do
table.insert(
parts,
string.format('%s (client id(s): %s)', encoding:upper(), table.concat(client_ids, ', '))
)
end
table.insert(lines, string.format('- Buffer %d: %s', bufnr, table.concat(parts, ', ')))
end
report_warn(
table.concat(lines, '\n'),
'Use the positionEncodings client capability to ensure all clients use the same position encoding'
)
else
report_info('No buffers contain mixed position encodings')
end
else
report_info('No active clients')
end
end
--- Performs a healthcheck for LSP
function M.check()
check_log()
check_active_clients()
check_watcher()
check_position_encodings()
end
return M

View File

@ -77,12 +77,7 @@ function M.on_inlayhint(err, result, ctx, _)
local col = position.character
if col > 0 then
local line = lines[position.line + 1] or ''
local ok, convert_result
ok, convert_result = pcall(util._str_byteindex_enc, line, col, client.offset_encoding)
if ok then
return convert_result
end
return math.min(#line, col)
return util._str_byteindex_enc(line, col, client.offset_encoding)
end
return col
end
@ -336,6 +331,8 @@ api.nvim_set_decoration_provider(namespace, {
for lnum = topline, botline do
if bufstate.applied[lnum] ~= bufstate.version then
api.nvim_buf_clear_namespace(bufnr, namespace, lnum, lnum + 1)
local hint_virtual_texts = {} --- @type table<integer, [string, string?][]>
for _, lnum_hints in pairs(client_hints) do
local hints = lnum_hints[lnum] or {}
for _, hint in pairs(hints) do
@ -348,7 +345,7 @@ api.nvim_set_decoration_provider(namespace, {
text = text .. part.value
end
end
local vt = {} --- @type {[1]: string, [2]: string?}[]
local vt = hint_virtual_texts[hint.position.character] or {}
if hint.paddingLeft then
vt[#vt + 1] = { ' ' }
end
@ -356,13 +353,18 @@ api.nvim_set_decoration_provider(namespace, {
if hint.paddingRight then
vt[#vt + 1] = { ' ' }
end
api.nvim_buf_set_extmark(bufnr, namespace, lnum, hint.position.character, {
virt_text_pos = 'inline',
ephemeral = false,
virt_text = vt,
})
hint_virtual_texts[hint.position.character] = vt
end
end
for pos, vt in pairs(hint_virtual_texts) do
api.nvim_buf_set_extmark(bufnr, namespace, lnum, pos, {
virt_text_pos = 'inline',
ephemeral = false,
virt_text = vt,
})
end
bufstate.applied[lnum] = bufstate.version
end
end
@ -370,7 +372,7 @@ api.nvim_set_decoration_provider(namespace, {
})
--- Query whether inlay hint is enabled in the {filter}ed scope
--- @param filter vim.lsp.inlay_hint.enable.Filter
--- @param filter? vim.lsp.inlay_hint.enable.Filter
--- @return boolean
--- @since 12
function M.is_enabled(filter)

View File

@ -166,6 +166,7 @@ local constants = {
-- Defined by the protocol.
RequestCancelled = -32800,
ContentModified = -32801,
ServerCancelled = -32802,
},
-- Describes the content type that a client supports in various

View File

@ -3,7 +3,7 @@ local log = require('vim.lsp.log')
local protocol = require('vim.lsp.protocol')
local validate, schedule, schedule_wrap = vim.validate, vim.schedule, vim.schedule_wrap
local is_win = uv.os_uname().version:find('Windows')
local is_win = vim.fn.has('win32') == 1
--- Checks whether a given path exists and is a directory.
---@param filename string path to check

View File

@ -140,12 +140,7 @@ local function tokens_to_ranges(data, bufnr, client, request)
local function _get_byte_pos(col)
if col > 0 then
local buf_line = lines[line + 1] or ''
local ok, result
ok, result = pcall(util._str_byteindex_enc, buf_line, col, client.offset_encoding)
if ok then
return result
end
return math.min(#buf_line, col)
return util._str_byteindex_enc(buf_line, col, client.offset_encoding)
end
return col
end
@ -197,12 +192,6 @@ function STHighlighter.new(bufnr)
highlighter:send_request()
end
end,
on_detach = function(_, buf)
local highlighter = STHighlighter.active[buf]
if highlighter then
highlighter:destroy()
end
end,
})
api.nvim_create_autocmd({ 'BufWinEnter', 'InsertLeave' }, {

View File

@ -120,6 +120,7 @@ end
---@param encoding string|nil utf-8|utf-16|utf-32|nil defaults to utf-16
---@return integer `encoding` index of `index` in `line`
function M._str_utfindex_enc(line, index, encoding)
local len32, len16 = vim.str_utfindex(line)
if not encoding then
encoding = 'utf-16'
end
@ -130,9 +131,15 @@ function M._str_utfindex_enc(line, index, encoding)
return #line
end
elseif encoding == 'utf-16' then
if not index or index > len16 then
return len16
end
local _, col16 = vim.str_utfindex(line, index)
return col16
elseif encoding == 'utf-32' then
if not index or index > len32 then
return len32
end
local col32, _ = vim.str_utfindex(line, index)
return col32
else
@ -148,27 +155,29 @@ end
---@param encoding string utf-8|utf-16|utf-32| defaults to utf-16
---@return integer byte (utf-8) index of `encoding` index `index` in `line`
function M._str_byteindex_enc(line, index, encoding)
-- LSP spec: if character > line length, default to the line length.
-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
local len8 = #line
if not encoding then
encoding = 'utf-16'
end
if encoding == 'utf-8' then
if index then
if index and index <= len8 then
return index
else
return #line
return len8
end
elseif encoding == 'utf-16' then
return vim.str_byteindex(line, index, true)
end
local len32, len16 = vim.str_utfindex(line)
if encoding == 'utf-16' then
return index <= len16 and vim.str_byteindex(line, index, true) or len8
elseif encoding == 'utf-32' then
return vim.str_byteindex(line, index)
return index <= len32 and vim.str_byteindex(line, index) or len8
else
error('Invalid encoding: ' .. vim.inspect(encoding))
end
end
local _str_utfindex_enc = M._str_utfindex_enc
local _str_byteindex_enc = M._str_byteindex_enc
--- Replaces text in a range with new text.
---
--- CAUTION: Changes in-place!
@ -333,12 +342,7 @@ local function get_line_byte_from_position(bufnr, position, offset_encoding)
-- character
if col > 0 then
local line = get_line(bufnr, position.line) or ''
local ok, result
ok, result = pcall(_str_byteindex_enc, line, col, offset_encoding)
if ok then
return result
end
return math.min(#line, col)
return M._str_byteindex_enc(line, col, offset_encoding or 'utf-16')
end
return col
end
@ -495,14 +499,15 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
e.end_col = last_line_len
has_eol_text_edit = true
else
-- If the replacement is over the end of a line (i.e. e.end_col is out of bounds and the
-- If the replacement is over the end of a line (i.e. e.end_col is equal to the line length and the
-- replacement text ends with a newline We can likely assume that the replacement is assumed
-- to be meant to replace the newline with another newline and we need to make sure this
-- doesn't add an extra empty line. E.g. when the last line to be replaced contains a '\r'
-- in the file some servers (clangd on windows) will include that character in the line
-- while nvim_buf_set_text doesn't count it as part of the line.
if
e.end_col > last_line_len
e.end_col >= last_line_len
and text_edit.range['end'].character > e.end_col
and #text_edit.newText > 0
and string.sub(text_edit.newText, -1) == '\n'
then
@ -1621,7 +1626,7 @@ function M._make_floating_popup_size(contents, opts)
if vim.tbl_isempty(line_widths) then
for _, line in ipairs(contents) do
local line_width = vim.fn.strdisplaywidth(line:gsub('%z', '\n'))
height = height + math.ceil(line_width / wrap_at)
height = height + math.max(1, math.ceil(line_width / wrap_at))
end
else
for i = 1, #contents do
@ -2038,7 +2043,7 @@ local function make_position_param(window, offset_encoding)
return { line = 0, character = 0 }
end
col = _str_utfindex_enc(line, col, offset_encoding)
col = M._str_utfindex_enc(line, col, offset_encoding)
return { line = row, character = col }
end
@ -2219,11 +2224,7 @@ function M.character_offset(buf, row, col, offset_encoding)
)
offset_encoding = vim.lsp.get_clients({ bufnr = buf })[1].offset_encoding
end
-- If the col is past the EOL, use the line length.
if col > #line then
return _str_utfindex_enc(line, nil, offset_encoding)
end
return _str_utfindex_enc(line, col, offset_encoding)
return M._str_utfindex_enc(line, col, offset_encoding)
end
--- Helper function to return nested values in language server settings
@ -2305,6 +2306,11 @@ function M._refresh(method, opts)
local first = vim.fn.line('w0', window)
local last = vim.fn.line('w$', window)
for _, client in ipairs(clients) do
for rid, req in pairs(client.requests) do
if req.method == method and req.type == 'pending' and req.bufnr == bufnr then
client.cancel_request(rid)
end
end
client.request(method, {
textDocument = textDocument,
range = make_line_range_params(bufnr, first - 1, last - 1, client.offset_encoding),

View File

@ -315,7 +315,7 @@ local function select_tabstop(tabstop)
move_cursor_to(range[1] + 1, range[2] + 1)
feedkeys('v')
move_cursor_to(range[3] + 1, range[4])
feedkeys('o<c-g>')
feedkeys('o<c-g><c-r>_')
end
end
@ -395,6 +395,15 @@ local function setup_autocmds(bufnr)
end
end,
})
vim.api.nvim_create_autocmd('BufLeave', {
group = snippet_group,
desc = 'Stop the snippet session when leaving the buffer',
buffer = bufnr,
callback = function()
M.stop()
end,
})
end
--- Expands the given snippet text.
@ -444,7 +453,7 @@ function M.expand(input)
local snippet_lines = text_to_lines(snippet_text)
-- Get the base indentation based on the current line and the last line of the snippet.
if #snippet_lines > 0 then
base_indent = base_indent .. (snippet_lines[#snippet_lines]:match('(^%s*)%S') or '') --- @type string
base_indent = base_indent .. (snippet_lines[#snippet_lines]:match('(^%s+)%S') or '') --- @type string
end
local shiftwidth = vim.fn.shiftwidth()

View File

@ -18,15 +18,19 @@ end
--- Hex decode a string.
---
--- @param enc string String to decode
--- @return string : Decoded string
--- @return string? : Decoded string
--- @return string? : Error message, if any
function M.hexdecode(enc)
assert(#enc % 2 == 0, 'string must have an even number of hex characters')
if #enc % 2 ~= 0 then
return nil, 'string must have an even number of hex characters'
end
local str = {} ---@type string[]
for i = 1, #enc, 2 do
local n = assert(tonumber(enc:sub(i, i + 1), 16))
str[#str + 1] = string.char(n)
end
return table.concat(str)
return table.concat(str), nil
end
return M

View File

@ -87,7 +87,7 @@ end
---@param srow integer
---@param erow integer 0-indexed, exclusive
function FoldInfo:add_range(srow, erow)
list_insert(self.levels, srow + 1, erow, '=')
list_insert(self.levels, srow + 1, erow, -1)
list_insert(self.levels0, srow + 1, erow, -1)
end
@ -268,6 +268,15 @@ end
---@package
function FoldInfo:do_foldupdate(bufnr)
-- InsertLeave is not executed when <C-C> is used for exiting the insert mode, leaving
-- do_foldupdate untouched. If another execution of foldupdate consumes foldupdate_range, the
-- InsertLeave do_foldupdate gets nil foldupdate_range. In that case, skip the update. This is
-- correct because the update that consumed the range must have incorporated the range that
-- InsertLeave meant to update.
if not self.foldupdate_range then
return
end
local srow, erow = self.foldupdate_range[1], self.foldupdate_range[2]
self.foldupdate_range = nil
for _, win in ipairs(vim.fn.win_findbuf(bufnr)) do
@ -421,9 +430,15 @@ api.nvim_create_autocmd('OptionSet', {
pattern = { 'foldminlines', 'foldnestmax' },
desc = 'Refresh treesitter folds',
callback = function()
for bufnr, _ in pairs(foldinfos) do
local buf = api.nvim_get_current_buf()
local bufs = vim.v.option_type == 'global' and vim.tbl_keys(foldinfos)
or foldinfos[buf] and { buf }
or {}
for _, bufnr in ipairs(bufs) do
foldinfos[bufnr] = FoldInfo.new()
compute_folds_levels(bufnr, foldinfos[bufnr])
api.nvim_buf_call(bufnr, function()
compute_folds_levels(bufnr, foldinfos[bufnr])
end)
foldinfos[bufnr]:foldupdate(bufnr, 0, api.nvim_buf_line_count(bufnr))
end
end,

View File

@ -40,7 +40,8 @@ end
local function guess_query_lang(buf)
local filename = api.nvim_buf_get_name(buf)
if filename ~= '' then
return vim.F.npcall(vim.fn.fnamemodify, filename, ':p:h:t')
local resolved_filename = vim.F.npcall(vim.fn.fnamemodify, filename, ':p:h:t')
return resolved_filename and vim.treesitter.language.get_lang(resolved_filename) or nil
end
end
@ -64,7 +65,7 @@ local function normalize_opts(buf, opts)
end
local lint_query = [[;; query
(program [(named_node) (list) (grouping)] @toplevel)
(program [(named_node) (anonymous_node) (list) (grouping)] @toplevel)
(named_node
name: _ @node.named)
(anonymous_node
@ -170,17 +171,17 @@ function M.lint(buf, opts)
--- @type (table|nil)
local parser_info = vim.F.npcall(vim.treesitter.language.inspect, lang)
local lang_context = {
lang = lang,
parser_info = parser_info,
is_first_lang = i == 1,
}
local parser = vim.treesitter.get_parser(buf)
parser:parse()
parser:for_each_tree(function(tree, ltree)
if ltree:lang() == 'query' then
for _, match, _ in query:iter_matches(tree:root(), buf, 0, -1, { all = true }) do
local lang_context = {
lang = lang,
parser_info = parser_info,
is_first_lang = i == 1,
}
lint_match(buf, match, query, lang_context, diagnostics)
end
end
@ -240,7 +241,7 @@ function M.omnifunc(findstart, base)
end
end
for _, s in pairs(parser_info.symbols) do
local text = s[2] and s[1] or '"' .. s[1]:gsub([[\]], [[\\]]) .. '"' ---@type string
local text = s[2] and s[1] or string.format('%q', s[1]):gsub('\n', 'n') ---@type string
if text:find(base, 1, true) then
table.insert(items, text)
end

View File

@ -154,7 +154,8 @@ end
---@param w integer
---@param b integer
local function set_dev_properties(w, b)
---@param opts nil|{ indent?: integer }
local function set_dev_options(w, b, opts)
vim.wo[w].scrolloff = 5
vim.wo[w].wrap = false
vim.wo[w].foldmethod = 'expr'
@ -165,6 +166,12 @@ local function set_dev_properties(w, b)
vim.bo[b].buftype = 'nofile'
vim.bo[b].bufhidden = 'wipe'
vim.bo[b].filetype = 'query'
vim.bo[b].swapfile = false
opts = opts or {}
if opts.indent then
vim.bo[b].shiftwidth = opts.indent
end
end
--- Updates the cursor position in the inspector to match the node under the cursor.
@ -220,14 +227,13 @@ function TSTreeView:draw(bufnr)
local text ---@type string
if item.node:named() then
if item.field then
text = string.format('%s: (%s', item.field, item.node:type())
else
text = string.format('(%s', item.node:type())
end
text = string.format('(%s', item.node:type())
else
text = string.format('%q', item.node:type()):gsub('\n', 'n')
end
if item.field then
text = string.format('%s: %s', item.field, text)
end
local next = self:get(i + 1)
if not next or next.depth <= item.depth then
@ -350,7 +356,7 @@ function M.inspect_tree(opts)
vim.b[buf].dev_inspect = w
vim.b[b].dev_base = win -- base window handle
vim.b[b].disable_query_linter = true
set_dev_properties(w, b)
set_dev_options(w, b, { indent = treeview.opts.indent })
local title --- @type string?
local opts_title = opts.title
@ -587,7 +593,7 @@ function M.edit_query(lang)
vim.b[buf].dev_edit = query_win
vim.bo[query_buf].omnifunc = 'v:lua.vim.treesitter.query.omnifunc'
set_dev_properties(query_win, query_buf)
set_dev_options(query_win, query_buf)
-- Note that omnifunc guesses the language based on the containing folder,
-- so we add the parser's language to the buffer's name so that omnifunc

View File

@ -139,8 +139,11 @@ function TSHighlighter.new(tree, opts)
-- but use synload.vim rather than syntax.vim to not enable
-- syntax FileType autocmds. Later on we should integrate with the
-- `:syntax` and `set syntax=...` machinery properly.
-- Still need to ensure that syntaxset augroup exists, so that calling :destroy()
-- immediately afterwards will not error.
if vim.g.syntax_on ~= 1 then
vim.cmd.runtime({ 'syntax/synload.vim', bang = true })
vim.api.nvim_create_augroup('syntaxset', { clear = false })
end
api.nvim_buf_call(self.bufnr, function()
@ -377,11 +380,15 @@ function TSHighlighter._on_spell_nav(_, _, buf, srow, _, erow, _)
return
end
-- Do not affect potentially populated highlight state. Here we just want a temporary
-- empty state so the C code can detect whether the region should be spell checked.
local highlight_states = self._highlight_states
self:prepare_highlight_states(srow, erow)
for row = srow, erow do
on_line_impl(self, buf, row, true)
end
self._highlight_states = highlight_states
end
---@private

Some files were not shown because too many files have changed in this diff Show More