Commit Graph

580 Commits

Author SHA1 Message Date
Mathias Fussenegger
69d4143e7b lsp: Allow decoded.result to be false
Some servers might respond to `workspace/executeCommand` requests with a
boolean result and that could be `false`.

A `false` result should be allowed and not trigger the `on_error`
handler:

    -- Invalid server message
    on_error(client_errors.INVALID_SERVER_MESSAGE, decoded)

Concrete example where this occurred is with eclipse.jdt.ls:

    vim.lsp.buf_request(
      0,
      'workspace/executeCommand',
      {
        command = 'java.project.isTestFile',
        arguments = { vim.uri_from_bufnr(0), },
      },
      function(err, _, resp)
        print(vim.inspect(err), vim.inspect(resp))
      end
    )
2021-04-30 20:17:56 +02:00
derekstride
44d4526e18
Ensure there is a nested table allocated for #set!
Fixes the following bug:
```
test/functional/helpers.lua:107: Error executing lua:
vim/treesitter/query.lua:256: attempt to index a nil value
```
2021-04-27 12:29:37 -02:30
Michael Lingelbach
11728988dc
Merge pull request #14429 from ckipp01/force
[LSP] - Don't automatically force shutdown on second restart.
2021-04-23 14:52:13 -07:00
Gabriel Sanches
8885ea7f24
lsp: make tagstack smarter motion-wise (#12262)
This commit prevents two things regarding the tagstack and jumping to
locations:

  - Pushing the same item twice in a row

  - Pushing an item where the destination is the same as the source

Both prevent having to press CTRL-T additional times just to pop items
that don't make the cursor move.
2021-04-23 14:50:35 -07:00
Michael Lingelbach
4eb29e079a Revert "lsp: fix blocking in closing of clients"
This reverts commit 2e6c09838f.

* Fixes #14428
* This commit caused neovim to close while open handles to the uv timer
  to kill active language servers were still open
2021-04-23 12:17:00 -07:00
Marco Hinz
be494023d8
lsp: check if config is nil 2021-04-23 20:56:44 +02:00
Marco Hinz
4de404a681
lsp: sort diagnostics by severity (#14372)
Allow to sort diagnostics (and thus signs and virtual text) by severity, so that
the most important message is shown first.

    vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(
      vim.lsp.diagnostic.on_publish_diagnostics, {
        severity_sort = true,
      }
    )

Fixes https://github.com/neovim/neovim/issues/13929
2021-04-23 20:09:56 +02:00
ckipp01
2a77d9d8a4 Don't automatically force shutdown on second restart.
This is maybe a bit of a niche case, but I hit on this often as I'm
developing a server, and therefore continually restarting it to get the
latest changes of the server. Previously, I could only do this once
since if you send in a request to restart/shut down the server, it will
register it as a `tried_graceful_shutdown = true` meaning that the next
restart would force it to be killed instead of another graceful exit.

Instead, this changes the name a bit and now it will only mark
`graceful_shutdown_failed = true` _if_ it actually fails to gracefully
shutdown. This change allows for a user to restart multiple times in a
situation like mine where nothing is going wrong, but I just want to
restart continually as I'm developing without having to close and
reopen.
2021-04-23 14:26:33 +02:00
Michael Lingelbach
26bd5a58df
Merge pull request #14180 from oberblastmeister/lsp_exit_perf
fix slow closing of lsp clients when exiting vim
2021-04-19 17:35:58 -07:00
Brian Shu
2e6c09838f lsp: fix blocking in closing of clients 2021-04-19 20:04:08 -04:00
Dingcheng Yue
6974d0c6c1 lsp: deep copy vim.lsp.log when reloading
If vim.lsp.log is loaded the second time,
the vim.log.levels will be modified with additional
entries from 0-5.
This will cause the require to fail as level:lower does
not exists on numbered value.
2021-04-16 11:43:20 +01:00
Brian Shu
ef5314ce59 lsp: add lsp.buf_request_all for invoking asynchronous callbacks
fixed nil issue

changed poll to 10

changed wording

added docs to once

comma

english
2021-04-15 12:54:59 -04:00
Mathias Fussenegger
046991e4d5 lsp: Remove vim.NIL handling from apply_text_document_edit
The rpc layer normalizes `vim.NIL` to `nil`, so the scenario tested
should never happen.
2021-04-14 21:42:03 +02:00
Mathias Fussenegger
b67f689e4c lsp: Accept text document edits with version zero
There were a couple of reports of "Buffer X newer than edits" problems.
We first assumed that it is incorrect for a server to send 0 as a
version - and stated that they should send a `null` instead, given that
in the specification the `textDocument` of a `TextDocumentEdit` is a
`OptionalVersionedTextDocumentIdentifier`.

But it turns out that this was a change in 3.16, and in 3.15 and earlier
versions of the specification it was a `VersionedTextDocumentIdentifier`
and language servers didn't have a better option than sending `0` if
they don't keep track of the version numbers.

So this changes the version check to always accept `0` values.

See

- https://github.com/neovim/neovim/issues/12970
- https://github.com/neovim/neovim/issues/14256
- https://github.com/haskell/haskell-language-server/pull/1727
2021-04-14 21:29:32 +02:00
Michael Lingelbach
cd3e74201a
lsp: fix _make_floating_popup_size when wrap_at is nil (#14359) 2021-04-14 13:01:14 +02:00
Thomas Vigouroux
e652b2987a
Merge pull request #14046 from nvim-treesitter/feature/language-tree-directive-config
feat(treesitter): allow injections to be configured through directives
2021-04-14 05:36:05 +02:00
Marco Hinz
6b16ec701e
lsp: fix off-by-one in line diagnostic highlighting 2021-04-14 02:11:47 +02:00
Michael Lingelbach
391fe1064e
Merge pull request #14119 from mfussenegger/lsp-debounce
lsp: Add a flag to debounce didChange notifications
2021-04-13 15:03:13 -07:00
Mathias Fussenegger
720c6353b5 lsp: Add a flag to debounce didChange notifications
Would help with cases as reported in https://github.com/neovim/neovim/issues/14087
2021-04-13 21:02:30 +02:00
Marco Hinz
3831825167
lsp: correct float placement when using borders
Because borders add up to 2 to the height of a float, we need to subtract that
from the anchor position, when opening a float in the lower half of the window.
2021-04-12 19:54:54 +02:00
Marco Hinz
a215adabc1
lsp: make sure borders are always inside of the screen
Add a helper function to get the additional width a border adds to a float to
make sure that the border is always inside the visible screen.
2021-04-12 19:51:18 +02:00
Marco Hinz
cd75d3289a
Merge pull request #14200 from teto/treesitter-checkhealth
feat: treesitter checkhealth
2021-04-07 16:40:56 +02:00
Michael Lingelbach
91cdc11984
Merge pull request #14309 from mjlbach/feature/hover_return_win_buf
lsp: hover window should return buf/winnr from focusable float
2021-04-07 00:58:32 -07:00
Michael Lingelbach
5610e8a4ac lsp: hover window should return buf/winnr from focusable float 2021-04-07 00:21:56 -07:00
Michael Lingelbach
2c0bcc539a lsp: update documentation on window borders 2021-04-06 23:51:15 -07:00
Thomas Vigouroux
952508d405
fix(ts): move checkhealth in runtime/vim 2021-04-06 19:03:04 +02:00
Thomas Vigouroux
e8bc3d717e
feat(ts): include parser ABI version in checkhealth 2021-04-06 19:02:58 +02:00
Matthieu Coudron
86ced59a6a
feat: treesitter checkhealth 2021-04-06 18:54:22 +02:00
elianiva
c84b1b1ad0 feat(lsp): make hover/signature_help borders configurable
change hl groups for the example

rename borders -> border
2021-04-06 12:13:31 +07:00
Michael Lingelbach
2c4e9c5245
lsp: floating window improvements (#14207)
* remove left/right padding feature from trim_and_pad
* use invisible borders by default on floating windows
2021-04-05 15:43:08 +02:00
Steven Sojka
8bea39f372 feat(treesitter): allow injections to be configured through directives 2021-04-02 12:48:16 -05:00
Stephan Seitz
43eb22d4c9 Fix #14192: Handle IO errors and close files in query.lua 2021-04-02 16:21:49 +02:00
Thomas Vigouroux
3f7cd18c4a
Merge pull request #14218 from steelsojka/bugfix/check-queries-exist
fix(treesitter): check highlight queries exist
2021-04-02 05:24:49 +02:00
Michael Lingelbach
3b01dd4183 lsp: allow launching language servers with uv_spawn using cwd arg 2021-04-01 14:24:37 -07:00
Thomas Vigouroux
11bea67a55
fix: allow accessing vim.treesitter.language without require 2021-04-01 16:51:36 +02:00
Fabian David Schmidt
a2bd2f220c fix: selectionrange over range for document symbols 2021-04-01 14:16:01 +02:00
Michael Lingelbach
3d25a72a60
Merge pull request #14264 from mjlbach/feature/handle_reloading_buffer
lsp: add on_reload callback for buffer edits outside of neovim
2021-04-01 01:08:39 -07:00
Michael Lingelbach
f738f089da
Merge pull request #14262 from mjlbach/feature/lsp_did_save_autocommand
lsp: clear did_save handler autocommand on each attach
2021-04-01 00:53:47 -07:00
Michael Lingelbach
f87ae324bb lsp: fix textDocument/workspaceSymbol -> workspace/symbol 2021-03-31 23:53:07 -07:00
Michael Lingelbach
92e106ba23 lsp: add on_reload callback for buffer edits outside of neovim 2021-03-31 22:41:00 -07:00
Michael Lingelbach
08941e163e lsp: clear did_save handler autocommand on each attach 2021-03-31 20:23:17 -07:00
TJ DeVries
06c065469b
ts: Add per-language highlight links 2021-03-31 18:09:00 +02:00
Thomas Vigouroux
94c2ce2ce4
Merge pull request #14252 from tjdevries/tjdevries/ts_query_overrides
ts: Add per-language query overriding
2021-03-31 17:59:42 +02:00
Michael Lingelbach
db47cf8153
Merge pull request #14233 from mjlbach/disable_utf16_conversion
lsp: use utf-8 when utf-16 not requested
2021-03-30 14:37:55 -07:00
Michael Lingelbach
0cadab1412 lsp: use utf-8 when utf-16 not requested 2021-03-30 14:14:09 -07:00
TJ DeVries
240cec9192
ts: Add language version to vim.treesitter (#14255) 2021-03-30 16:40:29 -04:00
TJ DeVries
04fb94cd80 ts: Add per-language query overriding 2021-03-30 08:25:11 -04:00
Michael Lingelbach
32cf278a19 lsp: fix utf-16 ranges to use second return value for incremental sync 2021-03-28 02:22:13 -07:00
Michael Lingelbach
b79596eb5e
Merge pull request #14231 from mjlbach/fix_utf16_ranges
lsp: fix utf16 ranges for incremental sync
2021-03-27 19:02:48 -07:00
Michael Lingelbach
af683fdb57 lsp: fix utf16 ranges for incremental sync 2021-03-27 18:31:29 -07:00
Steven Sojka
98f9df253e fix(treesitter): check highlight queries exist 2021-03-26 11:25:19 -05:00
Steven Sojka
2a794b8f5d fix(treesitter): dedupe runtime file list 2021-03-23 12:58:27 -05:00
Michael Lingelbach
9f5c8226bb
Merge pull request #14186 from mjlbach/feature/make_signature_help_beautiful
lsp: add syntax highlighting to signature help
2021-03-23 09:38:21 -07:00
Michael Lingelbach
3113d4befa lsp: add syntax highlighting to signature help 2021-03-22 10:57:21 -07:00
TJ DeVries
875979ec3f lsp: Unopened buffers return 0 for line count, which leads to broken positions 2021-03-22 10:22:23 -04:00
TJ DeVries
880fb0d146 lsp: Force re-display of diagnostics when opening a file 2021-03-22 10:21:56 -04:00
Vincent Rischmann
24ad2c7067 runtime/lua/vim/lsp: check emptyness in get_completion_word 2021-03-21 00:30:01 +01:00
Michael Lingelbach
2358e52fc4 lsp: set syntax instead of filetype for preview location highlighting 2021-03-19 12:55:58 -07:00
Mathias Fussenegger
84213b5b9a lsp: Add support for delete workspaceEdit resource operation 2021-03-18 19:53:43 +01:00
Mathias Fussenegger
191afb42be lsp: Add support for create workspaceEdit resource operation 2021-03-18 19:53:42 +01:00
Mathias Fussenegger
5e401b693b lsp: Add support for file rename via workspaceEdit 2021-03-18 19:53:14 +01:00
Matthieu Coudron
0ab88c2ea8
Merge pull request #14145 from teto/remove-tshighlighter
chore: remove deprecated lua module tshighlighter
2021-03-16 18:44:41 +01:00
Matthieu Coudron
b540141876 chore: remove deprecated lua module tshighlighter 2021-03-16 01:41:28 +01:00
Michael Lingelbach
054eb31dc7
Merge pull request #14098 from mjlbach/fix_highlighting_lsp_markdown
lsp: fix highlighting for lsp markdown code blocks
2021-03-15 10:28:05 -07:00
Mathias Fussenegger
16827817bb lsp: Use incremental sync by default
With the new implementation added in
https://github.com/neovim/neovim/pull/14079 I think this is now working
well enough to enable it by default.

There are high CPU usage issues popping up now and then and they might
at least partially be related to the full-text sync.
2021-03-11 20:13:52 +01:00
Michael Lingelbach
6b7cde3dd0 lsp: fix highlighting for lsp markdown code blocks 2021-03-10 17:26:22 -08:00
Michael Lingelbach
4ed860a64c
Merge pull request #14073 from mjlbach/feature/syntax_highlight_rule
lsp: add custom syntax rule for floating window
2021-03-10 14:15:24 -08:00
Josa Gesell
d1074e0077
lsp: Resolve codeLense server capabilities (#14056) 2021-03-10 17:02:09 -05:00
TJ DeVries
564dd7d8db
lsp: get_language_id (#14092)
* Allow specifying a languageId for a lsp

For some languages the filetype might not match the languageId the
language server accepts. In these cases the config for the language
server can contain a function which gets the current buffer and filetype
and returns a languageId. When it isn't provided the filetype is used
instead.

Example:
```lua
require'lspconfig'.sourcekit.setup{
    get_language_id = function(bufnr, ft)
        return 'swift'
    end;
}
```

Closes #13093

* lsp: Change to get_language_id

Co-authored-by: Jan Dammshäuser <mail@jandamm.de>
2021-03-10 16:53:23 -05:00
Michael Lingelbach
53414555eb lsp: fix endline such that it cannot point outside the buffer range 2021-03-10 09:17:20 -08:00
Michael Lingelbach
d49177afd9 lsp: add custom syntax rules for lsp floating window 2021-03-09 21:15:10 -08:00
Michael Lingelbach
e4e51c69d7 lsp: add incremental text synchronization
* Implementation derived from and validated by vim-lsc authored by Nate
  Bosch
2021-03-09 20:14:08 -08:00
Matthieu Coudron
5c4fbe34f9
Merge pull request #13993 from teto/gendoc
improve vimdoc generation
2021-03-07 17:20:09 +01:00
Michael Lingelbach
0496b572ac
Merge pull request #13919 from TheAlakazam/lsplogfix
fix: fix empty line in lsp log after each run
2021-03-06 09:40:57 -08:00
Piyush Jaipuriyar
82c09f7c0b lsp: add explicit entry on lsp log start
fix: address typo and review comments
2021-03-06 10:39:40 +05:30
Michael Lingelbach
3fbff98cfd
Merge pull request #13793 from mjlbach/fix_terminating_eol_diagnostic
[RDY] lsp: fix diagnostic reported on terminating EOL character
2021-03-05 07:27:50 -08:00
Michael Lingelbach
58be81d645 lsp: don't invoke vim.notify on sigterm of language server 2021-03-04 13:50:49 -08:00
Michael Lingelbach
bdb2512325 lsp: invoke vim.notify when client exits with code or signal other than 0 2021-03-04 10:55:50 -08:00
Matthieu Coudron
55d6699dfd chore: rename progress_callback to progress_handler 2021-03-04 15:42:05 +01:00
Michael Lingelbach
db96edb58d lsp: fix diagnostic reported on terminating EOL character 2021-03-02 09:42:00 -08:00
David Zhang
365c353c9a fix: show error when language server start fails and prevent future requests 2021-02-26 17:24:18 +08:00
Mathias Fussenegger
eff7666163 LSP: Resolve text_document_save capability according to spec
Fixes https://github.com/neovim/neovim/issues/13989
See https://github.com/microsoft/language-server-protocol/issues/288
2021-02-25 10:08:14 +01:00
Chris Kipp
7d82aaa6f5
[LSP] Add in more docs for highlight groups with document_highlight() (#13614)
Currently it's not 100% clear that without setting these, using the autocomds
to utilize the `textDocument/documentHighlight` functionality, nothing will
actually be visible since the highlight groups don't have any details. This
just adds in a couple simple extra notes to make sure that's done
2021-02-24 17:23:47 +01:00
Simon Hauser
6b7cc45c48
fix: treesitter languagetree crash when using telescope buffer previewer (#13986) 2021-02-23 21:39:35 -05:00
Matthieu Coudron
9d5f842807
lsp: remove deprecated references to 'callbacks' (#13945)
vim.lsp.callbacks was deprecated a few months ago. This is a cleanup before the release.
Use vim.lsp.handlers instead.
2021-02-23 00:02:51 +01:00
Matthieu Coudron
46a58b74f4
feat(lsp): use vim.notify for some errors (#13992) 2021-02-22 23:31:12 +01:00
Mathias Fußenegger
1caf58578c
lsp: Fix text edits operating on the last line of a document (#13677)
`lines` can be empty, in which case `#lines[#lines]` failed with an
error:

    lsp/util.lua:214: attempt to get length of a nil value
2021-02-19 22:20:42 -05:00
Michael Lingelbach
b2fcfc65b7
lsp: client stop cleanups (#13877)
* lsp: client stop cleanups

* Add diagnostic clearing to client.stop() method used by nvim-lspconfig
* Clear diagnostic cache to prevent stale diagnostics on client restart

* lsp: Add test for vim.lsp.diagnostic.reset
2021-02-19 22:05:49 -05:00
Björn Linse
94622ca66b buffer updates: add on_reload callback and handle it in treesitter parser 2021-02-10 18:58:46 +01:00
Björn Linse
fa5f583981 treesitter: propagate on_detach event properly 2021-02-10 18:57:49 +01:00
Matthieu Coudron
00423730b5
Merge pull request #13843 from teto/notif_provider
[RDY] Notification provider
2021-02-08 15:49:27 +01:00
Santos Gallegos
947f9a04d4 treesitter: small fixes
Mostly typos I found while reading the code.
2021-02-07 01:27:38 -05:00
runiq
94cf7bba00
lsp: Fix pumvisible() check introduced in #12900 (#13866)
`pumvisible()` returns a number, and numbers are always `true` in Lua,
so the return value needs to be checked explicitly.

Using https://github.com/neovim/neovim/pull/12900 as context, it appears
the intention was to move into the `if` branch when the completion popup
is not shown (i.e. `vim.fn.pumvisible() == 0`).
2021-02-04 12:35:17 +01:00
Matthieu Coudron
3f81f5c7a4 feat: adds vim.notify
Adds function to notify the user like this:
`:lua vim.notify("hello user")`
embeds log levels vim.log.levels.

you can then reassign vim.notify to for instance
```
function notify_external(msg, log_level, opts)
	vim.fn.jobstart({"notify-send", msg })
end
```
2021-01-31 00:18:22 +01:00
Michael Lingelbach
1a6d89eb90
lsp: match textDocument/didChange eol behavior (#13792)
We should be consistent in sending the EOL character to servers(I think). Julia expects this to match on bufwrite, or it crashes when vim appends the newline during the write process.
2021-01-25 17:52:40 +01:00
Michael Lingelbach
3a3e6742f9
lsp: clear diagnostics on client shutdown (#13788) 2021-01-23 17:43:06 +01:00
Steven Sojka
ed558e269a fix(languagetree): use tree nodes instead of regions in contains 2021-01-20 06:52:47 -06:00
Thomas Vigouroux
d9c1586e4a
Merge pull request #13765 from jvgrootveld/ts-default-start-end-row-on-capture
treesitter: default start and end row when omitted
2021-01-20 10:32:48 +01:00
Michael Lingelbach
d6d4e3d1ae
lsp: remove duplicate settings validation (#13789) 2021-01-18 21:02:30 -05:00
Michael Lingelbach
f9b3110549
lsp: validate and document server settings (#13698)
* update lua documentation
* run docgen
2021-01-18 14:11:37 -05:00
Mathias Fußenegger
3f63100d5b
LSP: Fix nil settings handling in workspace/configuration (#13708)
The `workspace/configuration` handler could fail with the following
error if `config.settings` is nil:

    runtime/lua/vim/lsp/util.lua:1432: attempt to index local 'settings' (a nil value)"

This ensures that `config.settings` is always initialized to an empty
table.
2021-01-18 19:33:10 +01:00
Chris Kipp
1a4d380b5a
LSP: Add in clientInfo to initalize_params. (#13757)
* Add in clienInfo to initalize_params.

Some servers (like Metals in my case) will actually pull this
info from the initalize_params and display it in the logs. I
know from the server perspective it helps at times to have this
available to pull from to have more details about the client and
version. You can see that this is part of the spec here:

microsoft.github.io/language-server-protocol/specification#initialize
2021-01-18 10:13:26 +01:00
Michael Lingelbach
6d659bb338
lsp: add client/registerCapability handler (#13780)
Until we support dynamicRegistration, we should handle the client/registerCapability in core. There are still some language servers that send this request despite dynamicRegistration not being registered client-side (we got an upstream fix for the node ones, but this depends on them bumping vscode-languageserver-node).
2021-01-18 10:11:19 +01:00
“jvgrootveld”
9bed991cfb treesitter: Fix linter warning and add helper function to remove duplicated logic
This function returns the start and stop value if set else the node's range is used
When the node's range is used, the stop is incremented by 1 to make the search inclusive
2021-01-18 08:17:12 +01:00
“jvgrootveld”
a2818819bb treesitter: default start and end row when omitted
Add support for default start and end row when omitted in the
query:iter_captures and query:iter_matches functions.

When the start and end row values are omitted, the values of the given
node is used. The end row value is incremented by 1 to include the node end
row in the match.

Updated tests and docs accordingly.
2021-01-15 21:44:40 +01:00
Thomas Vigouroux
acf6ed5541
fix(treesitter): use source() method on attach
Fixes an issue that tree-sitter always attached to the current buffer,
instead of the provided buffer.
2021-01-14 12:01:50 +01:00
Michael Lingelbach
ea8756f85d
logging: move to XDG_CACHE_HOME (#13739)
while there is some controversy, stdpath('cache') looks like  a better fit for logs than stdpath('data'): you can remove logs without preventing nvim to work which fits the XDG_CACHE_HOME definition of `user specific non-essential data files`.
2021-01-13 23:20:21 +01:00
Michael Lingelbach
77a6049e07
lsp: fix on_attach signature documentation (#13723)
* trim trailing whitespace from docs
2021-01-12 22:47:34 +01:00
TJ DeVries
9f3b2a757b
lsp: Add severity_limit for other diagnostics features (#13528)
* lsp: Add severity_limit for other diagnostics

* docs and tests

* fix: lint

* Add to other types

* fix: lint
2021-01-12 12:58:50 -05:00
TJ DeVries
e0a4399adc
fix(lsp): Allow subsequent text document edits to pass (#13534)
* fix: Allow subsequent text document edits to pass

* fixup: cleaner code

* add tests
2021-01-11 11:39:11 -05:00
Timmy Xiao
2bfd0ba8ae
LSP: Add diagnostic tags to client capabilities (#13578)
pyright (possibly others) does not send any hint diagnostics if we do not have tagSupport in PublishDiagnosticsClientCapabilities. This PR just adds them.
2021-01-05 21:15:08 +01:00
Björn Linse
885c2f7281 treesitter: simplify query reading logic
Only the plugin/package manager should "manage" after/. Consumers of
nvim_get_runtime_file() should not need to special case it (if your plugin
manager is broken then fix it instead).

Don't use vim.fn.readfile(). Lua can already read files. It is even
better at it than vim script.

expose M.get_query_files(). Listing the queries is essential for user
config debug, and let plugins do fun things with it.
Abstraction-by-obscurity is not useful (plugins can just cargo cult copy
the code anyway, better with public entry points).
2021-01-04 11:06:02 +01:00
Michael Lingelbach
fff4facdc4
LSP: fix messageRequest to not return nested title (#13674)
* LSP: fix window/showMessageRequest to not return nested title

* Add window/showMessageRequest handler to docs
2021-01-03 20:31:09 +01:00
Matthieu Coudron
48caf1df85
Merge pull request #13649 from mjlbach/move_from_nvim-lspconfig
LSP: Move workspace/configuration from nvim-lspconfig to core
2021-01-01 23:52:48 +01:00
jdrouhard
4a0a6f7bff
LSP: progress callback should only update existing dict for reports (#13652)
Change the update of the client.messages.progress table to overwrite only the percentage and message properties on $report, Previously we were overwriting the table which meant client.messages.progress[token].message.title was wiped on report.
2021-01-01 23:51:47 +01:00
Michael Lingelbach
e467d29390 LSP: Move workspace/configuration handler from nvim-lspconfig to core 2021-01-01 01:40:33 -08:00
Michael Lingelbach
8742082661 LSP: Add helper function from accessing language server settings from nvim-lspconfig 2021-01-01 01:40:33 -08:00
Michael Lingelbach
fd507e2788
LSP: window/showMessageRequest (#13641)
Another 3.16 compatibility. Solves Vue crashing currently. Currently not handling the return result, but would allow opening web browser in this case.
2020-12-31 00:09:33 +01:00
Michael Lingelbach
28b7574c94
lsp: Disable capabilities not currently supported by language client handlers (#13638)
Several language servers are incorrectly invoking handlers which are not yet implemented in core.
2020-12-30 23:54:02 +01:00
Michael Lingelbach
fb90b6ec98
LSP: implement window/workDoneProgress/create (#13640) 2020-12-30 23:17:35 +01:00
Adam P. Regasz-Rethy
93762072d1
lsp: Use correct bufnr for documentHighlight handler (#13622) 2020-12-29 00:05:30 +01:00
Josh French
6eecd4230d
lsp: Fire LspDiagnosticsChanged before returning (#13483)
Run hook even when transitioning from some diagnostics to no diagnostics
2020-12-23 23:29:37 +01:00
Nils
aa3b17d04a
lsp: Add <nomodeline> to doautocmd calls (#13576)
When using "au User LspDiagnosticsChanged redrawstatus!", modelines get processed again (see h: doautocmd). Fortunately this can be suppressed using the <nomodeline> flag. this replaces every doautocmd call, that issues a User command, with doautocmd <nomodeline>.
2020-12-21 20:03:50 +01:00
Matthieu Coudron
1e59134834
lsp: add $/progress report (#13294)
Heavily inspired by https://github.com/nvim-lua/lsp-status.nvim.
listen to the LspProgressUpdate event to update your statusline.
2020-12-20 21:59:25 +01:00
Mathias Fußenegger
abcbc5a9f3
lsp: Fix text payload in didSave notification (#13363)
According to the specification[1] the payload must look like this:

    interface DidSaveTextDocumentParams {
    	/**
    	 * The document that was saved.
    	 */
    	textDocument: TextDocumentIdentifier;

    	/**
    	 * Optional the content when saved. Depends on the includeText value
    	 * when the save notification was requested.
    	 */
    	text?: string;
    }

`text` must be on the same level as `textDocument´.

Where `TextDocumentIdentifier` is:

    interface TextDocumentIdentifier {
	/**
	 * The text document's URI.
	 */
	uri: DocumentUri;
    }

[1]: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didSave
2020-12-20 18:12:39 +01:00
Björn Linse
5e202f69b3
Merge pull request #13367 from nvim-treesitter/offset-lang-injection
feat(treesitter): add offset predicate for language injection
2020-12-16 13:59:36 +01:00
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
Steven Sojka
929f194145 feat(treesitter): add offset predicate for language injection
refactor(treesitter): add directives to queries
2020-12-15 07:03:47 -06: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
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