Commit Graph

6897 Commits

Author SHA1 Message Date
Luuk van Baal
c6864b0d14 fix(column): redraw 'statuscolumn' on wrapped lines with 'relativenumber'
Problem:  The 'statuscolumn' is not redrawn on the wrapped part of a
          line when moving the cursor with 'relativenumber' set.
Solution: Redraw the 'statuscolumn' for the entire line height in the
          "col_rows" win_line() code path.
2024-01-16 12:13:36 +01:00
zeertzjq
46a7c1b319
vim-patch:partial:9.1.0027: Vim is missing a foreach() func (#27037)
Problem:  Vim is missing a foreach() func
Solution: Implement foreach({expr1}, {expr2}) function,
          which applies {expr2} for each item in {expr1}
          without changing it (Ernie Rael)

closes: vim/vim#12166

e79e207760

Partial port as this doesn't handle non-materialized range() lists.

vim-patch:c92b8bed1fa6

runtime(help): delete duplicate help tag E741 (vim/vim#13861)

c92b8bed1f

Co-authored-by: Ernie Rael <errael@raelity.com>
2024-01-16 11:30:35 +08:00
zeertzjq
267e90f31d
fix(edit): don't go to Terminal mode when stopping Insert mode (#27033) 2024-01-16 10:42:09 +08:00
zeertzjq
a34451982f
vim-patch:8.1.1968: crash when using nested map() (#27029)
Problem:    Crash when using nested map().
Solution:   Clear the pointer in prepare_vimvar(). (Ozaki Kiichi,
            closes vim/vim#4890, closes vim/vim#4891)

27da7de7c5

Cherry-pick Test_filter_map_nested() from patch 8.1.1964.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-01-16 09:32:57 +08:00
zeertzjq
73e1942abe
vim-patch:9.1.0009: Cannot easily get the list of matches (#27028)
Problem:  Cannot easily get the list of matches
Solution: Add the matchstrlist() and matchbufline() Vim script
          functions (Yegappan Lakshmanan)

closes: vim/vim#13766

Omit CHECK_LIST_MATERIALIZE(): it populates a List with numbers only,
and there is a check for strings below.

f93b1c881a

vim-patch:eb3475df0d92

runtime(doc): Replace non-breaking space with normal space (vim/vim#13868)

eb3475df0d

Co-authored-by: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com>
2024-01-16 08:00:08 +08:00
Daniel Steinberg
7589336120
feat(terminal): respond to OSC background and foreground request (#17197)
The motivation for this update is Issue #15365, where background=light
is not properly set for Nvim running from an Nvim :terminal. This can be
encountered when e.g., opening a terminal to make git commits, which
opens EDITOR=nvim in the nested terminal.

Under the implementation of this commit, the OSC response always
indicates a black or white foreground/background. While this may not
reflect the actual foreground/background color, it permits 'background'
to be retained for a nested Nvim instance running in the terminal
emulator. The behaviour matches Vim.
2024-01-15 10:12:07 -06:00
zeertzjq
9c202b9392
fix(grid): handle clearing half a double-width char (#27023) 2024-01-15 23:45:11 +08:00
Luuk van Baal
967c7abde3 fix(column): keep track of number of lines with number of signs
Problem:  Some edge cases to the old (pre-#26406) and current "b_signcols"
          structure result in an incorrectly sized "auto" 'signcolumn'.
Solution: * Implement a simpler 'signcolumn' validation strategy by immediately
            counting the number of signs in a range upon sign insertion and
            deletion. Decrease in performance here but there is a clear path
            forward to decreasing this performance hit by moving signs to a
            dedicated marktree, or by adding meta-data to the existing
            marktree which may be queried more efficiently?
          * Also replace "max_count" and keep track of the number of lines with
            a certain number of signs. This makes it so that it is no longer
            necessary to scan the entire buffer when the maximum number of signs
            decreases. This likely makes the commit a net increase in performance.
          * To ensure correctness we also have re-initialize the count for an
            edited region that spans multiple lines. Such an edit may move the
            signs within it. Thus we count and decrement before splicing the
            marktree and count and increment after.
2024-01-15 09:37:53 +00:00
Evgeni Chasnovski
0c850add3e
fix(colorscheme): default statusline groups usability #26921
Problem: Current values of `StatusLine` and `StatusLineNC` are currently
  designed to be visually distinctive while being not intrusive.
  However, the compromise was more shifted towards "not intrusive".
  After the feedback, statusline highlight groups should be designed to:
  - Make current window clearly noticeable. Meaning `StatusLine` and
    `StatusLineNC` should obviously differ.
  - Make non-current windows clearly separable. Meaning `StatusLineNC`
    and `Normal`/`NormalNC` should obviously differ.

Solution:
  - Update `StatusLineNC` to have more visible background.
  - Update `StatusLine` to be inverted variant of `StatusLineNC`.
  - Update `WinBar` and `WinBarNC` to not link to `StatusLine` and
    `StatusLineNC` because it makes two goals harder to achieve.
  - Update `TabLine` to link to `StatusLineNC` instead of `StatusLine`
    to not be very visually intrusive.
2024-01-13 16:35:37 -08:00
bfredl
2dc439c672
Merge pull request #26734 from bfredl/splitaroo
fix(buffer_updates): correct buffer updates when splitting empty line
2024-01-13 10:59:46 +01:00
bfredl
e5d9b15044 fix(buffer_updates): correct buffer updates when splitting empty line
fixes #11591
2024-01-13 10:39:32 +01:00
zeertzjq
64a50d08c4 vim-patch:9.1.0021: i_CTRL-R- doesn't work for multibyte chars in Replace mode
Problem:  i_CTRL-R- doesn't work for multibyte chars in Replace mode,
          Coverity complains missing return value for u_save_cursor()
Solution: Use mb_charlen() and del_chars() instead, handle failure mode
          for u_save_cursor() correctly (@zeertzjq)

closes: vim/vim#13846

424ec1f235
2024-01-13 08:31:01 +08:00
zeertzjq
2783b6b0a4 vim-patch:9.1.0015: i_CTRL-R- no longer works in replace mode
Problem:  i_CTRL-R- no longer works in replace mode
Solution: delete characters in replace mode before putting, add a test,
          add a bit warning into the documentation, that i_CTRL-R-P/O
          is not supported in Replace mode for now

fixes: vim/vim#13792
closes: vim/vim#13816

5d5cbb2b9a

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-01-13 08:29:47 +08:00
zeertzjq
4142b8cd2c vim-patch:8.2.3439: deleted lines go to wrong yank register
Problem:    Deleted lines go to wrong yank register.
Solution:   Reset y_append when not calling get_yank_register(). (Christian
            Brabandt, closes vim/vim#8872)

78eb9cce91

Nvim has removed y_append static variable and already works as expected.

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-01-13 08:29:47 +08:00
dundargoc
c8f696f2b0 vim-patch:9.1.0025: A few typos in tests and justify.vim
Problem:  A few typos in tests and justify.vim
Solution: fix them

closes: vim/vim#13848

dc4c37b9d5

Co-authored-by: dundargoc <gocdundar@gmail.com>
2024-01-12 22:24:52 +01:00
Lewis Russell
07a7c0ec99
Merge pull request #26994 from lewis6991/vimhelpers
test: big cleanup
2024-01-12 19:40:58 +00:00
Lewis Russell
795f896a57 test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
Lewis Russell
4f81f506f9 test: normalise nvim bridge functions
- remove helpers.cur*meths
- remove helpers.nvim
2024-01-12 17:53:27 +00:00
Lewis Russell
c30f2e3182 test: typing for helpers.meths 2024-01-12 13:01:06 +00:00
Christian Clason
f46ae13685 vim-patch:9.1.0016: default diff highlighting is too noisy
Problem:  default diff highlighting is too noisy
Solution: Link diff highlighting groups to new
          Added/Removed/Changed, revert previous change
          (Romain Lafourcade)

Remove diff* links added in vim/vim#13776 and doc added in commit b1392be

The links added in vim/vim#13776 are way too noisy for the contexts in which
the `diff` syntax is applied (git commits, patches, etc.).

This commit:

- removes those links
- adds new default highlighting groups Added, Changed and
  Removed
- links the diff highlighting groups to those new defaults
- removes the doc changes
- adjusts the syntax_completion test for those newly added group
  names

Note: Changes to the default color schemes will be handled separately,
by adding links to those newly created Added/Removed/Changed
highlighting groups.

related: vim/vim#13776
closes vim/vim#13825

124371c5a1

Co-authored-by: Romain Lafourcade <romain.lafourcade@razorfish.fr>
2024-01-12 13:52:26 +01:00
Lewis Russell
284e0ad26d test: use vim.mpack and vim.uv directly 2024-01-12 12:04:20 +00:00
Lewis Russell
56a2ec5c79 test: use vim.inspect directly 2024-01-12 12:04:20 +00:00
Lewis Russell
7a259d01ae test: remove helpers.sleep() 2024-01-12 12:04:19 +00:00
Lewis Russell
d33e1da9b7 test: do not inject vim module into global helpers 2024-01-12 12:04:18 +00:00
zeertzjq
3bcf8e5622
vim-patch:9.1.0011: regexp cannot match combining chars in collection (#26992)
Problem:  regexp cannot match combining chars in collection
Solution: Check for combining characters in regex collections for the
          NFA and BT Regex Engine

Also, while at it, make debug mode work again.

fixes vim/vim#10286
closes: vim/vim#12871

d2cc51f9a1

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-01-12 14:09:10 +08:00
Lewis Russell
2f9ee9b6cf fix(doc): improve doc generation of types using lpeg
Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
2024-01-11 16:24:12 +00:00
JD
a767c046f4
feat(vim.iter): add Iter:flatten (#26786)
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
2024-01-10 20:57:51 -06:00
zeertzjq
a7550a20e0
fix(pum): handle right-click menu repositioning with multigrid (#26975) 2024-01-10 12:56:43 +08:00
Gregory Anders
fa17a5ab49
fix(terminal): use terminal buffer for TermRequest autocommand (#26974) 2024-01-09 21:31:37 -06:00
Ghjuvan Lacambre
beca827212
feat(terminal): trigger TermRequest autocommand events (#22159)
This commit implements a new TermRequest autocommand event and has Neovim
emit this event when children of terminal buffers emit an OSC or DCS sequence
libvterm does not handle.

The TermRequest autocommand event has additional data in the
v:termrequest variable.

Co-authored-by: Gregory Anders <greg@gpanders.com>
2024-01-09 08:27:56 -06:00
zeertzjq
d54156ed08
fix(extmarks): blending space shouldn't overwrite wide char (#26960) 2024-01-09 19:16:44 +08:00
zeertzjq
ee3d4f6b90
fix(extmarks): handle overwriting right half of wide char (#26951) 2024-01-09 05:37:08 +08:00
bfredl
aeb053907d refactor(options): use schar_T representation for fillchars and listchars
A bit big, but practically it was a lot simpler to change over all
fillchars and all listchars at once, to not need to maintain two
parallel implementations.

This is mostly an internal refactor, but it also removes an arbitrary
limitation: that 'fillchars' and 'listchars' values can only be
single-codepoint characters. Now any character which fits into a single
screen cell can be used.
2024-01-08 14:37:55 +01:00
James McCoy
8861ad83fd
fix(test/tui_spec): pass the expected NULL-sentinel to execl()
Since execl() is a variadic function, it requries a NULL-terminal to
indicate the end of its argument list, c.f. exec(3)

> The first argument, by convention, should point to the filename
> associated with the file being executed.  The list of arguments *must*
> be terminated by a null pointer

This fixes the failure seen on aarch64 and i386, due to garbage data
being considered part of the variadic arguments.
2024-01-06 06:57:31 -05:00
zeertzjq
14918118e8 vim-patch:9.1.0012: regression with empty inner blocks introduced
Problem:  regression with empty inner blocks introduced
          (after v9.1.0007)
Solution: Set correct cursor position, Check for visual mode
          being active (Maxim Kim)

relates: vim/vim#13514
closes: vim/vim#13819

3779516988

Co-authored-by: Maxim Kim <habamax@gmail.com>
2024-01-06 06:25:37 +08:00
zeertzjq
f38f86b1ad vim-patch:9.1.0007: can select empty inner text blocks
Problem:  can select empty inner text blocks
          (laurentalacoque)
Solution: make selecting empty inner text blocks an error

textobjects: Make selecting inner empty blocks an error

fixes: vim/vim#13514
closes: vim/vim#13523

ad4d7f446d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-01-06 06:24:02 +08:00
luukvbaal
c509f4907b
fix(column): fill 'statuscolumn' clickdefs with evaluated width (#26891) 2024-01-05 21:34:54 +08:00
zeertzjq
e09adfdcff
fix(terminal): check if mouse on statusline/tabline/winbar/vsep (#26892) 2024-01-05 10:59:52 +08:00
zeertzjq
dab5844082
vim-patch:9.1.0010: Keymap completion is not available (#26888)
Problem:  Keymap completion is not available
Solution: Add keymap completion (Doug Kearns)

Add keymap completion to the 'keymap' option, user commands and builtin
completion functions.

closes: vim/vim#13692

81642d9d6f

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2024-01-05 08:23:51 +08:00
Jaehwang Jung
dc48a98f9a fix(decorations): validate botline for on_win
Problem:
Many decoration providers (treesitter injection highlighting, semantic
token highlighting, inlay hint) rely on the correctness of the `botline`
argument of `on_win` callback. However, `botline` can be smaller than
the actual line number of the last displayed line if some lines are
folded. In such cases, some decorations will be missing in the lines not
covered by `botline`.

Solution:
Validate `botline` when invoking `on_win`.

NOTE:
It seems that the old code was deliberately avoiding this presumably due
to performance reasons. However, I haven't experienced noticeable lag
after this change, and I believe the cost of botline computation would
be much smaller than the cost of decoration providers.
2024-01-04 11:37:00 +00:00
Christian Clason
bdfea2a891 vim-patch:9.1.0001: when closing window, wincmd p may fail
Avoid `prevwin == curwin` when closing `curwin`

Problem:  When closing the current window (or when moving it to a tabpage), the
          previous window may refer to the new current window
          (`winnr() == winnr('#')`) if that window is selected as the
          new current window.

Solution: Set `prevwin = NULL` when switching away from an invalid `curwin` and
          the target window was the `prevwin`.
          (Sean Dewar)

related: vim/vim#4537
closes: vim/vim#13762

bf44b69d1f

Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
2024-01-03 23:09:55 +01:00
zeertzjq
12cdee7245
vim-patch:9.1.0002: a closing fold expr, may start a new fold (#26876)
Problem:  a closing fold expression may unexpectedly start a new fold
          when it should end a fold
          (reported by Shota Nozaki)
Solution: if a fold hasn't started yet, do not immediately
          start a new fold with level 1
          (Shota Nozaki)

fixes: vim/vim#12768
closes: vim/vim#13748

0689b87059

Co-authored-by: Shota Nozaki <emonkak@gmail.com>
2024-01-04 05:36:38 +08:00
Lewis Russell
3734519e3b feat(lua): add noref to deepcopy
Problem:

Currently `deepcopy` hashes every single tables it copies so it can be
reused. For tables of mostly unique items that are non recursive, this
hashing is unnecessarily expensive

Solution:

Port the `noref` argument from Vimscripts `deepcopy()`.

The below benchmark demonstrates the results for two extreme cases of
tables of different sizes. One table that uses the same table lots of
times and one with all unique tables.

| test                 | `noref=false` (ms) | `noref=true` (ms) |
| -------------------- | ------------------ | ----------------- |
| unique tables (50)   | 6.59               | 2.62              |
| shared tables (50)   | 3.24               | 6.40              |
| unique tables (2000) | 23381.48           | 2884.53           |
| shared tables (2000) | 3505.54            | 14038.80          |

The results are basically the inverse of each other where `noref` is
much more performance on tables with unique fields, and `not noref` is
more performant on tables that reuse fields.
2024-01-03 19:17:52 +00:00
Justin M. Keyes
04f2f864e2 refactor: format test/* 2024-01-03 02:09:29 +01:00
Justin M. Keyes
59d117ec99 build: enable lintlua for test/ dir
Problem:
Not all Lua code is checked by stylua. Automating code-style is an
important mechanism for reducing time spent on accidental
(non-essential) complexity.

Solution:
- Enable stylua for entire `test/` directory.
- Exclude these high-churn files until this issue is resolved: https://github.com/JohnnyMorganz/StyLua/issues/829
  ```
  test/functional/ui/decorations_spec.lua  | 3560 ++++++++++++++++++++++++++++++++++++----------------
  test/functional/ui/float_spec.lua        | 5826 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
  test/functional/ui/multigrid_spec.lua    | 1349 ++++++++++++++------
  ```
- Make surgical changes to these files (or add `stylua: ignore` in some
  small scopes) to improve the result:
  ```
  test/functional/vimscript/msgpack_functions_spec.lua | 1414 +++++++++++++++------
  test/functional/api/buffer_spec.lua                  | 1389 +++++++++++----------
  test/functional/api/vim_spec.lua                     | 2740 +++++++++++++++++++++++-----------------
  ```
- These "high churn" files are NOT excluded because the changes are
  largely an improvement:
  ```
  test/functional/plugin/lsp_spec.lua      | 2198 ++++++++++++++++++---------------
  test/functional/plugin/shada_spec.lua    | 4078 +++++++++++++++++++++++++++++++++++-------------------------
  test/functional/ui/cmdline_spec.lua      | 1199 +++++++++++-------
  test/functional/ui/popupmenu_spec.lua    | 1267 +++++++++++--------
  test/functional/ui/messages_spec.lua     | 1643 +++++++++++++++---------
  ```
- TODO: how to check "all directories"? With `GLOB_DIRS *` and `/.deps/` (or
  `.deps/`) in `.styluaignore`, Lua code in `.deps/` is still checked...
2024-01-03 02:09:28 +01:00
TheLeoP
3f788e73b3
feat(lsp): support connect via named pipes/unix domain sockets (#26032)
Closes https://github.com/neovim/neovim/issues/26031

Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
2024-01-02 10:08:36 +01:00
Evgeni Chasnovski
4ee656e4f3
feature(diagnostic): add vim.diagnostic.count() (#26807)
feat(diagnostic): add `vim.diagnostic.count()`

Problem: Getting diagnostic count based on the output of
  `vim.diagnostic.get()` might become costly as number of diagnostic
  entries grows. This is because it returns a copy of diagnostic cache
  entries (so as to not allow users to change them in place).
  Getting information about diagnostic count is frequently used in
  statusline, so it is important to be as fast as reasonbly possible.

Solution: Add `vim.diagnostic.count()` which computes severity
  counts without making copies.
2024-01-01 15:03:50 -06:00
Gregory Anders
164f1ea06d refactor(health): refactor provider healthchecks
* Prefer pure Lua functions over vim.fn
* Split up provider healthchecks into separate modules to help manage
  complexity
2024-01-01 20:12:37 +01:00
Christian Clason
b9cf388045 test(functional): remove faulty pending check
Problem: `functional/vimscript/api_functions_spec` skips a test if the
runtime files are not generated, but this check was broken in a
refactor.

Solution: Since runtime files are now generated for all test targets, do
not skip this test.
2023-12-30 18:09:16 +01:00
dundargoc
d51b615747 refactor: fix luals warnings 2023-12-30 17:40:53 +01:00
dundargoc
bf0be0f63e build: various improvements
- Use `#pragma once` for `cmake.config/config.h.in`
- Remove unused variable `CACHED_GENERATED_DIR`
- Reorganize and sort variables
- Introduce `STYLUA_DIRS` variable to ensure the `formatlua` and
  `lintlua-stylua` operates on the same files.
- Adjust variable scope to avoid using hacky directory properties.
- Add more necessary runtime files as test dependencies
2023-12-30 14:22:25 +01:00
dundargoc
31d7007bf7 docs: convert BACKERS.md to backers.txt
There is no reason for this file to be in project root, which is crowded
as is. This also fits nicely part of the ongoing work towards gathering
as much of the documentation as possible into one place.
2023-12-28 22:41:01 +01:00
zeertzjq
2b9d3869f8
fix(drawline): don't use temporary "v" variable when not needed (#26777) 2023-12-28 19:26:59 +08:00
dundargoc
714b075197
docs: small fixes (#26651)
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: WillLillis <wlillis@umass.edu>
2023-12-28 10:28:48 +08:00
JD
46ceefb52b
fix(clipboard): make getreg() accurate for clipboard registers (#26740)
Problem:  getreg("*") / getreg("+") disagree with :registers.
Solution: Avoid falling back to unnamed register if provider fails.
2023-12-28 09:57:13 +08:00
zeertzjq
b3940cf8a1
vim-patch:9.0.2188: cursor wrong after { in single line buffer (#26766)
Problem:  cursor wrong after { in single line buffer
          (Edwin Chan)
Solution: do not place the cursor at the end for a single
          line buffer when moving backwards
          (Gary Johnson)

closes: vim/vim#13780
closes: vim/vim#13783

9e6549d2fb

Co-authored-by: Gary Johnson <garyjohn@spocom.com>
2023-12-28 08:12:20 +08:00
zeertzjq
d82e105727
vim-patch:9.0.2187: Visual not drawn with 'breakindent' when line doesn't fit (#26765)
Problem:  Visual selection isn't drawn with 'breakindent' when the line
          doesn't fit in the window (Jaehwang Jung)
Solution: Adjust wlv->fromcol also for 'breakindent' (zeertzjq)

closes: vim/vim#13767
closes: vim/vim#13768

23627722d3
2023-12-28 07:47:22 +08:00
Raphael
382ea4d402
fix(inccommand): don't preview in Ex mode (#26587) 2023-12-27 15:18:22 +08:00
Nacho Nieva
c26dc1f77c
feat(defaults): map Q and @x to repeat in Visual mode (#26495) 2023-12-27 07:26:18 +08:00
dundargoc
0009c337bc test: simplify vim.fs tests
The exec_lua wrapper is no longer necessary.
2023-12-26 13:22:43 +01:00
luukvbaal
ec74538044
fix(column): correct width after truncated 'statuscolumn' error (#26737)
Problem:  Default number column has incorrect width after 'statuscolumn'
          is unset due to an error, but was also truncated.
Solution: Reverse 'statuscolumn' error and truncate return branches.
2023-12-26 09:07:58 +08:00
luukvbaal
bbd5c6363c
feat(extmarks): add virt_text_repeat_linebreak flag (#26625)
Problem:  Unable to predict which byte-offset to place virtual text to
          make it repeat visually in the wrapped part of a line.
Solution: Add a flag to nvim_buf_set_extmark() that causes virtual
          text to repeat in wrapped lines.
2023-12-26 07:16:03 +08:00
dundargoc
0a598c13b1 feat(vim.deprecate): only issue warning if neovim version is high enough
As specified by MAINTAIN.md, features should be soft deprecated at first
(meaning no warnings) to give people a chance to adjust. The problem
with this approach is that deprecating a feature becomes harder than
usual as during the soft deprecation period you need to remember not to
issue a warning, and during the hard deprecation period you need to
remember to start issuing a warning.

This behavior is only enforced if the `plugin` parameter is `nil` as
plugins may not want this specific behavior.
2023-12-25 21:20:09 +01:00
bfredl
e8acbc1ade refactor(cpoptions): remove 'p'
Deleting a cpo flag a day keeps the doctor away

We don't need two different ways to indent LISP code
2023-12-25 14:13:52 +01:00
zeertzjq
ddc8dd187d
refactor(drawline): reduce size of wlv.extra[] (#26733)
It's now only used for transchar_hex(), which only needs 11 bytes.
2023-12-25 18:57:55 +08:00
zeertzjq
a42df11786
test(extmarks): improve tests for ui_watched (#26732) 2023-12-25 15:50:58 +08:00
zeertzjq
2877672d70
feat(health): make :checkhealth support more split modifiers (#26731) 2023-12-25 10:21:13 +08:00
Pablo Arias
2ff2785c39
feat(health): checkhealth buffer can show in a split window (#26714)
:checkhealth now respects :vertical and :horizontal.
For example:
  :vertical checkhealth foo bar
will open the healthcheck buffer in a vertical split.
2023-12-25 08:30:56 +08:00
Jaehwang Jung
7fa292c52d fix(treesitter): outdated highlight due to tree with outdated region
Problem:
A region managed by an injected parser may shrink after re-running the
injection query. If the updated region goes out of the range to be
parsed, then the corresponding tree will remain outdated, possibly
retaining the nodes that shouldn't exist anymore. This results in
outdated highlights.

Solution:
Re-parse an invalid tree if its region intersects the range to be
parsed.
2023-12-24 09:47:59 +01:00
zeertzjq
0b66ab42c7
Merge pull request #26642 from famiu/refactor/options/misc
refactor(options): miscellanous refactors
2023-12-24 14:25:08 +08:00
Famiu Haque
547ccc2681
refactor(options): remove side effects from check_num_option_bounds() 2023-12-24 11:22:25 +06:00
zeertzjq
3c667d3e0f
fix(mappings): fix mapset() not replacing map with backslash (#26719) 2023-12-23 15:30:44 +08:00
Lewis Russell
2b0acacb3c fix(decor): allow adding providers during redraw
Fixes: #26652
2023-12-22 20:27:07 +00:00
Michal Liszcz
031088fc0a
fix(lsp): filetype matching to documentSelector in dynamic capabilities (#25425)
Use the get_language_id client option to resolve the filetype when
matching the document selector in a dynamic capability.


Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
2023-12-22 15:03:13 +01:00
bfredl
d9d9d94343
Merge pull request #26528 from bfredl/nodrawstate
refactor(drawline): remove LineDrawState and wlv->saved_n_extra
2023-12-22 11:49:06 +01:00
Steven Arcangeli
92204b06e7
refactor(lsp): move glob parsing to util (#26519)
refactor(lsp): move glob parsing to vim.glob

Moving the logic for using vim.lpeg to create a match pattern from a
glob into `vim.glob`. There are several places in the LSP spec that
use globs, and it's very useful to have glob matching as a
generally-available utility.
2023-12-22 11:40:01 +01:00
bfredl
66ac327db2 refactor(drawline): remove LineDrawState and wlv->saved_n_extra
We do not need an enum to keep track of what place in win_line() we
currently are at. We already have a variable which keeps track where
in the code we currently are (and thus what part of the line we are
currently rendering), it is called the _program counter_. When we need
non-linear or self-referential control-flow anyway for a laugh, we
have a mechanism for that, it is called _function calls_.

Do not "save" and "restore" the wlv->n_extra state every time the
columns are to be drawn. This sort of thing needs to go away. Instead of
setting the n_extra variables and then going to the outer while loop,
the text in the columns can be rendered by just simply putting the text
into the cells of the screen line, right away. Even in nvim this can be
tricky sometimes, luckily we can use function calls to abstract this
logic, which means that this handy data structure called the _call
stack_ is handling saving away state temporarily, and restoring it back
when we need it again.

Lastly, but not least, as we now have direct control how signs
are rendered, these can be stored as schar_T[2] and be directly
put on screen as such.
2023-12-22 10:54:28 +01:00
Luuk van Baal
2ded2e75f4 fix(column): avoid exceeding configured 'signcolumn' width 2023-12-21 10:57:01 +00:00
Evgeni Chasnovski
720a3518e3 refactor(runtime): rewrite 'vim' color scheme in Lua
Problem: Bundled 'vim' color scheme is written in Vimscript which
  implicitly assumes that the file is ported from Vim.
  This is not the case, at it is currently the Neovim's way of providing
  backward compatibility for color schemes.

Solution: Rewrite it in Lua to indicate that this runtime file comes
  from Neovim.
2023-12-21 11:06:39 +01:00
Christian Clason
2ed784f385 vim-patch:9.0.2179: no filetype detection for execline scripts
Problem:  no filetype detection for execline scripts
Solution: Add filetype detection for execline

as a prior to adding syntax support for execline (see
https://github.com/djpohly/vim-execline/issues/2), i went ahead and made
the filetype detection for execline scripts.

closes: vim/vim#13689

Signed-Off-By: Mazunki Hoksaas <rolferen@gmail.com>

63210c214a

Co-authored-by: Mazunki Hoksaas <rolferen@gmail.com>
2023-12-19 23:48:02 +01:00
zeertzjq
c95845f3df
vim-patch:9.0.2177: Wrong cursor position when dragging out of window (#26661)
Problem:  Wrong cursor position when dragging out of window.
Solution: Don't use ScreenCols[] when mouse is not in current window.

closes: vim/vim#13717

ec14924368
2023-12-20 05:58:48 +08:00
zeertzjq
a61d8b615c
vim-patch:9.0.2178: reg_executing() wrong for :normal with range (#26660)
Problem:  reg_executing() returns wrong result in :normal with range
          when 'showcmd' is set (after 8.2.4705).
Solution: Reset "pending_end_reg_executing" when executing a register.

closes: vim/vim#13707

615202bd0e
2023-12-20 05:27:18 +08:00
zeertzjq
49efdf8413
test: "diff" flag of 'fillchars' (#26657) 2023-12-19 22:46:38 +08:00
zeertzjq
674a20ac47
test: sign on wrapped line with signcolumn=number (#26654) 2023-12-19 21:25:33 +08:00
dundargoc
7f6b775b45 refactor: use bool to represent boolean values 2023-12-19 11:43:21 +01:00
dundargoc
693aea0e9e
docs: small fixes (#26448)
Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
Co-authored-by: Jordan Mandel <jordan.mandel@live.com>
2023-12-19 13:29:13 +08:00
zeertzjq
1cf51a07a6
fix(api): don't set coladd of mark (#26648) 2023-12-19 08:01:05 +08:00
Amanda Graven
428edcde70
feat(api): add forward and back mouse buttons 2023-12-18 21:24:27 +01:00
Gregory Anders
3a4aa3fc58
refactor: soft-deprecate diagnostic signs configured with :sign-define (#26618)
Diagnostic signs should now be configured with vim.diagnostic.config(),
but "legacy" sign definitions should go through the standard deprecation
process to minimize the impact from breaking changes.
2023-12-18 11:04:44 -06:00
zeertzjq
7d279a09e0
fix(lua): handle array with holes in luaeval() (#26630) 2023-12-18 12:14:37 +08:00
zeertzjq
d956bc6379
fix(options): setting 'scroll' with resized grid (#26628) 2023-12-18 10:15:23 +08:00
zeertzjq
75b8f4c8cb
test(core/job_spec): fix flakiness (#26623) 2023-12-18 07:09:32 +08:00
dundargoc
404fdb0f36 build: cmake fixes
- add EXTERNALPROJECT_OPTIONS variable to main build
- use `REQUIRED` keyword for IWYU.
- remove check_c_compiler_flag checks when `ENABLE_COMPILER_SUGGESTIONS`
  is `ON`. If we explicitly enable it then we probably want it to give
  an error if it doesn't exist, rather than silently skip it.
- Move dependency interface libraries to their find module and use them
  as a pseudo-imported target.
- Remove BUSTED_OUTPUT_TYPE. It's not used and we can reintroduce it
  again if something similar is needed.
- Use LINK_OPTIONS intead of LINK_FLAGS when generating the `--version`
  output.
2023-12-16 21:06:28 +01:00
notomo
c18f3cfcdb
fix(api): crash after nvim_win_set_config title/footer validation error (#26606) 2023-12-16 21:58:04 +08:00
Evgeni Chasnovski
574519d9d6 feat(highlight): tweak default color scheme
Problem: Updating default color scheme produced some feedback.

Solution: Address the feedback.

Outline of the changes:

- Colors `Grey1` and `Grey2` are made a little bit more extreme (dark -
  darker, light - lighter) to increase overall contrast.

- `gui` colors are treated as base with `cterm` colors falling back to
  using 0-15 colors which come from terminal emulator.

- Update highlight group definition to not include attribute definition
  if it is intended to staty uncolored.

- Tweak some specific highlight groups.

- Add a list of Neovim specific highlight groups which are now defined
  differently in a breaking way.

- Minor tweaks in several other places related to default color scheme.
2023-12-16 14:43:03 +01:00
zeertzjq
19fed6bde1
vim-patch:9.0.2168: Moving tabpages on :drop may cause an endless loop (#26605)
Problem:  Moving tabpages on :drop may cause an endless loop
Solution: Disallow moving tabpages on :drop when cleaning up the arglist
          first

Moving tabpages during drop command may cause an endless loop

When executing a :tab drop command, Vim will close all windows not in
the argument list. This triggers various autocommands. If a user has
created an 'au Tabenter * :tabmove -' autocommand, this can cause Vim to
end up in an endless loop, when trying to iterate over all tabs (which
would trigger the tabmove autocommand, which will change the tpnext
pointer, etc).

So instead of blocking all autocommands before we actually try to edit
the given file, lets simply disallow to move tabpages around. Otherwise,
we may change the expected number of events triggered during a :drop
command, which users may rely on (there is actually a test, that expects
various TabLeave/TabEnter autocommands) and would therefore be a
backwards incompatible change.

Don't make this an error, as this could trigger several times during the
drop command, but silently ignore the :tabmove command in this case (and
it should in fact finally trigger successfully when loading the given
file in a new tab). So let's just be quiet here instead.

fixes:  vim/vim#13676
closes: vim/vim#13686

df12e39b8b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-16 21:30:08 +08:00
mathew
e38027ef69 feat(ui): completeopt support popup like vim 2023-12-16 18:59:59 +08:00
bfredl
7e7da962de
Merge pull request #26512 from famiu/refactor/options/type_flags
refactor(options): remove option type macros
2023-12-16 11:39:30 +01:00
zeertzjq
046efa106e
vim-patch:323dda1484d9 (#26583)
runtime(termdebug): add Tbreak command

closes: vim/vim#13656

323dda1484

Co-authored-by: iam28th <artyom28th@gmail.com>
2023-12-15 06:27:49 +08:00
Famiu Haque
3c2c022e5e
refactor(options): remove option type macros
Problem: We have `P_(BOOL|NUM|STRING)` macros to represent an option's type, which is redundant because `OptValType` can already do that. The current implementation of option type flags is also too limited to allow adding multitype options in the future.

Solution: Remove `P_(BOOL|NUM|STRING)` and replace it with a new `type_flags` attribute in `vimoption_T`. Also do some groundwork for adding multitype options in the future.

Side-effects: Attempting to set an invalid keycode option (e.g. `set t_foo=123`) no longer gives an error.
2023-12-14 16:46:42 +06:00
Luuk van Baal
320e9c1c21 fix(extmark): only invalidate unpaired marks on deleted rows
Problem:  Unpaired marks are invalidated if its column is deleted,
          which may just be a "placeholder" column, e.g. for signs.
Solution: Only remove unpaired marks if its entire row is deleted.
2023-12-14 08:55:00 +00:00
zeertzjq
aa05133b0e
test(nvim_open_term): don't resize after creating terminal (#26570)
This makes the screen states consistently have no EOB lines.
2023-12-14 16:41:08 +08:00
Raphael
619407eb54
feat(nvim_open_term): convert LF => CRLF (#26384)
Problem:
Unlike termopen(), nvim_open_term() PTYs do not carriage-return the
cursor on newline ("\n") input.

    nvim --clean
    :let chan_id = nvim_open_term(1, {})
    :call chansend(chan_id, ["here", "are", "some", "lines"])

Actual behavior:

    here
        are
           some
               lines

Expected behaviour:

    here
    are
    some
    lines

Solution:
Add `force_crlf` option, and enable it by default.
2023-12-14 16:08:00 +08:00
Gregory Anders
29d5ff6ac4 fix(diagnostic): check for sign namespace instead of sign group 2023-12-13 09:30:13 -06:00
Raphael
8122470f83
refactor(diagnostic): set sign by using extmark (#26193)
after sign implementation refactor by using extmark, we can use
`nvim_buf_set_extmark` to set diagnostic sign instead use `sign_define`
2023-12-13 08:19:53 -06:00
zeertzjq
d65c6a0baf
vim-patch:9.0.2159: screenpos() may crash with neg. column (#26542)
Problem:  screenpos() may crash with neg. column
Solution: validate and correct column

closes: vim/vim#13669

ec54af4e26
2023-12-13 06:17:50 +08:00
Will Hopkins
69ffbb76c2
feat(iter): add Iter.take (#26525) 2023-12-12 14:27:24 -06:00
Gregory Anders
1907abb4c2
fix(stream): do not close handle if it is already closing (#26537)
uv_close asserts that a handle is not already closing. We can guard
against this assertion failure by manually checking the handle's closing
status ourselves.
2023-12-12 13:19:46 -06:00
zeertzjq
b40170f7a3
fix(lua): memory leak when using invalid syntax with exists() (#26530) 2023-12-12 20:34:02 +08:00
Raphael
1d4a5cd185
feat(eval): exists() function supports checking v:lua functions (#26485)
Problem:  Vimscript function exists() can't check v:lua functions.
Solution: Add support for v:lua functions to exists().
2023-12-12 19:06:22 +08:00
bfredl
e69834744b
Merge pull request #26486 from glepnir/fix_linebyte
fix(eval): use no_ff instead of ffdos as condition
2023-12-12 11:57:56 +01:00
glepnir
d95e3a4c9c fix: use no_ff instead of ffdos as condition
Problem: line2byte behavior is changed after commit b051b13. It no
longer return `-1` on empty buffer.

Solution: use `nof_ff` instead of `!ff_dos` as condition. Then
compatible behavior of line2byte() is restored.
2023-12-12 13:49:04 +08:00
zeertzjq
a9fbba81d5
test(treesitter/fold_spec): fix flakiness (#26524) 2023-12-12 10:44:17 +08:00
zeertzjq
b76cc974b9
fix(tui): don't forget to update cursor visibility (#26523) 2023-12-12 09:44:46 +08:00
Lewis Russell
8097b4a725
Merge pull request #26506 from tomtomjhj/tsfold
fix(treesitter): improve vim.treesitter.foldexpr
2023-12-11 19:30:53 +00:00
Jaehwang Jung
b88d1fb15f test(treesitter): more foldexpr tests 2023-12-12 02:29:59 +09:00
dundargoc
529498685b
Merge pull request #26458 from famiu/refactor/options/optionindex 2023-12-10 16:26:08 +01:00
zeertzjq
096211a87b
test: make text-only snapshots work (#26494) 2023-12-10 07:06:48 +08:00
zeertzjq
1037ce2e46 test: avoid repeated screen lines in expected states
This is the command invoked repeatedly to make the changes:

    :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
2023-12-09 22:15:02 +08:00
zeertzjq
5e43630a26 test: allow avoiding repeated screen lines in expected states
Allow a "*count" suffix in a screen line to repeat the screen line for
"count" times.

The change is made to Screen:expect() and Screen:get_snapshot() instead
of Screen:render() so that screen expectations generated using code can
still work and test failures can still be readable.

A snapshot is now also printed on failure so that there is no need to
run the test again with Screen:snapshot_util().
2023-12-09 22:14:50 +08:00
Famiu Haque
6346987601
refactor(options): reduce findoption() usage
Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over.

Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings.
2023-12-09 17:54:43 +06:00
Gregory Anders
c651fb3042
refactor(tui): use synchronized updates around actual buf flush (#26478)
Rather than writing the synchronized update begin and end sequences into
the TUI's internal buffer (where it is later flushed to the TTY), write
these sequences directly to the TTY before and after the TUI's internal
buffer is itself flushed to the TTY.

This guarantees that a synchronized update is always used when we are
actually sending data to the TTY. This means we do not need to keep
track of the TUI's "dirty" state (any sequences which affect the TUI
state will be written in the TUI's internal buffer, which is now
guaranteed to only ever be written when a synchronized update is
active).
2023-12-09 10:44:16 +08:00
zeertzjq
b8e227b621
vim-patch:9.0.2154: The option[] array is not sorted (#26475)
Problem:  The options[] array is not sorted alphabetically.
Solution: Sort it alphabetically.  Add a test.  Avoid unnecessary loop
          iterations in findoption().

closes: vim/vim#13648

Cherry-pick Test_set_one_column() change from patch 8.2.0432.

f48558e10a
2023-12-09 07:18:21 +08:00
Luuk van Baal
2289ca273c perf(column): avoid counting when max signs are removed from a range 2023-12-08 15:42:18 +00:00
zeertzjq
808fbe67a8
test(tui_spec): update cursor_address test for flush start (#26464) 2023-12-08 11:42:17 +08:00
zeertzjq
3bb5d2f219
test: use termopen() instead of :terminal more (#26462) 2023-12-08 08:00:27 +08:00
Gregory Anders
5e3c1b976a
test: fix Windows tests failures (#26461) 2023-12-08 06:58:03 +08:00
Gregory Anders
75aaec1b60
Merge pull request #26456 from gpanders/ignore-vim-runtime
fix(terminal): ignore $VIM and $VIMRUNTIME in pty jobs
2023-12-07 13:02:02 -08:00
Gregory Anders
8957df4f22 test: forward $VIMRUNTIME in child nvim instances 2023-12-07 11:54:22 -08:00
Gregory Anders
b2d471ab33
fix(lua): allow nil values in serialized Lua arrays (#26329)
When we convert a Lua table to an Object, we consider the table a
"dictionary" if it contains only string keys, and an array if it
contains all numeric indices with no gaps. While rare, Lua tables can
have both strictly numeric indices and gaps (e.g. { [2] = 2 }). These
currently cannot be serialized because it is not considered an array.

However, we know the maximum index of the table and as long as all of
the keys in the table are numeric, it is still possible to serialize
this table as an array. The missing indices will have nil values.
2023-12-07 08:01:27 -08:00
Luuk van Baal
4a34da82c1 perf(column): keep track of number of lines that hold up the 'signcolumn'
Problem:  The entire marktree needs to be traversed each time a sign is
          removed from the sentinel line.
Solution: Remove sentinel line and instead keep track of the number of
          lines that hold up the 'signcolumn' in "max_count". Adjust this
          number for added/removed signs, and set it to 0 when the
          maximum number of signs on a line changes. Only when
          "max_count" is decremented to 0 due to sign removal do we need
          to check the entire buffer.

          Also replace "invalid_top" and "invalid_bot" with a map of
          invalid ranges, further reducing the number of lines to be
          checked.

          Also improve tree traversal when counting the number of signs.
          Instead of looping over the to be checked range and counting
          the overlap for each row, keep track of the overlap in an
          array and add this to the count.
2023-12-07 14:22:24 +00:00
Justin M. Keyes
cca6c4c698 feat(rpc): allow empty string key in msgpack => Vim conversion
Problem:
Since e057b38e70 #20757 we support empty key in JSON encode/decode,
but we don't allow it in RPC object => Vim dict conversion. But empty
string is a valid key in Vim dicts and the msgpack spec.

Empty string key was disallowed in 7c01d5ff92 (2014) but that
commit/PR doesn't explicitly discuss it, so presumably it was a "seems
reasonable" decision (or Vimscript didn't allow empty keys until later).

Solution:
Remove the check in `object_to_vim()`. Note that
`tv_dict_item_alloc_len` will invoke `memcpy(…, 0)` but that's allowed
by the C spec: https://stackoverflow.com/a/3751937/152142
2023-12-07 12:57:25 +01:00
zeertzjq
aba954b662
fix(terminal): never propagate $COLORTERM from outer env (#26440)
If $COLORTERM is "truecolor" but the user sets 'notermguicolors',
propagating $COLORTERM to :terminal usually doesn't work well.
2023-12-07 19:14:56 +08:00
zeertzjq
94c2703a03
test(unit): correct header name (#26446) 2023-12-07 17:02:08 +08:00
zeertzjq
93011add10 test(inccommand_spec): actually trigger 'inccommand' preview 2023-12-07 15:32:56 +08:00
zeertzjq
1dba570e63
fix(inccommand): save and restore '[ and '] marks (#26442)
Undoing a change moves '[ and '] marks, so it is necessary to save and
restore them.
2023-12-07 12:04:02 +08:00
zeertzjq
6c3ddd8c51
test: set 'termguicolors' in outer Nvim instance (#26437)
Currently, the value of $COLORTERM in :terminal in tests depends on
outer environment because of 'notermguicolors'.

If $COLORTERM is not set in :terminal, an inner Nvim instance will try
to detect 'termguicolors' support, which may interfere with tests.

So set 'termguicolors' in outer Nvim instance unless $COLORTERM needs to
be overridden, and unset it in inner Nvim instance when running TUI.
2023-12-07 10:16:00 +08:00
zeertzjq
6b00b8a369
test(terminal): remove unnecessary string operations (#26434) 2023-12-07 07:15:37 +08:00
bfredl
8bb5089974
Merge pull request #26381 from bfredl/delaycolors
fix(startup): only send one default_colors_set event during startup
2023-12-06 19:58:02 +01:00
Gregory Anders
08545bd45b
Merge pull request #26407 from gpanders/default-tgc
feat(defaults): enable 'termguicolors' by default when supported by terminal
2023-12-06 10:55:50 -08:00
Gregory Anders
a5a346678a test: set notermguicolors in tests
Set 'notermguicolors' in tests which spawn a child Nvim process to force
existing tests to use 16 colors. Also refactor the child process
invocation to make things a little bit less messy.
2023-12-06 10:38:44 -08:00
bfredl
8f10362cdc fix(startup): only send one default_colors_set event during startup
If the color scheme is changed in a startup script, nvim used to send
multiple default_colors_set events, one for the default color scheme
and one for the user's chosen color scheme. This would cause flicker in
some UI:s. Throttle this event until we actually start drawing on the
screen.

fixes #26372
2023-12-06 18:46:39 +01:00
Justin M. Keyes
ca7f8786a0
test: unreliable 'nofsync' test #26423
Followup to 27501d3b6a.

Problem:
CI sometimes fails. Something is triggering an extra fsync().

    FAILED   test/functional/core/fileio_spec.lua @ 52: fileio fsync() with 'nofsync' #8304
    test/functional/core/fileio_spec.lua💯 Expected objects to be the same.
    Passed in:
    (number) 5
    Expected:
    (number) 4

Solution:
Relax the assertion.
2023-12-06 08:26:30 -08:00
Emanuel
e057b38e70
fix(json): allow objects with empty keys #25564
Problem:
Empty string is a valid JSON key, but json_decode() treats an object
with empty key as ":help msgpack-special-dict". #20757

    :echo json_decode('{"": "1"}')
    {'_TYPE': [], '_VAL': [['', '1']]}

Note: vim returns `{'': '1'}`.

Solution:
Allow empty string as an object key.

Note that we still (currently) disallow empty keys in object_to_vim() (since 7c01d5ff92):
f64e4b43e1/src/nvim/api/private/converter.c (L333-L334)

Fix #20757

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-12-06 07:56:04 -08:00
Justin M. Keyes
c84af395e8
test: 'nofsync' with deadly signal #26415
Problem:
The test for 'nofsync' swapfile preservation on a deadly signal, does
not actually assert anything.

followup to 1fd29a2884

Solution:
Check that swapfile contents are present after getting SIGTERM.
TODO: this doesn't really verify that 'fsync' was called; it still
passes with this patch:

    diff --git a/src/nvim/main.c b/src/nvim/main.c
    index 216e39f3e81c..7a635520401d 100644
    --- a/src/nvim/main.c
    +++ b/src/nvim/main.c
    @@ -838,7 +838,7 @@ void preserve_exit(const char *errmsg)
           if (errmsg != NULL) {
             os_errmsg("Vim: preserving files...\r\n");
           }
    -      ml_sync_all(false, false, true);  // preserve all swap files
    +      ml_sync_all(false, false, false);  // preserve all swap files
           break;
         }
       }

However it correctly fails with this patch, at least:

    diff --git a/src/nvim/main.c b/src/nvim/main.c
    index 216e39f3e81c..f2306c310ddc 100644
    --- a/src/nvim/main.c
    +++ b/src/nvim/main.c
    @@ -838,7 +838,6 @@ void preserve_exit(const char *errmsg)
           if (errmsg != NULL) {
             os_errmsg("Vim: preserving files...\r\n");
           }
    -      ml_sync_all(false, false, true);  // preserve all swap files
           break;
         }
       }
2023-12-06 07:11:36 -08:00
zeertzjq
f22e9e10f9
vim-patch:8.2.3695: confusing error for missing key (#26420)
Problem:    Confusing error for missing key.
Solution:   Use the actualy key for the error. (closes vim/vim#9241)

5c1ec439f0

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-12-06 16:49:40 +08:00
Gregory Anders
5b40a1c09d
feat(lua): implement Iter:join() (#26416) 2023-12-05 18:35:22 -08:00
dundargoc
cc38086039
docs: small fixes (#26243)
Co-authored-by: umlx5h <umlx5h21@protonmail.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Evan Farrar <evan@evanfarrar.com>
2023-12-06 08:04:21 +08:00
zeertzjq
06ff540e1c
vim-patch:9.0.2151: 'breakindent' is not drawn after diff filler lines (#26412)
Problem:  'breakindent' is not drawn after diff filler lines.
Solution: Correct check for whether 'breakindent' should be drawn.

closes: vim/vim#13624

588f20dece

Cherry-pick Test_diff_with_syntax() change from patch 9.0.1257.
2023-12-06 07:16:02 +08:00
Justin M. Keyes
27501d3b6a
test: fileio_spec is unreliable/flaky #26404
Problem:
CI sometimes fails. Something is triggering an extra fsync().

    FAILED   test/functional/core/fileio_spec.lua @ 52: fileio fsync() codepaths #8304
    test/functional/core/fileio_spec.lua:87: Expected objects to be the same.
    Passed in:
    (number) 3
    Expected:
    (number) 2
    stack traceback:
            test/functional/core/fileio_spec.lua:87: in function <test/functional/core/fileio_spec.lua:52>

Solution:
Relax the assertion to `fsync >= 2` instead of exactly 2.

(Note this is not a behavior change: the next assertion has always
checked `fsync == 4`, it's just that the intermediate 3rd fsync was
never explicitly asserted.)
2023-12-05 12:52:06 -08:00
bfredl
ca4fe083e5
Merge pull request #26361 from luukvbaal/invalid
fix(extmarks): restore old position before revalidating
2023-12-05 16:13:39 +01:00
Riccardo Mazzarini
0b74ad0a64
refactor(api): complete conversion from Dictionary to Dict(opts) (#26365) 2023-12-05 19:33:57 +08:00
Christian Clason
c9828200ac vim-patch:9.0.2148: Vim does not detect pacman.log file
Problem:  Vim does not detect pacman.log file
Solution: Detect pacmanlogs and add syntax highlighting

pacman.log is a filetype common to Arch Liux and related distributions.
Add some simple syntax highlighting for the pacmanlog filetype.

closes: vim/vim#13618

1e5d66408e

Co-authored-by: Ronan Pigott <ronan@rjp.ie>
2023-12-05 09:45:13 +01:00
Jaehwang Jung
3159a2c28f
fix(change): update fold after on_bytes (#26364)
Problem:
With vim.treesitter.foldexpr, `o`-ing two lines above a folded region
opens the fold. This does not happen with legacy foldexprs. For example,
make a markdown file with the following text (without indentation),
enable treesitter fold, and follow the instruction in the text.

    put cursor on this line and type zoo<Esc>
    initially folded, revealed by zo
    # then this fold will be opened
    initially folded, revealed by o<Esc>

Analysis:
* `o` updates folds first (done in `changed_lines`), evaluating
  foldexpr, and then invokes `on_bytes` (done in `extmark_splice`).
* Treesitter fold allocates the foldinfo for added lines (`add_range`)
  on `on_bytes`.
* Therefore, when treesitter foldexpr is invoked while running `o`, it
  sees outdated foldinfo.

Solution:
`extmark_splice`, and then `changed_lines`. This seems to be the
standard order in other places, e.g., `nvim_buf_set_lines`.
2023-12-05 08:40:48 +08:00
Justin M. Keyes
c3836e40a2
build: enable lintlua for test/unit/ dir #26396
Problem:
Not all Lua code is checked by stylua. Automating code-style is an
important mechanism for reducing time spent on accidental
(non-essential) complexity.

Solution:
- Enable lintlua for `test/unit/` directory.
- TODO: only `test/functional/` remains unchecked.

previous: 45fe4d11ad
previous: 517f0cc634
2023-12-04 14:32:39 -08:00
Jongwook Choi
cf612c64b0
fix(treesitter): allow passing lang to vim.treesitter.get_node() now correctly takes opts.lang (#26360)
PROBLEM: `vim.treesitter.get_node()` does not recognize the `lang` in
the option table. This option was used in somewhere else, for instance,
`vim.treesitter.dev` (for `inspect_tree`) but was never implemented.

SOLUTION: Make `get_node()` correctly use `opts.lang` when getting a
treesitter parser.
2023-12-04 10:00:49 +01:00
zeertzjq
5651c1ff27
vim-patch:9.0.2145: wrong scrolling in insert mode with smoothscroll (#26375)
Problem:  Wrong scrolling in Insert mode with 'smoothscroll' at the
          bottom of the window.
Solution: Don't use set_topline() when 'smoothscroll' is set.

fixes: vim/vim#13612
closes: vim/vim#13613

5b4d1fcbf0
2023-12-04 06:42:47 +08:00
Christian Clason
988b472d90
feat(treesitter): highlight help files by default (#26347) 2023-12-03 15:58:27 +01:00
Evgeni Chasnovski
64a14026d7
feat(highlight): update default color scheme
Problem: Default color scheme is suboptimal.

Solution: Start using new color scheme. Introduce new `vim` color scheme
for opt-in backward compatibility.

------
Main design ideas
- Be "Neovim branded".
- Be minimal for 256 colors with a bit more shades for true colors.
- Be accessible through high enough contrast ratios.
- Be suitable for dark and light backgrounds via exchange of dark and
  light palettes.

------
Palettes

- Have dark and light variants. Implemented through exporeted
  `NvimDark*` and `NvimLight*` hex colors.

- Palettes have 4 shades of grey for UI elements and 6 colors (red,
  yellow, green, cyan, blue, magenta).

- Actual values are computed procedurally in Oklch color space based on
  a handful of hyperparameters.

- Each color has a 256 colors variant with perceptually closest color.

------
Highlight groups

Use:

- Grey shades for general UI according to their design.

- Bold text for keywords (`Statement` highlight group). This is an
  important choice to increase accessibility for people with color
  deficiencies, as it doesn't rely on actual color.

- Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some
  minor text UI elements.

- Cyan as main syntax color, i.e. for function usage (`Function`
  highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI
  elements.

- Red to generally mean high user attention, i.e. errors; in particular
  for `ErrorMsg`, `DiffDelete`, `DiagnosticError`.

- Yellow very sparingly only with true colors to mean mild user
  attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`.

- Blue very sparingly only with true colors as `DiagnosticHint` and some
  additional important syntax group (like `Identifier`).

- Magenta very carefully (if at all).

------
Notes

- To make tests work without relatively larege updates, each one is
  prepended with an equivalent of the call `:colorscheme vim`.

  Plus some tests which spawn new Neovim instances also now use 'vim'
  color scheme.

  In some cases tests are updated to fit new default color scheme.
2023-12-02 18:53:19 +02:00
Luuk van Baal
1cc358aed6 fix(extmarks): restore old position before revalidating 2023-12-02 12:35:52 +01:00
zeertzjq
9d7544ac4c vim-patch:9.0.2143: [security]: buffer-overflow in ex_substitute
Problem:  [security]: buffer-overflow in ex_substitute
Solution: clear memory after allocating

When allocating the new_start pointer in ex_substitute() the memory
pointer points to some garbage that the following for loop in
ex_cmds.c:4743 confuses and causes it to accessing the new_start pointer
beyond it's size, leading to a buffer-overlow.

So fix this by using alloc_clear() instead of alloc(), which will
clear the memory by NUL and therefore cause the loop to terminate
correctly.

Reported by @henices, thanks!

closes: vim/vim#13596

abfa13ebe9

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
9cc346119b vim-patch:9.0.2142: [security]: stack-buffer-overflow in option callback functions
Problem:  [security]: stack-buffer-overflow in option callback functions
Solution: pass size of errbuf down the call stack, use snprintf()
          instead of sprintf()

We pass the error buffer down to the option callback functions, but in
some parts of the code, we simply use sprintf(buf) to write into the error
buffer, which can overflow.

So let's pass down the length of the error buffer and use sprintf(buf, size)
instead.

Reported by @henices, thanks!

b39b240c38

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
01edcd6db8 vim-patch:9.0.2141: [security]: buffer-overflow in suggest_trie_walk
Problem:  [security]: buffer-overflow in suggest_trie_walk
Solution: Check n before using it as index into byts array

Basically, n as an index into the byts array, can point to beyond the byts
array. So let's double check, that n is within the expected range after
incrementing it from sp->ts_curi and bail out if it would be invalid.

Reported by @henices, thanks!

0fb375aae6

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
7402655132 vim-patch:9.0.2140: [security]: use-after-free in win-enter
Problem:  [security]: use-after-free in win-enter
Solution: validate window pointer before calling win_enter()

win_goto() may stop visual mode, if it is active. However, this may in
turn trigger the ModeChanged autocommand, which could potentially free
the wp pointer which was valid before now became stale and points to now
freed memory.

So before calling win_enter(), let's verify one more time, that the
wp pointer still points to a valid window structure.

Reported by @henices, thanks!

eec0c2b3a4

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
387c5ba3de
revert: "memory: Free buffers after freeing variables" (#26356)
This reverts commit fe30d8ccef.

The original commit intends to prevent heap-use-after-free with EXITFREE
caused by changedtick_di, which is no longer a problem.

Freeing buffers after freeing variables will cause heap-use-after-free
with EXITFREE when a partial is used as prompt callback.
2023-12-02 09:55:11 +08:00
zeertzjq
fedbf32250
vim-patch:9.0.2139: html.angular ft is problematic (#26357)
Problem:  html.angular ft is problematic
Solution: partly revert v9.0.2137

The html.angular filetype causes issues and does not trigger FileType
autocommands for the html or angular filetypes.

So let's roll back that particular change and detect this only as html
file

related: https://github.com/vim/vim/pull/13594#issuecomment-1834465890

closes: vim/vim#13604

4f3480c943

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 09:42:16 +08:00
zeertzjq
548f03c66c
refactor: change event_create() to a macro (#26343)
A varargs functions can never be inlined, so a macro is faster.
2023-12-01 15:22:22 +08:00
zeertzjq
130cb4815a
fix(api): use a conditional stack for nvim_cmd (#26341) 2023-12-01 13:56:04 +08:00
ObserverOfTime
307d5bcc79 vim-patch:9.0.2137: Can't detect angular & mustache filetypes
Problem:  Can't detect angular & mustache filetypes
Solution: Detect *.mustache as Mustache filetype;
          detect *.component.html as html.angular filetype

closes: vim/vim#13594

7bed263c34
2023-11-30 18:40:27 +01:00
Gregory Anders
884a83049b
fix(tui): grow termkey's internal buffer for large escape sequences (#26309)
Some escape sequences (in particular, OSC 52 paste responses) can be
very large, even unbounded in length. These can easily overflow
termkey's internal buffer. In order to process these long sequences,
dynamically grow termkey's internal buffer.
2023-11-30 08:04:33 -06:00
bfredl
3b6dd8608d
Merge pull request #23657 from luukvbaal/extmark
fix(extmark): restore extmarks when completing original text
2023-11-30 11:48:16 +01:00
zeertzjq
85be914879
test: unskip more terminal tests on Windows (#26315) 2023-11-30 10:55:21 +08:00
zeertzjq
62dff43947
test(ex_terminal_spec): match descriptions (#26314) 2023-11-30 08:56:21 +08:00
zeertzjq
90b213990f test: :terminal when 'shell' uses backslashes 2023-11-30 07:32:28 +08:00
zeertzjq
73691b6c3d
test(ex_terminal_spec): unskip tests that work on Windows (#26310) 2023-11-30 07:06:23 +08:00
Luuk van Baal
8e97edb93f fix(extmark): restore extmarks when completing original text 2023-11-29 23:38:27 +01:00
zeertzjq
a6cba103ce
refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
Luuk van Baal
f4001d27ef perf(column): only invalidate lines affected by added sign 2023-11-29 10:17:15 +00:00
bfredl
584c6c25cc
Merge pull request #26292 from luukvbaal/decor
fix(decorations): do not apply sign highlight id as range attr id
2023-11-29 11:12:25 +01:00
zeertzjq
640680ccce
vim-patch:9.0.2134: ml_get error when scrolling (#26264)
Problem:  ml_get error when scrolling after delete
Solution: mark topline to be validated in main_loop
          if it is larger than current buffers line
          count

reset_lnums() is called after e.g. TextChanged autocommands and it may
accidentally cause curwin->w_topline to become invalid, e.g. if the
autocommand has deleted some lines.

So verify that curwin->w_topline points to a valid line and if not, mark
the window to have w_topline recalculated in main_loop() in
update_topline() after reset_lnums() returns.

fixes: vim/vim#13568
fixes: vim/vim#13578

c4ffeddfe5

The error doesn't happen in Nvim because Nvim triggers TextChanged after
calling update_topline().

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-29 13:24:24 +08:00
Luuk van Baal
a0e9ef09d7 fix(decorations): do not apply sign highlight id as range attr id 2023-11-29 03:57:23 +01:00
zeertzjq
aa9d9cafd0
vim-patch:9.0.2135: No test for mode() when executing Ex commands (#26282)
Problem:  No test for mode() when executing Ex commands
Solution: Add some test cases and simplify several other test cases.
          Also add a few more test cases for ModeChanged.

closes: vim/vim#13588

fcaeb3d42b
2023-11-29 06:51:00 +08:00
dundargoc
79b6ff28ad refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
Luuk van Baal
35cec0de4a fix(column): redraw and update signcols for paired extmark
Problem:  Signcolumn width does not increase when ranged sign does not
          start at sentinel line.
Solution: Handle paired range of added sign when checking signcols.
2023-11-28 16:44:20 +00:00
bfredl
ba564442ae
Merge pull request #26249 from bfredl/concealchar
feat(decoration): allow conceal_char to be a composing char
2023-11-28 11:01:21 +01:00
bfredl
ae3685798d feat(decoration): allow conceal_char to be a composing char
decor->text.str pointer must go. This removes it for conceal char,
in preparation for a larger PR which will also handle the sign case.

By actually allowing composing chars for a conceal chars, this
becomes a feature and not just a refactor, as a bonus.
2023-11-28 10:35:25 +01:00
zeertzjq
e6d38c7dac
vim-patch:9.0.2133: Cannot detect overstrike mode in Cmdline mode (#26263)
Problem:  Cannot detect overstrike mode in Cmdline mode
Solution: Make mode() return "cr" for overstrike

closes: vim/vim#13569

d1c3ef1f47
2023-11-28 11:46:20 +08:00
Christian Clason
a314703cf1
vim-patch:9.0.2131: not all nushell files detected (#26260)
Problem:  not all nushell files detected
Solution: use *.nu to detect nushell files

closes: vim/vim#13586

b9efc72c24

Co-authored-by: Daniel Buch Hansen <boogiewasthere@gmail.com>
2023-11-28 07:58:31 +08:00
Dmytro Soltys
72ed99319d fix(treesitter): don't invalidate parser when discovering injections
When parsing with a range, languagetree looks up injections and adds
them if needed. This explicitly invalidates parser, making `is_valid`
report `false` both when including and excluding children.

This is an attempt to describe desired behaviour of `is_valid` in tests,
with what ended up being a single line change to satisfy them.
2023-11-27 15:53:26 +01:00
zeertzjq
a03bd2b878
test: check vim.wait() error message in fast context (#26242) 2023-11-27 18:24:32 +08:00
Lewis Russell
84bbe4b0ca fix(lua): disallow vim.wait() in fast contexts
`vim.wait()` cannot be called in a fast callback since the main loop
cannot be run in that context as it is not reentrant

Fixes #26122
2023-11-27 09:09:21 +00:00
Christian Clason
38e98754a5 vim-patch:9.0.2128: runtime(swig): add syntax and filetype plugins
Add syntax and filetype plugins for SWIG (Simplified Wrapper Interface
Generator) description files.

The default syntax for .i files highlights comments in a reverse
color scheme which doesn't look well.  This syntax builds
on vim's c++ syntax by adding highlighting for common swig
directives and user defined directives.  For an alternative
syntax, see vimscript vim/vim#1247 (which I found after writing this).

closes: vim/vim#13562

2e31065a65

Co-authored-by: Julien Marrec <julien.marrec@gmail.com>
Co-authored-by: Matěj Cepl <mcepl@cepl.eu>
2023-11-26 00:41:59 +01:00
James McCoy
0da62b579f
Merge pull request #26203 from jamessan/swapfile-test-fix
fix(oldtest): always use a 64-bit int for swapfile block number
2023-11-25 07:08:27 -05:00
luukvbaal
6a2a37b1e1
fix(mouse): avoid dragging when clicking next to popupmenu (#26201) 2023-11-25 07:10:19 +08:00
James McCoy
a1ded1b113
fix(oldtest): always use a 64-bit int for swapfile block number
09d4133 changed blocknr_T from long to int64_t, so pe_bnum is now always 64-bit.  This was an incompatible change in the swapfile format for 32-bit systems, but there have been no complaints in the past 9 years so just adjust the test.
2023-11-24 15:22:00 -05:00
zeertzjq
55dbf5c379
fix(messages): validate msg_grid before using msg_grid_pos (#26189) 2023-11-24 10:44:19 +08:00
luukvbaal
a8a93e517f
fix(mouse): avoid dragging after click label popupmenu callback (#26187) 2023-11-24 09:15:50 +08:00
zeertzjq
fe94e04893
vim-patch:9.0.2126: unused assignments when checking 'listchars' (#26182)
Problem:  Unused assignments when checking the value of 'listchars'.
Solution: Loop only once when just checking the value.  Add a test to
          check that this change doesn't cause double-free.

closes: vim/vim#13559

00624a2fa0
2023-11-24 06:52:50 +08:00
zeertzjq
9510346141
vim-patch:9.0.2125: File info disappears when 'cmdheight' has decreased (#26180)
Problem:  File info disappears immediately when 'cmdheight' has just
          decreased due to switching tabpage and 'shortmess' doesn't
          contain 'o' or 'O'.
Solution: Make sure msg_row isn't smaller than cmdline_row.

fixes: vim/vim#13560
closes: vim/vim#13561

40ed6711bd
2023-11-24 06:13:24 +08:00
Luuk van Baal
df399ea0d2 fix(column): reset decor state before starting from top 2023-11-23 16:27:17 +00:00