Commit Graph

530 Commits

Author SHA1 Message Date
Michael Lingelbach
5902bed406 docs(lsp): fix locations_to_items docstring 2021-06-05 17:22:47 -07:00
Michael Lingelbach
36802b895f
Merge pull request #14730 from mjlbach/feature/open_loclist_on_win
fix(lsp): set_loclist should target current win
2021-06-05 17:12:55 -07:00
Michael Lingelbach
f214c19e2b
Merge pull request #14707 from ray-x/master
fix(lsp): floating window border size for string type
2021-06-05 15:00:07 -07:00
Michael Lingelbach
15abde1676 fix(lsp): set_loclist should target current win
Currently, for large number of diagnostics, the delay in populating
loclist may be sufficient for a user to switch to another window,
resulting in the loclist being populated on the wrong window.
2021-06-05 14:46:10 -07:00
Michael Lingelbach
d846bd7e06 feat(lsp): remove line from diagnostic quickfix
Adding the line takes up valuable horizontal screen space, and also
precludes using the quickfixtextfunc built into neovim due to the
harcoded `|`.
2021-06-05 13:39:30 -07:00
Folke Lemaitre
149efa9b2b
fix(lsp): max 1 floating preview per buffer. Fixes #11508 2021-06-05 10:13:01 +02:00
ray-x
351050a10f fix(lsp): floating window border size for string type 'none' and 'shadow' 2021-06-02 20:44:13 +10:00
Jose Alvarez
d4caafacc1 fix(lsp): check mode in omnifunc callback 2021-06-01 22:13:21 +09:00
Michael Lingelbach
b10cda83fa
Merge pull request #14693 from shadmansaleh/enhance/lsp/make_focusable_parameter_configurable
feat(lsp): Make focusability of lsp float configurable
2021-06-01 04:32:59 -07:00
shadmansaleh
68d48e25b6 docs(lsp): Fix opts param not captured by docgen
In the documentation for `vim.lsp.util.open_floating_preview`
the opts table keys were prefixed with `--` instead of `---`,
preventing capture by docgen.
2021-06-01 17:29:06 +06:00
shadmansaleh
0bd34cb4ec feat(lsp): Make focusability of lsp float configurable
This pr allows the user to specify whether `lsp.utils.open_floating_preview`
is focusable via the `opts` parameter. Defaults to true.

It can be configured by setting the focusable key inside opts parameter:

```lua
vim.lsp.util.open_floating_preview(contents, syntax, {focusable = false})
```
2021-06-01 17:23:35 +06:00
Michael Lingelbach
64bdaef327
Merge pull request #14694 from folke/lsp_popup_border 2021-06-01 01:52:38 -07:00
Folke Lemaitre
0ece34cbb8
fix(lsp): properly handle border character list without highlight groups. Fixes #14691 2021-06-01 09:36:29 +02:00
Michael Lingelbach
96dfa07642
Merge pull request #14635 from folke/lsp_get_lines
perf(lsp): get all lines from a file in one go (`locations_to_items`)
2021-05-31 11:12:23 -07:00
Michael Lingelbach
cabf8ab26b
Merge pull request #14649 from folke/lsp_float_refactor
refactor(lsp): consolidate the different floating window methods into `open_floating_preview`
2021-05-29 12:06:58 -07:00
Folke Lemaitre
64da499ac2
refactor(lsp): consolidate the different floating window methods into open_floating_preview 2021-05-29 13:42:15 +02:00
TJ DeVries
43956dea55
lua: Add vim.opt and fix scopes of vim.o (#13479)
* lua: Add vim.opt

* fixup: cleaning

* fixup: comments

* ty clason

* fixup: comments

* this is the last commit. period.
2021-05-28 17:24:48 +02:00
Mathias Fussenegger
e06a73900f lsp: Ensure floating markdown buffers are deleted on hide
After the change to use fancy_floating_markdown for the signature help I
noticed that scratch buffers start to accumulate.
2021-05-26 19:27:04 +02:00
Folke Lemaitre
54c441c80b
perf(lsp): get all lines from a file in one go 2021-05-25 12:23:39 +02:00
Mathias Fussenegger
5d4717010c lsp: Only mute RequestCancelled or ContentModified, but not other errors
handlers passed to `lsp_buf_request` weren't called if the server
responded with an error that looks like this:

     "decoded", {
      error = {
        code = -32601,
        message = "No delegateCommandHandler for foo"
      },
      id = 5,
      jsonrpc = "2.0"
    }

An example where that happens is both eclipse.jdt.ls and the
haskell-language-server when invoking a command that doesn't exist:

    :lua vim.lsp.buf_request(
      0,
      'workspace/executeCommand',
      { command = 'foo' },
      function(err, _, res)
        print(vim.inspect(err), vim.inspect(res))
      end
    )
2021-05-23 17:04:19 +02:00
Michael Lingelbach
0cbe748da3
Merge pull request #14615 from folke/faster_locations_to_items
perf(lsp): `locations_to_items`: use libuv for unloaded buffers to get line
2021-05-22 10:58:45 -07:00
Folke Lemaitre
c98e4d1a2a
perf(lsp): locations_to_items use libuv for unloaded buffers to get line 2021-05-22 18:56:48 +02:00
Michael Lingelbach
5b2be75256
Merge pull request #14269 from fdschmidt93/fix/document_symbol_range
fix(lsp): prefer selectionRange over range for document symbols in vim.lsp.util.symbols_to_items
2021-05-22 09:18:03 -07:00
Michael Lingelbach
9c7ad33006
Merge pull request #14603 from folke/format_on_save
fix(lsp): allow apply_text_edits to append text (insert at last line)
2021-05-22 09:13:06 -07:00
Folke Lemaitre
bfdd750fce feat(lsp): use fancy_floating_markdown for signature_help 2021-05-21 19:55:30 +02:00
Folke Lemaitre
02390af5a6 fix(lsp): clear current_syntax before formatting fancy markdown region 2021-05-21 19:18:22 +02:00
Folke Lemaitre
262645b325 fix(lsp): preview_location options and syntax fallback 2021-05-21 19:16:50 +02:00
Folke Lemaitre
d09f53d8ec fix(lsp): allow apply_text_edits and set_lines to insert text after the last line. Fixes #14017 2021-05-21 09:06:00 +02:00
Folke Lemaitre
07f54201c7 feat(lsp): lsp.util.fancy_floating_markdown improvements
fix: fancy_floating_markdown: syn region must include keepend to make sure syntax regions are applied correctly. Fixes #14594

feat: fancy_floating_markdown: handle <pre></pre> code blocks as a markdown code block with plaintext

fix: possible nil check for markdown code blocks till end of buffer

refactor: only one check is needed to see if stripped[h.finish +1] is valid

fix(lsp): dont't set doc ownsyntax, since it breaks contained syntaxes. Set regions for the markdown blocks intsead

fix: apply markdown formatting for code blocks without a language

fix: use markdownCodeBlock when no language was set in a code block
2021-05-21 00:34:30 +02:00
Michael Lingelbach
045e47ec55
Merge pull request #14563 from mjlbach/fix_intelephense_langserver
lsp: handle case where CompletionItem.insertTextFormat is nil
2021-05-19 12:39:44 -07:00
Marco Hinz
f6a86a3d7d
Merge pull request #14589 from mhinz/revert-smarter-tagstack
Unfortunately, there are some subtle bugs in the smarter tagstack changes,
so we'll revert them for now and try to come up with a better approach.

One of the added tests, adds current position to jumplist before jumping,
is valuable though and changed to still work after reverting the other two
commits.

Closes #14571
2021-05-19 18:58:21 +02:00
Cédric Barreteau
ca336c681d lsp: handle unsupported call hierarchy call 2021-05-19 11:55:03 -04:00
Marco Hinz
34922fba6b
Revert "lsp: make tagstack smarter motion-wise (#12262)"
This reverts commit 8885ea7f24.
2021-05-19 15:33:32 +02:00
Marco Hinz
3e5c484ec5
Revert "lsp: fix regression in jump_to_location() (#14446)"
This reverts commit 993ca90c9b.
2021-05-19 15:31:41 +02:00
Michael Lingelbach
63df353545 lsp: handle case where CompletionItem.insertTextFormat is nil
* Update tests to use explicit insertTextFormat for snippets
2021-05-16 15:25:34 -07:00
Michael Lingelbach
ba04b3d838
Merge pull request #14555 from mickael-menu/fix/range-code-action
lsp: Fix range end offset off by one character
2021-05-14 12:30:47 -07:00
Mickaël Menu
c23640140d
lsp: Fix range end offset off by one character 2021-05-14 18:33:23 +02:00
Raymond W. Ko
7c95697026
treesitter: add predicate "any-of?" (#14344)
For the case of Clojure and other Lisp syntax highlighting, it is
necessary to create huge regexps consisting of hundreds of symbols with
the pipe (|) character. To make things more difficult, these Lisp
symbols sometimes consists of special characters that are themselves
part of special regexp characters like '*'. In addition to being
difficult to maintain, it's performance is suboptimal.

This patch introduces a new predicate to perform 'source' matching in
amortized constant time. This is accomplished by compiling a hash table
on the first use.
2021-05-14 17:41:20 +02:00
Stephan Seitz
5c9b4948d4
treesitter: do not escape in match? (#14382) 2021-05-11 11:52:47 +02:00
Thomas Vigouroux
3fc71ea228
Merge pull request #14418 from DerekStride/treesitter-set-directive
[RDY] tree-sitter ensure there is a nested table allocated for `#set!`
2021-05-03 21:41:39 +02:00
Michael Lingelbach
ad81144442
Merge pull request #14334 from DarwinSenior/vim.log
lsp: deep copy vim.lsp.log when reloading
2021-05-02 23:40:34 -07:00
Michael Lingelbach
cfaf666ac9
Merge pull request #14462 from kabouzeid/feature/formatting_seq_sync
[LSP] Support for sequential formatting with multiple clients
2021-05-02 12:52:27 -07:00
Karim Abou Zeid
bcf03affbd Increase default LSP sync timeout to 1000ms 2021-05-02 17:08:57 +02:00
Karim Abou Zeid
d923f38882 Add client.request_sync doc 2021-05-02 16:24:58 +02:00
Karim Abou Zeid
f0f3fddcdd Synchronous formatting methods notify the user on timeout and interrupted 2021-05-02 16:16:49 +02:00
Karim Abou Zeid
dc9c6ea219 Support multiple range formatting clients 2021-05-02 15:37:31 +02:00
Karim Abou Zeid
54368736d0 doc clarification 2021-05-02 15:23:13 +02:00
Karim Abou Zeid
48a59f8f4f Add formatting_seq_sync, change formatting and formatting_sync 2021-05-01 21:12:40 +02:00
francisco souza
993ca90c9b
lsp: fix regression in jump_to_location() (#14446)
This fixes a regression that was introduced in [1] by accidentally leaving out a line.

1: https://github.com/neovim/neovim/pull/12262
2021-05-01 19:28:21 +02:00
TJ DeVries
27da5511a0
docs: Treesitter (#13260)
* doc & fixes: Generate treesitter docs

* fixup to treesitter-core

* docs(treesitter): fix docs for most functions

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
2021-05-01 08:19:48 -04:00
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