Commit Graph

3630 Commits

Author SHA1 Message Date
Javier López
9249dcdda1 feat(runtime/health): support lua healthchecks
- Refactor health.vim to discover lua healthcheck in the runtime
  directories lua/**/health{/init}.lua
- Support healthchecks for lua submodules e.g :checkhealth vim.lsp and
  also support wildcard "*" at the end for all submodules
  :checkhealth vim*
- Refactor health.vim to use variable scope instead of output capturing
- Create health.lua module to wrap report functions and future
  extensibility.
- Move away from searching just in the runtimepath, use
  `nvim_get_runtime_file` due to #15632

Example:
Plugin linter in rtp can declare it's checkhealts in lua module
`lua/linter/health{/init}.lua` that returns a table with a method
"check" that when executed calls the report functions provided by the
builtin lua module require("health").

The plugin also has a submodule `/lua/linter/providers` in which it
defines `/lua/linter/providers/health{/init}.lua`

This plugin healthcheck can now be run by the ex command:
  `:checkhealth linter linter.providers`

Also calling all submodules can be done by:
  `:checkhealth linter*

And "linter" and "linter.provider" would be discovered when:
  `:checkhealth`
2021-10-04 14:28:54 -05:00
Gregory Anders
c7a63f35db
feat(startup): load builtin plugins with --clean #15893
Closes #15605
2021-10-04 07:01:49 -07:00
Gregory Anders
088026205f refactor: define diagnostic highlights in syntax.c 2021-10-03 20:06:06 -06:00
Justin M. Keyes
8a9f292991
Merge #15218 from gpanders/split-trimempty
feat(lua): add "noempty" param to vim.split()
2021-10-03 17:33:12 -07:00
dundargoc
a0bf28cd54
vim-patch:8.2.3469: some files with json syntax are not recognized (#15891)
Problem:    Some files with json syntax are not recognized.
Solution:   Add a few file patterns. (Emiliano Ruiz Carletti, closes vim/vim#8947)
50c5689342
2021-10-03 16:50:51 -06:00
zeertzjq
7ba11e06c0
vim-patch:8.2.3466: completion submode not indicated for virtual replace (#15886)
Problem:    Completion submode not indicated for virtual replace.
Solution:   Add submode to "Rv". (closes vim/vim#8945)
cc8cd44533
2021-10-03 15:04:51 -04:00
zeertzjq
04b59ebd85
vim-patch:8.2.3465: cannot detect insert scroll mode (#15885)
Problem:    Cannot detect insert scroll mode.
Solution:   Add "scroll" to complete_info(). (closes vim/vim#8943)
27fef59dd1
2021-10-03 14:53:58 -04:00
Christian Clason
9fe704f88e
vim-patch:8.2.3464: nginx files are not recognized (#15883)
Problem:    nginx files are not recognized.
Solution:   Add several file patterns. (Chris Aumann, closes vim/vim#8922)
8b8c0ed657
2021-10-03 13:40:59 +02:00
Gregory Anders
23d13aa4cc
Merge pull request #15786 from gpanders/diagnostic-signs-unique-severity 2021-10-02 21:01:40 -06:00
Gregory Anders
0f554ef6f8 refactor(diagnostics): always make 'set' go through 'show'
Always make calls to `vim.diagnostic.set` call `vim.diagnostic.show`.
This creates an easier to reason about code path and is also less
surprising when users wish to override override `vim.diagnostic.show`
with custom behavior and `vim.diagnostic.set` is called with empty
diagnostics.

Functionally, the end result is the same: when `show` is called with an
empty diagnostics list, it just calls `hide` and then returns, which is
exactly what `reset` does right now.
2021-10-02 20:37:09 -06:00
Gregory Anders
1124439954 docs(diagnostic): add blurb on how to replace builtin handlers 2021-10-02 20:37:09 -06:00
zeertzjq
4449297d12
docs(lsp): clarify parameters of some util functions (#15851)
`pad_left` and `pad_right` are unused
List used keys of `opts` in `make_floating_popup_options`
2021-10-02 17:55:54 -07:00
zeertzjq
b3e815094b
fix(float)!: always anchor to corner of window including border #15832
N, W, S, E are all inclusive, i.e., always anchor to the exact corner of the
window (including border). This line may also need change in this case (change
0 to -1):

This is most consistent and easiest to reason about, especially with GUIs whose
border do not need to have width/height of 1/1 in cell units.

Fix #15789
2021-10-02 17:36:24 -07:00
dundargoc
ac973d5532
docs: remove obsolete text on language #15875 2021-10-02 14:30:13 -07:00
Michael Lingelbach
724ffe7095
feat(diagnostics): add vim.diagnostic.get_namespaces (#15866)
Many vim.diagnostic functions expect the user to pass in a namespace id.

This PR allows the user to list active diagnostic namespaces:

```lua
:lua print(vim.inspect(vim.diagnostic.get_namespaces()))

{
  [7] = {
    name = "vim.lsp.client-1",
    opts = {},
    sign_group = "vim.diagnostic.vim.lsp.client-1"
  }
}
```
2021-10-01 22:50:28 -07:00
Gregory Anders
36408146ad
docs(diagnostics): add "priority" option to signs table (#15860)
This feature was added in #15785, but the docs for
vim.diagnostic.config() weren't updated.
2021-10-01 19:07:55 -06:00
Daniel Steinberg
88442c2fa6 docs: add 'plus one' to correct getmousepos docs
This change was applied to Vim as part of 90df4b9.
90df4b9d42
2021-09-29 11:13:49 -04:00
Daniel Steinberg
096309037b chore: remove empty line
This update was part of vim-patch:4c29502.
4c295027a4
The other parts of that patch were applied to Neovim in ad6bb38.
2021-09-29 11:13:49 -04:00
Daniel Steinberg
3b9e75b366 vim-patch:8.1.2304: cannot get the mouse position when getting a mouse click
Problem:    Cannot get the mouse position when getting a mouse click.
Solution:   Add getmousepos().
db3a205147
2021-09-29 11:13:49 -04:00
Mathias Fußenegger
ec4731d982
feat(lsp): add codeAction/resolve support (#15818)
Closes https://github.com/neovim/neovim/issues/15339 and https://github.com/neovim/neovim/issues/15828
2021-09-28 14:04:01 -07:00
Mathias Fußenegger
19a77cd5a7
feat(lsp): add client command support to codelens (#15820)
Also adds a check against the server capabilities to fix
https://github.com/neovim/neovim/issues/15183
2021-09-28 09:19:19 -07:00
Mathias Fußenegger
ff18a8bcc4
refactor(lsp): remove json encode/decode wrappers (#15826) 2021-09-28 09:13:44 -07:00
Mathias Fußenegger
9ca7b6b71a
fix(ui): s/format_entry/format_item to match docs (#15819)
Follow up to https://github.com/neovim/neovim/pull/15771
2021-09-27 16:12:03 -07:00
Mathias Fußenegger
63fde086d9
feat(ui): add vim.ui.select and use in code actions (#15771)
Continuation of https://github.com/neovim/neovim/pull/15202

A plugin like telescope could override it with a fancy implementation
and then users would get the telescope-ui within each plugin that
utilizes the vim.ui.select function.

There are some plugins which override the `textDocument/codeAction`
handler solely to provide a different UI. With custom client commands and
soon codeAction resolve support, it becomes more difficult to implement
the handler right - so having a dedicated way to override the picking
function will be useful.
2021-09-27 21:57:28 +02:00
Michael Lingelbach
96614f84ab
fix(lsp): avoid serializing boolean as key (#15810)
In vim.lsp.buf.references, the key vim.type_idx (which evaluates to a
boolean) was set to equal vim.types.dictionary. This resulted in a
boolean key in json which is not allowed by the json spec, and which
lua-cjson fails to serialize.
2021-09-27 00:32:30 -07:00
Gregory Anders
187e3a3b7e
refactor(diagnostic): use sign priority for severity_sort #15785
Rather than relying on the order in which signs are placed to dictate
the order in which they are displayed, explicitly set the priority of
the sign according to the severity of the diagnostic and the value of
severity_sort. If severity_sort is false or unset then all signs use the
same priority.
2021-09-26 16:02:18 -07:00
Mathias Fußenegger
73280a7987
feat(lsp): allow subset of CodeActionContext as arg to code_action methods (#15793)
This makes it easier to filter the code actions. For example:

    vim.lsp.buf.code_action { only = 'refactor' }
2021-09-26 23:40:28 +02:00
Michael Lingelbach
c217766f7c
feat(lsp): use cjson for lsp rpc (#15759) 2021-09-26 22:53:04 +02:00
Gregory Anders
84f66909e4 refactor: use kwargs parameter in vim.split 2021-09-25 20:11:32 -06:00
Gregory Anders
5fa26e2c2f feat: add trimempty optional parameter to vim.split
The `split()` VimL function trims empty items from the returned list by
default, so that, e.g.

  split("\nhello\nworld\n\n", "\n")

returns

  ["hello", "world"]

The Lua implementation of vim.split does not do this. For example,

  vim.split("\nhello\nworld\n\n", "\n")

returns

  {'', 'hello', 'world', '', ''}

Add an optional parameter to the vim.split function that, when true,
trims these empty elements from the front and back of the returned
table. This is only possible for vim.split and not vim.gsplit; because
vim.gsplit is an iterator, there is no way for it to know if the current
item is the last non-empty item.

Note that in order to preserve backward compatibility, the parameter for
the Lua vim.split function is `trimempty`, while the VimL function uses
`keepempty` (i.e. they are opposites). This means there is a disconnect
between these two functions that may surprise users.
2021-09-25 20:11:30 -06:00
Justin M. Keyes
55d1e630b4
Merge #15731 vim-patch:7.4.725,8.2.{0597,0598,0924,1035}
fixes #14581
2021-09-24 05:11:19 -07:00
Chris Kipp
433bda405e
fix(lsp): guard textDocument/codeAction command logic #15769
Problem:

    Error executing vim.schedule lua callback: ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: command: expected string, got
     nil
    stack traceback:
            ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: in function 'execute_command'
            ...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:151: in function <...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:113>
            ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:465: in function 'callback'
            ...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:1325: in function 'handler'
            ...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:899: in function 'cb'
            vim.lua:281: in function <vim.lua:281>


Solution:

This is a follow-up to the work done in
6c03601e3a.
There are valid situations where a `textDocument/codeAction` is returned
without a command, since a command in optional. For example from Metals,
the Scala language server when you get a code action to add a missing
import, it looks like this:

```json
Result: [
  {
    "title": "Import \u0027Instant\u0027 from package \u0027java.time\u0027",
    "kind": "quickfix",
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 6,
            "character": 10
          },
          "end": {
            "line": 6,
            "character": 17
          }
        },
        "severity": 1,
        "source": "bloop",
        "message": "not found: value Instant"
      }
    ],
    "edit": {
      "changes": {
        "file:///Users/ckipp/Documents/scala-workspace/sanity/src/main/scala/Thing.scala": [
          {
            "range": {
              "start": {
                "line": 6,
                "character": 10
              },
              "end": {
                "line": 6,
                "character": 17
              }
            },
            "newText": "Instant"
          },
          {
            "range": {
              "start": {
                "line": 1,
                "character": 0
              },
              "end": {
                "line": 1,
                "character": 0
              }
            },
            "newText": "\nimport java.time.Instant\n"
          }
        ]
      }
    }
  }
]
```

This change just wraps the logic that grabs the command in a conditional
to skip it if there is no command.
2021-09-23 18:20:10 -07:00
Gregory Anders
9cde1e5891
fix(diagnostic): check for nil in show_diagnostics (#15772) 2021-09-23 09:52:21 -07:00
Gregory Anders
057606e845
fix(diagnostic): don't return nil when callers expect a table (#15765)
diagnostic_lines() returns a table, so make the early exit condition an
empty table rather than 'nil'. This way, functions that use the input
from diagnostic_lines don't have to do a bunch of defensive nil checking
and can always assume they're operating on a table.
2021-09-23 08:23:57 -07:00
Justin M. Keyes
c05b10748c doc(dev_style.txt): misc updates 2021-09-23 06:59:30 -07:00
Dundar Göc
5f49d0efee doc: convert neovim style guide to vim doc. 2021-09-23 06:59:30 -07:00
Sean Dewar
f9779facca
vim-patch:8.2.0924: cannot save and restore a register properly
Problem:    Cannot save and restore a register properly.
Solution:   Add getreginfo() and make setreg() accept a dictionary. (Andy
            Massimino, closes vim/vim#3370)
bb861e293e

Cherry-pick eval.txt changes for getreginfo() from:
6aa57295cf
207f009326
2021-09-23 02:04:11 +01:00
Gregory Anders
d999c96cf3
feat(diagnostic): allow customized diagnostic messages (#15742)
Provide a 'format' option for virtual text and floating window previews
that allows the displayed text of a diagnostic to be customized.
2021-09-22 12:20:15 -07:00
Michael Lingelbach
248974a4c6
Merge pull request #14115 from mfussenegger/lsp-commands
lsp: Add a registry for client side code action commands
2021-09-22 11:42:56 -07:00
Christian Clason
fb6f27e86f
vim-patch:34cc7d8c034f #15753
Update runtime files
34cc7d8c03
2021-09-22 06:12:06 -07:00
Gregory Anders
bc652f148f refactor(diagnostic): remove get_virt_text_chunks()
This function isn't compatible with including diagnostic sources when
"source" is "if_many" since it only has access to diagnostics for a
single line. Rather than having an inconsistent or incomplete interface,
make this function private. It is still exported as part of the module
for backward compatibility with vim.lsp.diagnostics, but it can
eventually be made into a local function.
2021-09-21 18:54:28 -06:00
Gregory Anders
d43151ea0b feat(diagnostic): add option to include diagnostic source
Add an option to virtual text display and floating window previews to
include diagnostic source in the diagnostic message.
2021-09-21 18:54:26 -06:00
Gregory Anders
17b7968f02
fix(diagnostic): preserve fields from LSP diagnostics via user_data (#15735)
* preserve fields from LSP diagnostics via adding a user_data table to the diagnostic, which can hold arbitrary data in addition to the lsp diagnostic information.
2021-09-21 15:27:12 -07:00
Mathias Fußenegger
8164adc144
fix(lsp): update lsp-handler signature in call_hierarchy (#15738)
This fixes the handler signature and also prevents n+1 requests firing
if there are multiple clients.

(The first `prepareCallHierarchy` handler is called once per client,
each invocation used `buf_request` to make more requests using *all*
clients)
2021-09-21 15:05:49 -07:00
Mathias Fussenegger
6c03601e3a feat(lsp): add a registry for client side code action commands
This builds on https://github.com/neovim/neovim/pull/14112 and closes
https://github.com/neovim/neovim/issues/12326
2021-09-20 22:26:00 +02:00
Mathias Fussenegger
187579fe19 feat(lsp): include original request params in handler ctx
This is mostly motivated by https://github.com/neovim/neovim/issues/12326

Client side commands might need to access the original request
parameters.

Currently this is already possible by using closures with
`vim.lsp.buf_request`, but the global handlers so far couldn't access
the request parameters.
2021-09-20 22:06:54 +02:00
Gregory Anders
0216aed20c
fix(diagnostic): clamp line numbers in display layer (#15729)
Some parts of LSP need to use cached diagnostics as sent from the LSP
server unmodified. Rather than fixing invalid line numbers when
diagnostics are first set, fix them when they are displayed to the user
(e.g. in show() or one of the get_next/get_prev family of functions).
2021-09-20 11:32:21 -07:00
Gregory Anders
e61ea7772e
feat(diagnostic): match(), tolist(), fromlist() #15704
* feat(diagnostic): add vim.diagnostic.match()
  Provide vim.diagnostic.match() to generate a diagnostic from a string and
  a Lua pattern.
* feat(diagnostic): add tolist() and fromlist()
2021-09-19 15:13:23 -07:00
zeertzjq
51567db4b6 vim-patch:8.2.3424: a sequence of spaces is hard to see in list mode
Problem:    A sequence of spaces is hard to see in list mode.
Solution:   Add the "multispace" option to 'listchars'. (closes vim/vim#8834)
f14b8ba137
2021-09-19 13:13:44 +08:00
zeertzjq
963474321b vim-patch:8.1.1071: cannot get composing characters from the screen
Problem:    Cannot get composing characters from the screen.
Solution:   Add screenchars() and screenstring(). (partly by Ozaki Kiichi,
            closes vim/vim#4059)
2912abb3a2
2021-09-19 13:13:44 +08:00