Commit Graph

26542 Commits

Author SHA1 Message Date
Justin M. Keyes
d2f8133024 docs: misc
Co-authored-by: Kevin Pham <keevan.pham@gmail.com>
2023-08-03 14:01:53 +02:00
Raphael
214b125132
fix(gen_lsp.lua): no notifications in lsp.Methods #24530
Problem:
- Notifications are missing from `lsp.Methods`.
- Need a way to represent `$/` prefixed methods.

Solution:
- Generate notifications.
- Use "dollar_" prefix for `$/` methods.
2023-08-03 02:52:21 -07:00
Marc Jakobi
4a06de40e7
docs(lua): fix generated fname param annotations #24533 2023-08-02 11:22:44 -07:00
zeertzjq
1ee905a63a
docs(builtin): fix alignment of comments in code blocks (#24529) 2023-08-02 22:14:32 +08:00
Justin M. Keyes
d086bc1e85
docs: drop "Can also be used as a method" #24508
Now that we "own" builtin.txt, we cant remove the repetitive mention of
Vimscript's UFCS syntax. It's noisy to mention this for each function,
and it's also not a Vimscript feature that should be encouraged.

Also change the builtin.txt heading to "NVIM REFERENCE MANUAL", which
indicates when a help file is Nvim-owned.
2023-08-01 16:17:26 -07:00
Lewis Russell
6425869771
feat(lua): add meta file for vim submodules (#24525) 2023-08-01 18:03:33 +01:00
Tyler Miller
0804034c07
fix(loader): cache path ambiguity #24491
Problem: cache paths are derived by replacing each reserved/filesystem-
path-sensitive char with a `%` char in the original path. With this
method, two different files at two different paths (each containing `%`
chars) can erroneously resolve to the very same cache path in certain
edge-cases.

Solution: derive cache paths by url-encoding the original (path) instead
using `vim.uri_encode()` with `"rfc2396"`. Increment `Loader.VERSION` to
denote this change.
2023-08-01 08:28:28 -07:00
Justin M. Keyes
dfe19d6e00
Merge #24504 feat(lsp): protocol.Methods 2023-08-01 07:36:57 -07:00
Justin M. Keyes
f41496ce74 feat(gen_lsp.lua): sort by name, handle failure #24504 2023-08-01 16:13:22 +02:00
mathew
da09f9b551 feat(gen_lsp.lua): protocol.Methods #24504 2023-08-01 16:05:06 +02:00
Lewis Russell
48d533272e
feat(lua-types): types for vim.api.* (#24523) 2023-08-01 14:20:44 +01:00
Chris AtLee
e55e80d51c
fix(lsp): inlay hints: "Failed to delete autocmd" when closing buffer #24469
Problem:
"Failed to delete autocmd" error when deleting LspNotify autocmd. #24456

Solution:
Change a few things in the inlay_hint and diagnostic LSP code:
1. Re-introduce the `enabled` flag for the buffer state tables. Previously I was
   relying on the presence of an autocmd id in the state table to track whether
   inlay_hint / diagnostic was enabled for a buffer. There are two reasons why
   this doesn't work well:
  - Each time inlay_hint / diagnostic is enabled, we call `nvim_buf_attach` on
    the buffer, resulting in multiple `on_reload` or `on_detach` callbacks being
    registered.
  - Commands like `bwipeout` delete buffer local autocmds, sometimes before our
    `on_detach` callbacks have a chance to delete them first. This causes the
  - Use module local enabled state for diagnostic as well. bwipeout can race
    with on_detach callbacks for deleting autocmds. Error referenced in #24456.
2. Change the `LspDetach` autocmd to run each time (i.e., remove the `once`
   flag). Since we're only registering autocmds once per buffer now, we
   need to make sure that we set the enabled flag properly each time the LSP
   client detaches from the buffer.
  - Remove `once` from the LspDetach autocmds for inlay_hint and diagnostic.
    We only set up the autocmd once now. Gets removed when buffer is deleted.
3. Have the `LspNotify` handler also refresh the inlay_hint / diagnostics when
   receiving the `textDocument/didOpen` event. Before this point, the LSP
   backend doesn't have the contents of the buffer, so can't provide inlay hints
   or diagnostics.

Downsides of this approach:
* When inlay_hint / diagnostics are disabled on a buffer, it will continue to
  receive `LspNotify` events for that buffer. The callback exits early since the
  `enabled` flag is false.

Alternatives:
* Can we wrap the call to `nvim_del_autocmd` in `pcall` to swallow any errors
  resulting from trying to delete the autocmd?

Fixes #24456

Helped-by: Maria José Solano <majosolano99@gmail.com>
2023-08-01 05:13:52 -07:00
Lewis Russell
20bfdbe832
docs(builtin): right align tags (#24522) 2023-08-01 11:12:00 +01:00
zeertzjq
ccb5a76e5a
fix(defaults): don't use nvim_feedkeys in default mappings (#24520)
Problem:    Using nvim_feedkeys in default mappings makes it hard to use
            them as a part of another mapping.
Solution:   Use an expression mapping and stop Visual mode later.

Fix #24518.
2023-08-01 18:07:02 +08:00
Lewis Russell
9b5f58185e
docs(builtin): fix and annotate language blocks (#24506) 2023-08-01 09:57:52 +01:00
zeertzjq
12ccea5967
build: fix --luamod-dev not working properly (#24519)
Fixes a regression from #23112.
2023-08-01 11:57:46 +08:00
Mathias Fußenegger
996dd36c77
feat(lsp): add actionable advice to lsp client quit error msg (#24510)
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-07-29 16:10:40 +02:00
altermo
2736cb3adf
docs(lua): vim.str_utf_{start,end,pos} #24424
Closes #24422
2023-07-29 07:08:32 -07:00
Lewis Russell
42333ea98d
feat(docs): generate builtin.txt (#24493)
- eval.lua is now the source of truth.

- Formatting is much more consistent.

- Fixed Lua type generation for polymorphic functions (get(), etc).

- Removed "Overview" section from builtin.txt
  - Can generate this if we really want it.

- Moved functions from sign.txt and testing.txt into builtin.txt.

- Removed the *timer* *timers* tags since libuv timers via vim.uv should be preferred.

- Removed the temp-file-name tag from tempname()

- Moved lueval() from lua.txt to builtin.txt.

* Fix indent

* fixup!

* fixup! fixup!

* fixup! better tag formatting

* fixup: revert changes no longer needed

* fixup! CI

---------

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-07-28 14:48:41 +01:00
zeertzjq
c1c2a1b5dd
fix(inccommand): don't save information of a buffer twice (#24501)
Problem:    'inccommand' doesn't restore 'undolevels' properly for a
            buffer shown in multiple windows.
Solution:   Don't save information of a buffer twice.
2023-07-28 15:41:58 +08:00
ObserverOfTime
df2f5e3912
fix(editorconfig): highlight properties with dashes (#24407)
also add metadata comment and update Lua code in syntax file
2023-07-27 14:39:05 +02:00
Christian Clason
41cefe5130
build(deps): bump tree-sitter-c to v0.20.4 (#24495) 2023-07-27 12:45:08 +02:00
Sean Dewar
8fe9f41f7f
Merge pull request #24457 from seandewar/relax-cmdwin
feat(api): relax cmdwin restrictions for a few functions
2023-07-26 21:27:35 +01:00
Sean Dewar
a47be0b2d9
fix(window): prevent win_size_restore from changing cmdheight
Currently it only skips if `Rows` changed, but it's possible for the height of
the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which
can cause the value of `&cmdheight` to change when the sizes are restored.

This is a Vim bug, so I've submitted a PR there too. No telling when it'll be
merged though, given the current lack of activity there.

`ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`.
Not ideal, as we also care about the height of the last statusline for other
values of `&ls`. Meh.

Introduce `last_stl_height` for getting the height of the last statusline and
use it in `win_size_save/restore` and `last_status` (means
`last_status_rec`'s `statusline` argument will now be true if `&ls` is 3,
but that does not change the behaviour).

Also corrects the logic in `comp_col` to not assume there's a last statusline
if `&ls` is 1 and the last window is floating.
2023-07-26 20:44:46 +01:00
Sean Dewar
472271199e
feat(api): allow win_hide to close cmdwin or non-previous windows
This aligns its behaviour better with `nvim_win_close`.

Note that `:hide` is actually incapable of closing the cmdwin, unlike `:close`
and `:quit`, so this is a bit of a difference in behaviour.
2023-07-26 20:44:46 +01:00
Sean Dewar
5d921e28c1
feat(api): allow win_close in cmdwin to close wins except previous
Disallow closing the previous window from `nvim_win_close`, as this will cause
issues.

Again, no telling how safe this is. It also requires exposing old_curwin. :/

Also note that it's possible for the `&cmdheight` to change if, for example,
there are 2 tabpages and `nvim_win_close` is used to close the last window in
the other tabpage while `&stal` is 1. This is addressed in a later commit.
2023-07-26 20:44:46 +01:00
Sean Dewar
6b4970f6e0
feat(api): allow open_win/win_set_buf in the cmdwin in some cases
Problem: As discussed on Matrix, there was some interest in having
`nvim_open_win` again be able to open floats in the cmdwin (e.g: displaying a
hover doc related to what's in the cmdwin). After #23228, this was disallowed.

Solution: Allow `nvim_open_win` in the cmdwin as long as `!enter` and
`buffer != curbuf` (the former can cause all sorts of issues, and the latter
can crash Nvim after closing cmdwin). Also allow `nvim_win_set_buf` in a similar
fashion.

Note that we're not *entirely* sure if this is 100% safe (cmdwin is a
global-state-using-main-loop-calling beast), but this seems to work OK..?

Also:
  - Check the buffer argument of `nvim_open_win` earlier, and abort if it's
    invalid (it used to still open a window in this case).

  - Untranslate `e_cmdwin` errors in the API (other errors in the API are not
    translated: although not detailed in the API contract yet, errors are
    supposed to be stable).
2023-07-26 20:44:46 +01:00
zeertzjq
ccf328172b
fix(gen_vimfn_types): don't include tag before signature's line (#24492)
When signature is a bit long or there are too many tags, the tags appear
before the signature's line. Don't include the line with tags in the
previous function' docs.

Also fix lint warnings.
2023-07-26 21:07:39 +08:00
Lewis Russell
fd089c8e50
feat(lua): typing for vim.fn.* (#24473)
Problem:
  No LSP information for `vim.fn.*`

Solution:
  Add meta file for `vim.fn.*`.
2023-07-26 09:50:54 +01:00
zeertzjq
b8b7782037
vim-patch:partial:8.1.1981: the evalfunc.c file is too big (#24490)
Problem:    The evalfunc.c file is too big.
Solution:   Move undo functions to undo.c.  Move cmdline functions to
            ex_getln.c.  Move some container functions to list.c.

08c308aeb5

Undo functions only. Cmdline functions have already been moved.
A lot of container functions have been added to eval/funcs.c instead of
list.c in previously ported Vim 8.2.x patches, so deal with that later.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-07-26 15:18:09 +08:00
zeertzjq
14d047ad2f
test(inccommand): add a test for #20248 (#24489) 2023-07-26 11:58:26 +08:00
Alexandre Teoi
643bea31b8
fix(inccommand): restrict cmdpreview undo calls (#24289)
Problem:
The cmdpreview saved undo nodes on cmdpreview_prepare() from ex_getln.c may
become invalid (free) if the preview function makes undo operations, causing
heap-use-after-free errors.

Solution:
Save the buffer undo list on cmdpreview_prepare)_ and start a new empty one. On
cmdpreview_restore_state(), undo all the entries in the new undo list and
restore the original one. With this approach, the preview function will be
allowed to undo only its own changes.

Fix #20036
Fix #20248
2023-07-26 11:22:57 +08:00
Mathias Fußenegger
74bd4aba57
fix(lsp): fix multi client handling workspace_folder methods (#18839)
`buf_notify` sends the notification to all clients of a buffer, calling
that inside a loop over clients multiplies the amount of notifications.
2023-07-25 16:57:19 +02:00
zeertzjq
aba3ceccb7
vim-patch:9.0.1335: no test for bad use of spaces in help files (#24483)
Problem:    No test for bad use of spaces in help files.
Solution:   Add checks for use of spaces in help files.  Ignore intentional
            spaces. (Hirohito Higashi, closes vim/vim#11952)

d950984489

Cherry-pick changes from patch 9.0.1604.

Co-authored-by: h-east <h.east.727@gmail.com>
Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-07-25 20:58:09 +08:00
Christoph Hasse
20c331915f
fix(lsp): SignatureHelp docstring is not escaped #16702
Problem:
Nvim LSP client always treats signature.documentation as markdown, even
if the server returns a plain string.
Per https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#signatureInformation
in a SignatureInformation response, the documentation field can be
either "string" or "MarkupContent".

Solution:
If signature.documentation is a string, treat it as "plaintext".

Closes #16563
2023-07-25 05:40:13 -07:00
zeertzjq
898384ac69
test(core/startup_spec): use retry() instead of jobwait() (#24481)
This should work on Windows.
2023-07-25 20:32:59 +08:00
ii14
aaa151d506
docs: remove trailing spaces #24455 2023-07-25 05:07:13 -07:00
Raphael
4d0f4c3de9
fix(lsp): E403 if doc contains multiple codeblocks #24458
Problem:
Content that has codeblocks with different languages, results in
multiple calls to:
    syntax include vim syntax/vim.vim
which raises error:
    E403: syntax sync: line continuations pattern specified twice
Before ba8f19ebb6, this was avoided by
using pcall() to ignore the error.

Solution:
Restore the use of pcall() to ignore the error.
We plan to replace this logic with a treesitter approach, so this is
good enough for now.

Fix #24431
2023-07-25 04:38:48 -07:00
zeertzjq
c0fa721ade
fix(startup): make recovery mode work without --headless (#24477) 2023-07-25 19:02:39 +08:00
Mathias Fußenegger
7668f89d5b
fix(lsp): replace @private with @nodoc for public client functions (#24415)
* fix(lsp): replace @private with @nodoc for public client functions

To prevent lua-ls warnings in plugins which use the functions.

* fix(lsp): remove duplicate type annotations/class definitions

These annotations became duplicate with https://github.com/neovim/neovim/pull/23750
2023-07-24 20:21:35 +02:00
Bruce Weirdan
966eb8e0b3
fix(lsp): announce publishDiagnostics.dataSupport (#24442)
Neovim already passed `data` element from published diagnostic to code action, but failed to announce it in client capabilities.

Here is the test that shows that `data` element is returned by `vim.lsp.diagnostic.get_line_diagnostics()`:

f56c184809/test/functional/plugin/lsp/diagnostic_spec.lua (L103-L115)

and then `get_line_diagnostics()` is used to construct the context for code action request:

f56c184809/runtime/lua/vim/lsp/buf.lua (L742)
2023-07-24 19:26:17 +02:00
Mitchell Hanberg
a37d568082
fix(lsp): send empty "added" list when removing workspace folder #24440
When adding `workspace/didChangeWorkspaceFolders` support to my [language server](https://github.com/elixir-tools/next-ls), I noticed that when neovim removes a workspace, it sends an empty table (which is serialized to an empty JSON array) for the value in the `added` field.

This does not follow the spec; the `added` table should just be empty.

The following error led me to this discovery. Note the payload includes `"added" => [[]]`:

```
22:46:48.476 [error] LSP Exited.

Last message received: handle_notification %{"jsonrpc" => "2.0", "method" => "workspace/didChangeWorkspaceFolders", "params" => %{"event" => %{"added" => [[]], "removed" => [%{"name" => "/Users/mitchell/src/gen_lsp", "uri" => "file:///Users/mitchell/src/gen_lsp"}]}}}

** (MatchError) no match of right hand side value: {:error, %{"params" => %{"event" => %{"added" => [error: "expected a map"]}}}}
    (gen_lsp 0.4.0) lib/gen_lsp.ex:265: anonymous fn/4 in GenLSP.loop/3
    (gen_lsp 0.4.0) lib/gen_lsp.ex:292: GenLSP.attempt/3
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
```
2023-07-24 09:09:53 -07:00
Keith Smiley
add7e106d5
fix(lsp): noisy warning about offset_encodings #24441
In the case you hit this warning in a buffer (like with C++ and clangd),
this message potentially fires over and over again making it difficult
to use the editor at all.
2023-07-24 08:58:59 -07:00
marshmallow
6a486c44e6
fix(gx): move to to _init_default_mappings #24420
Problem:
netrw may conflict with the Nvim default "gx" mapping.

Solution:
Initialize keymapping earlier by moving it to vim._init_default_mappings().
That also avoids needing to check maparg().
2023-07-24 08:35:19 -07:00
Micah Halter
48085e40bb
fix(treesitter): stop() should treat 0 as current buffer #24450 2023-07-24 07:26:38 -07:00
ii14
78b56b21b4
docs(vim_diff): fixed inconsistent autocmds behavior #24453 2023-07-24 07:10:55 -07:00
zeertzjq
5fb4c397a1
fix(mouse): drag vsep of window with 'statuscolumn' (#24462)
Problem:    Cannot drag a vertical separator to the right of a window
            whose 'statuscolumn' is wider than itself.
Solution:   Never treat a click on a vertical separator as a click on
            'statuscolumn'.
2023-07-24 18:16:53 +08:00
zeertzjq
01e273c340
fix(statuscolumn): don't update clicks if current width is 0 (#24459) 2023-07-24 15:18:24 +08:00
fredizzimo
f2ce31d3dc
fix(terminal): call validate_cursor() before screen update (#24425)
Problem:
When the CurSearch highlight group is set, and a search is active and
you are listening to the remote UI "win_viewport" events, then typing is
very unresponsive, because "win_viewport" is not sent as soon as the
character is typed. On the other hand if you refresh the screen on
"flush", the screen will scroll with a delay since "win_viewport" comes
too late. I estimate this delay be up to one second, but it varies. 

Solution:
Call validate_cursor() before drawing the screen, just like other modes.
No tests have been added because only the intermediate state is wrong.
2023-07-23 23:01:51 +08:00
zeertzjq
59289fb987
fix(highlight): make CurSearch work properly with 'winhl' (#24448) 2023-07-23 21:36:32 +08:00