Commit Graph

6420 Commits

Author SHA1 Message Date
zeertzjq
d4c2fc6ff6
fix(terminal): keep focus when scrolling number column of another window (#25848) 2023-10-31 15:23:20 +08:00
zeertzjq
c881092ffe
fix(terminal): don't lose focus on <MouseMove> (#25845) 2023-10-31 12:05:37 +08:00
bfredl
6d1a2f2c3c
Merge pull request #25674 from famiu/refactor/options/unify_string_options
refactor(options): unify `set_option` and `set_string_option`
2023-10-30 20:06:57 +01:00
Famiu Haque
e19cc9c9b7 refactor(options)!: unify set_option and set_string_option
While the interfaces for setting number and boolean options are now unified by #25394, there is still a separate `set_string_option` function that is used for setting a string option. This PR removes that function and merges it with set_option.

BREAKING CHANGE: `v:option_old` is now the old global value for all global-local options, instead of just string global-local options. Local value for a global-local number/boolean option is now unset when the option is set (e.g. using `:set` or `nvim_set_option_value`) without a scope, which means they now behave the same way as string options.

Ref: #25672
2023-10-30 21:38:02 +06:00
Maria José Solano
0fe0cf5ada
fix(lsp): do not cancel snippet when selecting placeholder (#25835) 2023-10-30 12:58:28 +01:00
dundargoc
2dc9ceb99c
docs: small fixes (#25585)
Co-authored-by: tmummert <doczook@gmx.de>
Co-authored-by: parikshit adhikari <parikshitadhikari@gmail.com>
2023-10-29 16:02:32 +08:00
Raphael
0da27e9bde
fix(api): load buffer first on nvim_buf_set_lines (#25823)
Fix #22670
Fix #8659
2023-10-29 15:44:52 +08:00
zeertzjq
82b1a389ba
fix(terminal): avoid Insert mode in Terminal buffer (#25820) 2023-10-29 09:32:03 +08:00
Christian Clason
c34e816608 vim-patch:9.0.2079: Not all Dart files detected
Problem:  Not all Dart files detected
Solution: Add shebang filetype detection for Dart

closes: vim/vim#13449

c1c177a47b

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-10-29 01:36:51 +02:00
luukvbaal
f2fb05238a
vim-patch:9.0.2081: smoothscroll may result in wrong cursor position (#25815)
Problem:  With 'smoothscroll' set, "w_skipcol" is not reset when unsetting 'wrap'.
          Resulting in incorrect calculation of the cursor position.
Solution: Reset "w_skipcol" when unsetting 'wrap'.

fixes:  vim/vim#12970
closes: vim/vim#13439

1bf1bf569b
2023-10-29 06:05:29 +08:00
Famiu Haque
43a7945f1b test: add test coverage for #25741 2023-10-28 22:51:07 +06:00
zeertzjq
ac353e87ae
vim-patch:9.0.2075: TextChangedI may not always trigger (#25808)
Problem:  TextChangedI may not always trigger
Solution: trigger it in more cases: for insert/
          append/change operations, and when
          opening a new line,

fixes: vim/vim#13367
closes: vim/vim#13375

4bca4897a1

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-10-28 10:42:18 +08:00
zeertzjq
063a78fda2 vim-patch:9.0.2077: CI fails because of trailing whitespace in test
Problem:  CI fails because of trailing whitespace in test
Solution: Remove it

87ca5e86fa

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-10-28 06:17:08 +08:00
zeertzjq
0b23207c73 vim-patch:9.0.2074: Completion menu may be wrong
Problem:  Completion menu may be wrong
Solution: Check for the original direction of the completion menu,
          add more tests, make it work with 'noselect'

completion: move in right direction when  filling completion_info()

When moving through the insert completion menu and switching directions,
we need to make sure we start at the correct position in the list and
move correctly forward/backwards through it, so that we do not skip
entries and the selected item points to the correct entry in the list
of completion entries generated by the completion_info() function.

The general case is this:

1) CTRL-X CTRL-N, we will traverse the list starting from
   compl_first_match and then go forwards (using the cp->next pointer)
   through the list (skipping the very first entry, which has the
   CP_ORIGINAL_TEXT flag set (since that is the empty/non-selected entry

2) CTRL-X CTRL-P, we will traverse the list starting from
   compl_first_match (which now points to the last entry). The previous
   entry will have the CP_ORIGINAL_TEXT flag set, so we need to start
   traversing the list from the second prev pointer.

There are in fact 2 special cases after starting the completion menu
with CTRL-X:

3)  CTRL-N and then going backwards by pressing CTRL-P again.
    compl_first_match will point to the same entry as in step 1 above,
    but since compl_dir_foward() has been switched by pressing CTRL-P
    to backwards we need to pretend to be in still in case 1 and still
    traverse the list in forward direction using the cp_next pointer

4)  CTRL-P and then going forwards by pressing CTRL-N again.
    compl_first_match will point to the same entry as in step 2 above,
    but since compl_dir_foward() has been switched by pressing CTRL-N
    to forwards we need to pretend to be in still in case 2 and still
    traverse the list in backward direction using the cp_prev pointer

For the 'noselect' case however, this is slightly different again. When
going backwards, we only need to go one cp_prev pointer back. And
resting of the direction works again slightly different. So we need to
take the noselect option into account when deciding in which direction
to iterate through the list of matches.

related: vim/vim#13402
related: vim/vim#12971
closes: vim/vim#13408

daef8c7437

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-10-28 06:16:55 +08:00
Jongwook Choi
add1b10b79
fix(diagnostic): virtual_text prefix function should have index and total (#25801)
The prefix option of the diagnostic virtual text can be a function,
but previously it was only a function of diagnostic.

This function should also have additional parameters index and total,
more consistently and similarily as in the prefix function for
`vim.diagnostic.open_float()`.

These additional parameters will be useful when there are too many
number of diagnostics in a single line.
2023-10-27 08:17:46 -05:00
Christian Clason
5753e5e7eb vim-patch:9.0.2071: objdump files not recognized
Problem:  objdump files not recognized
Solution: detect *.objdump files, add a filetype plugin

Added the objdump file/text format

closes: vim/vim#13425

10407df7a9

Co-authored-by: Colin Kennedy <colinvfx@gmail.com>
2023-10-27 10:03:09 +02:00
zeertzjq
9dc440400c
vim-patch:9.0.2068: [security] overflow in :history (#25794)
Problem:  [security] overflow in :history
Solution: Check that value fits into int

The get_list_range() function, used to parse numbers for the :history
and :clist command internally uses long variables to store the numbers.
However function arguments are integer pointers, which can then
overflow.

Check that the return value from the vim_str2nr() function is not larger
than INT_MAX and if yes, bail out with an error. I guess nobody uses a
cmdline/clist history that needs so many entries... (famous last words).

It is only a moderate vulnerability, so impact should be low.

Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-q22m-h7m2-9mgm

9198c1f2b1

N/A patch:
vim-patch:9.0.2073: typo in quickfix.c comments

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-10-27 06:37:52 +08:00
Lajos Koszti
ba6761eafe
fix(lsp): fix omnicomplete in middle of the line (#25787)
Fixes a regression from 5e5f5174e3

Until that commit we had a logic like this:
`local prefix = startbyte and line:sub(startbyte + 1) or line_to_cursor:sub(word_boundary)`

The commit changed the logic and no longer cut off the line at the cursor,  resulting in a prefix that included trailing characters
2023-10-26 22:40:36 +02:00
Maria José Solano
15983cf2c6
fix(lsp): cancel session when leaving snippet region (#25762) 2023-10-26 07:29:05 +02:00
nwounkn
9de157bce4
fix(float): win_get_bordertext_col returning negative column number (#25752)
Problem:
  `win_get_bordertext_col` returns column < 1 for right or center
  aligned text, if its length is more than window width.

Solution:
  Return max(resulting_column, 1)
2023-10-26 11:44:28 +08:00
zeertzjq
f2fc44550f
vim-patch:9.0.2064: cannot use buffer-number for errorformat (#25782)
Problem:  cannot use buffer-number for errorformat
Solution: add support for parsing a buffer number using '%b' in
          'errorformat'

closes: vim/vim#13419

b731800522

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-26 07:42:29 +08:00
zeertzjq
684e93054b
fix(terminal): assign channel to terminal earlier (#25771) 2023-10-25 09:59:02 +08:00
Christian Clason
0b1ec3b162 vim-patch:9.0.2063: pacman hooks are detected as conf filetype
Problem:  pacman hooks are detected as conf filetype
Solution: make it consistent to pacman.conf and detect those
          hooks as confini

Because confini has much better syntax highlighting than conf.

For reference, I identified pacman.conf and pacman hooks as dosini in
https://github.com/vim/vim/pull/6335, then
https://github.com/vim/vim/pull/10213 changed them to conf, then
https://github.com/vim/vim/pull/10518 changed pacman.conf to confini but
forgot to change hooks.

closes: vim/vim#13399

7d254dbc2d

Co-authored-by: Guido Cella <guido@guidocella.xyz>
2023-10-24 10:15:47 +02:00
Christian Clason
4f0adb6a78 vim-patch:9.0.2062: Janet files are not recognised
Problem:  Janet files are not recognised
Solution: Add filename and shebang detection (without
          adding an extra filetype plugin)

Those are used by the Janet language:
http://www.janet-lang.org

closes: vim/vim#13400

c038427d2a

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-10-24 10:15:47 +02:00
Christian Clason
94fee35446 vim-patch:9.0.2061: not able to detect xkb filetypes
Problem:  not able to detect xkb filetypes
Solution: Detect files below /u/s/X11/xkb as xkb files (without adding
          an extra filetype)

Those files are used from the X11 xkb extension

closes: vim/vim#13401

ae9021a840

Co-authored-by: Guido Cella <guido@guidocella.xyz>
2023-10-24 10:15:47 +02:00
Christian Clason
5f0224e848 vim-patch:9.0.2060: *.{gn,gni} files are not recognized
Problem:  *.{gn,gni} files are not recognized
Solution: Detect some as gn filetype (without adding an extra filetype)

Those come from: https://gn.googlesource.com/gn/

closes: vim/vim#13405

84394f2be4

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-10-24 10:15:47 +02:00
zeertzjq
d432bba4e4
fix(marks): handle switching buffer properly (#25763) 2023-10-24 16:10:36 +08:00
Maria José Solano
94127cb5df fix(lsp): do not add extra indentation 2023-10-23 17:21:41 +02:00
Maria José Solano
370232dbef fix(lsp): track snippet deletion 2023-10-23 17:21:41 +02:00
Mathias Fussenegger
5e5f5174e3 fix(lsp): fix off-by-one error for omnifunc word boundary
Fixes https://github.com/neovim/neovim/issues/25177

I initially wanted to split this into a refactor commit to make it more
testable, but it appears that already accidentally fixed the issue by
normalizing lnum/col to 0-indexing
2023-10-23 08:26:38 +02:00
glepnir
ae4ca4edf8 feat(complete): support f flag for complete buffer part 2023-10-21 20:06:36 +08:00
Mathias Fussenegger
195301c609 refactor(lsp): deprecate completion util methods
Relates to https://github.com/neovim/neovim/issues/25272
2023-10-21 13:49:05 +02:00
zeertzjq
9971bea6f1
vim-patch:9.0.2059: outstanding exceptions may be skipped (#25736)
Problem:  outstanding exceptions may be skipped
Solution: When restoring exception state, process remaining outstanding
          exceptions

closes: vim/vim#13386

0ab500dede

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-21 18:46:52 +08:00
zeertzjq
c049ce56cd
vim-patch:9.0.2058: tests: avoid error when no swap files exist (#25735)
Problem:  tests: avoid error when no swap files exist
Solution: use unlet! so that no error message is reported
          in case the variable does not exists

When s:GetSwapFileList() does not find any swapfiles, it will return an
empty list []. This means, that the variable 'name' will not be
declared, cause the following unlet command to fail and causing a 1 sec
delay on running the tests.

So let's instead use the :unlet! command which simply skips reporting an
error when the variable given as parameter does not exists.

closes: vim/vim#13396

a36acb7ac4
2023-10-21 18:14:32 +08:00
Maria José Solano
f1775da07f
feat(lsp): add snippet API (#25301) 2023-10-21 08:51:26 +02:00
zeertzjq
7a6e27958a
ci(cirrus): don't run lua/help_spec (#25498) 2023-10-21 07:21:19 +08:00
Famiu Haque
6c87d3e0fb refactor(options): get_option_value_strict() and SREQ_*
`SREQ_*` values are now actual typedef'd enums. `get_option_value_strict()` has also been refactored and split into two functions, `get_option_attrs()` for getting the option attributes, and `get_option_value_strict()` for getting the actual value. Moreover, it now returns an `OptVal`. Other miscellaneous refactors have also been made.
2023-10-20 13:35:47 +01:00
Christian Clason
f4b896198f vim-patch:9.0.2056: no digraph for quadruple prime
Problem:  no digraph for quadruple prime
Solution: add quadruple prime digraph using 4'

closes: vim/vim#13380

47416d1a74

Co-authored-by: Jonathan Wright <quaggy@gmail.com>
2023-10-20 13:03:36 +02:00
Gregory Anders
3ea13bca14 vim-patch:9.0.2053: zig filetype detection test wrong
Problem:  zig filetype detection test wrong
Solution: Remove .zir pattern, add new test for .zon pattern

closes: vim/vim#13389

a8c664a042

Co-authored-by: Gregory Anders <greg@gpanders.com>
2023-10-19 13:06:58 -05:00
zeertzjq
a096165977
vim-patch:9.0.2050: Vim9: crash with deferred function call and exception (#25715)
Problem:  Vim9: crash with deferred function call and exception
Solution: Save and restore exception state

Crash when a deferred function is called after an exception and another
exception is thrown

closes: vim/vim#13376
closes: vim/vim#13377

c59c1e0d88

The change in check_due_timer() is N/A as Nvim calls timer callbacks on
the main loop.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-19 18:34:48 +08:00
zeertzjq
09fb243bdd vim-patch:9.0.2045: tests: checking for swap files takes time
Problem:  tests: checking for swap files takes time
Solution: don't check for swap files  when test has been skipped

Check for swap files takes a considerable about of time, so don't do
that for skipped tests to avoid wasting time.

closes: vim/vim#13371

a0e1f06f04
2023-10-18 18:30:20 +08:00
zeertzjq
9e3640a779 vim-patch:9.0.2044: Vim9: exceptions confuse defered functions
Problem:  Vim9: exceptions confuse defered functions
Solution: save and restore exception state when calling defered
          functions

closes: vim/vim#13364
closes: vim/vim#13372

0672595fd5

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-18 18:29:47 +08:00
zeertzjq
366d0c7887
fix(move): check the correct buffer (#25698) 2023-10-18 10:34:55 +08:00
zeertzjq
bbc74d51ad
test(autocmd/termxx_spec): fix flakiness (#25694) 2023-10-18 07:19:29 +08:00
zeertzjq
4db4168aaf
vim-patch:8.2.4497: wrong color for half of wide character next to pum scrollbar (#25693)
Problem:    Wrong color for half of wide character next to pum scrollbar.
Solution:   Redraw the screen cell with the right color. (closes vim/vim#9874)

35d8c2010e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-10-18 06:40:08 +08:00
zeertzjq
bc5dfda441
vim-patch:9.0.2041: trim(): hard to use default mask (#25692)
Problem:  trim(): hard to use default mask (partly revert v9.0.2040)
Solution: use default mask when it is empty

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

Currently, an empty 'mask' will make 'trim()' call return 'text' value
that is passed in unmodified.  It is unlikely that someone is using it,
so the chances of scripts being broken by this change are low.

Also, this reverts commit 9.0.2040 (which uses v:none for the default
and requires to use an empty string instead).

closes: vim/vim#13358

8079917447

vim-patch:9.0.2040: trim(): hard to use default mask

Problem:  trim(): hard to use default mask
Solution: Use default 'mask' when it is v:none

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

'v:none' is already used to mean "use the default argument value" in
user defined functions.  See |none-function_argument| in help.

closes: vim/vim#13363

6e6386716f

Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
2023-10-18 06:08:14 +08:00
zeertzjq
272ef27115
vim-patch:9.0.2035: [security] use-after-free with wildmenu (#25687)
Problem:  [security] use-after-free with wildmenu
Solution: properly clean up the wildmenu when exiting

Fix wildchar/wildmenu/pum memory corruption with special wildchar's

Currently, using `wildchar=<Esc>` or `wildchar=<C-\>` can lead to a
memory corruption if using wildmenu+pum, or wrong states if only using
wildmenu. This is due to the code only using one single place inside the
cmdline process loop to perform wild menu clean up (by checking
`end_wildmenu`) but there are other odd situations where the loop could
have exited and we need a post-loop clean up just to be sure. If the
clean up was not done you would have a stale popup menu referring to
invalid memory, or if not using popup menu, incorrect status line (if
`laststatus=0`).

For example, if you hit `<Esc>` two times when it's wildchar, there's a
hard-coded behavior to exit command-line as a failsafe for user, and if
you hit `<C-\><C-\><C-N>` it will also exit command-line, but the clean
up code would not have hit because of specialized `<C-\>` handling.

Fix Ctrl-E / Ctrl-Y to not cancel/accept wildmenu if they are also
used for 'wildchar'/'wildcharm'. Currently they don't behave properly,
and also have potentially memory unsafe behavior as the logic is
currently not accounting for this situation and try to do both.
(Previous patch that addressed this: vim/vim#11677)

Also, correctly document Escape key behavior (double-hit it to escape)
in wildchar docs as it's previously undocumented.

In addition, block known invalid chars to be set in `wildchar` option,
such as Ctrl-C and `<CR>`. This is just to make it clear to the user
they shouldn't be set, and is not required for this bug fix.

closes: vim/vim#13361

8f4fb007e4

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-17 22:43:42 +08:00
zeertzjq
356a6728ac
vim-patch:9.0.2037: A few remaining cmdline completion issues with C-E/Y (#25686)
Problem:  A few remaining cmdline completion issues with C-E/Y
Solution: Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not
          used at the end

Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end

A few places in the cmdline completion code only works properly when the
user hits Tab (or 'wildchar') at the end of the cmdline, even though
it's supposed to work even in the middle of the line.

For fuzzy search, `:e ++ff`, and `:set hl=`, fix completion code to make
sure to use `xp_pattern_len` instead of assuming the entire `xp_pattern`
is the search pattern (since it contains texts after the cursor).

Fix Ctrl-E / Ctrl-Y to not jump to the end when canceling/accepting a
wildmenu completion. Also, make them work even when not using
`set wildoptions+=pum` as there is no drawback to doing so.
(Related issue where this was brought up: vim/vim#13331)

closes: vim/vim#13362

209ec90b9b

Cherry-pick ex_getln.c changes from patch 9.0.2035.

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-17 21:42:34 +08:00
zeertzjq
c9963e2212
vim-patch:9.0.2039: completion shows current word after completion restart (#25682)
Problem:  completion shows current word after completion restart
Solution: remove the word being completed after completion restart

The word being completed is shown in a completion list after completion
restart, because it isn't removed from the current buffer before
searching for matches.

Also adjust `Test_complete_add_onechar` to match the new behavior.

closes: vim/vim#13349

2e3cd52fa0

Co-authored-by: nwounkn <nwounkn@gmail.com>
2023-10-17 17:49:22 +08:00
Famiu Haque
5df4fdf253 refactor(options)!: make OptionSet v: values use typval
BREAKING CHANGE: This breaks the OptionSet autocommand, as the `v:` values associated with it (`v:option_new`, `v:option_old`, `v:option_oldlocal` and `v:option_oldglobal`) are now the same type as the option, instead of all option values being converted to strings.
2023-10-17 00:08:47 +06:00