Commit Graph

294 Commits

Author SHA1 Message Date
Thomas Vigouroux
25e20da550
feat(buffer_updates): allow ignoring when previewing
Also adds a test that we actually subscribe to buffer events when in
CMDPREVIEW.
2020-12-15 22:29:27 +01:00
Matthew Nibecker
e8ae3ade77
Fix lsp tests breaking from new LuaJIT version
Apparently the new version of LuaJIT changed the consistency with which it
sorted table dictionaries. IIRC lua sorts dictionary keys by memory address, so
it would appear that the reasons tests were previously passing was because of
a differentiation in the implementation of the lua runtime.

Ensure that array fields in the lsp protocol tables are consistently created,
by using ipair when generating arrays for completionItemKind and
symbolItemKind.

For CodeActionKind, the current implementation includes both the keys and the
values in the array. This is incorrect. Ensure that only the values are
included in the array and sort them for consistency.
2020-12-13 21:03:27 -05:00
Thomas Vigouroux
99007bcc12
Merge pull request #13450 from nvim-treesitter/fix-unknown-language-parser
fix(treesitter): don't throw an error for missing injected langs
2020-12-10 11:12:39 +01:00
Kevin Fleming
fb1c08a86f
doc: Fix incorrect LSP diagnostic-related helptags (#13388) 2020-12-09 11:21:16 +01:00
Olivier Roques
222a0452fa
doc: Add missing parameter end_pos for range_formatting (#13481) 2020-12-09 11:19:56 +01:00
TJ DeVries
08ec36efaf
feat: Allow incremental sync & lsp flags (#13371) 2020-12-08 21:09:33 -05:00
Steven Sojka
e15c5f58df fix(treesitter): don't throw an error for missing injected langs 2020-12-04 16:56:29 -06:00
Steven Sojka
2985c17867 fix(treesitter): incorrect method name call 2020-12-04 16:15:47 -06:00
Mathias Fußenegger
f5e0f17968
lsp: Change diagnosticg.get_all to return {bufnr: Diagnostic[]} (#13310)
Allows users to associate the diagnostics with the right bufnr.
2020-12-03 14:22:15 -05:00
runiq
5c7141cc71
lsp: Make open_floating_preview buffers ephemeral (#13437)
Fixes #13429.
2020-12-03 14:20:56 -05:00
eightpigs
fa73bb70fc
lsp: Fix "unsupported_method" error when the buffer does not have an LSP Server (#13175) 2020-12-03 01:00:54 -05:00
Yuki Ito
900228a20f lsp: Reduce memory usage for buffering the message from LSP. 2020-11-29 06:49:44 +09:00
Raphael
0e7f965a1b
use if_nil variable replace vim.F.if_nil 2020-11-26 14:32:38 +08:00
Raphael
dd00c74737
Lsp: fix vim.F.ifnil to vim.F.if_nil (#13384) 2020-11-25 21:17:03 -05:00
Michael Lingelbach
0d83a1c43f
LSP: Feature/add workspace folders (#12638)
* First implementation of workspace folders
* Add completion for current directory
* Add tracking of workspace folders
* Add workspace folder listing
* Add checks on adding/removing workspaces
* Add appropriate initialization options
* Add documentation
* Make workspaceFolders available wherever client is
2020-11-25 21:07:02 +01:00
Björn Linse
ca7fa2a43a
Merge pull request #13357 from vigoux/luahl-priority
feat(luahl): add priority mechanism
2020-11-25 12:43:08 +01:00
Thomas Vigouroux
c0a6989d93
feat(luahl): add priority mechanism
Base priority is 0x1000, in order to stay kinda backward compatible.
Also set tree-sitter default highlight to 100 (middle-ish value)
2020-11-25 10:10:05 +01:00
Thomas Vigouroux
e6d1656831
languagetree: call changedtree callback per tree
Also fix a typo
2020-11-24 16:53:03 +01:00
Thomas Vigouroux
52d76f0a32
fix(treesitter): allow ranges in set_included_ranges 2020-11-23 15:09:32 +01:00
Steven Sojka
1a631026a9
feat(treesitter): add language tree
Implement the LanguageTree structure to enable language injection.

This is done be removing the old Parser metatable and replacing by the
new structure, with the same API (almost).

Some noticeable differences :
  - `parser:parse()` now returns a table of trees
  - There is no incremental parsing for child (injected) languages

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
2020-11-23 08:06:17 +01:00
Mathias Fußenegger
0798ad3a3a
lsp: Expose all diagnostics (#13285)
* lsp: Remove duplicate `diagnostics` fallback in diagnostic.display

* lsp: Expose all diagnostics

Before the changes in #12655 it was possible to retrieve all diagnostics
via `vim.lsp.util.diagnostics_by_buf`.

This adds a `diagnostic.get_all()` to enable users to retrieve all
diagnostics.

Use cases for that could include loading all diagnostics into the
quickfix list, or to build an enhanced goto_next that can move across
buffers.
2020-11-14 14:39:05 -05:00
TJ DeVries
35325ddac0
doc: fixup sign information (#13281)
Thanks to @sunzoje for finding the outdated documentation.
2020-11-13 00:02:40 -05:00
TJ DeVries
f75be5e9d5
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
    - Instead, all functions must be found in vim.lsp.diagnostic
    - For now, they issue a warning ONCE per neovim session. In a
      "little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
    - For a "little while" we will just redirect `vim.lsp.callbacks` to
      `vim.lsp.handlers`. However, we will remove this at some point, so
      it is recommended that you change all of your references to
      `callbacks` into `handlers`.
    - This also means that for functions like |vim.lsp.start_client()|
      and similar, keyword style arguments have moved from "callbacks"
      to "handlers". Once again, these are currently being forward, but
      will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
  inconsistently named.
    - For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
  |lsp-highlight-diagnostics|

General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
  provides a much nicer configuration strategy, so as to not recommend
  globally overwriting builtin neovim mappings.

LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
  customization for users without having to copy & paste entire files /
  functions / etc.

Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
    - For each of the gotos, auto open diagnostics is available as a
      configuration option
- Configurable diagnostic handling:
    - See |vim.lsp.diagnostic.on_publish_diagnostics()|
    - Delay display until after insert mode
    - Configure signs
    - Configure virtual text
    - Configure underline
- Set the location list with the buffers diagnostics.
    - See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
    - They are now cached on save, to enhance lookups.
    - Particularly useful for checking in statusline, etc.
- Actual testing :)
    - See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting

NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)

Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 22:21:34 -05:00
Stephan Seitz
0276c8addd tree-sitter: Put base languages first in queries
This reverts the handling of base languages to the old way how
nvim-treesitter handled them. When a language extends a base language
it usually wants to be able to overwrite queries.

Related: https://github.com/nvim-treesitter/nvim-treesitter/issues/633
2020-11-08 13:55:42 +01:00
francisco souza
5161ff88fa
lsp: fix formatting_sync with multiple clients (#13233)
buf_request_sync returns a table indexed by the client id, so when
starting a second client on a separate buffer, result[1] will be nil.

Closes #13232.

Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
2020-11-07 23:31:55 +01:00
Thomas Vigouroux
c7d460c197
treesitter: separate tree and parser
While this might sound silly, it is needed for further improvements.
2020-11-04 08:14:20 +01:00
Thomas Vigouroux
186ba3b688
Merge pull request #13178 from steelsojka/fix-empty-main-query-file
fix(treesitter): account for no main query file
2020-11-02 18:16:37 +01:00
TJ DeVries
dc14b1468a
lsp: remove vim.NIL from processing (#13174)
* lsp: remove vim.NIL from processing

* lsp: remove instances of vim.NIL
2020-11-02 08:50:44 -05:00
Jesse
720d442d19
lsp: complete support for CodeActionKinds to capabilities (#13180)
We support applying all kinds in the spec equivalently and some servers (including dartls) won't send code actions if support for the relevant kinds is not explicitly stated in the client capabilities. Therefore, this PR makes that support explicit.

Also, as we support all CodeActionKinds, we should also mark the server as supporting code actions when it specifies code action kinds. This is also done in this PR.
2020-11-01 18:11:32 +01:00
Björn Linse
8821587748
Merge pull request #13192 from bfredl/nodeid
] treesitter: add node:id()
2020-11-01 17:27:38 +01:00
Björn Linse
03c478ae53 treesitter: add node:id() 2020-11-01 14:59:17 +01:00
TJ DeVries
98024853f4
lsp: Remove snippet lies (#13183)
We don't actually support snippets in core in the way that users would
truly expect. So, by default, we will not say that builtin-lsp has
`snippetSupport`.

To re-enable, users can do the following:

First, get a capabilities dictionary with

`local capabilities = vim.lsp.protocol.make_client_capabilities()`

Then override

`capabilities.textDocument.completion.completionItem.snippetSupport = true`

and then pass those capabilties to the setup function.

```
nvim_lsp.server_name.setup {
  ...,
  capabilities = capabilities,
  ...,
}
```

See https://github.com/neovim/neovim/issues/12795
2020-10-30 10:58:12 -04:00
Steven Sojka
e27af09052 fix(treesitter): account for no main query file 2020-10-28 07:34:11 -05:00
Michael Lingelbach
fd7aa6768a
lsp: Fix case where active_signature == vim.NIL (#13114) 2020-10-27 22:39:24 -04:00
Matthieu Coudron
a22fe09b90
Merge pull request #13154 from fsouza/fix-callback-logic
[RDY] lsp: fix fallback for callback in method_unsupported
2020-10-25 22:09:41 +01:00
Mathias Fußenegger
7fef16e1d6
lsp: Store diagnostics for unloaded buffers (#13102)
To avoid loading buffers https://github.com/neovim/neovim/pull/12440
changed the logic to not process diagnostics for unloaded buffers.

This is problematic for language servers where compile errors or build
errors are reported via diagnostics. These errors may prevent the
language server from providing all functions and it is difficult for
users to debug it without having access to the errors.

For example, with eclipse.jdt.ls there may be a problem with gradle (the
build tool for java), it results in a diagnostics like this:

    org.gradle.toolingapi/build.gradle|1 col 1| Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.8.1-bin.zip'.

This would be invisible to users unless the user happens to open the
right file. In this case the user would actually never see the error,
because the language server isn't attached to the build configuration
files.

This changes the behaviour to at least store the diagnostics. The other
operations which are more expensive are still skipped.
2020-10-25 14:27:11 -04:00
francisco souza
1f0f92f8ec
lsp: fix fallback for callback in method_unsupported
Missed this #12764. My bad :((
2020-10-25 08:17:34 -04:00
francisco souza
6312792d8a
lsp: only send buf requests to servers that support the request (#12764)
Refactors how required capabilities are detected and validated, and make
sure requests are only sent to clients that support it (and only fail if
no clients support the provided method).

The validation happens at the buf_request level, because we assume that
if someone is sending the request directly through the client, they know
what they're doing. Also, let unknown methods go through.

This is extracted from #12518 and closes #12755.

Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
2020-10-25 00:28:15 -04:00
Mathias Fußenegger
df726408d7
lsp: Fix "client has shut down" errors during initializing (#13103)
Language servers can already send log messages to the client while the
server is still being initialized.

This currently leads to "client has shut down" messages which are
confusing to the user as the server is properly starting.

To fix this this changes the `get_client_by_id` method to also return a
client if it is still initializing.
2020-10-22 14:59:17 -04:00
Jan Edmund Lazo
9817d99140
Merge pull request #13043 from tkuneck/fix-min-float-win-size
[RDY] Opts.wrap_at is sometimes a bool, ensure it falls back to a valid num…
2020-10-17 22:30:01 -04:00
TJ DeVries
0ad5b34170
Merge pull request #12053 from tjdevries/tjdevries/nicer_validate
vim.validate(): include stacktrace in message
2020-10-17 16:47:18 -04:00
Thomas Vigouroux
95238598e4 treesitter: allow multiple highlighters per buffer 2020-10-12 18:23:14 +02:00
Thomas Vigouroux
bdbc56f931 treesitter: allow custom parser for highlighter
Also allow to get parser ranges.

This will be useful for language injection, allowing us to tweak the
parser's ranges on the fly.

Update runtime/lua/vim/treesitter.lua

Co-authored-by: Paul Burlumi <paul@burlumi.com>
2020-10-12 18:23:14 +02:00
Thomas Vigouroux
d3f544002c treesitter: runtime queries
Runtime queries just work like ftplugins, that is:

- Queries in the `after` directory are sourced _after_ the "base" query
- Otherwise, the last define query takes precedence.

Queries can be found in the `queries` directory.

Update runtime/lua/vim/treesitter/query.lua

Co-authored-by: Paul Burlumi <paul@burlumi.com>
2020-10-11 21:18:28 +02:00
Björn Linse
0b615dae07 api: multiple decoration providers at once 2020-10-10 15:16:45 +02:00
Justin M. Keyes
8e77d70e29 test/vim.validate(): assert normalized stacktrace
- The previous commit lost information in the tests. Instead, add some
  more "normalization" substitutions in pcall_err(), so that the general
  shape of the stacktrace is included in the asserted text.
- Eliminate contains(), it is redundant with matches()
2020-10-05 09:47:59 -04:00
TJ DeVries
aad7a74053 vim.validate(): include stacktrace in message 2020-10-05 09:47:59 -04:00
Tony Kuneck
6d066af27a Opts.wrap_at is sometimes a bool, ensure it falls back to a valid number in the call to math.min 2020-10-04 01:06:44 -07:00
Christian Clason
e5d98d8569
LSP: Fix separator width on hover (fixes #13006, #12998) (#13007)
* fix insert_separator conditional
* only draw separator over wrapped width
2020-09-30 18:03:40 +02:00
Thomas Vigouroux
3c5141d2cf
treesitter: add string parser (#13008) 2020-09-30 09:32:43 -04:00