Commit Graph

155 Commits

Author SHA1 Message Date
Jesse
f559e5249e
LSP: Add textDocument/codeAction support (#11607)
* Add textDocument/codeAction

* Add callback for workspace/executeCommand
* Escape newlines in codeAction titles
* Return empty list in get_line_diagnostics if no buffer diagnostics
* Add stub documentation
* Validate context parameter in code_action
* Add support for edit in CodeAction responses
* Group diagnostics by line in vim.lsp.util.get_line_diagnostics()
* Advertise code action literal support
2020-05-16 01:18:59 +02:00
Mathias Fußenegger
da6f38ab3c
LSP: Add workspace.applyEdit client capabilities (#12313)
applyEdit is supported by the built-in client.
2020-05-14 18:56:33 +02:00
landerlo
02155f5c10
lsp: fix bug when documentEdit version=null for unattached buffer (#12272) 2020-05-13 23:14:52 -04:00
Mathias Fußenegger
55b62a937c
LSP: Make applyEdit return a response (#12270)
According to the specification workspace/applyEdit needs to respond with
a `ApplyWorkspaceEditResponse`

See https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit

This is a subset of https://github.com/neovim/neovim/pull/11607
2020-05-11 16:56:35 +02:00
Christian Clason
281e44f7bb
lsp: Make apply_text_edits non-ASCII safe (#12223)
* Make apply_text_edits non-ASCII safe

Use `vim.str_byteindex` to correct starting and ending positions for text edits if the line contains non-ASCII characters.

Fixes #12221

* text_edit may be applied to other buffers

* make sure the buffer is loaded

* add comments

* add test for non-ASCII edits
2020-05-08 10:04:41 -04:00
Hirokazu Hata
9a67b030d9
lsp: Handle unknown CompletionItemKind and SymbolKind (#12257)
* lsp: handle kinds not specified in protocol

fix: #12200
If the client set "symbolKind.valueSet",
the client must handle it properly even if it receives a value outside the specification.

* test: add lsp.util.{get_completion_item_kind_name, get_symbol_kind_name} test case

* lsp: make lsp.util.{get_completion_item_kind_name, get_symbol_kind_name} private
2020-05-07 16:23:25 -04:00
Gabriel Sanches
7432b3ca4c
lsp: set buflisted when jumping to location (#12253) 2020-05-07 09:30:42 -04:00
Gabriel Sanches
f605eeec65
lsp: fix tagstack for location jump #12248 2020-05-04 20:12:35 -07:00
Mathias Fußenegger
2c40a38b39
LSP: Avoid URI-to-fname conversion for non-file URIs #12243
Fixes https://github.com/neovim/neovim/issues/12210
2020-05-04 20:06:40 -07:00
Matthieu Coudron
496b668ad1
Merge pull request #12237 from h-michael/vim-nil
lsp: text_document.version may be vim.NIL not nil
2020-05-04 09:53:00 +02:00
Christian Clason
501ef95298
lsp: fixup workspace symbol capabilities (#12233)
use workspace.symbol instead of workspaceSymbol to mimic the lsp spec.
2020-05-03 18:01:04 +02:00
Matthieu Coudron
d13c1642ae
Merge pull request #12228 from h-michael/fix-docsyms-to-items
lsp: fix lsp.util.symbols_to_items with DocumentSymbol has children
2020-05-02 18:42:10 +02:00
Christian Clason
ea347b18d8
lsp: add workspace/symbol (#12224)
* lsp: add workspace/symbol
* refactor symbol callback
* set hierarchical symbol support to true
* add documentation and default mapping

Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>
2020-05-02 17:56:05 +02:00
Christian Clason
2f42e4d0c8
LSP: Support LocationLink (#12231)
* support LocationLink in callbacks
* announce linkSupport in client capabilities
2020-05-02 15:21:07 +02:00
Hirokazu Hata
d0af0f5c9e
lsp: fix lsp.util.symbols_to_items
fix: https://github.com/neovim/neovim/pull/11931#issuecomment-622422581

There was an error in the process of flattening the hierarchical structure.
So when DocumentSymbol has children, our client can't handle it correctly.
2020-05-02 15:16:35 +09:00
ckipp01
6dc8398944 [LSP] check for vim.NIL and add apply_text_document_edit tests 2020-05-01 17:40:03 +02:00
Thomas Vigouroux
e5022c61ed
treesitter: unknown predicates always match #12173 2020-04-30 22:43:30 -07:00
Matthieu Coudron
42b441738d
Merge pull request #12204 from archseer/lsp-user-data
lsp/completion: Expose completion_item under completed_items.user_data + vim-patch:8.2.0084
2020-04-30 15:25:15 +02:00
Ghjuvan Lacambre
f9055c585f
LSP: enable using different highlighting rules for LSP signs (#12176)
This commit creates 4 new highlight groups:
- LspDiagnosticsErrorSign
- LspDiagnosticsWarningSign
- LspDiagnosticsInformationSign
- LspDiagnosticsHintSign

These highlight groups are linked to their corresponding LspDiagnostics
highlight groups by default.

This lets users choose a different color for their sign columns and
virtualtext diagnostics.
2020-04-29 16:53:13 +02:00
Blaž Hrastnik
e4a1be779b lsp/completion: Expose completion_item under completed_items.user_data.
By passing through completion_item it's now possible for snippet plugins
to add LSP snippet support.
2020-04-29 13:26:56 +09:00
Yen3
e9cc383614
LSP: support tagstack #12096 2020-04-28 07:47:22 -07:00
Hirokazu Hata
4e6531ddbd
lsp: use vim.tbl_isempty to check sign (#12190)
ref: #12164
fix #12201
sign_getdefined() returns a list, {} if the sign is not defined.
2020-04-28 07:41:39 -07:00
jakbyte
5f41717838
LSP: don't redefine LspDiagnostics signs #12164
fix #12162
2020-04-26 15:36:40 -07:00
Mathias Fußenegger
50ff37308a
LSP: Fix show_line_diagnostics #12186
Messed this up in ef0398fe88
2020-04-26 14:56:30 -07:00
Chris Kipp
663b83814d
LSP: Add a check for null version in VersionedTextDocumentIdentifier (#12185)
According to the spec there is the possibility that when a
VersionedTextDocumentIdentifier is used in a TextEdit the value may be
null. Currently we don't check for this and always assume that it's set.
So currently if a TextEdit comes in for a rename for example with the
version null, it fails as we are comparing the bufnumber with nil.

https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
2020-04-26 16:51:41 +02:00
Thore Weilbier
68511924d0
LSP: remove obsolete "peek definition" code #12178
The method with the name 'textDocument/peekDefinition' is not part of
the official language server protocol specification. Therefore no
language server can/will support this. Thereby all related code and
documentation as been removed.
2020-04-25 21:47:48 -07:00
Mathias Fußenegger
ef0398fe88
LSP: Expose diagnostics grouped by bufnr (#11932)
Expose `vim.lsp.buf.diagnostics_by_buf`

This makes it easier to customize the diagnostics behavior. For example
to defer the update they can override the
`textDocument/publishDiagnostics` callback to only call
`buf_diagnostics_save_positions` and then defer the other actions to a
autocmd event.
2020-04-25 15:46:58 +02:00
Hirokazu Hata
78d58eaf61
lsp: remove buffer version on buffer_detach (#12029)
When we save the buffer, the buffer is detached and attached again.
So the client also needs to remove the buffer version once.
2020-04-25 14:58:35 +02:00
Thore Weilbier
deb4566cab
lsp: callback for references now opens qf (#12171)
In contrast to other callbacks for LSP requests like
`textDocument/documentSymbols`, does the one for references not open the
quickfix window after the quickfix list was filled. This left the user
in a situation he don't know what or if something had happen.

Related to: neovim/neovim#12170
2020-04-23 13:36:19 +02:00
Hirokazu Hata
633322a020
lsp: do not assert even if the code does not exist in ErrorCodes (#11981)
There is ErrorCodes in the LSP specification, but in ResponseError.code
it is not used and the actual type is number.
Some language servers response original error cods and this is valid spec.
So we shouldn't assert even if the code does not exist in ErrorCodes.

ref: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#responseMessage
2020-04-21 15:42:48 +02:00
Khangal
0c637898f9
lsp: textDocument/definition can return Location or Location[] (#12014)
* https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition

Co-authored-by: Khangal Jargalsaikhan <khangal.j@irbis.sg>
2020-04-21 15:16:58 +02:00
Matthieu Coudron
9678fe4cfb
Merge pull request #11989 from Weypare/textEdit
LSP/completion: add textEdit support
2020-04-20 21:31:19 +02:00
Andrey Avramenko
e6cfc1b158 LSP/completion: Add completion text helper function 2020-04-20 14:09:13 +03:00
Hirokazu Hata
adec9fb444
lsp: export convert_signature_help_to_markdown_lines (#11950)
This function is also useful for users to create their own `textDocument/signatureHelp` callback function.
2020-04-19 23:40:54 +02:00
Tristan Konolige
bf0f745861
lua: allow deepcopy of functions (#12136) 2020-04-19 01:04:37 +02:00
Hirokazu Hata
c5466ba6ef
lsp: replace the event that closes the signature help preview window from InsertCharPre to CursolMovedI (#11954)
In the case of InsertCharPre, it is inconvenient because the signature help is displayed
when backspaced in insert mode, so change it to CursolMovedI.
2020-04-18 19:04:47 +02:00
Ghjuvan Lacambre
7d4451c657
LSP: fix breakage when severity isn't specified (#12027)
Before this commit, the LSP client would throw errors when messages
without severity would be sent by the server. We make severity default
to `Error` as a kludge before proper heuristics to discover the severity
of a message are found.
2020-04-18 18:21:08 +02:00
Thomas Vigouroux
1fb44ba835 treesitter: escape backslashes in queries
Treesitter changed their decoders and apparently thus causing this
change.

This decoder change happened on
ee9a3c0ebb218990cf391ed987be7f2448c54a73.
2020-04-18 09:20:13 +02:00
George Zhao
51b4fc4778
lsp: provide a default for missing reference kind (#12127)
Fix #12122

>Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp/util.lua:560: Expected lua string

Some lsp server(e.g. https://github.com/bash-lsp/bash-language-server) not have kind in reference, reference["kind"] is nil
2020-04-16 18:30:03 +02:00
Hirokazu Hata
4139678f97
vim.uri: fix uri_to_fname (#12059)
fix: #12056
If the colon of the drive letter of windows is URI encoded,
it doesn't match the expected pattern, so decode it first.
2020-03-30 14:30:24 +02:00
Björn Linse
5a5c2f0290
Merge pull request #11927 from Jesse-Bakker/lsp-buf-version
LSP: Use buffer version instead of changedtick for edits
2020-03-16 21:57:51 +01:00
Andrey Avramenko
ccb038dc6a LSP/completion: add textEdit support
According to lsp specification, value of insertText should be ignored if
textEdit is provided.
2020-03-06 19:40:46 +02:00
Hirokazu Hata
fbc4c4fd36
lsp: make showMessage and logMessage callbacks different (#11942)
According to the LSP specification, showMessage is what is displayed and logMessage is what is stored.
Since these are different things, I devide the callback into those that match.
2020-03-02 14:27:30 +01:00
Hirokazu Hata
e35ff7371f
lua: add vim.tbl_len() #11889 2020-03-01 23:38:43 -08:00
Hirokazu Hata
16262472cd
lsp: add 'textDocument/documentSymbol’ callback
Spec: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
2020-03-01 09:10:02 +09:00
Hirokazu Hata
f157fdef7e
lsp: add bufnr to callback function arguments
DocumentSymbol type doesn't have location field.
So when we'll add 'textDocument/documentSymbol’ handler, we can't decide which file have we jump to.
2020-02-28 09:03:17 +09:00
Jesse Bakker
1fe01b36de Use buffer version instead of changedtick for edits 2020-02-27 14:53:11 +01:00
Mathias Fussenegger
38201650cd LSP: Remove diagnostic message handling in locations_to_items
`locations_to_items` is for turning `Location[]` into items, not for
`Diagnostic[]`
2020-02-27 12:50:12 +01:00
Mathias Fussenegger
220a2b05c6 LSP/references: Add context to locations returned by server
This changes the `textDocument/references' callback to annotate the
locations returned by the server with the content present at the
locations range.

The quickfix list then looks as follows:

    cr8/insert_fake_data.py|17 col 32| from .misc import parse_table, parse_version
    cr8/insert_fake_data.py|43 col 15| version = parse_version(r['rows'][0][0])
    cr8/java_magic.py|8 col 22| from cr8.misc import parse_version
    cr8/java_magic.py|30 col 19| version = parse_version(fst)
    cr8/java_magic.py|33 col 16| return parse_version(version_str)

Instead of:

    cr8/insert_fake_data.py|17 col 32|
    cr8/insert_fake_data.py|43 col 15|
    cr8/java_magic.py|8 col 22|
    cr8/java_magic.py|30 col 19|
    cr8/java_magic.py|33 col 16|
2020-02-27 12:49:49 +01:00
Björn Linse
52124f286c
Merge pull request #11880 from bfredl/tree-sitter-regex
add regex support in treesitter queries
2020-02-27 12:28:47 +01:00