Commit Graph

484 Commits

Author SHA1 Message Date
Lewis Russell
2afcdbd63a
feat(Man): port to Lua (#19912)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-02 15:20:29 +01:00
Sean Dewar
813476bf72
fix(exceptions): restore did_throw (#20000)
`!did_throw` doesn't exactly imply `!current_exception`, as `did_throw = false`
is sometimes used to defer exception handling for later (without forgetting the
exception). E.g: uncaught exception handling in `do_cmdline()` may be deferred
to a different call (e.g: when `try_level > 0`).

In #7881, `current_exception = NULL` in `do_cmdline()` is used as an analogue of
`did_throw = false`, but also causes the pending exception to be lost, which
also leaks as `discard_exception()` wasn't used.

It may be possible to fix this by saving/restoring `current_exception`, but
handling all of `did_throw`'s edge cases seems messier. Maybe not worth
diverging over.

This fix also uncovers a `man_spec.lua` bug on Windows: exceptions are thrown
due to Windows missing `man`, but they're lost; skip these tests if `man` isn't
executable.
2022-08-30 23:13:52 +01:00
Mathias Fussenegger
60ec6e34d5 feat(lsp): add tcp support 2022-08-28 14:07:53 +02:00
Mathias Fußenegger
e99de3f12f
fix(lsp): send didOpen if name changes on write (#19583)
`:saveas newName` changes the name of an existing buffer.
Due to the buffer re-use it skips the lsp attach phase and immediately
sends a `didSave` notification to the server.
Servers get confused about this, because they expect a `didOpen`
notification first.

Closes https://github.com/neovim/neovim/issues/18688
2022-08-01 22:32:53 +02:00
ii14
13abe20b5f
refactor(lsp): use autocmd api (#19407)
* refactor(lsp): use autocmd api

* refactor(lsp): inline BufWritePost and VimLeavePre callbacks
2022-07-17 19:13:33 +02:00
L3MON4D3
6f6286e4f9
fix(lsp): small bugs in snippet-parser #18998
This fixes the following bugs:
`${1:else_text}` -> format with if_text: "else_text"
`${1:-else_text}` -> format with if_text: "else_text"
`${1:}` in `format` (eg. empty else_text) -> error.
`${1:}` (eg. empty placeholder) -> error.

Thanks hrsh7th :)
2022-06-29 09:53:49 -07:00
Justin M. Keyes
b6467dfc23 test(report): formatting, drop dumplog()
Don't need to dumplog() on each failed test because we now have test-ids
that associate log messages with tests.
2022-06-15 19:23:10 -07:00
Mathias Fußenegger
e4df1c9b9e
fix(lsp): fix multi client handling in code action (#18869)
Fixes https://github.com/neovim/neovim/issues/18860
2022-06-05 16:43:32 +02:00
Mathias Fußenegger
c6d747e6a5
feat(lsp): send didChangeConfiguration after init (#18847)
Most LSP servers require the notification to correctly load the
settings and for those who don't it doesn't cause any harm.

So far this is done in lspconfig, but with the addition of vim.lsp.start
it should be part of core.
2022-06-03 18:16:11 +02:00
Javier Lopez
d837b6d50c
fix(checkhealth): skip vim.health #18816
Problem:
https://github.com/neovim/neovim/pull/18720#issuecomment-1142614996

The vim.health module is detected as a healthcheck, which produces spurious errors:

    vim: require("vim.health").check()
    ========================================================================
    - ERROR: Failed to run healthcheck for "vim" plugin. Exception:
      function health#check, line 20
      Vim(eval):E5108: Error executing lua [string "luaeval()"]:1: attempt to call field 'check' (a nil value)
      stack traceback:
      [string "luaeval()"]:1: in main chunk

Solution:
Skip vim.health when discovering healthchecks.
2022-06-01 07:10:10 -07:00
bfredl
58b9b7e7c4 fix(ci): remove 2000ms blocking wait in many plugin/lsp_spec.lua tests
Cuts down typical run time for `plugin/lsp_spec.lua`
from 70 secs to 12 secs in ASAN CI build.

This happens in ASAN/EXIT_FREE builds where nvim waits 2000ms due to
unclosed handled. I wasn't able to pin-point the exact cause.
But these tests ran in nested context where two server/client pairs
were setup for no good reason. Moving these tests out so only one client
is being setup fixed the exit hang.
2022-05-22 14:14:58 +02:00
Gregory Anders
2ffafc7aa9 feat(lsp): add LspAttach and LspDetach autocommands
The current approach of using `on_attach` callbacks for configuring
buffers for LSP is suboptimal:

1. It does not use the standard Nvim interface for driving and hooking
   into events (i.e. autocommands)
2. There is no way for "third parties" (e.g. plugins) to hook into the
   event. This means that *all* buffer configuration must go into the
   user-supplied on_attach callback. This also makes it impossible for
   these configurations to be modular, since it all must happen in the
   same place.
3. There is currently no way to do something when a client detaches from
   a buffer (there is no `on_detach` callback).

The solution is to use the traditional method of event handling in Nvim:
autocommands. When a LSP client is attached to a buffer, fire a
`LspAttach`. Likewise, when a client detaches from a buffer fire a
`LspDetach` event.

This enables plugins to easily add LSP-specific configuration to buffers
as well as enabling users to make their own configurations more modular
(e.g. by creating multiple LspAttach autocommands that each do
something unique).
2022-05-18 11:21:00 -06:00
Arsham Shirvani
f6ba7d69be
fix(man.vim): q in "$MANPAGER mode" does not quit #18443
Problem:
q in "$MANPAGER mode" does not quit Nvim. This is because
ftplugin/man.vim creates its own mapping:
    nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
which overrides the one set by the autoload file when using :Man!
("$MANPAGER mode")

Solution:
Set b:pager during "$MANPAGER mode" so that ftplugin/man.vim can set the
mapping correctly.

Fixes #18281
Ref #17791

Helped-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2022-05-13 07:49:08 -07:00
Fredrik Ekre
a9d25e9472
fix(lsp): perform client side filtering of code actions (#18392)
Implement filtering of actions based on the kind when passing the 'only'
parameter to code_action(). Action kinds are hierachical with a '.' as
the separator, and the filter thus allows, for example, both 'quickfix'
and 'quickfix.foo' when requestiong only 'quickfix'.

Fix https://github.com/neovim/neovim/pull/18221#issuecomment-1110179121
2022-05-12 18:48:02 +02:00
Mathias Fußenegger
55187de115
fix(lsp): fix rename capability checks and multi client support (#18441)
Adds filter and id options to filter the client to use for rename.
Similar to the recently added `format` function.

rename will use all matching clients one after another and can handle a
mix of prepareRename/rename support. Also ensures the right
`offset_encoding` is used for the `make_position_params` calls
2022-05-05 23:56:00 +02:00
William Boman
94eb72cc44
fix(lsp): make sure to always reset active codelens refreshes (#18331)
This fixes issues where subsequent calls to vim.lsp.codelens.refresh()
would have no effect due to the buffer not getting cleared from the
active_refresh table.

Examples of how such scenarios would occur are:
  - A textDocument/codeLens result yielded an error.
  - The 'textDocument/codeLens' handler was overriden in such a way that
    it no longer called vim.lsp.codelens.on_codelens().
2022-05-05 18:50:12 +02:00
Mathias Fußenegger
0344736aa6
fix(lsp): handle textDocumentSync.save bool capability (#18332)
Follow up to https://github.com/neovim/neovim/pull/17814
2022-04-30 22:13:26 +02:00
Mathias Fußenegger
88411613e2
feat(lsp): add async option to vim.lsp.buf.format (#18322)
Deprecates the existing `vim.lsp.buf.formatting` function.
With this, `vim.lsp.buf.format` will replace all three:

- vim.lsp.buf.formatting
- vim.lsp.buf.formatting_sync
- vim.lsp.buf.formatting_seq_sync
2022-04-30 17:23:50 +02:00
Michael Lingelbach
5b04e46d23
feat(lsp): add vim.lsp.buf.format (#18193) 2022-04-30 15:36:40 +02:00
Michael Lingelbach
c618b314c6
chore(lsp): remove capabilities sanitization (#17814)
* feat(lsp)!: remove capabilities sanitization

Users must now access client.server_capabilities which matches the same
structure as the protocol.

https://microsoft.github.io/language-server-protocol/specification

client.resolved_capabilities is no longer used to gate capabilities, and
will be removed in a future release.

BREAKING CHANGE


Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
2022-04-30 11:22:30 +02:00
Fredrik Ekre
df09e03cf7
feat(lsp): options to filter and auto-apply code actions (#18221)
Implement two new options to vim.lsp.buf.code_action():
 - filter (function): predicate taking an Action as input, and returning
   a boolean.
 - apply (boolean): when set to true, and there is just one remaining
   action (after filtering), the action is applied without user query.

These options can, for example, be used to filter out, and automatically
apply, the action indicated by the server to be preferred:

    vim.lsp.buf.code_action({
        filter = function(action)
            return action.isPreferred
        end,
        apply = true,
    })

Fix #17514.
2022-04-30 10:14:31 +02:00
ii14
55135cea61
fix(lsp): fix unnecessary buffers being added on empty diagnostics (#18275)
Some language servers send empty `textDocument/publishDiagnostics`
messages after indexing the project with URIs corresponding to unopened buffers.
This commit guards against opening buffers corresponding to empty diagnostics.
2022-04-26 10:00:28 -07:00
Fredrik Ekre
6160973f36
fix(lsp): fix lookup of boolean values in workspace/configuration (#18026) 2022-04-15 11:12:41 +02:00
dundargoc
61205c1def
chore: fix typos (#17755)
Co-authored-by: Jordan Haine <jhaine@securitycompass.com>
2022-03-25 19:57:59 +01:00
Tim Pope
af427dedf6
fix(lsp): set tabSize from 'shiftwidth', not 'softtabstop' (#17787)
The use of 'softtabstop' to set tabSize was introduced in 5d5b068,
replacing 'tabstop'.  If we look past the name tabSize and at the actual
purpose of the field, it's the indentation width used when formatting.
This corresponds to the Vim option 'shiftwidth', not 'softtabstop'.
The latter has the comparatively mundane purpose of controlling what
happens when you hit the tab key (and even this is incomplete, as it
fails to account for 'smarttab').
2022-03-20 10:41:46 -07:00
Michael Lingelbach
3800615da9
fix(lsp): handle insertion of previous line (#17618) 2022-03-06 07:52:11 -08:00
Michael Lingelbach
a5e475fcc2
fix(lsp): start incremental sync range at previous newline character (#17610)
This change forces the start of an incremental sync range to begin always on an existing line.
2022-03-05 09:17:56 -08:00
David Shen
5d6006f9bf
feat(diagnostic): add "code" to the diagnostic structure (#17510) 2022-03-02 18:42:27 -07:00
TJ DeVries
991e472881 feat(lua): add api and lua autocmds 2022-02-27 22:04:55 +01:00
Edmund Cape
300b009f47 fix(healthcheck): handle empty reports 2022-02-09 10:18:22 +08:00
zeertzjq
a87ecf5d08 fix(health): do not run external processes in a shell 2022-02-03 18:38:37 +08:00
Michael Lingelbach
bc722c8a74
fix(lsp): strictly enforce passing offset encoding (#17049)
This removes the "fallback" to utf-16 in many of our helper functions. We
should always explicitly pass these around when possible except in two
locations:

* generating params with help utilities called by buf.lua functions
* the buf.lua functions themselves

Anything that is called by the handler should be passed the offset encoding.
2022-01-13 02:34:04 -08:00
Mathias Fußenegger
e7cd811567
fix(lsp): handle negative activeSignature in signatureHelp (#17064)
omnisharp-roslyn can send negative values:

    {
      activeParameter = 0,
      activeSignature = -1,
      signatures = { {
          documentation = "",
          label = "TestEntity.TestEntity()",
          parameters = {}
        } }
    }

In 3.16 of the specification `activeSignature` is defined as `uinteger`
and therefore negative values shouldn't be allowed, but within 3.15 it
was defined as `number` which makes me think we can be a bit lenient in
this case and handle them.

The expected behavior is quite clear:

    The active signature. If omitted or the value lies outside the
    range of `signatures` the value defaults to zero or is ignored if
    the `SignatureHelp` has no signatures.

Fixes an error:

    util.lua:1685: attempt to get length of local 'lines' (a nil value)
    util.lua:1685: in function 'trim_empty_lines'
    handlers.lua:334: in function 'textDocument/signatureHelp'
2022-01-13 01:47:36 -08:00
hrsh7th
43ef7df22d
fix(lsp): fix applying multiple out-of-range TextEdits (#17037) 2022-01-13 10:28:13 +01:00
Mathias Fußenegger
074b033e7e
refactor(lsp): debounce timer per buf and unify with non-debounce (#17016)
Part of the `pending_change` closure in the `changetracking.prepare` was
a bit confusing because it has access to `bufnr` and `uri` but it could
actually contain pending changes batched for multiple buffers.

(We accounted for that by grouping `pending_changes` by a `uri`, but
it's not obvious what's going on)

This commit changes the approach to do everything per buffer to avoid
any ambiguity.

It also brings the debounce/no-debounce a bit closer together: The
only difference is now whether a timer is used or if it is triggered
immediately
2022-01-11 18:10:29 +01:00
Michael Lingelbach
55a59e56ed
feat(lsp): enable default debounce of 150 ms (#16908) 2022-01-05 08:36:35 -08:00
Michael Lingelbach
1b04da52b3
feat(lsp): add buf_detach_client (#16250)
This allows the user to detach an active buffer from the language
client. If no clients remain attached to a buffer, the on_lines callback
is used to cancel nvim_buf_attach.
2021-12-21 10:53:34 -08:00
matveyt
734fba0d88
feat(runtime): new checkhealth filetype (#16660) 2021-12-18 09:14:42 -07:00
Rishikesh Vaishnav
36c401db24
fix(lsp): correctly align start and end range to codepoints during incremental sync (#16670)
Closes #16624

Fixes two issues with aligning the start position and end position to
codepoints when calculating the start and end range.

When aligning the start position:
* use aligned byte index to calculate character index rather than 
  the unadjusted byte

When aligning the end position:
* do not adjust the end byte if it falls on a UTF-8 codepoint
* align byte to the first byte of the next codepoint rather than the
  last byte of the current codepoint
* compute character character end range on the aligned byte index

This commit also adds additional test coverage, including multibyte operations
that previously failed before this commit.
2021-12-17 18:05:00 -08:00
Michael Lingelbach
a2749482d9
chore(lsp): clean up initialization process (#16369)
* send vim.NIL instead of not sending workspaceFolders
* read fallback rootPath and rootUri from workspaceFolders
* update documentation
2021-11-21 11:39:30 -05:00
Michael Lingelbach
f71be1f87b
fix(lsp): improve incremental sync robustness (#16358)
closes https://github.com/neovim/neovim/issues/16352

* improve handling of multi-byte deletions
2021-11-18 16:49:46 -05:00
Michael Lingelbach
87a053f126
fix(lsp): fix edge cases in incremental sync (#16308) 2021-11-15 08:51:30 -08:00
Mathias Fußenegger
ee3a58d42e
fix(lsp): ensure buffers are re-attached on rename (#16266)
If a LSP server sent a workspace edit containing a rename the buffers
file name changed without the server receiving a close notification for
the old buffer and without the client properly re-attaching on the new
file.

This affected `Move` code-actions in nvim-jdtls, but also
`vim.lsp.buf.rename` on a class level.
2021-11-14 12:55:16 +01:00
Michael Lingelbach
2ecf0a4c61
fix(lsp): rewrite incremental sync (#16252)
* use codeunits/points instead of byte ranges when applicable
* take into account different file formats when computing range and
  sending text (dos, unix, and mac supported)
* add tests of incremental sync
2021-11-09 14:37:48 -08:00
Sebastian Lyng Johansen
16d4af6d2f
feat(ui): add vim.ui.input and use in lsp rename (#15959)
* vim.ui.input is an overridable function that prompts for user input
* take an opts table and the `on_confirm` callback, see `:help vim.ui.input` for more details
* defaults to a wrapper around vim.fn.input(opts)
* switches the built-in client's rename handler to use vim.ui.input by default
2021-11-07 07:13:53 -08:00
Gregory Anders
03b805aee6
feat(lua): enable stack traces in error output (#16228) 2021-11-06 08:26:10 -06:00
Michael Lingelbach
519d8deb08
feat(lsp): add per-client commands (#16101) 2021-11-01 03:14:59 -07:00
Gregory Anders
e921e98ce3
refactor(diagnostic): make display handlers generic (#16137)
Rather than treating virtual_text, signs, and underline specially,
introduce the concept of generic "handlers", of which those three are
simply the defaults bundled with Nvim. Handlers are called in
`vim.diagnostic.show()` and `vim.diagnostic.hide()` and are used to
handle how diagnostics are displayed.
2021-10-29 18:47:34 -07:00
jdrouhard
d1c470957b
feat(lsp): track pending+cancel requests on client object #15949 2021-10-29 05:45:01 -07:00
hrsh7th
bd2f61c6c4
fix(lsp): fix cursor row after textEdits (#16038) 2021-10-18 11:49:33 -07:00
Christian Clason
fbc5b7b090 chore(test): adapt healthcheck test to new css syntax
The runtime file update
2286304cdb
added a `syn keyword` for `css`, which affects (via `html` and
`markdown` syntax files) the highlighting of `:checkhealth` output
(before, `ERROR:` was highlighted with `healthError`; now the colon is
no longer included).
2021-10-16 19:17:28 +02:00
Michael Lingelbach
d288daac2b
fix(lsp): do not invoke handlers for unsupported methods (#15926)
Closes https://github.com/neovim/neovim/issues/15174

Instead of invoking handlers with unsupported methods, pre-compute which
clients support a given method and only notify the user if no clients
support the given method.
2021-10-10 22:32:50 -07:00
Michael Lingelbach
4f4dbfe81c
fix(lsp): update tests using 0.5.0 handler calls (#15969)
Fixes test regression introduced in https://github.com/neovim/neovim/pull/15262
2021-10-08 14:01:55 -07:00
Rishikesh Vaishnav
3f09732195
fix(lsp): expose ContentModified error code to callbacks (#15262) 2021-10-08 11:19:33 -07:00
Javier Lopez
acd5e831b6
fix(checkhealth): mitigate issues with duplicate healthchecks #15919
* fix(runtime/health): mitigate issues with duplicate healthchecks
  Previously if a healthcheck was found as Lua and Vim it was executed
  both times.
  This new implementations prefers Lua, therefore if two are found It only
  runs the Lua one, this way a plugin can mantain both implementations the
  Lua one with the method `check()` and the autoload function `#check()`
  (for none HEAD nvim versions).
  **Note: This will require plugins to use `check()` as the function name,
  since the autoload function that wraps the lua implementation won't be
  called**
* docs(health): use spaces and don't overuse backtics

followup to #15259
2021-10-05 15:37:39 -07:00
Javier López
8b43b07333 feat(ex_checkhealth): provide function for command line completion
Move away from providing completion with ExpandRTDir to ExpandGeneric
providing the function get_healthcheck_name which caches the results for
the current command line prompt.

It does the almost the same thing the Vim function 'get_healthcheck'
implemented in 'runtime/autoload/health.vim' does.
2021-10-04 16:51:54 -05:00
Javier López
c65f956015 test(runtime/health): cover lua healthchecks
- Add tests for lua healthchecks (failure, success and submodules).
- Reword some of the test naming for improved logs readability.
- Modify render test to accomodate the changes of the health autoload function.
- Add test for :checkhealth completion of Lua healtchecks.
2021-10-04 14:28:54 -05:00
zeertzjq
b3e815094b
fix(float)!: always anchor to corner of window including border #15832
N, W, S, E are all inclusive, i.e., always anchor to the exact corner of the
window (including border). This line may also need change in this case (change
0 to -1):

This is most consistent and easiest to reason about, especially with GUIs whose
border do not need to have width/height of 1/1 in cell units.

Fix #15789
2021-10-02 17:36:24 -07:00
Justin M. Keyes
069d1de184 fix(lsp_spec): tests depended on previous session
- fix tests which accidentally depended on previous session
2021-10-02 08:26:57 -07:00
Mathias Fußenegger
ec4731d982
feat(lsp): add codeAction/resolve support (#15818)
Closes https://github.com/neovim/neovim/issues/15339 and https://github.com/neovim/neovim/issues/15828
2021-09-28 14:04:01 -07:00
Mathias Fußenegger
19a77cd5a7
feat(lsp): add client command support to codelens (#15820)
Also adds a check against the server capabilities to fix
https://github.com/neovim/neovim/issues/15183
2021-09-28 09:19:19 -07:00
Michael Lingelbach
248974a4c6
Merge pull request #14115 from mfussenegger/lsp-commands
lsp: Add a registry for client side code action commands
2021-09-22 11:42:56 -07:00
Gregory Anders
17b7968f02
fix(diagnostic): preserve fields from LSP diagnostics via user_data (#15735)
* preserve fields from LSP diagnostics via adding a user_data table to the diagnostic, which can hold arbitrary data in addition to the lsp diagnostic information.
2021-09-21 15:27:12 -07:00
Mathias Fussenegger
6c03601e3a feat(lsp): add a registry for client side code action commands
This builds on https://github.com/neovim/neovim/pull/14112 and closes
https://github.com/neovim/neovim/issues/12326
2021-09-20 22:26:00 +02:00
Mathias Fussenegger
187579fe19 feat(lsp): include original request params in handler ctx
This is mostly motivated by https://github.com/neovim/neovim/issues/12326

Client side commands might need to access the original request
parameters.

Currently this is already possible by using closures with
`vim.lsp.buf_request`, but the global handlers so far couldn't access
the request parameters.
2021-09-20 22:06:54 +02:00
hrsh7th
41cfba63cd
feat(lsp): improve vim.lsp.util.apply_text_edits (#15561)
- Fix the cursor position after applying TextEdits
- Support reversed range of TextEdit
- Invoke nvim_buf_set_text one by one
2021-09-18 13:19:21 -07:00
Gregory Anders
c13242cf47
fix(diagnostic): remove useless highlight links (#15683)
These links were actually defined backwards: the highlight groups
actually being used for display are the new "Diagnostic*" groups, so
linking the old "LspDiagnostics*" groups to these does absolutely
nothing, since there is nothing actually being highlighted with the
LspDiagnostics* groups.

These links were made in an attempt to preserve backward compatibility
with existing colorschemes. We could reverse the links to maintain this
preservation, but then that disallows us from actually defining default
values for the new highlight groups.

Instead, just remove the links and be done with the old LspDiagnostics*
highlight groups.

This is not technically a breaking change: the breaking change already
happened in #15585, but this PR just makes that explicit.
2021-09-17 08:17:54 +02:00
Gregory Anders
888a6ec6ce fix(lint): remove unused function from diagnostic spec 2021-09-16 14:40:13 -06:00
Gregory Anders
a5bbb932f9 refactor: move vim.lsp.diagnostic to vim.diagnostic
This generalizes diagnostic handling outside of just the scope of LSP.
LSP clients are now a specific case of a diagnostic producer, but the
diagnostic subsystem is decoupled from the LSP subsystem (or will be,
eventually).

More discussion at [1].

[1]: https://github.com/neovim/neovim/pull/15585
2021-09-15 14:09:47 -06:00
hrsh7th
516775e9d8
fix(lsp): correctly parse LSP snippets #15579
Fixes #15522
2021-09-14 04:31:41 -07:00
Zi How Poh
c1f573fbc9
feat(lsp): support textDocument/prepareRename (#15514) 2021-09-08 17:00:15 +02:00
Jose Alvarez
3f526feebf
fix(lsp): update workspace/applyEdit handler signature (#15573) 2021-09-05 12:48:54 -07:00
Michael Lingelbach
23fe6dba13
Merge pull request #15504 from mjlbach/feat/change-handler-signature
feat(lsp)!: change handler signature
2021-09-05 10:27:52 -07:00
Michael Lingelbach
df17d7844e feat(lsp)!: change handler signature
Previously, the handler signature was:

  function(err, method, params, client_id, bufnr, config)

In order to better support external plugins that wish to extend the
protocol, there is other information which would be advantageous to
forward to the client, such as the original params of the request that
generated the callback.

In order to do this, we would need to break symmetry of the handlers, to
add an additional "params" as the 7th argument.

Instead, this PR changes the signature of the handlers to:

  function(err, result, ctx, config)

where ctx (the context) includes params, client_id, and bufnr. This also leaves
flexibility for future use-cases.

BREAKING_CHANGE: changes the signature of the built-in client handlers, requiring
updating handler calls
2021-09-05 10:04:30 -07:00
zeertzjq
f6e662bbe9
feat(lsp): get_border_size(): support repeating border char list #15474 2021-08-27 04:19:17 -07:00
Gregory Anders
d8ab8cccd0 test: update tests to work with 'hidden' 2021-08-18 12:17:12 -06:00
James McCoy
bcca62a760
Merge pull request #15368 from jamessan/fragility
test(lsp): disable finicky test when TEST_SKIP_FRAGILE is set
2021-08-14 21:21:50 -04:00
James McCoy
8491077314
test(lsp): disable finicky test when TEST_SKIP_FRAGILE is set 2021-08-13 23:53:55 -04:00
Andrea Cappuccio
adebbebdd7
fix(lsp): properly handle nil lines when trimming empty lines (#15325) 2021-08-10 20:52:30 +02:00
Jan Edmund Lazo
5cead86975
fixup! vim-patch:8.2.3019: location list only has the start position. 2021-07-31 16:58:10 -04:00
Björn Linse
a3e2636afd fix(ci): disable broken test on openbsd on all CI due to resource constraints 2021-07-23 19:35:32 +02:00
Gregory Anders
1aeb945553
feat(lsp): allow diagnostics to be disabled for a buffer (#15134)
Add two new methods to allow diagnostics to be disabled (and re-enabled)
in the current buffer. When diagnostics are disabled they are simply not
displayed to the user, but they are still sent by the server and
processed by the client.

Disabling diagnostics can be helpful in a number of scenarios. For
example, if one is working on a buffer with an overwhelming amount of
diagnostic warnings it can be helpful to simply disable diagnostics
without disabling the LSP client entirely. This also allows users more
flexibility on when and how they may want diagnostic information to be
displayed. For example, some users may not want to display diagnostic
information until after the buffer is first written.
2021-07-19 11:49:55 -07:00
Alessandro Pezzoni
82a443e1f3 test(lsp): file URIs do not allow relative paths 2021-07-10 18:27:37 +01:00
Matthieu Coudron
3552916cb9
fix(doc): remove reference to vim.lsp.callbacks (#14576)
too old now, can be confusing
2021-06-28 23:02:17 +02:00
Akin Sowemimo
444f175335 fix(lsp): do not convert vim.NIL to nil in lists 2021-06-24 11:23:19 +01:00
Matthieu Coudron
9a39a11807 fixup! vim-patch:8.2.3020: unreachable code (#14866) 2021-06-22 10:35:36 +02:00
Mathias Fussenegger
2bdd553c9e feat(lsp): Add codelens support 2021-06-14 21:45:14 +02:00
Mathias Fussenegger
f03a4d616b feat(lsp): Split out a diagnostics_to_items function from set_loclist
Makes it easier to re-use the logic to populate the quickfix list
instead of the location list.
2021-06-07 18:24:32 +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
9051064672
test(lsp_spec): improve correctness
References https://github.com/neovim/neovim/issues/14571
2021-05-19 16:35:02 +02:00
Marco Hinz
34922fba6b
Revert "lsp: make tagstack smarter motion-wise (#12262)"
This reverts commit 8885ea7f24.
2021-05-19 15:33:32 +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
francisco souza
9149fe48a9 lsp: add a test for the jump_to_location + jump list fix 2021-05-06 17:56:24 -04:00
Jan Edmund Lazo
278ca5f456
vim-patch:ebdf3c964a90
Update runtime files.
ebdf3c964a

Omit vim9.
2021-04-27 09:21:35 -04: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
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
Björn Linse
2df527e1ff test/lsp: disable tracking in LSP tests (here be dragons) 2021-04-03 16:27:58 +02: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
Josa Gesell
d1074e0077
lsp: Resolve codeLense server capabilities (#14056) 2021-03-10 17:02:09 -05:00
Michael Lingelbach
0869cbd55c
Merge pull request #14079 from mjlbach/incremental_sync
lsp: add incremental text synchronization
2021-03-09 21:03:31 -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
Björn Linse
f901149de4 state: throttle batched event processing when input is available
before, calling vim.schedule() from inside an event would execute
the scheduled callback immediately after this event without
checking for user input in between. Break event processing
whenever user input or an interrupt is available.
2021-03-08 16:08:58 +01: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
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
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
Mathias Fußenegger
459a6c845e
lsp/tests: Ensure client is stopped in basic_init tests (#13798) 2021-01-27 15:32:07 +01: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
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
Michael Lingelbach
f3bbc92476 LSP: add test for workspace/configuration handler 2021-01-01 01:40:46 -08: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
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
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
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
Björn Linse
1b0e4a5906 lua: make vim.inspect available early so it can be used for path debugging 2020-11-05 14:46:41 +01: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
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
Anmol Sethi
3229ba0cde
lsp: Fix bad sortText comparison (#12485)
The spec indicates we have to fallback to comparing by label
if sortText is falsy.

Closes #12431
2020-08-30 22:29:47 -07:00
Andreas Johansson
82bfdbfe5c
Revert "lsp: Fix text edits with the same start position (#12434)" (#12564)
This reverts commit 44fe8828f0.
2020-07-30 13:37:19 -04:00
cbarrete
08efa7037e
lsp: Add support for call hierarchies (#12556)
* LSP: Add support for call hierarchies

* LSP: Add support for call hierarchies

* LSP: Add support for call hierarchies

* LSP: Jump to call location

Jump to the call site instead of jumping to the definition of the
caller/callee.

* LSP: add tests for the call hierarchy callbacks

* Fix linting error

Co-authored-by: Cédric Barreteau <>
2020-07-18 15:10:09 -04:00
Mathias Fußenegger
554b21261e
lsp: Use nvim_buf_get_lines in locations_to_items and add more tests (#12357)
* LSP: Add tests & use nvim_buf_get_lines in locations_to_items

This is to add support for cases where the server returns a URI in the
locations that does not have a file scheme but needs to be loaded via a
BufReadCmd event.

* LSP: Don't iterate through all lines in locations_to_items

* fixup! LSP: Don't iterate through all lines in locations_to_items

* fixup! fixup! LSP: Don't iterate through all lines in locations_to_items

* fixup! fixup! fixup! LSP: Don't iterate through all lines in locations_to_items
2020-06-30 11:48:04 -04:00
David Lukes
ebee9ebe2b lsp: Add sync variant of LSP formatting
Also, factor out a `vim.lsp.util.get_effective_tabstop()` helper and add
tests for it.
2020-06-22 09:48:41 +02:00
francisco souza
70d4b31b83
lsp: Add new highlight groups used in show_line_diagnostics (#12473)
* lsp: support custom hl groups in show_line_diagnostics

Closes #12472.

* runtime: add docs for the new lsp highlight groups

Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
2020-06-18 08:04:49 -04:00
Andreas Johansson
44fe8828f0
lsp: Fix text edits with the same start position (#12434)
According to the LSP spec[1], multiple edits can have the same starting
position, and if that is the case, they should be applied in the order
as they come in the array.

The implementation uses a reverse sort to not interfere with non applied
edits, but failed to take into account the spec.

[1] https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textedit
2020-06-14 15:23:16 -04:00
David Lukes
6d1404faf0
test: Fix ignored LSP tests (#12470)
* Fix ignored LSP tests

* Restructure _make_floating_popup_size tests

Co-authored-by: Christian Clason <christian.clason@uni-due.de>

Co-authored-by: Christian Clason <christian.clason@uni-due.de>
2020-06-11 20:34:34 -04:00
Christian Clason
b7f3f11049
lsp: compute height of floating preview correctly for wrapped lines (#12380)
* take wrapping into account when computing float height

* factor out size calculation

* add test

* accept and pass through opts.wrap_at in floating_preview

* make padding configurable

* slightly refactor fancy_floating_markdown to make use of make_position

* padding using string.format

* move trim and pad to separate function

* nit

Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>

* remove mention of backward compat

* make lint happy

Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>
2020-06-04 14:23:03 -04:00
notomo
ac5a3f2c56
lua: fix behavior when split empty string (#12429)
* lua: fix behavior when split empty string

* test: lsp.util.apply_text_edits with an empty edit
2020-06-04 08:48:48 -04:00
Hirokazu Hata
96568d5b07
Merge pull request #12343 from ndreas/fix/lsp-multibyte-indexing
Fix LSP multibyte indexing
2020-06-04 12:16:42 +09:00
Viktor Kojouharov
5a9226c800
lua: simple snippet support in the completion items (#12118)
Old behavior is: foo(${placeholder: bar, ...)

with lots of random garbage you'd never want inserted.

New behavior is: foo(bar, baz) 

(which maybe is good, maybe is bad [depends on user], but definitely better than it was).

-----

* Implement rudimentary snippet parsing

Add support for parsing and discarding snippet tokens from the completion items.

Fixes #11982

* Enable snippet support

* Functional tests for snippet parsing

Add simplified real-world snippet text examples to the completion items
test

* Add a test for nested snippet tokens

* Remove TODO comment

* Return the unmodified item if the format is plain text

* Add a plain text completion item
2020-05-28 08:31:56 -04:00
Hirokazu Hata
15b762761a
lsp: make the command error message more detailed (#11633)
* lsp.lua: make the error message more detailed

* test: add lsp._cmd_part test
2020-05-26 08:55:45 -04:00
Andreas Johansson
67eb3bfbc3 Add tests for jump_to_location 2020-05-19 08:51:10 +02:00
Andreas Johansson
4fbbe1c957
lsp: Handle end lines in apply_text_edits (#12314)
If the LSP sends an end line that is larger than what nvim considers to be the
last line, you get an Index out of bounds error when fetching the line from
nvim, a change that was introduced in #12223. This change removes the strict
indexing and checks the return value from nvim_buf_get_lines.
2020-05-17 13:47:14 -04: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
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
Hirokazu Hata
67634da714
lsp: add a lsp.util.apply_text_edits test(pending)
We don't handle non-ASCII characters well in UTF-16.
So I add a non-ASCII characters test case.
2020-05-04 09:05:16 +09:00
Hirokazu Hata
0107a194fa
lsp: fix apply_text_document_edit test
lsp.util.buf_versions must be set in advance.
Use helper.insert to create an anonymous buffer,
so create a named buffer for testing without using insert.
2020-05-04 08:10:27 +09:00
Hirokazu Hata
3eae7d52c5
lsp: add lsp.util.symbols_to_items test 2020-05-02 15:16:43 +09:00
ckipp01
6dc8398944 [LSP] check for vim.NIL and add apply_text_document_edit tests 2020-05-01 17:40:03 +02: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
Mathias Fußenegger
50ff37308a
LSP: Fix show_line_diagnostics #12186
Messed this up in ef0398fe88
2020-04-26 14:56:30 -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
Andrey Avramenko
49045b173e test: add docs for get_completion_word test 2020-04-20 20:20:14 +03:00
Andrey Avramenko
a0d2bfeeb5 test: add get_completion_word test for text_doc...
...ument_completion_list_to_complete_items
2020-04-20 18:35:54 +03: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
Justin M. Keyes
b353a5c05f
test: always dump logs on failure #11886
Whenever `eq()`, `ok()`, etc. fails, include log tail in the failure
message. This helps to correlate log messages with a particular test
failure.
2020-02-16 23:30:24 -08:00
Justin M. Keyes
6e13b9d261 test/LSP: assert contents of log file 2020-02-16 22:09:28 -08:00
Justin M. Keyes
4cf48dc329 test/LSP: dump logs on error
This will help debug CI flakey failures.

TODO: helpers.assert_log()  -- Explicitly check contents of the logfile.
2020-02-16 19:04:40 -08:00
Justin M. Keyes
1eb0f5371a LSP: fix validate_client_config
- `cmd_env` is a table not a function.
- tests: Set $NVIM_LOG_FILE for fake LSP server.
2020-02-16 17:53:33 -08:00
Justin M. Keyes
c15bd6cd27 test/LSP: use less-generic exit code
- os.exit(1) is too generic, since code 1 may be caused by Nvim exiting
  for some other reason.  Change it to os.exit(101).
- style: de-architect json_encode/json_decode calls.

Failure seen in travis macOS job:
https://travis-ci.org/neovim/neovim/jobs/647849133

    [  FAILED  ] test/functional/plugin/lsp_spec.lua@ 266 SP basic_init test should not send didOpen if the buffer closes before init
    test/functional/plugin/lsp_spec.lua:297: exit code
    Expected objects to be the same.
    Passed in:
    (number) 1
    Expected:
    (number) 0
    stack traceback:
      test/functional/plugin/lsp_spec.lua:297: in function 'on_exit'
      test/functional/plugin/lsp_spec.lua💯 in function 'test_rpc_server'
      test/functional/plugin/lsp_spec.lua:272: in function <test/functional/plugin/lsp_spec.lua:266>
2020-02-16 17:52:48 -08:00
Justin M. Keyes
b04165859d test: style 2020-02-16 17:24:21 -08:00
Justin M. Keyes
0a1c6d9a37 LSP: highlight groups test, doc 2020-01-08 22:18:18 -08:00
Justin M. Keyes
8c8681d594 test: hoist buf_lines() 2020-01-08 09:41:41 -08:00
Justin M. Keyes
844cd9cef1 test: just say no to hyper-granularity
- Move plugin/lsp/* to plugin/*
- Merge lsp/util_spec.lua into lsp_spec.lua
2020-01-08 09:30:59 -08:00
Justin M. Keyes
8b84119650 LSP: eliminate lsp.stop_all_clients()
Reduce API surface.  We don't need so many variations of functions. Too
many functions means verbose, largely redundant documentation, tests,
and cognitive burden.
2019-12-31 15:39:17 -08:00
Ashkan Kiani
34a59242a0 Revert "runtime: Add vim.lsp.get_client_by_name" #11623
reverts 680693e263 #11603
2019-12-29 09:05:32 +01:00
Hirokazu Hata
680693e263 runtime: Add vim.lsp.get_client_by_name (#11603)
Since the client name is more obvious than the client id for the user, add an
API to get the lsp client by the client name.
2019-12-28 09:28:00 -08:00
Ashkan Kiani
52566dd780 LSP: Fix flaky test #11618 2019-12-27 12:20:17 +01:00
Ashkan Kiani
b4ca07896c lualint 2019-11-21 15:23:43 -08:00
Ashkan Kiani
bcae04f6c6 Updates
- Use correct implementation of text_edits.
- Send indent options to rangeFormatting and formatting.
- Remove references to vim bindings and filetype from lsp.txt
- Add more examples to docs.
- Add before_init to allow changing initialize_params.
2019-11-21 15:19:06 -08:00
Björn Linse
76e0a8bd93 lsp: transmit "\n" after last line when 'eol' is set
Otherwise some servers like clangd will emit spurious
"no newline at end of file" warnings.
2019-11-21 11:12:57 +01:00
Ashkan Kiani
00dc12c5d8 lua LSP client: initial implementation (#11336)
Mainly configuration and RPC infrastructure can be considered "done". Specific requests and their callbacks will be improved later (and also served by plugins). There are also some TODO:s for the client itself, like incremental updates.

Co-authored by at-tjdevries and at-h-michael, with many review/suggestion contributions.
2019-11-13 21:55:26 +01:00
Björn Linse
4987311fb5 tests/ui: remove unnecessary screen:detach()
It is perfectly fine and expected to detach from the screen just by
the UI disconnecting from nvim or exiting nvim. Just keep detach() in
screen_basic_spec, to get some coverage of the detach method itself.

This avoids hang on failure in many situations (though one could argue
that detach() should be "fast", or at least "as fast as resize",
which works in press-return already).

Never use detach() just to change the size of the screen, try_resize()
method exists for that specifically.
2019-10-13 22:10:42 +02:00
Björn Linse
a330129a28 tests/ui: cleanup illegitimate usages of "attr_ignore"
"attr_ignore" is an anti-pattern, with snapshot_util()
just include all the highlights already.
2019-10-13 22:10:42 +02:00
Justin M. Keyes
607d610d06
test/shada_spec: avoid exit_event race #10951
Doing clear() multiple times in quick succession provokes the
`exit_event` race described in #8813.

- Avoid it by removing unnecessary reset() call.
- Replace unnecessary nested describe() blocks with it() blocks.

ref d4a0b6c4e1
2019-09-05 09:48:34 -07:00
Daniel Hahler
dcc8fcf0b9 tests: assert:set_parameter('TableFormatLevel', 100) #10925
luassert uses 3 by default, which is often not enough.

Instead of documenting how to increase it, let's use a more fitting
(sane) default of 100 levels.
2019-09-03 04:29:49 -07:00
Daniel Hahler
1d6e368159 Fix lualint: remove unused var 2019-08-07 14:20:23 +02:00
Daniel Hahler
4f148edd75 tests: more cleanup of plugin/shada_spec
Ref: https://github.com/neovim/neovim/pull/10701/commits/330a6713#r311005754
Closes https://github.com/neovim/neovim/pull/10710.
2019-08-07 12:47:21 +02:00
Justin M. Keyes
330a6713bf test: Eliminate plugin/helpers.lua 2019-08-05 23:55:57 +02:00
Justin M. Keyes
d4a0b6c4e1 test/man_spec: remove plugin_helpers.reset()
The call to plugin_helpers.reset() is redundant with the clear() call
above it.  Probably just a copy-paste mistake.

Avoids exit_event race #8813.

Helped-by: Björn Linse <bjorn.linse@gmail.com>
2019-08-05 04:51:49 +02:00
Kovas Palunas
fdd8dcae01 man.vim: Handle ANSI escape sequences with ":" #10267
closes #10267
2019-06-30 15:25:49 +02:00
Jan Edmund Lazo
4abed17496 functionaltest: win: enable shada FileWriteCmd 2018-10-31 22:55:07 -04:00
Björn Linse
4da5cb38d3 startup: always wait for UI with --embed, unless --headless also is supplied 2018-09-22 10:18:28 +02:00
Björn Linse
bd8d43c6fe startup: wait for embedder before executing startup commands and files
Give embeders a chance to set up nvim, by processing a request before
startup. This allows an external UI to show messages and prompts from
--cmd and buffer loading (e.g. swap files)
2018-09-18 19:22:16 +02:00
ZyX
a9fa66b5b8 functests: Add tests 2018-09-06 02:12:36 +03:00
James McCoy
e243dbdc32
test: man_spec: Fix use of nested [[ quoting
Lua (not LuaJIT) complains about the "^[[" strings inside the expect,
since it sees them as nested quotes.  Change the quoting to [=[ ]=] to
avoid the issue.
2018-02-02 07:28:56 -05:00
Justin M. Keyes
f8010ea3ec
test: robust cleanup, unique filenames #7950 (#7950)
Use unique filenames to avoid test conflicts.
Use read_file() instead of io.popen(), to ensures the file is closed.
Use helpers.rmdir(), it is far more robust than lfs.

closes #7911
2018-02-01 03:12:37 +01:00
Marco Hinz
72a7a884b4
tests: :checkhealth completion 2018-01-18 22:47:37 +01:00
Justin M. Keyes
59888b68ab Merge #7623 'man.vim: highlight bold, underlined text' 2018-01-09 10:10:22 +01:00
Jan Edmund Lazo
7311fb7cad win: enable more functional tests
- plugin/shada_spec.lua: Use \r\n as Windows EOL for tests on
  BufWriteCmd, FileWriteCmd, FileAppendCmd. Alternative is 'set
  fileformat=unix'.
2018-01-06 17:47:00 +01:00
Gabriel Holodak
eb44519b5d Address PR comments 2017-12-27 23:28:04 -05:00
Gabriel Holodak
134c0f0bdb Add functional tests for man highlighting 2017-12-27 23:27:14 -05:00
Justin M. Keyes
f5d4da0144
:checkhealth : validate 'runtimepath' (#7526) 2017-11-10 22:37:54 +01:00
Justin M. Keyes
3bcee71cc8 :checkhealth : validate $VIM 2017-10-17 01:51:21 +02:00
Justin M. Keyes
d214df4e9b doc: replace ":CheckHealth" with ":checkhealth" 2017-10-17 01:51:21 +02:00
Justin M. Keyes
5baeb4a49c ex-cmds: :checkhealth
Built-in `:checkhealth` checks for valid $VIMRUNTIME by attempting to
autoload `health#check()`.

closes #2977
closes #3159
2017-10-17 01:51:20 +02:00
Justin M. Keyes
c4ab110e04 health.vim: fix highlighting
`:syntax keyword` is affected by 'iskeyword'. When we aligned
'iskeyword' to that of filetype=help, colon (:) is now included.
Simplest way to deal with this is to include colon (:) in the `:syntax
keyword` directive.

Also:
- change "SUGGESTIONS" mouthful to "ADVICE"
- change "SUCCESS" to "OK"
2017-10-15 12:06:13 +02:00
Justin M. Keyes
d15317ece4 health.vim: fix test 2017-07-15 16:15:47 +02:00
James McCoy
d67e48379f
test: shada: Replace hard-coded 704 with dynamic version 2017-07-14 06:44:22 -04:00
AdnoC
5908f562df test: Fix and add cases for unnamed register
Also:

Add ru to shada tests with all keys

Add test for unset unnamed and register 0
2017-05-31 13:31:05 -04:00
AdnoC
beca4dc16c eval/shada: Add testing for unnamed register with setreg and startup 2017-05-31 13:19:08 -04:00
ZyX
65fb622000 functests: Replace execute with either command or feed_command
Hope this will make people using feed_command less likely: this hides bugs.
Already found at least two:

1. msgpackparse() will show internal error: hash_add() in case of duplicate
   keys, though it will still work correctly. Currently silenced.
2. ttimeoutlen was spelled incorrectly, resulting in option not being set when
   expected. Test was still functioning somehow though. Currently fixed.
2017-04-09 03:24:08 +03:00
Justin M. Keyes
a90beeadbb defaults: 'showcmd', 'belloff', 'ruler'
- Vim "unix default" of 'noshowcmd' is serving few users. And it's
  inconsistent.
- 'ruler' and 'belloff=all' improve the out-of-the-box experience.
- Continue to use 'noshowcmd' and 'noruler' by default in the functional
  tests to keep them fast.

TODO: Add a "disable slow stuff" command or mapping to address the
use-case of a very slow terminal connection.
2017-03-16 18:44:10 +01:00
ZyX
24b3b938e8 plugin/shada: Handle NUL characters with intchar correctly
Fixes #5482
2017-01-04 15:06:33 +03:00
ZyX
d82f5d1ba2 plugin/msgpack: Support character constants like '\0' 2017-01-04 14:53:02 +03:00
Justin M. Keyes
44e6ee930f build: Target luacheck HEAD.
https://github.com/mpeterv/luacheck/pull/81#issuecomment-261099606

> If you really want to use bleeding-edge version you should get the
> rockspec from master branch, not a fixed commit ...
> The correct way to install from a specific commit is cloning that
> commit and running "luarocks make" from project directory. The reason
> is that running "install" or "build" on an scm rockspec fetches
> sources from master but uses build description from the rockspec
> itself, which may be outdated.
2016-11-17 00:55:39 +01:00
Tommy Allen
84eed76b55 CheckHealth: Include v:throwpoint in error message (#5575)
* health.vim: Include v:throwpoint in error message

* health/provider.vim: Check for ruby executable

* health/provider.vim: Combine subprocess stdout and stderr

* test: Updated CheckHealth test
2016-11-12 11:59:15 +01:00
Justin M. Keyes
c853fd6fab CheckHealth: more checks 2016-10-25 15:55:29 +02:00
Justin M. Keyes
3c24704ac8 health.vim: Show results incrementally.
Also:

- improve precision of "No healthcheck found"
- fix SUGGESTIONS syntax group definition
- fix indentation of SUGGESTIONS
2016-09-05 19:22:01 -04:00
Björn Linse
1c22cab2fd api: consistently use nvim_ prefix and update documentation 2016-08-31 21:57:06 +02:00
Rui Abreu Ferreira
39c628d031 Mark some functional tests as pending in Windows 2016-08-26 08:21:41 +01:00
Justin M. Keyes
ed49d9d866 CheckHealth: Accept [plugin1 [, plugin2 [, ...]]] args.
To healthcheck the "foo" plugin:
    :CheckHealth foo
To healthcheck the "foo" and "bar" plugins:
    :CheckHealth foo bar
To run all auto-discovered healthchecks:
    :CheckHealth
2016-08-21 22:03:28 -04:00
Justin M. Keyes
545e7a4163 CheckHealth
- Overlay markdown syntax/filetype, don't invent new filetypes/syntaxes.
- migrate s:check_ruby()
- s:indent_after_line1
- Less-verbose output
2016-08-21 21:25:33 -04:00
TJ DeVries
2cc523c3af CheckHealth
- Use execute() instead of redir
- Fixed logic on suboptimal pyenv/virtualenv checks.
- Move system calls from strings to lists. Fixes #5218
- Add highlighting
- Automatically discover health checkers
- Add tests

Helped-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Helped-by: Tommy Allen <tommy@esdf.io>

Closes #4932
2016-08-21 21:25:33 -04:00
Björn Linse
f282b8ecac tests: don't ignore highlights in various tests 2016-08-14 21:53:02 +02:00
ZyX
2126ec0c5b functests: Fix matchparen_spec.lua 2016-06-17 20:38:03 +03:00
ZyX
ff470bb853 functests: Check logs in lua code
It is otherwise impossible to determine which test failed sanitizer/valgrind
check. test/functional/helpers.lua module return was changed so that tests which
do not provide after_each function to get new check will automatically fail.
2016-06-10 21:50:49 +03:00
Justin M. Keyes
4682b21ef2 Merge pull request #4654 from KillTheMule/testlint
Satisfy testlint.
2016-05-06 01:13:39 -04:00
KillTheMule
360d0513d1 Satisfy testlint.
For that, make luatest ignore the preload.lua files.
2016-04-28 19:30:17 +02:00
KillTheMule
f931e78fe4 test: matchparen_spec.lua
Covers vim-patch 7.4.1296
2016-04-27 21:48:18 -04:00
ZyX
a64114eba0 functests: Make json_functions_spec use new NIL where appropriate 2016-04-18 02:48:20 +03:00
ZyX
6e5498c3e3 runtime/msgpack: Add support for special values 2016-04-18 02:44:03 +03:00
Thiago de Arruda
c18d5917e3 Update lua client to 0.0.1-24
The new version of the lua client uses libmpack as a backend, and some test
scripts had to be updated to reflect that.
2016-04-13 09:21:32 -03:00
Björn Linse
8eb8ebf905 tests: update tests to use [gs]et_lines instead of [gs]et_line_slice 2016-04-01 11:29:51 +02:00
Thiago de Arruda
96af115c71 Normalize nan/-nan in plugin/msgpack_spec.lua
-NaN doesn't exist in the IEEE 754 spec, it is a hardware-specific detail
abstracted away by luajit(and not by lua or nvim), so there's no need to test
it.  Normalize all tests that involve -nan so the suite will be compatible with
both Lua and Luajit.
2016-03-07 13:08:48 -03:00
Marco Hinz
483d4abee7 Test: remove artifacts from root directory
The tests would leave the following test files in the root directory:

    Xtest-functional-plugin-shada.shada
    Xtest-functional-plugin-shada.shada.tmp.f

Clean them up in teardown().
2015-12-01 20:46:13 +01:00
Felipe Morales
80cf03602e Merge pull request #3581 from ZyX-I/fix-shada
Store last search direction when writing ShaDa files
2015-11-23 23:03:29 +01:00
ZyX
b98cea909f shada: Also store last search direction
Note: it looks like viminfo files do not store search direction intentionally.
After reading viminfo file search direction was considered to be “forward”.

Note 2: all files created on earlier Neovim version will automatically receive
“forward” direction.

Fixes #3580
2015-11-23 17:08:01 +03:00
Marco Hinz
d9fbc1865b test/functional: clean up according to luacheck (part 2) 2015-11-23 13:57:21 +01:00
ZyX
ae0576a472 runtime: Add shada.vim syntax file 2015-11-01 21:27:28 +03:00
ZyX
9037a180de runtime: Add [ft]plugin/shada.vim files that automatically open .shada 2015-11-01 21:27:28 +03:00
ZyX
8d9063bb2a runtime: Add autoload/shada.vim helper file
Contains most of the logic
2015-11-01 21:27:28 +03:00
ZyX
136c560023 functests: Do not run some tests if there is no -NaN 2015-11-01 21:27:27 +03:00
ZyX
00a638179d runtime: Add autoload/msgpack.vim helper file 2015-11-01 21:27:27 +03:00