Commit Graph

31963 Commits

Author SHA1 Message Date
luukvbaal
f25dd7a8d5 fix(display): correctly store winline info for concealed lines (#32656)
Off-by-one error in storing last line number for a logical line.
2025-02-27 13:15:47 +01:00
glepnir
ac1c5ccb2c fix(popup): reuse pum preview float win, set 'winfixbuf' #32636
Problem:
popup floating window is closed and recreated for each item selection,
this is a bit wasteful.

Solution:
- Hide the preview win (instead of closing it) when the menu is still displayed:
    1. When selected_item is -1.
    2. When switching from an item with an "info" field to one without.
- When pum is undisplayed it is still closed.
2025-02-27 02:41:29 -08:00
David Briscoe
6a9555c0fa doc: clarify window-id, tab-id, nvim_set_current_x #32528
Problem:
Descriptions are somewhat vague. nvim_set_current_line modifies contents
but nvim_set_current_buf does not, etc.

Solution:
- Make it clear that these functions accept or return a winid/tabid by
  linking to that concept in help.
- Only these few files use the term "handles", so replace them with the
  more conventional terminology.
- Add a new help section for tab-ID. This concept is unique to neovim
  because vim exposes tabnr, but not tab handles. This section is
  modelled after `:h winid`.
2025-02-27 02:05:00 -08:00
zeertzjq
746139fa1e refactor(do_source): remove duplicate assignments (#32654)
The code above have already set sc_lnum to 0.
2025-02-27 17:39:25 +08:00
luukvbaal
f86864f22f fix(move): 'scrolloff' cursor correction no longer handles folds properly (#32642)
Problem:  f58e7d5f passed `&botline` to `plines_win_full()`, (probably)
          assuming it would be set to the first line of the fold.
Solution: Reinstate call to `hasFolding()` to do so.
2025-02-27 08:52:19 +01:00
zeertzjq
1e4c708033 test: option set by Lua autocommand has correct script context (#32652) 2025-02-27 05:48:52 +00:00
zeertzjq
877f3b7288 refactor(shada): fix coverity warning about leaking memory (#32650) 2025-02-27 10:38:04 +08:00
zeertzjq
189bba7c77 Merge pull request #32649 from zeertzjq/vim-9.1.1151
vim-patch:9.1.{1151,1152}
2025-02-27 09:17:36 +08:00
zeertzjq
f56d2b3c59 vim-patch:9.1.1152: Patch v9.1.1151 causes problems
Problem:  Patch v9.1.1151 causes problems
Solution: partially revert it (John Marriott)

closes: vim/vim#16736

18bacc811c

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-02-27 08:55:43 +08:00
zeertzjq
e1a3128ec4 vim-patch:9.1.1151: too many strlen() calls in getchar.c
Problem:  too many strlen() calls in getchar.c
Solution: store last inserted and recorded lengths,
          add functions to retrieve those and use those
          functions (John Marriott)

closes: vim/vim#16720

d3c4b7e946

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-02-27 08:55:14 +08:00
Justin M. Keyes
3cce657031 refactor: old references to scripts/ dir #32647 2025-02-26 23:00:54 +00:00
Justin M. Keyes
4f42b69b4a Merge #32601 vim.text.indent() 2025-02-26 14:31:03 -08:00
Justin M. Keyes
4a997a1732 test: unreliable swapfile_preserve_recover_spec
Problem:
Test sometimes fails on bsd (cirrus ci):

    test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:589: retry() attempts: 464
    test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:590: Expected objects to be the same.
    Passed in:
    (table: 0x0d5f1aa44070) {
      [1] = ''
     *[2] = ''
      [3] = '[Process exited 1]' }
    Expected:
    (table: 0x0d5ea3eb8718) {
      [1] = ''
     *[2] = '[Process exited 1]'
      [3] = '' }
    stack traceback:
      test/testutil.lua:104: in function 'retry'
      test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:589: in function <test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:556>

Solution:
Filter out empty items to avoid irrelevant redraw-timing assumptions.
2025-02-26 23:06:22 +01:00
Justin M. Keyes
be1fbe38b3 feat(lua): vim.text.indent()
Problem:
Indenting text is a common task in plugins/scripts for
presentation/formatting, yet vim has no way of doing it (especially
"dedent", and especially non-buffer text).

Solution:
Introduce `vim.text.indent()`. It sets the *exact* indentation because
that's a more difficult (and thus more useful) task than merely
"increasing the current indent" (which is somewhat easy with a `gsub()`
one-liner).
2025-02-26 23:06:22 +01:00
IpsumCapra
f4921e2b7d fix(shada): ":wshada/:rshada [filename]" with shadafile=NONE #32538
Problem: read/write shada function logic was skipped entirely if it was
detected the shadafile option was set to 'NONE'.

Solution: The filename is now always resolved. When the shadafile option
is set to 'NONE' AND no filename was passed, the filename resolves to an
empty string, which causes the read/write functions to return.
Regardless of whether the option is set to 'NONE', when a filename is
explicitly passed, it gets resolved and the read/write logic is
accessed.
2025-02-26 11:03:50 -08:00
Lewis Russell
0f24b0826a build: move all generator scripts to src/gen/
- Move all generator Lua scripts to the `src/gen/`
- Add a `.luarc.json` to `src/gen/`
- Add a `preload.lua` to `src/gen/`
  - Add `src` to `package.path` so it aligns with `.luarc.json'
- Fix all `require` statements in `src/gen/` so they are consistent:
    - `require('scripts.foo')` -> `require('gen.foo')`
    - `require('src.nvim.options')` -> `require('nvim.options')`
    - `require('api.dispatch_deprecated')` -> `require('nvim.api.dispatch_deprecated')`
2025-02-26 16:54:37 +00:00
zeertzjq
85caaa70d4 refactor(gen_api_dispatch): avoid trailing spaces (#32632)
Problem:
Generated Lua API bindings may have trailing spaces (e.g. nvim_set_hl).

Solution:
Add leading spaces only if arg_free_code is non-empty.
Also:
- Remove an unnecessary string.format() in write_shifted_output() args.
- Fix incorrect indent for the nlua_push_keydict() below.
2025-02-26 20:23:27 +08:00
James McCoy
c619d1da61 Merge pull request #32631 from jamessan/snprintf-binary
fix(vim_snprintf): special-case handling of binary format
2025-02-26 04:23:52 -07:00
Tristan Knight
7ead328a48 build(cjson): sync with upstream (#32114)
Sync with commit 91ca29db9a
2025-02-26 09:40:02 +01:00
zeertzjq
b0a1d35f69 fix(eval): don't shorten $HOME in v:stacktrace (#32634) 2025-02-26 07:33:11 +00:00
zeertzjq
f4bb7417b7 refactor: remove unnecessary allocation for "run Nvim with -V1" (#32633) 2025-02-26 05:55:29 +00:00
James McCoy
453f2c52d2 fix(vim_snprintf): special-case handling of binary format
A binary format spec always expects a corresponding unsigned long long
value. However, that explicit handling didn't get included when porting
the code from Vim, so binary format spec was falling through to the
"unsigned" and "length_modifier = NUL" portion of the code:

        } else {
          // unsigned
          switch (length_modifier) {
          case NUL:
            uarg = (tvs
                    ? (unsigned)tv_nr(tvs, &arg_idx)
                    : (skip_to_arg(ap_types, ap_start, &ap, &arg_idx,
                                   &arg_cur, fmt),
                       va_arg(ap, unsigned)));
            break;

This incorrectly read an "unsigned" value from an "unsigned long long"
variable, which would produce incorrect results on certain platforms.
2025-02-25 21:58:22 -05:00
zeertzjq
a2b464944a refactor(options): fix coverity warning about unintialized sc_chan (#32630) 2025-02-26 01:47:29 +00:00
Riley Bruins
93278e7720 fix(extmark): clearer error message for invalid ephemeral mark usage 2025-02-26 01:08:51 +01:00
zeertzjq
23f7e5593d Merge pull request #32614 from brianhuster/vim-094494b
vim-patch: improve &keywordprg in Vim ftplugin
2025-02-26 07:51:10 +08:00
zeertzjq
e2aca58bcc fix(lua): don't override script ID from :source (#32626)
Problem:  When setting an option, mapping etc. from Lua without -V1, the
          script ID is set to SID_LUA even if there already is a script
          ID assigned by :source.
Solution: Don't set script ID to SID_LUA if it is already a Lua script.
          Also add _editor.lua to ignorelist to make script context more
          useful when using vim.cmd().
2025-02-25 23:40:21 +00:00
zeertzjq
9c43e5cd4a vim-patch:580e457: runtime(vim): make VimKeywordPrg even smarter for regexes
closes: vim/vim#16729

580e457a2a

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
2025-02-26 07:31:49 +08:00
brianhuster
6db439ff01 vim-patch:094494b: runtime(vim): improve &keywordprg in ftplugin
- let keywordprg in vim filetype handle context-sensitive help calls by
  detecting the syntax group of the word under the cursor
- reformat whitespace
- add modeline

related: vim/vim#16677
closes: vim/vim#16680

094494bf2e

Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
Co-authored-by: Andrew Radev <andrey.radev@gmail.com>
Co-authored-by: "D. Ben Knoble" <ben.knoble+github@gmail.com>
Co-authored-by: Gary Johnson <garyjohn@spocom.com>
Co-authored-by: Tim Pope <code@tpope.net>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-02-26 07:31:03 +08:00
luukvbaal
af0a2157ad fix(move): wrong cursor row on concealed line (#32629)
Problem:  Cursor row calculation does not take into account concealed lines.
Solution: Break the loop when the next calculated line is concealed.
2025-02-25 23:45:52 +01:00
Luuk van Baal
c3337e357a fix(treesitter): nil check query for has_conceal_line 2025-02-25 16:21:16 +01:00
zeertzjq
3bdc3a1689 test(ui/cursor_spec): reduce flakiness (#32627) 2025-02-25 21:29:10 +08:00
Luuk van Baal
47aaddfa0d fix(lsp): resize hover window for concealed lines
Problem:  Height of a (markdown) `vim.lsp.util.open_floating_preview()`
          window can be reduced to account for concealed lines (after #31324).
Solution: Set the window height to the text height of the preview window.
          Set 'concealcursor' to avoid unconcealing the cursorline when
          entering the hover window.
2025-02-25 14:26:58 +01:00
Luuk van Baal
8ba047e33f feat(treesitter): vertical conceal support for highlighter
TSHighlighter now places marks for conceal_lines metadata. A new
internal decor provider callback _on_conceal_line was added that
instructs the highlighter to place conceal_lines marks whenever the
editor needs to know whether a line is concealed. The bundled markdown
queries use conceal_lines metadata to conceal code block fence lines.
2025-02-25 13:09:01 +01:00
Luuk van Baal
f58e7d5fac feat(marks): add conceal_lines to nvim_buf_set_extmark()
Implement an extmark property that conceals lines vertically.
2025-02-25 13:09:01 +01:00
zeertzjq
a31ccc3b1f vim-patch:9.1.1140: filetype: m17ndb files are not detected (#32618)
Problem:  filetype: m17ndb files are not detected
Solution: detect m17ndb files as m17ndb filetype,
          include filetype, syntax and indent files for the
          new filetype (David Mandelberg).

References:

https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html describes the
format. https://git.savannah.nongnu.org/cgit/m17n/m17n-db.git/tree/ has
examples of the files.

closes: vim/vim#16696

ed7d8e55ac

Also adjust the xkb parent pattern according to dev_vimpatch.txt.

Co-authored-by: David Mandelberg <david@mandelberg.org>
2025-02-25 09:20:44 +00:00
Artem
0c650da799 test: combined injections (#32611)
* refactor: rewrite test without trailing whitespace

* test: combined injection tests
2025-02-25 09:12:49 +00:00
glepnir
c9a2b16c48 vim-patch:9.1.1145: multi-line completion has wrong indentation for last line (#32625)
Problem:  When expanding omni completion items with newlines (e.g.
          `then\n\t\nend`), the end statement gets wrong indentation.
Solution: Add OPENLINE_FORCE_INDENT flag to make open_line() use
          second_line_indent directly (glepnir)

closes: vim/vim#16614

5090a1fecb
2025-02-25 06:30:21 +00:00
zeertzjq
095c0876c2 fix(api): don't override Vimscript SID (#32610)
Problem:  When calling an API from Vimscript to set an option, mapping,
          etc., :verbose shows that it's set from an API client.
Solution: Don't override current_sctx.sc_sid when calling an API from
          Vimscript. Also fix the inverse case where API channel id is
          not set when calling an API from RPC. Move channel id into
          sctx_T to make saving and restoring easier.

Related #8329
2025-02-25 01:17:51 +00:00
phanium
614c9322d5 fix(lua): SIGSEGV in luv callback with error(nil) #32595
Problem:
luv callback `vim.uv.new_timer():start(0, 0, function() error() end)`
causes SIGSEGV, since `xstrdup` gets NULL from `lua_tostring`.
Similar to: a5b1b83a26

Solution:
Check NULL before `xstrdup`.
2025-02-24 13:34:49 -08:00
zeertzjq
56fabcadb6 vim-patch:025dc48: runtime(vim): Update base-syntax, match :CompilerSet and :SynMenu commands (#32605)
closes: vim/vim#16713

025dc48e88

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2025-02-24 04:16:36 +00:00
zeertzjq
01236c3bfe vim-patch:9.1.1143: illegal memory access when putting a register (#32604)
Problem:  illegal memory access when putting a register
Solution: make sure cursor column doesn't become negative

e0029daa35

Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-02-24 11:20:37 +08:00
Evgeni Chasnovski
268a3de0a7 feat(complete): CompleteDone reason "cancel", "discard" #32600
Problem: there is no way to distinguish between user's explicit
  completion stop/cancel and other automated reasons.

Solution: update "cancel" reason to be set only on explicit CTRL-e, and
  set intentionally vague "discard" otherwise.
2025-02-23 14:08:26 -08:00
Evgeni Chasnovski
07c5f41da3 fix(float): can set title/footer without setting border #32594
Problem: setting title and/or footer without explicitly setting border
  shows "title/footer/ requires border to be set" error.
  At the same time, explicitly setting `border = "none"` (which is
  default) shows expected no-border-no-title-no-footer window without
  error.

Solution: allow setting title/footer without explicitly setting border.
2025-02-23 09:08:16 -08:00
Yi Ming
6bc7979044 fix(lsp): reset the applied hints on refresh request #32446 2025-02-23 08:48:08 -08:00
Justin M. Keyes
2a733ec6cc revert "feat(ftplugin): set 'omnifunc' of Lua to 'v:lua.vim.lua_omnifunc'" #32597
This reverts commit f398e3a61a.
2025-02-23 08:21:24 -08:00
Justin M. Keyes
9304a417af Merge #32503 feat(lsp): use the meta model to generate server capability map 2025-02-23 08:20:19 -08:00
Riley Bruins
0c9c140f91 refactor(treesitter): simplify parsing coroutine logic
Lua coroutines can yield across non-coroutine function boundaries,
meaning that we don't need to wrap each helper function in a coroutine
and resume it within `_parse()`. If we just have them yield when
appropriate, this will be caught by the top level `_parse()` coroutine,
and resuming the `_parse()` will resume from the position in the helper
function where we yielded last.
2025-02-23 17:12:58 +01:00
Phạm Bình An
f398e3a61a feat(ftplugin): set Lua 'omnifunc' to vim.lua_omnifunc #32491
Problem:
- Many other ftplugin have defined 'omnifunc', but the Lua one doesn't
  define one, even though there is `vim.lua_omnifunc()`
- Users may want "stupid" completion to fix Lua config with
  `nvim --clean` in case they breaks it

Solution:
Set 'omnifunc' to 'v:lua.vim.lua_omnifunc' in ftplugin/lua.lua
2025-02-23 07:57:16 -08:00
Dan Sully
b283736388 fix(lua): @private => @nodoc #32587
Problem:
vim.log.levels.* and vim.opt_local are marked `@private` but they should be `@nodoc`.

Solution:
Fix the annotation.
2025-02-23 07:51:12 -08:00
dundargoc
4a0ee22e77 build: make makefile work on msys
Relying on $(OS) doesn't work as it's too naive, so we check if $PATH
contains a colon instead.

Closes https://github.com/neovim/neovim/issues/31027
2025-02-23 11:38:29 +01:00