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.
* 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
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>
* 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.
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)
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
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>
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.
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
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.
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>
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.
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>
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>
- 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()