* Fix completion item text selection priority
According to the Language Server Protocol 3.17 specification:
- filterText is only used for filtering and sorting completion items
- When textEdit is provided, insertText must be ignored
* Fix filtering should be performed on filterText
If `filterText` exists, the filtering target has been changed from `word`.
The filter is defined as follows in the LSP specification:
```
A string that should be used when filtering a set of completion items.
When omitted the label is used as the filter text for this item.
```
* Fix remove unnecessary empty check condition
---------
Co-authored-by: mattn <mattn.jp@gmail.com>
* fix(text_edit): discarded change from the initial buffer
When multiple calls to apply_text_edits, the changes made to the current
buffer are discarded if the following text_edit concerns a file that
is not in the buffer list.
The problem comes from the _switch function, which executes `edit!` when
it detects that the target is not in the buffer list. If a change was
made to the current buffer before that, that change is discarded
(definition of `edit!`).
The fix consists of a different logic: when _switch detects that the
target is not in the buffer list, it calls `badd` prior to switching to
the buffer that has just been added. No more `edit!`, no more discarded
changes.
The added test fails without the patch in the _switch function.
* use better way to have a named buffer
At some point when writing the `LspStopServer` description I've
incorrectly merged two sentences into. Fixed that and added a few minor
clarifications.
* fix languageId incorrectly set to "ctrlspace"
* remove get_line_count_buf() which incorrectly returned line('$') for hidden buffers
The problem was that current buffer may not be the one requested. Later it
caused vim to throw exception about invalid line number when setting text props,
and that led to initialization failure for some buffers (and lsp_buffer_enabled
autocommand not fired).
* don't register server twice
* skip registering server only if server_info matches
* revert changes to lsp#register_server
---------
Co-authored-by: Krzysztof Sachanowicz <ksachanowicz@striketechnologies.com>
It is convenient to be able to stop all LSP servers, regardless of the
currently active buffer.
Also, it seems confusing that when a server name is specified, it is
only stopped if it is also one handling the current buffer type. I
would imagine it is quite rare to have more than one server handing a
specific buffer type. And if one explicitly specified a name, it seems
reasonable to stop this particular server, regardless of the currently
active buffer.
When set `let g:lsp_use_native_client = 1` to enable native lsp client support,
if call `:LspStopServer` to stop the lsp server, the server stopped but the
status still show it as `running` by `:LspStatus`, this patch try to fix
this issue.
When using typescript-language-server, in content `Math.ab|`, if you type
`<C-X><C-o>` for omni completion, it will be completed with `s`. Then, the
content will become `Math.abs|`. If you continue typing `(`, the `(` will
be removed. Also, if type `<CR>`, a new line will be added, resulting in
`Math.abs|s\nMath.ab`. This patch attempts to fix this issue.
It is not immediately clear what are the possible values for this
configuration parameter. And it is nice to be a bit more explicit about
the meaning of each option.
Co-authored-by: Prabir Shrestha <mail@prabir.me>
It is sometimes useful to generate `workspace_config` using a callback.
For example, if the produced config needs to include some information
from the actual workspace.