Commit Graph

813 Commits

Author SHA1 Message Date
David Hotham
98f578293b
fix(lsp): don't update active_clients on exit_timeout (#16192) 2021-10-31 12:05:57 -07:00
Michael Lingelbach
52fa1d26db
feat(lsp): add formatexpr (#16186)
Co-authored-by: Meck <yesmeck@gmail.com>
Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
2021-10-31 05:40:26 -07:00
Michael Lingelbach
4da0351651
fix(lsp): add placeholder cancel function (#16189)
Fixes a bug introduced by https://github.com/neovim/neovim/pull/15949

When no supported clients for a given method are available, buf_request
returns early with a nil value. If buf_request_sync is called on a
buffer with no clients that support a given method, the returned
`cancel` method (which is nil), is invoked, resulting in an error.

Solution: return an empty function handle
2021-10-31 04:44:45 -07:00
Michael Lingelbach
c9e5c778b0
feat(lsp): default to botright for setting qflist (#16177)
* Opens quickfix list spanning the entire nvim window in location
  handlers

closes https://github.com/neovim/neovim/issues/12241
2021-10-30 08:17:00 -07:00
Gregory Anders
e921e98ce3
refactor(diagnostic): make display handlers generic (#16137)
Rather than treating virtual_text, signs, and underline specially,
introduce the concept of generic "handlers", of which those three are
simply the defaults bundled with Nvim. Handlers are called in
`vim.diagnostic.show()` and `vim.diagnostic.hide()` and are used to
handle how diagnostics are displayed.
2021-10-29 18:47:34 -07:00
jdrouhard
d1c470957b
feat(lsp): track pending+cancel requests on client object #15949 2021-10-29 05:45:01 -07:00
Folke Lemaitre
cb15055c29
fix(lsp): cleanup progress messages for the correct client (#16110) 2021-10-21 09:36:27 -07:00
Michael Lingelbach
80456cf836
feat(lsp): add exit_timeout flag (#16070)
* This flag allows customizing the time before sending kill -15 to the
  server. If set to false, neovim exits immediately after sending
  request('shutdown'). Otherwise, polls until all servers have shutdown,
  and then kills remaining servers via kill -15 at exit_timeout
  duration. Defaults to 500 ms.
2021-10-21 09:36:01 -07:00
Michael Lingelbach
c5525f265b
fix(lsp): avoid duplicates in client attached buffers (#16099)
closes https://github.com/neovim/neovim/issues/16058

* add client.attached_buffers
* only update client.attached_buffers in on_attach
* use table instead of list for attached_buffers to avoid duplication
2021-10-20 09:33:09 -07:00
Mathias Fußenegger
dc6c9fe442
fix(lsp): adjust legacy show diagnostic functions to use correct scope (#16106)
* `where` was renamed to `scope`
2021-10-20 08:27:55 -07:00
Gregory Anders
427bac6877
fix(diagnostic): allow floats to be focusable (#16093)
Setting focus_id allows the float to be focused by calling the function
a second time (a feature of open_floating_preview).
2021-10-19 16:29:52 -06:00
Gregory Anders
a2994c82e3
fix(diagnostic): handle diagnostics placed past the end of line (#16095) 2021-10-19 16:27:49 -06:00
Gregory Anders
dfef90a518
fix(gen_vimdoc.py): spacing around inline elements #16092
The spacing fix drew attention to a couple of places that were using
incorrect formatting such as the key listing for `nvim_open_win`, so
those were fixed too.
2021-10-19 12:55:22 -07:00
Gregory Anders
064411ea7f
refactor(diagnostic)!: replace 'show_*' functions with 'open_float' (#16057)
'show_line_diagnostics()' and 'show_position_diagnostics()' are
almost identical; they differ only in the fact that the latter also
accepts a column to form a full position, rather than just a line. This
is not enough to justify two separate interfaces for this common
functionality.

Renaming this to simply 'show_diagnostics()' is one step forward, but
that is also not a good name as the '_diagnostics()' suffix is
redundant. However, we cannot name it simply 'show()' since that
function already exists with entirely different semantics.

Instead, combine these two into a single 'open_float()' function that
handles all of the cases of showing diagnostics in a floating window.
Also add a "float" key to 'vim.diagnostic.config()' to provide global
values of configuration options that can be overridden ephemerally.
This makes the float API consistent with the rest of the diagnostic API.

BREAKING CHANGE
2021-10-19 11:45:51 -06:00
sim
aa4f0879e3
feat(lsp): set codelens virtual text hl_mode to combine (#16048)
It looks a bit off with the extmark going over the cursorline.

(With hl_mode combine it keeps the background of the cursorline under the codelens virtualtext)
2021-10-19 18:41:57 +02:00
Josa Gesell
e7ea54a3df
feat(lsp): use vim.ui.select() in codelenses (#16004)
Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com> Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2021-10-18 11:52:22 -07:00
hrsh7th
bd2f61c6c4
fix(lsp): fix cursor row after textEdits (#16038) 2021-10-18 11:49:33 -07:00
Gregory Anders
bcc9ba51fa
fix(lsp): persist diagnostic config for clients
Persist configuration settings set with `vim.lsp.with` and
`vim.lsp.diagnostic.on_publish_diagnostics` by setting the config for
the namespace associated with the client.
2021-10-18 10:01:41 -06:00
Gregory Anders
d2d30dfabd
fix(diagnostic): do not override existing config settings #16043
When using `true` as the value of a configuration option, the option is
configured to use default values. For example, if a user configures
virtual text to include the source globally (using
vim.diagnostic.config) and a specific namespace or producer configures
virtual text with `virt_text = true`, the user's global configuration is
overriden.

Instead, interpret a value of `true` to mean "use existing settings if
defined, otherwise use defaults".
2021-10-17 07:18:35 -07:00
Michael Lingelbach
68b2a9e569
fix: correctly capture uri scheme on windows (#16027)
closes https://github.com/neovim/neovim/issues/15261

* normalize uri path to forward slashes on windows
* use a capture group on windows that avoids mistaking drive letters as uri scheme
2021-10-15 12:03:41 -07:00
Jose Alvarez
ee342d3cef
fix(lsp): maintain client_ids table structure when filtering (#15991) 2021-10-11 08:52:11 -07:00
Michael Lingelbach
d288daac2b
fix(lsp): do not invoke handlers for unsupported methods (#15926)
Closes https://github.com/neovim/neovim/issues/15174

Instead of invoking handlers with unsupported methods, pre-compute which
clients support a given method and only notify the user if no clients
support the given method.
2021-10-10 22:32:50 -07:00
jdrouhard
45fa70adcb
fix(lsp): add done flag to messages returned in util.get_progress_messages() (#15985) 2021-10-10 11:41:16 -07:00
francisco souza
fcc11d5942
fix(lsp): add textDocument/prepareRename to capability map (#15961)
This is a simple fix for #15899, as it should at least stop calling
`prepareRename` on servers that don't support renaming.

I imagine a better fix would be to inspect the actual value for, but
that requires some plumbing changes on how capabilities are evaluated
before sending requests out.

Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
2021-10-08 11:30:18 -07:00
Gregory Anders
d5dd0aa1e6
fix(diagnostic): error on invalid severity value (#15965)
Users can pass string values for severities that match with the enum
names (e.g. "Warn" or "Info") which are converted to the corresponding
numerical value in `to_severity`. Invalid strings were simply left
as-is, which caused confusing errors later on. Instead, report an
invalid severity string right up front to make the problem clear.
2021-10-08 12:28:02 -06:00
Rishikesh Vaishnav
3f09732195
fix(lsp): expose ContentModified error code to callbacks (#15262) 2021-10-08 11:19:33 -07:00
Mathias Fußenegger
e9d6f7ca6c
feat(lsp): utilize textEdit.range for startbyte in omnifunc (#15957)
Closes https://github.com/neovim/neovim/issues/15784
2021-10-08 08:47:59 -07:00
Gregory Anders
7f93b2ab01
fix: support severity_sort option for show_diagnostic functions (#15948)
Support the severity_sort option for show_{line,position}_diagnostics.
2021-10-07 19:19:30 -06:00
Sean Dewar
b55944e8af
feat(diagnostic): update jumplist on goto_next/prev (#15942) 2021-10-07 08:46:17 -07:00
Michael Lingelbach
912a6e5a9c
feat(lsp): improve json deserialization performance (#15854)
* Add optional second table argument to vim.json.decode which takes
  a table 'luanil' which can include the 'object' and/or 'array' keys. These
  options use luanil when converting NULL in json objects and arrays
  respectively. The default behavior matches the original lua-cjson.
* Remove recursive_convert_NIL function from rpc.lua, use
  vim.json.decode with luanil = { object = true } instead. This removes a hotpath
  in the json deserialization pipeline by dropping keys with json NULL
  values throughout the deserialized table.
2021-10-05 08:37:20 -07:00
Javier Lopez
0a7a215aa6
fix(healthcheck): update builtins to the new convention #15914
Adjust some builtin healthchecks to use Lua, after #15259
2021-10-05 05:05:33 -07:00
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
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
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
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
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
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
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
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
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
Gregory Anders
924e8e4f2d
fix(diagnostic): only update decorations for loaded buffers (#15715)
When vim.diagnostic.config() is called, the decorations for diagnostics
are re-displayed to use the new configuration. This should only be done
for loaded buffers.
2021-09-18 14:01:03 -07:00
hrsh7th
41cfba63cd
feat(lsp): improve vim.lsp.util.apply_text_edits (#15561)
- Fix the cursor position after applying TextEdits
- Support reversed range of TextEdit
- Invoke nvim_buf_set_text one by one
2021-09-18 13:19:21 -07:00
Gregory Anders
ef52433847 fix(diagnostic): resolve nil bufnr in show_line_diagnostics 2021-09-18 09:44:30 -06:00
Gregory Anders
0dcf4ab27b fix(diagnostic): remove check on nil return value
vim.diagnostic._set_signs doesn't return anything, so checking the
return value will always fail.
2021-09-17 21:10:10 -06:00
Gregory Anders
445ef41314 refactor(diagnostic): combine config() and set() calls 2021-09-17 21:07:24 -06:00
Gregory Anders
15d501ff7a refactor(diagnostic): group local functions together 2021-09-17 21:07:24 -06:00
Gregory Anders
938ed458e2 fix(diagnostic): change default severity_sort order
When severity_sort is true, higher severities should be displayed before
lower severities (e.g. ERROR is displayed over WARN).

Also improved the test case for this.
2021-09-17 14:59:30 -06:00
Gregory Anders
32c0631183 fix(diagnostic): support severity_sort 2021-09-17 10:50:25 -06:00
Gregory Anders
f87779a24d fix(diagnostic): correctly handle folder level diagnostics 2021-09-17 09:28:11 -06:00
Gregory Anders
15fbc9b69e docs(diagnostics): fix typos 2021-09-17 08:57:51 -06:00
Gregory Anders
3fd145007c fix(diagnostic): fix wrong data type in setqflist() 2021-09-17 08:53:08 -06:00
Gregory Anders
71e0e6cc63 fix(diagnostic): don't overwrite existing sign definitions 2021-09-17 08:44:52 -06:00
Christian Clason
22d146760e fix(diagnostic): don't convert diagnostic table twice
The recursive implementation of vim.lsp.diagnostic.get() applied
`diagnostic_vim_to_lsp` twice, and the second time gave wrong
results because of the unexpected format.

Fixes https://github.com/neovim/neovim/issues/15689
2021-09-17 13:35:57 +02:00
Christian Clason
3e230da90b fix(diagnostic): show_line_diagnostic with empty lnum
The documentation claims to default to the current line number if
the argument `lnum` is nil, but that was never actually done.

Fixes https://github.com/neovim/neovim/issues/15690
2021-09-17 13:33:54 +02:00
Christian Clason
4881456e83
fix(diagnostic): nvim_echo takes three args (#15687)
Fixup for https://github.com/neovim/neovim/pull/15585
Closes https://github.com/neovim/neovim/issues/15686
2021-09-17 09:21:17 +02:00
Gregory Anders
c13242cf47
fix(diagnostic): remove useless highlight links (#15683)
These links were actually defined backwards: the highlight groups
actually being used for display are the new "Diagnostic*" groups, so
linking the old "LspDiagnostics*" groups to these does absolutely
nothing, since there is nothing actually being highlighted with the
LspDiagnostics* groups.

These links were made in an attempt to preserve backward compatibility
with existing colorschemes. We could reverse the links to maintain this
preservation, but then that disallows us from actually defining default
values for the new highlight groups.

Instead, just remove the links and be done with the old LspDiagnostics*
highlight groups.

This is not technically a breaking change: the breaking change already
happened in #15585, but this PR just makes that explicit.
2021-09-17 08:17:54 +02:00
Justin M. Keyes
2e8103475e
Merge #15585 refactor: move vim.lsp.diagnostic to vim.diagnostic
## Overview

- Move vim.lsp.diagnostic to vim.diagnostic
- Refactor client ids to diagnostic namespaces
- Update tests
- Write/update documentation and function signatures

Currently, non-LSP diagnostics in Neovim must hook into the LSP subsystem. This
is what e.g. null-ls and nvim-lint do. This is necessary because none of the
diagnostic API is exposed separately from the LSP subsystem.

This commit addresses this by generalizing the diagnostic subsystem beyond the
scope of LSP. The `vim.lsp.diagnostic` module is now simply a specific
diagnostic producer and primarily maintains the interface between LSP clients
and the broader diagnostic API.

The current diagnostic API uses "client ids" which only makes sense in the
context of LSP. We replace "client ids" with standard API namespaces generated
from `nvim_create_namespace`.

This PR is *mostly* backward compatible (so long as plugins are only using the
publicly documented API): LSP diagnostics will continue to work as usual, as
will pseudo-LSP clients like null-ls and nvim-lint. However, the latter can now
use the new interface, which looks something like this:

```lua
-- The namespace *must* be given a name. Anonymous namespaces will not work with diagnostics
local ns = vim.api.nvim_create_namespace("foo")

-- Generate diagnostics
local diagnostics = generate_diagnostics()

-- Set diagnostics for the current buffer
vim.diagnostic.set(ns, diagnostics, bufnr)
```

Some public facing API utility methods were removed and internalized directly in `vim.diagnostic`:

* `vim.lsp.util.diagnostics_to_items`

## API Design

`vim.diagnostic` contains most of the same API as `vim.lsp.diagnostic` with
`client_id` simply replaced with `namespace`, with some differences:

* Generally speaking, functions that modify or add diagnostics require a namespace as their first argument, e.g.

  ```lua
  vim.diagnostic.set({namespace}, {bufnr}, {diagnostics}[, {opts}])
  ```

   while functions that read or query diagnostics do not (although in many cases one may be supplied optionally):

   ```lua
   vim.diagnostic.get({bufnr}[, {namespace}])
   ```

* We use our own severity levels to decouple `vim.diagnostic` from LSP. These
  are designed similarly to `vim.log.levels` and currently include:

  ```lua
  vim.diagnostic.severity.ERROR
  vim.diagnostic.severity.WARN
  vim.diagnostic.severity.INFO
  vim.diagnostic.severity.HINT
  ```

  In practice, these match the LSP diagnostic severity levels exactly, but we
  should treat this as an interface and not assume that they are the same. The
  "translation" between the two severity types is handled transparently in
  `vim.lsp.diagnostic`.

* The actual "diagnostic" data structure is: (**EDIT:** Updated 2021-09-09):

  ```lua
  {
    lnum = <number>,
    col = <number>,
    end_lnum = <number>,
    end_col = <number>,
    severity = <vim.diagnostic.severity>,
    message = <string>
  }
  ```

This differs from the LSP definition of a diagnostic, so we transform them in
the handler functions in vim.lsp.diagnostic.

## Configuration

The `vim.lsp.with` paradigm still works for configuring how LSP diagnostics are
displayed, but this is a specific use-case for the `publishDiagnostics` handler.
Configuration with `vim.diagnostic` is instead done with the
`vim.diagnostic.config` function:

```lua
vim.diagnostic.config({
    virtual_text = true,
    signs = false,
    underline = true,
    update_in_insert = true,
    severity_sort = false,
}[, namespace])
```

(or alternatively passed directly to `set()` or `show()`.)

When the `namespace` argument is `nil`, settings are set globally (i.e. for
*all* diagnostic namespaces). This is what user's will typically use for their
local configuration. Diagnostic producers can also set configuration options for
their specific namespace, although this is generally discouraged in order to
respect the user's global settings. All of the values in the table passed to
`vim.diagnostic.config()` are resolved in the same way that they are in
`on_publish_diagnostics`; that is, the value can be a boolean, a table, or
a function:

```lua
vim.diagnostic.config({
    virtual_text = function(namespace, bufnr)
        -- Only enable virtual text in buffer 3
        return bufnr == 3
    end,
})
```

## Misc Notes

* `vim.diagnostic` currently depends on `vim.lsp.util` for floating window
  previews. I think this is okay for now, although ideally we'd want to decouple
  these completely.
2021-09-16 14:23:42 -07:00
Gregory Anders
4fca63dbf7 fix(lint): remove unused parameters from deprecated functions 2021-09-16 15:01:09 -06:00
Gregory Anders
0c86bf563c refactor: remove UTF to byte col conversion 2021-09-16 11:26:45 -06:00
Gregory Anders
a5bbb932f9 refactor: move vim.lsp.diagnostic to vim.diagnostic
This generalizes diagnostic handling outside of just the scope of LSP.
LSP clients are now a specific case of a diagnostic producer, but the
diagnostic subsystem is decoupled from the LSP subsystem (or will be,
eventually).

More discussion at [1].

[1]: https://github.com/neovim/neovim/pull/15585
2021-09-15 14:09:47 -06:00
Michael Lingelbach
685cf39813
feat(lsp): improve logging (#15636)
* Simplify rpc encode/decode messages to rpc.send/rcp.receive
* Make missing handlers message throw a warning
* Clean up formatting style in log
* Move all non-RPC loop messages to trace instead of debug
* Add format func option to log to allow newlines in per log entry
2021-09-15 11:35:04 -07:00
hrsh7th
516775e9d8
fix(lsp): correctly parse LSP snippets #15579
Fixes #15522
2021-09-14 04:31:41 -07:00
Justin M. Keyes
329047b3db
docs #15625
fix #12261
fix #15536
fix #15623
fix #15572
ref #14244
ref #15034

close #15555
close #14957
2021-09-10 06:59:17 -07:00
Javier Lopez
4b452d4efb
perf(lua): optimize vim.deep_equal #15236
By remembering the keys already compared in repeating a comparison is
avoided. Thanks: https://stackoverflow.com/a/32660766
2021-09-10 06:22:40 -07:00
Zi How Poh
c1f573fbc9
feat(lsp): support textDocument/prepareRename (#15514) 2021-09-08 17:00:15 +02:00
Michael Lingelbach
384a43fe71
chore(lsp): fix formatting in vim.lsp.log (#15596) 2021-09-07 21:48:19 -07:00
Michael Lingelbach
e6777a7a04 feat(lsp): add warning message for large log size 2021-09-07 20:52:08 -07:00
Michael Lingelbach
e26802650d feat(lsp): add lsp healthcheck
Add healthcheck for language server client, currently only checks
logging status.
2021-09-07 20:51:40 -07:00
Mathias Fußenegger
687a0b3d3e
fix(lsp): adapt codelens resolve to handler signature change (#15578)
Follow up to https://github.com/neovim/neovim/pull/15504
2021-09-06 17:30:53 +02:00
Jose Alvarez
3f526feebf
fix(lsp): update workspace/applyEdit handler signature (#15573) 2021-09-05 12:48:54 -07:00
Michael Lingelbach
23fe6dba13
Merge pull request #15504 from mjlbach/feat/change-handler-signature
feat(lsp)!: change handler signature
2021-09-05 10:27:52 -07:00
Michael Lingelbach
df17d7844e feat(lsp)!: change handler signature
Previously, the handler signature was:

  function(err, method, params, client_id, bufnr, config)

In order to better support external plugins that wish to extend the
protocol, there is other information which would be advantageous to
forward to the client, such as the original params of the request that
generated the callback.

In order to do this, we would need to break symmetry of the handlers, to
add an additional "params" as the 7th argument.

Instead, this PR changes the signature of the handlers to:

  function(err, result, ctx, config)

where ctx (the context) includes params, client_id, and bufnr. This also leaves
flexibility for future use-cases.

BREAKING_CHANGE: changes the signature of the built-in client handlers, requiring
updating handler calls
2021-09-05 10:04:30 -07:00
Mathias Fußenegger
5c643dee7b
docs(lsp): remove private lsp.diagnostic functions from docs (#15541)
Both `apply_to_diagnostic_items` and `show_diagnostics` are local
functions and cannot be called by users.
2021-09-01 14:28:15 +02:00
Mathias Fußenegger
684550ff38
docs(lsp): document codelens.get bufnr parameter (#15540)
Alternative to https://github.com/neovim/neovim/pull/15224
2021-09-01 13:29:11 +02:00
Jose Alvarez
325fad8983
fix(lsp): resolve bufnr in buf_is_attached (#15523) 2021-08-30 07:46:00 -04:00
Björn Linse
6896d22b63 fix(lua): preserve argument lists which are not lists 2021-08-29 16:04:50 +02:00
Jose Alvarez
04938eed3e
fix(lsp): check if buffer is valid in changetracking (#15505) 2021-08-28 11:57:06 +02:00
zeertzjq
f6e662bbe9
feat(lsp): get_border_size(): support repeating border char list #15474 2021-08-27 04:19:17 -07:00
notomo
274a3504a7
fix(lua): verify buffer in highlight.on_yank (#15482)
Resolve an issue with deferred clearing of highlight failing if the 
buffer is deleted before the timeout by checking whether the
buffer is valid first.
2021-08-26 16:37:36 +02:00
Thomas Vigouroux
a373ca1d82
Merge pull request #15466 from vigoux/ts-query-auto
feat(ts): add query module in treesitter keys
2021-08-24 17:45:54 +02:00
Michael Lingelbach
5d633546bf
fix(lsp): enable additional capabilities (#15470)
Declaration, type-definition, and implementation capabilities were
previously disabled if the client received table output from the server
capabilities. The workDoneProgress capability is sent for many servers
for all supported capabilities as part of this table. Default to setting 
capability to table instead of false.
2021-08-23 16:25:15 -04:00
Thomas Vigouroux
8e0963d307
feat(ts): add query module in treesitter keys 2021-08-23 15:34:08 +02:00
Gregory Anders
c2a211b8e3
docs: make Lua docstrings consistent #15255
The official developer documentation in in :h dev-lua-doc specifies to
use "--@" for special/magic tokens. However, this format is not
consistent with EmmyLua notation (used by some Lua language servers) nor
with the C version of the magic docstring tokens which use three comment
characters.

Further, the code base is currently split between usage of "--@",
"---@", and "--- @". In an effort to remain consistent, change all Lua
magic tokens to use "---@" and update the developer documentation
accordingly.
2021-08-22 13:55:28 -07:00
Björn Linse
69741107e6
Merge pull request #15429 from bfredl/hl_2
perf(treesitter): avoid string lookup of highlight name in hot loop
2021-08-19 19:15:16 +02:00
Mathias Fußenegger
ff0833cb4e
feat(lsp): allow root_dir to be nil (#15430)
According to the protocol definition `rootPath`, `rootUri` and
`workspaceFolders` are allowed to be null.

Some language servers utilize this to provide "single file" support.
If all three are null, they don't attempt to index a directory but
instead only provide capabilities for a single file.
2021-08-19 18:15:18 +02:00
Zi How Poh
ea39ff5732
feat(lsp): jump to diagnostics by position (#14795) 2021-08-19 11:36:01 -04:00
Björn Linse
2460f0a702 perf(treesitter): avoid string lookup of highlight name in hot loop
These numbers are guaranteed to be stable even if you do "highlight
clear" (all attributes disappear, but not the id to name mapping itself)
2021-08-19 16:45:04 +02:00
Mathias Fussenegger
c1e17866c8 docs(lsp): prevent internal comments from showing as vim.lsp.init docs 2021-08-16 20:27:51 +02:00
Andrea Cappuccio
adebbebdd7
fix(lsp): properly handle nil lines when trimming empty lines (#15325) 2021-08-10 20:52:30 +02:00
Hans Pinckaers
1a10acb997
fix(lsp): floating popup should take offset_x into account when positioning (#15297) 2021-08-09 23:56:58 +02:00
max397574
a3d5f391cf
docs: Add some references to LSP specification (#15321) 2021-08-09 19:45:00 +02:00
Thomas Vigouroux
faa3007927
Merge pull request #14767 from theHamsta/no-treesitter-mapping-to-non-existent
fix(treesitter): do not map hl_group when no mapping is set
2021-08-07 11:44:41 +02:00
Folke Lemaitre
e7bde44d6d
fix(lsp): prevent duplicate lines seperated by newlines (#15284) 2021-08-06 17:15:49 -04:00
Stephan Seitz
912152d635 chore: remove reference to nvim-treesitter in comment 2021-08-06 22:08:45 +02:00
Stephan Seitz
f489d98653 fix(treesitter): do not map hl_group when no mapping is set
This changes the behavior of the hl_cache to the old one.

- when the capture exists as a hlgroup -> use it
- when hl_map contains a mapping -> use it
- else do nothing (before: map capture to non-existing capture)

Before also captures `@foo.bar` would intend to use the hlgroup `foo.bar`
which results in a confusing error since hlgroups can't contain dots.
2021-08-06 22:04:28 +02:00
Gregory Anders
2093b12b82 refactor: remove remaining references to nvim_buf_set_virtual_text 2021-08-03 11:39:46 -06:00
Mathias Fußenegger
24f2b9ef1c
fix(lsp): Include client name in handler error messages (#15227)
Makes it easier to tell with language server caused an error.
2021-07-31 22:26:02 +02:00
Gregory Anders
3521bf7672
feat(lsp): implement vim.lsp.diagnostic.redraw() (#15203)
Add a new function to redraw diagnostics from the current diagnostic
cache, without receiving a "publishDiagnostics" message from the server.
This is already being done in two places in the Lua stdlib, so this
function unifies that functionality in addition to providing it to third
party plugins.

An example use case for this could be a command or key-binding for
toggling diagnostics virtual text. The virtual text configuration option
can be toggled using `vim.lsp.with` followed by
`vim.lsp.diagnostic.redraw()` to immediately redraw the diagnostics
with the updated setting.
2021-07-29 09:02:17 -07:00
Gregory Anders
3e00d4f01c
feat(lsp): make list handlers configurable (#15199)
The handlers for textDocument/references, textDocument/documentSymbol,
and workspace/symbol open their results in the quickfix list by default
and are not configurable. They are also incompatible with `vim.lsp.with`
as they do not accept a configuration parameter.

Add a `config` parameter to the handler for these three messages which
allows them to be configured with `vim.lsp.with`. Additionally, add a
new configuration option 'loclist' that, when true, causes these
handlers to open their results in the location list rather than the
quickfix list.
2021-07-26 11:39:50 -07:00
Thomas Vigouroux
5c42e2a87f
docs(ts): add documentation for listing fns 2021-07-25 20:52:05 +02:00
Stephan Seitz
b2a9afef6d treesitter: add query.list_directives 2021-07-24 20:57:45 +02:00
Stephan Seitz
242608e669 feat(treesitter): allow to set highlight priority for queries 2021-07-22 21:38:57 +02:00
Marc Jakobi
a8c3d50fad
lsp: add vim.lsp.diagnostic.set_qflist() function (#14831)
* Add vim.lsp.diagnostic.set_qflist() function
* replaces opts.open_loclist with unified opts.open
2021-07-22 08:48:28 -07:00
sim
710b9ed1c7
lsp(start_client): Allow passing custom workspaceFolders to the LSP (#15132)
Some language servers *cough*rust-analyzer*cough* need an empty/custom
workspaceFolders for certain usecases. For example, rust-analyzer
needs an empty workspaceFolders table for standalone file support
(See https://github.com/rust-analyzer/rust-analyzer/pull/8955).

This can also be useful for other languages that need to commonly
open a certain directory (like flutter or lua), which would help
prevent spinning up a new language server altogether.

In case no workspaceFolders are passed, we fallback to what we had
before.
2021-07-20 22:00:38 +02:00
Folke Lemaitre
9358aa04c4
docs: made can_merge private (#15138) 2021-07-19 14:23:28 -07:00
Gregory Anders
4ed2d4fd66
fix(lsp): allow diagnostic.clear to accept nil bufnr (#15137)
Passing `nil` is equivalent to passing 0, i.e. it simply uses the
current buffer number.

This fixes a bug when vim.lsp.diagnostic.disable() is called without
arguments.
2021-07-19 14:23:12 -07:00
Gregory Anders
1aeb945553
feat(lsp): allow diagnostics to be disabled for a buffer (#15134)
Add two new methods to allow diagnostics to be disabled (and re-enabled)
in the current buffer. When diagnostics are disabled they are simply not
displayed to the user, but they are still sent by the server and
processed by the client.

Disabling diagnostics can be helpful in a number of scenarios. For
example, if one is working on a buffer with an overwhelming amount of
diagnostic warnings it can be helpful to simply disable diagnostics
without disabling the LSP client entirely. This also allows users more
flexibility on when and how they may want diagnostic information to be
displayed. For example, some users may not want to display diagnostic
information until after the buffer is first written.
2021-07-19 11:49:55 -07:00
rayx
c487a73fa2
feat(lsp): allow configuring zindex for floating windows (#15086) 2021-07-19 09:03:59 -07:00
Folke Lemaitre
526fc609b8
fix(shared): do not treat empty tables as list in deep extend (#15094)
An empty table was previously always treated as a list, which means that
while merging tables, whenever an empty table was encountered it would
  always truncate any table on the left.

`vim.tbl_deep_extend("force", { b = { a = 1 } }, { b = {} })`

Before: `{ b = {} }`
After: `{ b = { a = 1 } }`
2021-07-19 08:52:44 -07:00
Folke Lemaitre
c36df20aef
feat: aggregate code actions from all clients (#15121) 2021-07-18 01:58:35 -07:00
Ido Ariel
d8f5f4d090
doc(lsp): various small fixes (#15113)
- remove incorrect usage of docstrings
- fix make_formatting_params return type documentation to 'DocumentFormattingParams'
- make progress_handler private
- fix links
2021-07-17 11:15:57 +02:00
Michael Lingelbach
19a2e59f7e
Merge pull request #15017 from donbex/local-file-uri
fix(lsp): accept file URIs without a hostname
2021-07-14 12:20:13 -07:00
Michael Lingelbach
c31bc6ea73
fix(lsp): pass bufnr for async formatting (#15084)
the `textDocument/rangeFormatting` nad `textDocument/formatting` did not
pass bufnr to apply_text_edits, meaning edits were applied to
the user's currently active buffer. This could result in text being
applied to the wrong buffer.
2021-07-14 09:15:43 -07:00
Michael Lingelbach
eece0735fe
fix(lsp): avoid ipairs on non-sequential tables (#15059)
ipairs terminates on the first nil index when iterating over table keys:

for i,k in ipairs( {[1] = 'test', [3] = 'test'} ) do
  print(i, k)
end

prints:
1 test

Instead, use pairs which continues iterating over the entire table:

for i,k in pairs( {[1] = 'test', [3] = 'test'} ) do
  print(i, k)
end

prints:
1 test
3 test
2021-07-11 11:34:26 -07:00
Mathias Fussenegger
c21a6972a0 fix(lsp): Ensure human readable errors are printed
`return err_message(tostring(err))` caused errors to be printed as
`table: 0x123456789` instead of showing the error code and error
message.

This also removes some `if err` blocks that never got called because at
the end of `handlers.lua` all the handlers are wrapped with logic that
adds generic error handling.
2021-07-11 11:22:35 +02:00
Mathias Fussenegger
256570a7a6 fix(lsp): Ensure users get feedback on references/symbols errors or empty results
Relates to https://github.com/neovim/neovim/issues/15050

Users should get some indication if there was an error or an empty
result.
2021-07-11 10:57:00 +02:00
Mathias Fußenegger
7c61d9c3bf
fix(lsp): Add separator between codelens in virttext (#15049)
Before:

  Lens1Lens2

After:

  Lens1 | Lens2

Fixes https://github.com/neovim/neovim/issues/15048
2021-07-10 21:35:38 +02:00
Oliver Marriott
0b64d5ecd1
fix(lsp): correctly check for windows in lsp logger (#14954) 2021-07-10 11:11:33 -07:00
Tom Payne
1dab9357de feat(vim.uri): Allow URI schemes other than file: without authority 2021-07-10 18:27:37 +01:00
Alessandro Pezzoni
a2c2a08652 fix(lsp): accept file URIs without a hostname
RFC 8089, which defines the file URI scheme, also allows URIs without a
hostname, i.e. of the form file:/path/to/file. These are returned by
some language servers and accepted by other LSP implementations, such as
VSCode's, so it is reasonable for us to accept them as well.
2021-07-10 18:27:37 +01:00
Mathias Fussenegger
e43dbfdd05 feat(lsp): Make line diagnostics display prettier
Adds indentation that matches the number prefix to ensure diagnostic
messages spawning multiple lines align.

Before:

    Diagnostics:
    1. • Variable not in scope: red :: t0 -> t
    • Perhaps you meant one of these:
        ‘rem’ (imported from Prelude), ‘read’ (imported from Prelude),
        ‘pred’ (imported from Prelude)
    2. • Variable not in scope: repeDoubleColon :: [Char] -> t0
    • Perhaps you meant ‘replaceDoubleColon’ (line 32)

After:

    Diagnostics:
    1. • Variable not in scope: red :: t0 -> t
       • Perhaps you meant one of these:
           ‘rem’ (imported from Prelude), ‘read’ (imported from Prelude),
           ‘pred’ (imported from Prelude)
    2. • Variable not in scope: repeDoubleColon :: [Char] -> t0
       • Perhaps you meant ‘replaceDoubleColon’ (line 32)
2021-07-09 20:36:08 +02:00
Folke Lemaitre
9132b76da6
fix(lsp): support duplicate params in signature help (#15032) 2021-07-09 03:38:29 -07:00
Folke Lemaitre
03d15d9e09
fix(lsp): restore diagnostics extmarks that were moved to the last edit line (#15023) 2021-07-08 08:40:41 -07:00
Folke Lemaitre
af263711a3
feat(lsp): highlight active parameter in signature help (#15018) 2021-07-07 23:04:35 -07:00
Folke Lemaitre
77b33e4b9f
fix(lsp): restore diagnostics extmarks on buffer changes (#15011) 2021-07-07 22:31:39 +02:00
Folke Lemaitre
910967e5af
fix(lsp): prevent double <text> for cached plaintext markup 2021-07-05 00:39:46 +02:00
jadedpasta
490615612e
fix(vim.opt): vimL map string values not trimmed (#14982)
Options formatted as a list of comma-separated key-value pairs may have
values that contain leading and trailing whitespace characters. For
example, the `listchars` option has a default value of
`"tab:> ,trail:-,nbsp:+"`. When converting this value to a lua table,
leading and trailing whitespace should not be trimmed.

Co-authored-by: Robert Hrusecky <robert.hrusecky@utexas.edu>
2021-07-04 00:14:39 -07:00
TJ DeVries
19b7cef0a7 fix(vim.opt): Fix #14828 with empty values being incorrectly inserted 2021-06-29 09:18:59 -04:00
TJ DeVries
6ecec87c09 fix(vim.opt): Fix #14668 Now correctly handles unescaped commas in isfname style 2021-06-29 08:42:07 -04:00
TJ DeVries
9119ea1bec fix(vim.opt): Fix #14669 whichwrap now acts as expected 2021-06-29 08:42:07 -04:00
David Zhang
b02e64c4df fix(vim.opt): Add basic error handling 2021-06-29 08:42:07 -04:00
ckipp01
e6175f6389 fix(vim.opt): Get window options before setting.
This closes #14677, but I also am a little unsure if there are times
where this may not be correct. However, this just changes the behavior
that even if `was_set` was false, we still get for
`nvim_win_get_option`.
2021-06-29 08:42:07 -04:00
TJ DeVries
1d3ee1c441 fix(vim.opt): #14708 Now lets you put duplicate values in wildmode 2021-06-29 08:42:07 -04:00
jimman2003
bdf3df4027
Fixed +1 -1 in util.lua (#14913)
No point in adding and then subtracting I believe ;)
2021-06-26 13:43:18 -04:00
Folke Lemaitre
e680d7d6af
fix(lsp): render the last line in stylize_markdown 2021-06-25 11:45:42 -07:00
Folke Lemaitre
28dde1038f
style(lsp): make get_markdown_fences private 2021-06-25 18:32:00 +02:00
Michael Lingelbach
5d792701cf
Merge pull request #14904 from mfussenegger/nil-message-callbacks
fix(lsp): Handle nil message_callbacks
2021-06-25 09:13:01 -07:00
Michael Lingelbach
7b5a233d64
Merge pull request #14617 from folke/fancy_markdown_fences_support
feat(lsp): use `g:markdown_fenced_languages` in `vim.lsp.util.stylized_markdown`
2021-06-25 09:02:28 -07:00
Folke Lemaitre
aa1e20497a
feat(lsp): use markdown_fenced_languages in stylized_markdown 2021-06-25 17:27:38 +02:00
Mathias Fussenegger
58473178ff fix(lsp): Handle nil message_callbacks
The `onexit` handler could set `message_callbacks` to `nil` within the
luv event loop while the mainloop runs a function that tries to access
`message_callbacks`.

This adds some checks to prevent errors in that case.

Fixes https://github.com/neovim/neovim/issues/14863
2021-06-25 14:45:17 +02:00
Mathias Fussenegger
7ea652e4bf fix(lsp): Set dir completion option for add_workspace_folder
Given that the input is pre-filled with a path, it should be possible to
use dir completion.
2021-06-25 14:28:17 +02:00
Akin Sowemimo
444f175335 fix(lsp): do not convert vim.NIL to nil in lists 2021-06-24 11:23:19 +01:00
Michael Lingelbach
060255253f fix(lsp): handlers should focus quickfix list 2021-06-21 20:44:37 -07:00
Steven Arcangeli
43835ab0da fix(lsp): fix severity_limit logic in set_loclist 2021-06-19 07:35:17 -07:00
Folke Lemaitre
39d9713c5b
chore(lsp): removed deprecated floating preview methods 2021-06-17 07:48:40 +02:00
Lukas Reineke
f76f72a27b
fix(lsp): add bufnr to formatting requests
Add the buffer number to the `textDocument/formatting` request, so
that it is passed to the handler.
The built-in formatting handlers do not use the buffer number, but user
overrides should have access to it.
2021-06-15 23:53:43 -07:00
Shadman
3df0e475e8
docs(lsp): Clarify opts for show_line_diagnostics() 2021-06-15 23:21:04 -07:00
cbarrete
8cdffd42dd
docs(lsp): annotate call_hierarchy function as private 2021-06-14 23:19:23 -07:00
Jaehwang Jerry Jung
b8dfa2f112
fix(lsp): fix on_detach in lsp.diagnostic
`lsp.diagnostic.get_all()` was returning diagnotics for `:bwipeout`-ed
buffers because the diagnostic cache is not cleared. The first argument
of on_detach callback is the string "detach", not the bufnr.
2021-06-14 23:07:52 -07:00
Folke Lemaitre
d7d1f40d2c
fix(lsp): replace --- by a line in stylize_markdown 2021-06-15 07:35:58 +02:00
Michael Lingelbach
98b597bf03
Merge pull request #14737 from rktjmp/lsp-guard-against-negative-lines
[RDY] fix(lsp): guard against negative diagnostic line numbers
2021-06-14 15:01:58 -07:00
Timothée Sterle
15039d7597
fix(lsp): allow 'rounded' and 'solid' in floats 2021-06-14 23:19:45 +02:00
Mathias Fussenegger
2bdd553c9e feat(lsp): Add codelens support 2021-06-14 21:45:14 +02:00
Michael Lingelbach
141647cfbb
Merge pull request #14765 from folke/lsp_plaintext
fix(lsp): convert_input_to_markdown_lines: preserve plaintext
2021-06-12 17:48:04 -07:00
Folke Lemaitre
afb0274c28
fix(lsp): convert_input_to_markdown_lines: preserve plaintext 2021-06-12 21:47:17 +02:00
Oliver Marriott
ee4735881d fix(lsp): guard against negative diagnostic line numbers 2021-06-13 03:38:59 +10:00
Michael Lingelbach
f9b9b82047 fix(lsp): cap diagnostic end range to buf length
Closes #14743
2021-06-10 22:16:34 -04:00
Mathias Fussenegger
f03a4d616b feat(lsp): Split out a diagnostics_to_items function from set_loclist
Makes it easier to re-use the logic to populate the quickfix list
instead of the location list.
2021-06-07 18:24:32 +02:00
Michael Lingelbach
4ce61742cf
Merge pull request #14726 from folke/lsp_single_popup_per_buffer
fix(lsp): max 1 floating preview per buffer. Fixes #11508
2021-06-06 03:22:10 -07:00
Viktor Kojouharov
36d05845f7 feat(lsp): extend diagnostic.set_loclist
add option to show workspace diagnostic instead of the current buffer's
2021-06-06 09:59:46 +02:00
Michael Lingelbach
5902bed406 docs(lsp): fix locations_to_items docstring 2021-06-05 17:22:47 -07:00
Michael Lingelbach
36802b895f
Merge pull request #14730 from mjlbach/feature/open_loclist_on_win
fix(lsp): set_loclist should target current win
2021-06-05 17:12:55 -07:00
Michael Lingelbach
f214c19e2b
Merge pull request #14707 from ray-x/master
fix(lsp): floating window border size for string type
2021-06-05 15:00:07 -07:00
Michael Lingelbach
15abde1676 fix(lsp): set_loclist should target current win
Currently, for large number of diagnostics, the delay in populating
loclist may be sufficient for a user to switch to another window,
resulting in the loclist being populated on the wrong window.
2021-06-05 14:46:10 -07:00
Michael Lingelbach
d846bd7e06 feat(lsp): remove line from diagnostic quickfix
Adding the line takes up valuable horizontal screen space, and also
precludes using the quickfixtextfunc built into neovim due to the
harcoded `|`.
2021-06-05 13:39:30 -07:00
Folke Lemaitre
149efa9b2b
fix(lsp): max 1 floating preview per buffer. Fixes #11508 2021-06-05 10:13:01 +02:00
ray-x
351050a10f fix(lsp): floating window border size for string type 'none' and 'shadow' 2021-06-02 20:44:13 +10:00
Jose Alvarez
d4caafacc1 fix(lsp): check mode in omnifunc callback 2021-06-01 22:13:21 +09:00
Michael Lingelbach
b10cda83fa
Merge pull request #14693 from shadmansaleh/enhance/lsp/make_focusable_parameter_configurable
feat(lsp): Make focusability of lsp float configurable
2021-06-01 04:32:59 -07:00
shadmansaleh
68d48e25b6 docs(lsp): Fix opts param not captured by docgen
In the documentation for `vim.lsp.util.open_floating_preview`
the opts table keys were prefixed with `--` instead of `---`,
preventing capture by docgen.
2021-06-01 17:29:06 +06:00
shadmansaleh
0bd34cb4ec feat(lsp): Make focusability of lsp float configurable
This pr allows the user to specify whether `lsp.utils.open_floating_preview`
is focusable via the `opts` parameter. Defaults to true.

It can be configured by setting the focusable key inside opts parameter:

```lua
vim.lsp.util.open_floating_preview(contents, syntax, {focusable = false})
```
2021-06-01 17:23:35 +06:00
Michael Lingelbach
64bdaef327
Merge pull request #14694 from folke/lsp_popup_border 2021-06-01 01:52:38 -07:00
Folke Lemaitre
0ece34cbb8
fix(lsp): properly handle border character list without highlight groups. Fixes #14691 2021-06-01 09:36:29 +02:00
Michael Lingelbach
96dfa07642
Merge pull request #14635 from folke/lsp_get_lines
perf(lsp): get all lines from a file in one go (`locations_to_items`)
2021-05-31 11:12:23 -07:00
Michael Lingelbach
cabf8ab26b
Merge pull request #14649 from folke/lsp_float_refactor
refactor(lsp): consolidate the different floating window methods into `open_floating_preview`
2021-05-29 12:06:58 -07:00
Folke Lemaitre
64da499ac2
refactor(lsp): consolidate the different floating window methods into open_floating_preview 2021-05-29 13:42:15 +02:00
TJ DeVries
43956dea55
lua: Add vim.opt and fix scopes of vim.o (#13479)
* lua: Add vim.opt

* fixup: cleaning

* fixup: comments

* ty clason

* fixup: comments

* this is the last commit. period.
2021-05-28 17:24:48 +02:00