Commit Graph

609 Commits

Author SHA1 Message Date
Lewis Russell
8f02ae82e2 test: use integers for API Buffer/Window/Tabpage EXT types 2024-01-16 19:11:49 +00: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
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
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
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
Justin M. Keyes
04f2f864e2 refactor: format test/* 2024-01-03 02:09:29 +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
dundargoc
0009c337bc test: simplify vim.fs tests
The exec_lua wrapper is no longer necessary.
2023-12-26 13:22:43 +01: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
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
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
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
Will Hopkins
69ffbb76c2
feat(iter): add Iter.take (#26525) 2023-12-12 14:27:24 -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
dundargoc
529498685b
Merge pull request #26458 from famiu/refactor/options/optionindex 2023-12-10 16:26:08 +01: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
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
zeertzjq
3bb5d2f219
test: use termopen() instead of :terminal more (#26462) 2023-12-08 08:00:27 +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
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
Gregory Anders
5b40a1c09d
feat(lua): implement Iter:join() (#26416) 2023-12-05 18:35:22 -08: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
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
zeertzjq
fec5e3ab24
fix(vim.region): handle multibyte inclusive selection properly (#26129) 2023-11-21 14:25:45 +08:00
Mathias Fußenegger
7ca2d64e8b
test: skip failing watch file tests on freebsd (#26110)
Quick fix as follow up to https://github.com/neovim/neovim/pull/26108

kqueue only reports events on a watched folder itself, not for files
created or deleted within. So the approach the PR took doesn't work on FreeBSD.

We'll either need to bring back polling for it, combine watching with manual
file tracking, or disable LSP file watching on FreeBSD
2023-11-19 18:37:49 +01:00
Mathias Fußenegger
de28a0f84c
perf(lsp): replace file polling on linux with per dir watcher (#26108)
Should help with https://github.com/neovim/neovim/issues/23291

On linux `new_fs_event` doesn't support recursive watching, but we can
still use it to watch folders.

The downside of this approach is that we may end up sending some false
`Deleted` events. For example, if you save a file named `foo` there will
be a intermediate `foo~` due to the save mechanism of neovim.

The events we get from vim.uv in that case are:

- rename: foo~
- rename: foo~
- rename: foo
- rename: foo
- change: foo
- change: foo

The mechanism in this PR uses a debounce to reduce this to:

- deleted: foo~
- changed: foo

`foo~` will be the false positive.
I suspect that for the LSP case this is good enough. If not, we may need
to follow up on this and keep a table in memory that tracks available
files.
2023-11-19 14:25:32 +01:00
Maria José Solano
4972c80489 refactor(snippet): rename test utilities 2023-11-17 17:10:27 +01:00
Maria José Solano
7e36c8e972 feat(lsp): support for choice snippet nodes 2023-11-17 17:10:27 +01:00
Gregory Anders
4bf47222c9
feat: add vim.text module (#26069) 2023-11-16 11:35:54 -06:00
dundargoc
4e33ef747c test: skip failing test on freebsd
The watch_file test started failing on bsd after
3ca967387c.
2023-11-10 21:10:15 +01:00
zeertzjq
d5a85d737a
fix(f_wait): flush UI before blocking (#25962) 2023-11-10 15:24:36 +08:00
altermo
3198038224
fix(lua): correct return value for on_key with no arguments (#25911) 2023-11-07 08:33:38 +08:00
Gregory Anders
224f303ee5
feat(stdlib): add vim.base64 module (#25843)
Add base64 encode() and decode() functions to a vim.base64 module.
2023-10-31 09:15:32 -05:00
Maria José Solano
0fe0cf5ada
fix(lsp): do not cancel snippet when selecting placeholder (#25835) 2023-10-30 12:58:28 +01: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
Maria José Solano
15983cf2c6
fix(lsp): cancel session when leaving snippet region (#25762) 2023-10-26 07:29:05 +02: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
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