Commit Graph

6207 Commits

Author SHA1 Message Date
glepnir
5183651773 fix(highlight): correct hi command output 2023-09-17 17:47:51 +08:00
zeertzjq
f5953edbac
fix(float): update position of anchored windows first (#25133) 2023-09-14 07:42:22 +08:00
bfredl
b04286a187 feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions

The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.

Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).

Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.

Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2023-09-12 10:38:23 +02:00
Jaehwang Jung
65738202f8
fix(decorations): better approximation of botline #24794
Problem:
* The guessed botline might be smaller than the actual botline e.g. when
  there are folds and the user is typing in insert mode. This may result
  in incorrect treesitter highlights for injections.
* botline can be larger than the last line number of the buffer, which
  results in errors when placing extmarks.

Solution:
* Take a more conservative approximation. I am not sure if it is
  sufficient to guarantee correctness, but it seems to be good enough
  for the case mentioned above.
* Clamp it to the last line number.

Co-authored-by: Lewis Russell <me@lewisr.dev>
2023-09-11 12:29:39 -07:00
Sergey Slipchenko
f859d16aea
fix(tests): set SHELL=sh #24941
Problem:
Some tests fail with $SHELL=fish #6172
Related: https://github.com/neovim/neovim/pull/6176

Solution:
Replace "echo -n" with "printf", because "echo" in sh may be provided
as a shell builtin, which does not accept an "-n" flag to avoid a
trailing newline (e.g. on macos). "printf" is more portable (defined by
POSIX) and it does not output a trailing newline by itself.
Fixes #6172

TODO:
Other test failures may be related to "session leader" issue: https://github.com/neovim/neovim/issues/2354
Checked by running `:terminal ./build/bin/tty-test` from Nvim with
`shell=/bin/fish` (inherited from `$SHELL`) and it indeed complains
about "process does not own the terminal". With `shell=sh` it doesn't complain. And
unsetting `$SHELL` seems to make `nvim` to fall back to `shell=sh`.

    FAILED   test/functional/terminal/tui_spec.lua @ 1017: TUI paste: terminal mode
    test/functional/terminal/tui_spec.lua:1024: Row 1 did not match.
    Expected:
      |*tty ready                                         |
      |*{1: }                                                 |
      |*                                                  |
      |                                                  |
      |{5:^^^^^^^                                           }|
      |{3:-- TERMINAL --}                                    |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |*process does not own the terminal                 |
      |*                                                  |
      |*[Process exited 2]{1: }                               |
      |                                                  |
      |{5:^^^^^^^                                           }|
      |{3:-- TERMINAL --}                                    |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
        test/functional/ui/screen.lua:622: in function '_wait'
        test/functional/ui/screen.lua:352: in function 'expect'
        test/functional/terminal/tui_spec.lua:1024: in function <test/functional/terminal/tui_spec.lua:1017>

    FAILED   test/functional/terminal/tui_spec.lua @ 1551: TUI forwards :term palette colors with termguicolors
    test/functional/terminal/tui_spec.lua:1567: Row 1 did not match.
    Expected:
      |*{1:t}ty ready                                         |
      |                                                  |
      |*                                                  |
      |                                                  |
      |{2:^^^^^^^                                           }|
      |                                                  |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |*{1:p}rocess does not own the terminal                 |
      |                                                  |
      |*[Process exited 2]                                |
      |                                                  |
      |{2:^^^^^^^                                           }|
      |                                                  |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
        test/functional/ui/screen.lua:622: in function '_wait'
        test/functional/ui/screen.lua:352: in function 'expect'
        test/functional/terminal/tui_spec.lua:1567: in function <test/functional/terminal/tui_spec.lua:1551>
2023-09-11 10:01:00 -07:00
bfredl
616a9bac32
Merge pull request #24901 from faergeek/more-intuitive-cursor-update
fix(api): more intuitive cursor updates in nvim_buf_set_text
2023-09-11 10:45:45 +02:00
Christian Clason
60e5d0fbcc vim-patch:9.0.1891: No runtime support for Mojo
Problem:  No runtime support for Mojo
Solution: Add basic filetype and syntax plugins

closes: vim/vim#13062
closes: vim/vim#13063

0ce2c594d0

Co-authored-by: Mahmoud Abduljawad <mahmoud@masaar.com>
2023-09-11 10:05:54 +02:00
Sergey Slipchenko
d22172f36b
fix(api): more intuitive cursor updates in nvim_buf_set_text
Fixes #22526
2023-09-11 08:16:03 +04:00
zeertzjq
e8d25675a2 vim-patch:9.0.1894: CI: trailing whitespace in tests
Problem:  CI: trailing white space in tests
Solution: clean up the trailing white space

e5f7cd0a60

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-11 11:16:50 +08:00
zeertzjq
6484f338a4 vim-patch:9.0.1893: CI: strptime test fails on BSD14
Problem:  CI: strptime test fails on BSD14
Solution: Skip the test

983d808674

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-11 11:16:50 +08:00
zeertzjq
2b475cb5cc
fix(mouse): click on 'statuscolumn' with 'rightleft' (#25090) 2023-09-11 08:29:33 +08:00
Sergey Slipchenko
af0684f0d5
test: unignore test which froze sourcehut (#25067) 2023-09-11 05:53:05 +08:00
dundargoc
9f8f287c61 build: remove luarocks
Luarocks is no longer needed after
25e51d393a.
2023-09-10 15:32:47 +02:00
Grace Petryk
5e3cf9fb4b
feat(lsp): improve control over placement of floating windows (#24494) 2023-09-10 10:02:23 +02:00
bfredl
d4e80a051e
Merge pull request #25039 from glepnir/fix_hl
fix(highlight): add create param in nvim_get_hl api function
2023-09-09 13:01:40 +02:00
zeertzjq
b9d9cd7742 vim-patch:partial:9.0.1886: Various Typos
Problem:  Various Typos
Solution: Fix Typos

This is a collection of typo related commits.

closes: vim/vim#12753
closes: vim/vim#13016

ee17b6f70d

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl>
Co-authored-by: Viktor Szépe <viktor@szepe.net>
Co-authored-by: nuid64 <lvkuzvesov@proton.me>
Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com>
Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
2023-09-09 17:58:32 +08:00
zeertzjq
bc09fc04b8 vim-patch:9.0.1877: missing test for patch 9.0.1873
Problem:  missing test for patch 9.0.1873
Solution: add a test trying to exchange windows

Add a test, making sure that switching windows is not allowed when
textlock is active, e.g. when running `:s/<pat>/\=func()/`

18d2709aa1

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-09 17:53:01 +08:00
glepnir
8afb3a49c0 fix(highlight): add create param in nvim_get_hl 2023-09-09 17:15:58 +08:00
bfredl
5970157e1d refactor(map): enhanced implementation, Clean Code™, etc etc
This involves two redesigns of the map.c implementations:

1. Change of macro style and code organization

The old khash.h and map.c implementation used huge #define blocks with a
lot of backslash line continuations.

This instead uses the "implementation file" .c.h pattern. Such a file is
meant to be included multiple times, with different macros set prior to
inclusion as parameters. we already use this pattern e.g. for
eval/typval_encode.c.h to implement different typval encoders reusing a
similar structure.

We can structure this code into two parts. one that only depends on key
type and is enough to implement sets, and one which depends on both key
and value to implement maps (as a wrapper around sets, with an added
value[] array)

2. Separate the main hash buckets from the key / value arrays

Change the hack buckets to only contain an index into separate key /
value arrays
This is a common pattern in modern, state of the art hashmap
implementations. Even though this leads to one more allocated array, it
is this often is a net reduction of memory consumption. Consider
key+value consuming at least 12 bytes per pair. On average, we will have
twice as many buckets per item.
Thus old implementation:

  2*12 = 24 bytes per item

New implementation

  1*12 + 2*4 = 20 bytes per item

And the difference gets bigger with larger items.
One might think we have pulled a fast one here, as wouldn't the average size of
the new key/value arrays be 1.5 slots per items due to amortized grows?
But remember, these arrays are fully dense, and thus the accessed memory,
measured in _cache lines_, the unit which actually matters, will be the
fully used memory but just rounded up to the nearest cache line
boundary.

This has some other interesting properties, such as an insert-only
set/map will be fully ordered by insert only. Preserving this ordering
in face of deletions is more tricky tho. As we currently don't use
ordered maps, the "delete" operation maintains compactness of the item
arrays in the simplest way by breaking the ordering. It would be
possible to implement an order-preserving delete although at some cost,
like allowing the items array to become non-dense until the next rehash.

Finally, in face of these two major changes, all code used in khash.h
has been integrated into map.c and friends. Given the heavy edits it
makes no sense to "layer" the code into a vendored and a wrapper part.
Rather, the layered cake follows the specialization depth: code shared
for all maps, code specialized to a key type (and its equivalence
relation), and finally code specialized to value+key type.
2023-09-08 12:48:46 +02:00
bfredl
6985e12cae refactor(build): derocksify luacheck 2023-09-07 15:26:30 +02:00
Tom Praschan
131a1ee82d
feat(lsp): add original LSP Location as item's user_data in locations_to_items (#23743) 2023-09-07 10:12:02 +02:00
Evgeni Chasnovski
d272143318
fix(diagnostic): always return copies of diagnostic items (#25010) 2023-09-06 12:54:18 -05:00
zeertzjq
0909843647 vim-patch:9.0.1874: CI may fail in test_recover_empty_swap
Problem:  CI may fail in test_recover_empty_swap
Solution: Set directory option

Fix failing Test_recover_empty_swap test

:recover by default not only looks in the current directory, but also in
~/tmp for files to recover. If it finds some files to recover, it will
interactively prompt for a file to recover. However, prompting doesn't
work when running the test suite (and even if it would, there is no one
that can answer the prompt).

So it doesn't really make sense during testing, to inspect different
directories for swap files and prompt and wait (which will lead to a
timeout and therefore a failing test).

So set the 'directory' option temporarily to the current directory only
and reset it back once the test finishes.

closes: vim/vim#13038

1c7397f3f1

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-06 06:28:23 +08:00
zeertzjq
3e5a7f258a vim-patch:partial:9.0.0669: too many delete() calls in tests
Problem:    Too many delete() calls in tests.
Solution:   Use deferred delete where possible.

db77cb3c08

Include test_recover.vim changes only.
Cherry-pick test_recover.vim change from patch 8.2.3637.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-09-06 06:28:23 +08:00
zeertzjq
33d6cf70cc
test(old): reorder test_quickfix.vim to match upstream (#25029) 2023-09-06 06:28:03 +08:00
Lewis Russell
4ce9875feb
Merge pull request #25006 from lewis6991/fix/systemkill
`vim.system` fixes and improvements
2023-09-05 21:50:18 +01:00
Lewis Russell
80d1333b73 refactor(vim.system): factor out on_exit handling 2023-09-05 17:10:04 +01:00
Lewis Russell
6d5f12efd2 fix(vim.system): make timeout work properly
Mimic the behaviour of timeout(1) from coreutils.
2023-09-05 17:10:01 +01:00
zeertzjq
c3e176f6e2
fix(options): correct condition for calling did_set_option() (#25026) 2023-09-05 20:03:25 +08:00
Lewis Russell
a44521f46e fix(vim.system): let on_exit handle cleanup after kill
Fixes #25000
2023-09-05 10:18:26 +01:00
zeertzjq
65d3378009
vim-patch:9.0.1866: undo is synced after character find (#25021)
vim-patch:9.0.1866: undo is synced after character find

Problem:  Undo is synced after character find.
Solution: Set no_u_sync when calling gotchars_nop().

closes: vim/vim#13022
closes: vim/vim#13024

dccc29c228
2023-09-05 06:25:51 +08:00
zeertzjq
c431d820e7
vim-patch:9.0.1856: issues with formatting positional arguments (#25013)
Problem:  issues with formatting positional arguments
Solution: fix them, add tests and documentation

closes: vim/vim#12140
closes: vim/vim#12985

Tentatively fix message_test. Check NULL ptr.

aa90d4f031

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-09-04 08:49:50 +08:00
zeertzjq
bebdf1dab3
vim-patch:9.0.1848: [security] buffer-overflow in vim_regsub_both() (#25001)
Problem:  buffer-overflow in vim_regsub_both()
Solution: Check remaining space

ced2c7394a

The change to do_sub() looks confusing. Maybe it's an overflow check?
Then the crash may not be applicable to Nvim because of different casts.
The test also looks confusing. It seems to source itself recursively.
Also don't call strlen() twice on evaluation result.

N/A patches for version.c:
vim-patch:9.0.1849: CI error on different signedness in ex_cmds.c
vim-patch:9.0.1853: CI error on different signedness in regexp.c

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 13:47:55 +08:00
zeertzjq
087ef52997
vim-patch:9.0.1840: [security] use-after-free in do_ecmd (#24993)
Problem:  use-after-free in do_ecmd
Solution: Verify oldwin pointer after reset_VIsual()

e1dc9a6275

N/A patches for version.c:
vim-patch:9.0.1841: style: trailing whitespace in ex_cmds.c

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 11:15:43 +08:00
Maria José Solano
517dfdf0fc
fix(shada): update marks when using delmarks! (#24978) 2023-09-03 10:34:09 +08:00
zeertzjq
b55010a539 vim-patch:9.0.1846: [security] crash in fullcommand
Problem:  crash in fullcommand
Solution: Check for typeval correctly

4c6fe2e2ea

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 09:14:30 +08:00
zeertzjq
272c4fba83
vim-patch:9.0.1852: i_CTRL-O does not reset Select Mode (#24990)
Problem:  i_CTRL-O does not reset Select Mode
Solution: Reset select mode on CTRL-O in insert mode

closes: vim/vim#13001
closes: vim/vim#12115

d69aecf141

Co-authored-by: pierreganty <pierreganty@gmail.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 09:04:58 +08:00
dundargoc
f30844008b
build: download busted from own neovim/deps repository
Downloading the necessary files all at once instead of doing dependency
handling with luarocks speeds up installation immensely. We speed up the
process even more by using luv as a replacement for the C modules in the
busted dependencies, which allows us to skip costly compilation times.

Co-authored-by: bfredl <bjorn.linse@gmail.com>
2023-09-03 00:38:10 +02:00
zeertzjq
0c86828ac5
fix(ui): avoid ambiguity about chunk that clears part of line (#24982)
Co-authored-by: bfredl <bjorn.linse@gmail.com>
2023-09-02 18:50:12 +08:00
zeertzjq
bc43575c52
test(shada/marks_spec): load the file with the marks (#24979) 2023-09-02 10:23:43 +08:00
zeertzjq
592a8f1e90
vim-patch:9.0.1828: cursor wrong with virt text before double-width char (#24967)
Problem:  Wrong cursor position with virtual text before double-width
          char at window edge.
Solution: Check for double-width char before adding virtual text size.

closes: vim/vim#12977

ac2d8815ae
2023-09-01 06:45:27 +08:00
Lewis Russell
dd0e77d48a fix(query_error): multiline bug 2023-08-31 15:12:17 +01:00
Amaan Qureshi
845d5b8b64 feat(treesitter): improve query error message 2023-08-31 13:33:40 +01:00
Chris AtLee
c235959fd9
fix(lsp): only disable inlay hints / diagnostics if no other clients are connected (#24535)
This fixes the issue where the LspNotify handlers for inlay_hint /
diagnostics would end up refreshing all attached clients.

The handler would call util._refresh, which called
vim.lsp.buf_request, which calls the method on all attached clients.

Now util._refresh takes an optional client_id parameter, which is used
to specify a specific client to update.

This commit also fixes util._refresh's handling of the `only_visible`
flag. Previously if `only_visible` was false, two requests would be made
to the server: one for the visible region, and one for the entire file.

Co-authored-by: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com>
Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2023-08-31 10:00:24 +02:00
Maria José Solano
ee56daebb6
fix(shada): update deleted marks (#24936)
Fix #4295
Close #16067

Co-authored-by: chentau <tchen1998@gmail.com>
2023-08-31 10:15:49 +08:00
zeertzjq
839d919098
vim-patch:9.0.1825: wrong cursor position with virt text and 'linebreak' (#24957)
Problem:  Wrong cursor position with virtual text before a whitespace
          character and 'linebreak'.
Solution: Always set "col_adj" to "size - 1" and apply 'linebreak' after
          adding the size of 'breakindent' and 'showbreak'.

closes: vim/vim#12956

6e55e85f92

N/A patches:
vim-patch:9.0.1826: keytrans() doesn't translate recorded key typed in a GUI
2023-08-31 08:35:08 +08:00
zeertzjq
5d49542b56
vim-patch:9.0.1820: Rexx files may not be recognised (#24956)
Problem:  Rexx files may not be recognised
Solution: Add shebang detection and improve disambiguation of *.cls
	  files

closes: vim/vim#12951

e06afb7860

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 08:20:00 +08:00
zeertzjq
7914881356
vim-patch:9.0.1797: Vimball/Visual Basic filetype detection conflict (#24947)
Problem:  Vimball/Visual Basic filetype detection conflict
Solution: runtime(vb): Improve Vimball and Visual Basic detection logic

Only run Vimball Archiver's BufEnter autocommand on Vimball archives.
Fixes vim/vim#2694.

closes: vim/vim#12899

f97f6bbf56

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 07:44:33 +08:00
zeertzjq
6463116818
vim-patch:9.0.1807: runtime: crystal scripts not recognised (#24949)
Problem:  runtime: crystal scripts not recognised
Solution: Filetype detect Crystal scripts by shebang line

closes: vim/vim#12935

9b73902dbe

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 04:38:28 +08:00
zeertzjq
497cf996eb
vim-patch:9.0.1803: runtime(filetype): Add norg language detection (#24948)
runtime(filetype): Add norg markup language detection

closes: vim/vim#12913

03e44a1d70

Co-authored-by: NTBBloodbath <bloodbathalchemist@protonmail.com>
2023-08-31 04:38:01 +08:00