Commit Graph

5733 Commits

Author SHA1 Message Date
Lewis Russell
9b5f58185e
docs(builtin): fix and annotate language blocks (#24506) 2023-08-01 09:57:52 +01: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
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
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
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
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
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
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
Christian Clason
ad95b36985
fix(treesitter): update markdown parser and queries (#24429) 2023-07-22 19:57:58 +02:00
Chris AtLee
4b57ff77fe
refactor(lsp): use LspNotify for inlay_hint (#24411) 2023-07-22 11:00:17 +02:00
Lewis Russell
24e3ee9d07
fix(api/options): validate buf and win
Fixes #24398
2023-07-22 09:52:13 +01:00
Gnik
cfcda91827
docs(lua): add missing word in docs for vim.empty_dict (#24401) 2023-07-22 15:42:25 +08:00
Justin M. Keyes
02d859a073
Merge #24392 from mrshmllow/gx_win
fix(ui.open): some URLs fail on Windows
2023-07-21 06:37:34 -07:00
Chris AtLee
4448f594d3
docs(lsp): clean up LSP event documentation #24413
Alphabetize LSP events, and make formatting consistent.
2023-07-21 04:42:47 -07:00
marshmallow
519b9929e9 fix(ui.open): some URLs fail on Windows
Problem:
On Windows, `explorer.exe` fails to open some URLs, for example:

    :lua vim.ui.open('https://devdocs.io/#q=lua%20lua_call')

https://github.com/neovim/neovim/pull/23401#issuecomment-1641015704

Solution:
Use rundll32 instead.
2023-07-21 13:36:57 +02:00
zeertzjq
ca9f4a7cb1
docs: also change "vimL" and "viml" to "Vimscript" (#24414) 2023-07-21 16:30:05 +08:00
Chris AtLee
63b3408551
feat(lsp): implement textDocument/diagnostic (#24128) 2023-07-20 09:03:48 +02:00
futsuuu
86ce3878d6
docs(lua): clarify fs.find() documentation #24394 2023-07-19 09:55:35 -07:00
Mathias Fußenegger
2f22ed6a00
feat(lsp): handle multiple clients in omnifunc (#24381)
Also fixes https://github.com/neovim/neovim/issues/24369 by adding an
extra `vim.schedule` to ensure the `vim.fn.complete` call happens
outside of a luv callback
2023-07-19 07:10:11 +02:00
Lewis Russell
be74807eef
docs(lua): more improvements (#24387)
* docs(lua): teach lua2dox how to table

* docs(lua): teach gen_vimdoc.py about local functions

No more need to mark local functions with @private

* docs(lua): mention @nodoc and @meta in dev-lua-doc

* fixup!

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>

---------

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-07-18 15:42:30 +01:00
Lewis Russell
9fcb0a64ee
refactor(lua2dox): overhaul (#24386) 2023-07-18 12:24:53 +01:00
Mike
e4da418ba8
fix(fs.lua): normalize slash truncation (#23753)
Preserve last slash in windows' root drive directories
2023-07-18 14:36:04 +08:00
Lewis Russell
80cf0f3d29
Merge pull request #24363 from lewis6991/docs/luatypes
docs(lua): move some function docs to lua files
2023-07-17 17:40:14 +01:00
Mathias Fußenegger
1b9ccd38a1
feat(lsp)!: rename vim.lsp.get_active_clients to get_clients (#24113) 2023-07-17 18:27:16 +02:00
Lewis Russell
6e9b204afb fix: doc errors 2023-07-17 17:09:16 +01:00
Lewis Russell
69d49727d7 fix: luacheck 2023-07-17 16:32:56 +01:00
Lewis Russell
c2d7c2826c docs(lua): change *lua-foo* -> *vim.foo* 2023-07-17 16:25:29 +01:00
Lewis Russell
0ac3c4d631 docs(lua): move function docs to lua files 2023-07-17 16:25:28 +01:00
Lewis Russell
881d17a113
feat(options)!: remove compatible behaviours for vim 5.0 and earlier 2023-07-17 14:27:21 +01:00
Lewis Russell
3fd504dbec docs: handle whitespace in emmycomments 2023-07-17 12:59:10 +01:00
Lewis Russell
a54f88ea64 docs(lua): do not render self args 2023-07-17 12:59:06 +01:00
Lewis Russell
d0b612f360 refactor: rename _meta.lua to _options.lua 2023-07-17 12:59:04 +01:00
Kai Ting
c3de6524a5
fix(clipboard): ignore exit caused by signal #23378
Problem:
If clipboard job exits by signal, the exit code is >=128:
939d9053bd
xclip 0.13 often exits with code 143, which spams unhelpful messages:

    clipboard: error invoking xclip: Waiting for selection requests,
    Control-C to quit   Waiting for selection request number 1

Solution:
Don't show a warning if the clipboard tool exit code is >=128.
Fixes: #7054
2023-07-16 04:15:30 -07:00
zeertzjq
047c22a28c
docs(term.txt): reorder paragraphs about TUI input (#24367)
Make |tui-modifyOtherKeys| and |tui-csiu| tags appear at a better place.
Also adapt the |<Tab>| help update from dad4473f02
2023-07-16 18:39:45 +08:00
Mike
251ca45ac9
fix(lsp): markdown code fence should allow space before info string #24364
Problem:
Bash language server returns "hover" markdown content that starts with
a code fence and info string of `man` preceded by whitespace, which Nvim
does not render properly.

See 0ee73c53ce/server/src/server.ts (L821C15-L821C15)
```typescript
function getMarkdownContent(documentation: string, language?: string): LSP.MarkupContent {
  return {
    value: language
      ? // eslint-disable-next-line prefer-template
        ['``` ' + language, documentation, '```'].join('\n')
      : documentation,
    kind: LSP.MarkupKind.Markdown,
  }
}
```

For example,
```
    ``` man
    NAME
       git - the stupid content tracker
    ```
```

If I remove the white space, then it is properly formatted. 
```    
    ```man instead of ``` man
```

Per CommonMark Spec https://spec.commonmark.org/0.30/#info-string
whitespace is allowed before and after the `info string` which
identifies the language in a codeblock.
> The line with the opening code fence may optionally contain some text
> following the code fence; this is trimmed of leading and trailing
> spaces or tabs and called the [info
> string](https://spec.commonmark.org/0.30/#info-string). If the [info
> string](https://spec.commonmark.org/0.30/#info-string) comes after
> a backtick fence, it may not contain any backtick characters. (The
> reason for this restriction is that otherwise some inline code would
> be incorrectly interpreted as the beginning of a fenced code block.)

 Solution:
 Adjust stylize_markdown() to allow whitespace before codeblock info.
2023-07-16 03:11:45 -07:00
zeertzjq
abe39f2b24
feat(api)!: change return type of nvim_win_text_height to Dict (#24365) 2023-07-16 18:02:53 +08:00