Commit Graph

278 Commits

Author SHA1 Message Date
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
notomo
4a996bc431
lsp: Add vim.lsp.buf.range_code_action() (#12962)
Allows to execute code_action for a given range.
:'<,'>lua vim.lsp.buf.range_code_action()
2020-09-24 21:53:08 +02:00
Rasmus Ishøy Michelsen
4f8d98e583
lsp: Handle ContentModified the same way as RequestCancelled (#12803)
* Added the ContentModified error to be hidden from users, like RequestCancelled
* Fixed tests (and ill-formed lua code)
* Simplified if-expression
2020-09-22 21:54:34 +02:00
Raphael
569e75799d
lsp: remove popup No signature available. (#12915)
* lsp: remove popup No signature available.

 If no signatures. we shouldn't popup No signature available ..It will make noise when use
` api.nvim_command("autocmd CompleteDone <buffer> lua vim.lsp.buf.signature_help()")`

* fix ci test failed remove whitespace

* print message when no signature help

* Add comment
2020-09-18 09:37:53 -04:00
Raphael
f34eeba2d8
lsp: fix failed switch window error (#12900)
* fix failed switch window error

* checks if  window already exists
2020-09-14 11:03:02 -04:00
TJ DeVries
4a2618c817
doc: Add docs for uri functions (#12887) 2020-09-14 09:12:17 -04:00
Björn Linse
4042975df4 luahl: global the luahl 2020-09-13 07:46:39 +02:00
Thomas Vigouroux
e4b5efa51e fix: use luahl in treesitter 2020-09-13 07:46:39 +02:00
beardedsakimonkey
01ae5e7c38
lsp: fix lsp.buf.formatting_sync() null response (#12752)
Co-authored-by: tim apple <tim@tims-MacBook-Pro.local>
2020-09-12 18:39:52 +02:00
Xuyuan Pang
f3b5531ae8
lsp: Fix parameter markdown rendering for signature help (#12832) 2020-09-12 18:33:31 +02:00
Thomas Vigouroux
cf0e1bc1fe wip trying to fix the highlighter 2020-09-09 21:22:21 +02:00
Björn Linse
9437327d5e treesitter: use new on_bytes interface
This will significantly reduce the parsing work
needed e.g. when rehighlighting after every keypress
in insert mode.

Also add safety check for tree-sitter trying to read
past the end of a line. This can happen after we sent
an incorrect buffer update.
2020-09-09 21:22:21 +02:00
Thomas Vigouroux
1ff064126d treesitter: revert wrong optimization in highlights 2020-09-09 16:00:19 +02:00
Thomas Vigouroux
c3e6b6119c
Merge pull request #12858 from kyazdani42/fix/no-ts-hl-without-query-value
treesitter: check hl group exists before passing it in nvim_get_hl_id_by_name
2020-09-06 17:18:47 +02:00
kiyan42
7e0c4e5329 apply bfredl suggestion 2020-09-06 15:32:24 +02:00
Björn Linse
9c929e7d23 lint: just bit twiddlin' 2020-09-06 11:25:23 +02:00
Thomas Vigouroux
20c1526552 treesitter: simplify match_preds 2020-09-06 10:30:39 +02:00
Thomas Vigouroux
2d6437f5fb treesitter: use lua-match? instead of match? 2020-09-06 10:29:47 +02:00
Steven Sojka
fb55cb2d91
fix(highlight): compare rows vs columns in range highlight check (#12852) 2020-09-05 17:22:54 -04:00
kiyan42
981f3f17a0 treesitter: check hl group exists before passing it in nvim_get_hl_id_by_name 2020-09-05 21:43:40 +02:00
Björn Linse
1e14dacd08
Merge pull request #12847 from nvim-treesitter/ts-list-predicates
treesitter: allow to list supported predicates
2020-09-04 17:01:49 +02:00
Thomas Vigouroux
3fd6e3b923 treesitter: allow to list supported predicates 2020-09-04 15:24:23 +02:00
Thomas Vigouroux
1832d18083 treesitter: update to use buf_set_extmark 2020-09-03 15:40:31 +02:00
Justin M. Keyes
948e625e1e
Merge #12468 'lsp: logging' 2020-09-01 20:50:08 -07:00
Gıyaseddin Tanrıkulu
e86b15b25c
lsp/make_position_param(): handle empty buffer #12825
Fix  #12623

problem: nvim_buf_get_lines(0) returns empty during startup, where no buffers are loaded yet.
solution: return empty object

Happens during startup, where buffer may not be loaded yet, because...
`source_startup_scripts()` is done before `edit_buffers()`:
9bb552875d/src/nvim/main.c (L362)
9bb552875d/src/nvim/main.c (L480)
2020-09-01 20:45:47 -07:00
Stephan Seitz
b058c671d2 treesitter: avoid escaping complete query strings
Escape "\\" only for `vim-match?` not for `match?`
Fixes #12595
2020-08-31 17:24:38 +02:00