Commit Graph

1454 Commits

Author SHA1 Message Date
Raphael
6e8ed5abaa
perf(diagnostic): use api variable and improve validate (#21111)
* fix(diagnostic): use api variable and improve validate

* fix: fix test case
2022-11-19 06:41:47 -07:00
Grzegorz Rozdzialik
cfdf5e6f37
fix(lsp): ignore hover and signatureHelp responses on buffer change (#21121)
Language servers can take some time to respond to the
`textDocument/hover` and `textDocument/signatureHelp` messages. During
that time, the user could have already moved to another buffer. The
popup was always shown in the current buffer, which could be a different
one than the buffer for which the request was sent.

This was particularly annoying when moving to a buffer with a `BufLeave`
autocmd, as that autocmd was triggered when the hover popup was shown
for the original buffer.

Ignoring the response from these 2 messages if they are for a buffer
that is not the current one leads to less noise. The popup will only be
shown for the buffer for which it was requested.

A more robust solution could involve cancelling the hover/signatureHelp
request if the buffer changes so the language server can free its
resources. It could be implemented in the future.
2022-11-19 12:27:00 +01:00
Mathias Fußenegger
af204dd0f1
feat(lsp): run handler in coroutine to support async response (#21026)
To illustrate a use-case this also changes `window/showMessageRequest`
to use `vim.ui.select`
2022-11-19 10:48:49 +01:00
Matthew Gramigna
523b1943c3
vim-patch:9.0.0897: Clinical Quality Language files are not recognized (#21094)
Problem:    Clinical Quality Language files are not recognized.
Solution:   Add the "*.cql" pattern. (Matthew Gramigna, closes vim/vim#11452)

12babe45a3

Co-authored-by: mgramigna <mgramigna@mitre.org>
2022-11-18 00:39:31 +01:00
Gregory Anders
f1922e78a1 feat: add vim.secure.read()
This function accepts a path to a file and prompts the user if the file
is trusted. If the user confirms that the file is trusted, the contents
of the file are returned. The user's decision is stored in a trust
database at $XDG_STATE_HOME/nvim/trust. When this function is invoked
with a path that is already marked as trusted in the trust database, the
user is not prompted for a response.
2022-11-17 08:23:41 -07:00
Max
e15f61b1bd fix(lua): make vim.deepcopy work with vim.NIL
style: changed double quotes to single quotes

feat: add tests

fix tests
2022-11-14 21:14:27 +01:00
Steven Arcangeli
b3f781ba91
fix: vim.ui.input always calls callback #21006
Followup to #20883
Related: #18144

This patch changes the behavior of the default `vim.ui.input` when the user
aborts with `<C-c>`. Currently, it produces an error message + stack and causes
`on_confirm` to not be called. With this patch, `<C-c>` will cause `on_confirm`
to be called with `nil`, the same behavior as when the user aborts with `<Esc>`.
I can think of three good reasons why the behavior should be this way:

1. Easier for the user to understand** It's not intuitive for there to be two
   ways to abort an input dialog that have _different_ outcomes. As a user,
   I would expect any action that cancels the input to leave me in the same
   state. As a plugin author, I see no value in having two possible outcomes for
   aborting the input. I have to handle both cases, but I can't think of
   a situation where I would want to treat one differently than the other.

2. Provides an API that can be overridden by other implementations** The current
   contract of "throw an error upon `<C-c>`" cannot be replicated by async
   implementations of `vim.ui.input`. If the callsite wants to handle the case
   of the user hitting `<C-c>` they need to use `pcall(vim.ui.input, ...)`,
   however an async implementation will instantly return and so there will be no
   way for it to produce the same error-throwing behavior when the user inputs
   `<C-c>`. This makes it impossible to be fully API-compatible with the
   built-in `vim.ui.input`.

3. Provides a useful guarantee to the callsite** As a plugin author, I want the
   guarantee that `on_confirm` will _always_ be called (only catastrophic errors
   should prevent this). If I am in the middle of some async thread of logic,
   I need some way to resume that logic after handing off control to
   `vim.ui.input`. The only way to handle the `<C-c>` case is with `pcall`,
   which as already mentioned, breaks down if you're using an alternative
   implementation.
2022-11-12 06:57:35 -08:00
Lewis Russell
07eb4263ca feat(spell): support nospell in treesitter queries 2022-11-12 10:19:03 +00:00
Justin M. Keyes
4d2373f5f6
feat(checkhealth): use "help" syntax, avoid tabpage #20879
- If Nvim was just started, don't create a new tab.
- Name the buffer "health://".
- Use "help" syntax instead of "markdown". It fits better, and
  eliminates various workarounds.
- Simplfy formatting, avoid visual noise.
- Don't print a "INFO" status, it is noisy.
- Drop the ":" after statuses, they are already UPPERCASE and highlighted.
2022-11-11 18:33:31 -08:00
euclidianAce
0faf007a23
fix(man.lua): use env command (#21007)
Previously man.lua would use the `env` field in the parameters of
`vim.loop.spawn` to override things like MANPAGER. This caused issues on
NixOS since `spawn` will _override_ the environment rather than _append_
to it (and NixOS relies on a heavily modified environment). Using the
`env` command to append to the environment solves this issue.
2022-11-09 23:26:02 +00:00
Jongwook Choi
59ff4691f6
fix(vim.ui.input): return empty string when inputs nothing (#20883)
fix(vim.ui.input): return empty string when inputs nothing

The previous behavior of `vim.ui.input()` when typing <CR> with
no text input (with an intention of having the empty string as input)
was to execute `on_confirm(nil)`, conflicting with its documentation.

Inputting an empty string should now correctly execute `on_confirm('')`.
This should be clearly distinguished from cancelling or aborting the
input UI, in which case `on_confirm(nil)` is executed as before.
2022-11-08 08:15:15 +08:00
Christian Clason
050b0e30b9
vim-patch:9.0.0843: VHS tape files are not recognized (#20995)
Problem:    VHS tape files are not recognized.
Solution:   Add a filetype pattern. (Carlos Alexandro Becker, closes vim/vim#11452)

1756f4b218

Co-authored-by: Carlos A Becker <caarlos0@users.noreply.github.com>
2022-11-07 22:28:28 +01:00
zeertzjq
850d7146fc
fix(paste): feed keys as typed in cmdline mode (#20959) 2022-11-06 12:43:05 +08:00
Kevin Hwang
cc5b7368d6
fix(man.lua): set modifiable before writing page (#20914) 2022-11-03 09:13:29 +08:00
Justin M. Keyes
cc7c378bf3 feat(checkhealth): check runtime ($VIMRUNTIME)
Move man/health.lua into the "runtime" check.

fix #20696
2022-10-30 16:23:58 +01:00
Justin M. Keyes
3213bc36c5 refactor(checkhealth): convert "nvim" check to Lua 2022-10-30 15:50:59 +01:00
Justin M. Keyes
c7a88a470f feat(checkhealth): improve treesitter report 2022-10-30 15:50:59 +01:00
lvimuser
e0dff29adc
fix(lsp/window_showDocument): correctly handle external resources #20867
- since cmd is a list, it runs directly ('no shell') and we shouldn't
  escape.
- typo: shellerror -> shell_error
2022-10-30 02:35:22 -07:00
Martin Kunz
356244d50b
fix(docs): nil as viable argument for goto_prev (#20852)
Added `nil` as a possible option to `vim.diagnostics.goto_prev` in the
docs
2022-10-28 17:13:27 -06:00
NAKAI Tsuyoshi
4573cfa3ad
fix(lua): pesc, tbl_islist result types #20751
Problem:
- pesc() returns multiple results, it should return a single result.
- tbl_islist() returns non-boolean in some branches.
- Docstring: @generic must be declared first

Solution:
Constrain docstring annotations.
Fix return types.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2022-10-24 05:53:53 -07:00
Christian Clason
8371907203
vim-patch:9.0.0814: aws config files are not recognized (#20769)
vim-patch:436e5d395fd6 (since upstream tagged the wrong commit)

Problem:    Aws config files are not recognized.
Solution:   Use "confini" for aws config files. (Justin M. Keyes,
            closes vim/vim#11416)
436e5d395f
2022-10-21 16:36:43 +02:00
Christian Clason
e554f5c545
fix(filetype): don't pass empty string to detect (#20766)
Problem: `*.db` files use empty string as default filetype, which is
inconsistent with the rest of the code which uses `nil` instead.
Solution: don't pass a default empty string
2022-10-21 14:04:53 +02:00
Christian Clason
45ae5c6dc5
vim-patch:9.0.0808: jsonnet filetype detection has a typo (#20753)
Problem:    jsonnet filetype detection has a typo.
Solution:   Change "libjsonnet" to "libsonnet". (Maxime Brunet, closes vim/vim#11412)
6c8bc37a10
2022-10-20 22:49:22 +02:00
ObserverOfTime
fad558b6af
vim-patch:9.0.0798: clang format configuration files are not recognized (#20741)
Problem:    Clang format configuration files are not recognized.
Solution:   Use yaml for Clang format configuration files. (Marwin Glaser,
            closes vim/vim#11398)
3c708c4390
2022-10-19 11:08:01 -06:00
Christian Clason
228a04070e
vim-patch:9.0.0779: lsl and lm3 file extensions are not recognized (#20704)
Problem:    lsl and lm3 file extensions are not recognized.
Solution:   Add *.lsl and *.lm3 patterns. (Doug Kearns, closes vim/vim#11384)
4ac8e7948c
2022-10-18 20:05:50 +02:00
Christian Clason
e427313545
vim-patch:9.0.0782: OpenVPN files are not recognized (#20702)
Problem:    OpenVPN files are not recognized.
Solution:   Add patterns for OpenVPN files. (closes vim/vim#11391)
4bf67ec52e
2022-10-17 18:36:10 +02:00
Mahmoud Al-Qudsi
39911d76be
fix(man): handle absolute paths as :Man targets (#20624)
* fix(man): handle absolute paths as :Man targets

Previously, attempting to provide `:Man` with an absolute path as the name would
cause neovim to return the following error:

```
Error detected while processing command line:
/usr/local/share/nvim/runtime/lua/man.lua:690: /usr/local/share/nvim/runtime/lua/man.lua:683: Vim:E426: tag not found: nil(nil)
Press ENTER or type command to continue
```

..because it would try to validate the existence of a man page for the provided
name by executing `man -w /some/path` which (on at least some Linux machines
[0]) returns `/some/path` instead of the path to the nroff files that would be
formatted to satisfy the man(1) lookup.

While man pages are not normally named after absolute paths, users shouldn't be
blamed for trying. Given such a name/path, neovim would **not** complain that
the path didn't have a corresponding man file but would error out when trying
to call the tag function for the null-propagated name-and-section `nil(nil)`.
(The same underlying error existed before this function was ported to lua, but
did not exhibit the lua-specific `nil(nil)` name; instead a tag lookup for `()`
would fail and error out.)

With this patch, we detect the case where `man -w ...` returns the same value as
the provided name to not only prevent invoking the tag function for a
non-existent/malformed name+sect but also to properly report the non-existence
of a man page for the provided lookup (the absolute path).

While man(1) can be used to directly read an nroff-formatted document via `man
/path/to/nroff.doc`, `:Man /path/to/nroff.doc` never supported this behavior so
no functionality is lost in case the provided path _was_ an nroff file.

[0]: `man -w /absolute/path` returning `/absolute/path` observed on an Ubuntu
18.04 installation.

* test: add regression test for #20624

Add a functional test to `man_spec.lua` to check for a regression for #20624 by
first obtaining an absolute path to a random file and materializing it to disk,
then attempting to query `:Man` for an entry by that same name/path.

The test passes if nvim correctly reports that there is no man page
correspending to the provided name/path and fails if any other error (or no
error) is shown.
2022-10-17 10:37:44 +01:00
Christian Clason
042eb74ff1
feat(runtime)!: remove filetype.vim (#20428)
Made obsolete by now graduated `filetype.lua` (enabled by default).

Note that changes or additions to the filetype detection still need to
be made through a PR to vim/vim as we port the _logic_ as well as tests.
2022-10-17 08:52:40 +02:00
Jonas Strittmatter
d44f088834
vim-patch:9.0.0771: cannot always tell the difference beween tex and … (#20687)
vim-patch:9.0.0771: cannot always tell the difference beween tex and rexx files

Problem:    Cannot always tell the difference beween tex and rexx files.
Solution:   Recognize tex by a leading backslash. (Martin Tournoij,
            closes vim/vim#11380)
bd053f894b
2022-10-17 08:18:57 +02:00
David Hotham
8f31a730c0
fix(lsp): reporting bogus capabilities in CodeActionKind #20678
Problem:
LSP client provides bogus capabilities in CodeActionKind.
LSP logs show this in the "initialize" message:
    codeActionKind = { valueSet = { "Empty", "QuickFix",
    "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite",
    "Source", "SourceOrganizeImports", "", "quickfix", "refactor",
    "refactor.extract", "refactor.inline", "refactor.rewrite", "source",
    "source.organizeImports" }

Solution:
Only the values from the CodeActionKind table should be presented, not also the
keys.

fix #20657
2022-10-16 15:24:39 -07:00
Christian Clason
e26b48bde6
vim-patch:9.0.0752: Rprofile files are not recognized (#20658)
Problem:    Rprofile files are not recognized.
Solution:   Recognize Rprofile files as "r". (closes vim/vim#11369)
7e120ffccb
2022-10-15 10:12:25 +02:00
Justin M. Keyes
e5cb3104d0
docs: fix/remove invalid URLs #20647 2022-10-14 08:01:13 -07:00
Daniel Zhang
81986a7349
fix(lua): on_yank error with blockwise multibyte region #20162
Prevent out of range error when calling `str_byteindex`.
Use `vim.str_byteindex(bufline, #bufline)` to cacluate utf length of `bufline`.
fix #20161
2022-10-14 02:12:46 -07:00
Lewis Russell
288208257c feat(cscope)!: remove 2022-10-13 16:37:23 +01:00
Christian Clason
4f305fba14
vim-patch:9.0.0731: clang-tidy configuration files are not recognized (#20620)
Problem:    clang-tidy configuration files are not recognized.
Solution:   Recognize clang-tidy files as yaml. (closes vim/vim#11350)
af40f9af33
2022-10-12 15:23:42 +02:00
Lewis Russell
b126b11840 fix(man): support MacOS 13
MacOS 13 has changed its version of `man` to an version that doesn't
properly support `man -w` (without arguments). In order to workaround
this we simply fallback to $MANPATH.

Fixes #20579
2022-10-11 15:38:15 +01:00
Lewis Russell
cba05c541d
refactor(man): pass env directly to spawn() (#20591) 2022-10-11 13:25:42 +01:00
Christian Clason
8781213f00
vim-patch:9.0.0711: SubStation Alpha files are not recognized (#20577)
Problem:    SubStation Alpha files are not recognized.
Solution:   Add patterns for SubStation Alpha files. (closes vim/vim#11332)
084f2620ec
2022-10-10 17:51:31 +02:00
Lewis Russell
4ccc57fd7a feat(man): add health check
Fixes #20432
2022-10-10 15:58:44 +01:00
Justin M. Keyes
a7a83bc4c2 fix(docs-html): update parser
- Improve generated HTML by updating parser which includes fixes for
  single "'" and single "|":
  https://github.com/neovim/tree-sitter-vimdoc/pull/31
- Updated parser also fixes the conceal issue for "help" highlight
  queries https://github.com/neovim/tree-sitter-vimdoc/issues/23 by
  NOT including whitespace in nodes.
  - But this means we need to restore the getws() function which scrapes
    leading whitespace from the original input (buffer).
2022-10-10 01:05:18 +02:00
Justin M. Keyes
09dffb9db7
docs: various #12823
- increase python line-length limit from 88 => 100.
- gen_help_html: fix bug in "tag" case (tbl_count => tbl_contains)

ref #15632
fix #18215
fix #18479
fix #20527
fix #20532

Co-authored-by: Ben Weedon <ben@weedon.email>
2022-10-09 05:21:52 -07:00
Folke Lemaitre
8c2226fc30
fix(lua): properly configure luacheck and remove local vim = ... lines (#20551) 2022-10-09 12:40:56 +02:00
ObserverOfTime
b05e10ef72
vim-patch:9.0.0692: PoE filter files are not recognized (#20542)
Problem:    PoE filter files are not recognized.
Solution:   Add a pattern to detect PoE filter files. (closes vim/vim#11305)
b7f52f5659
2022-10-08 17:46:31 +02:00
lvimuser
0773a9ee3a
feat(lsp): support window/showDocument (#19977) 2022-10-08 10:22:25 +02:00
Folke Lemaitre
1da7b4eb69 feat: added support for specifying types for lua2dox 2022-10-06 15:42:21 +01:00
Folke Lemaitre
24a1c7f556 feat: added support for optional params to lua2dox 2022-10-06 15:38:28 +01:00
Folke Lemaitre
c8d1b9a2d6 docs: added proper annotations to functions in shared.lua 2022-10-06 15:38:27 +01:00
Elizabeth Paź
548a4e2587 docs(docstrings): fix runtime type annotations 2022-10-05 15:25:03 +02:00
August Masquelier
b075f49d92
feat(lsp): add bufnr option to lsp.start (#20473) 2022-10-04 20:44:19 +02:00
Raphael
a5e347ce1d
refactor(diagnostic): remove deprecated function (#20423) 2022-10-01 09:36:11 -06:00
Mathias Fußenegger
e54541f7f9
refactor(lsp): remove deprecated lsp functions (#20421) 2022-10-01 11:35:36 +02:00
dundargoc
df646572c5
docs: fix typos (#20394)
Co-authored-by: Raphael <glephunter@gmail.com>
Co-authored-by: smjonas <jonas.strittmatter@gmx.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-30 09:53:52 +02:00
Jonas Strittmatter
33dd917d7f
fix(filetype): add missing return to changelog detection function (#20403) 2022-09-29 16:26:19 +02:00
Sergey Berezhnoy
94718e479d
fix(query): fix unnatural order for inherits in treesitter queries (#20298)
close #20297
2022-09-29 16:25:07 +02:00
Justin M. Keyes
16336c486e feat(gen_help_html.lua): adapt to new parser
- adapt to parser changes from https://github.com/vigoux/tree-sitter-vimdoc/pull/16
- numerous other generator improvements
2022-09-28 18:34:20 +02:00
ObserverOfTime
f46060c4cb
vim-patch:9.0.0604: luacheckrc file is not recognized (#20371)
Problem:    Luacheckrc file is not recognized.
Solution:   Use lua filetype for luacheckrc. (closes vim/vim#11236)
49c311c9b1
2022-09-27 16:10:19 +02:00
Christian Clason
fe0727a1bf vim-patch:9.0.0602: new TypeScript extensions are not recognized
Problem:    New TypeScript extensions are not recognized.
Solution:   Recognize .mts and .cts files. (closes vim/vim#11237)
7fc6c0e4da
2022-09-27 13:04:34 +02:00
Christian Clason
e176f9dacf vim-patch:9.0.0600: GYP files are not recognized
Problem:    GYP files are not recognized.
Solution:   Recognize GYP files. (closes vim/vim#11242)
d324742292
2022-09-27 12:39:09 +02:00
Christian Clason
760a8754c0 vim-patch:9.0.0599: latexmkrc files are not recognized
Problem:    Latexmkrc files are not recognized.
Solution:   Use Perl filetype for latexmkrc files. (closes vim/vim#11241)
cde0319385
2022-09-27 12:37:44 +02:00
Justin M. Keyes
63be765182
fix(docs): invalid :help links #20345
Fix those naughty single quotes.

closes #20159
2022-09-25 16:58:27 -07:00
Justin M. Keyes
4686bda06c
Merge #20331 refactor(treesitter)!: rename x_position => x_pos 2022-09-25 08:37:05 -04:00
Christian Clason
2a5692c646
vim-patch:9.0.0583: only recognizing .m3u8 files is inconsistent (#20342)
Problem:    Only recognizing .m3u8 files is inconsistent.
Solution:   Also matc .m3u files. (issue vim/vim#11204)
b9725bc7f6
2022-09-25 13:59:11 +02:00
Justin M. Keyes
3169fc54a1 refactor(treesitter): rename x_position => x_pos
"pos" has a long precedent as "position" in vim, and there is no reason
to use a verbose name here.
2022-09-25 13:46:15 +02:00
Christian Clason
f8b656c582
vim-patch:9.0.0566: Nim files are not recognized (#20317)
Problem:    Nim files are not recognized.
Solution:   Add patterns for Nim files. (Nbiba Bedis, closes vim/vim#11205)
9fd1583c83
2022-09-24 12:59:37 +02:00
shaunsingh
caf5738fa9
fix(lsp): create missing directory before creating file (#19835)
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
2022-09-24 12:46:21 +02:00
Christian Clason
24b5449b3d
vim-patch:9.0.0562: HSL playlist files are not recognized (#20307)
Problem:    HSL playlist files are not recognized.
Solution:   Add a pattern to recognize HSL palylist files. (Benoît Ryder,
            closes vim/vim#11204)
35fdd9a67d
2022-09-24 10:16:30 +02:00
Mike
14610332b2
fix(lsp): use correct function name in deprecated message (#20308)
fix: use correct function name in deprecated message
2022-09-23 19:20:56 -06:00
Lewis Russell
679f3072f6
Merge pull request #20103 from lewis6991/refactor/vim_opt 2022-09-22 13:59:04 +01:00
bfredl
02f8ca59a8 fix(tests): indicate in test logs when nvim exit times out
When it happens it wastes 2 seconds which is NOT included in the
normal busted timing info. It is hard to correct this, but we
can at least print a warning when this happens.
2022-09-22 10:38:11 +02:00
Jonas Strittmatter
b4b05f160d
feat(filetype): expand environment variables in filetype patterns (#20145) 2022-09-21 15:58:57 -06:00
ofwinterpassed
ec94014cd1
fix(lsp): out of bounds error in lsp.util.apply_text_edits (#20137)
Co-authored-by: Jonas Strittmatter <40792180+smjonas@users.noreply.github.com>
2022-09-20 22:14:58 +02:00
Christian Clason
ae30e388de
vim-patch:9.0.0510: Chatito files are not recognized (#20260)
Problem:    Chatito files are not recognized.
Solution:   Add a pattern for Chatito files. (closes vim/vim#11174)
7c046ae99b
2022-09-20 14:10:00 +02:00
Lewis Russell
abe2d90693
feat(lua): move compat module from runtime to test (#20257) 2022-09-20 11:15:32 +01:00
Lewis Russell
e762158305
docs(lua): opts in vim.keymap.{set,del} can be optional (#20255) 2022-09-20 10:42:45 +01:00
Mathias Fußenegger
10196f1b46
fix(lsp): support false result in handlers (#20252)
Closes https://github.com/neovim/neovim/issues/20111
2022-09-20 09:28:23 +02:00
Christian Clason
8dc61713d9
vim-patch:9.0.0497: LyRiCs files are not recognized (#20239)
Problem:    LyRiCs files are not recognized.
Solution:   Add a pattern to detect LyRiCs files. (closes vim/vim#11155)
65ee49decf
2022-09-18 14:16:24 +02:00
Christian Clason
e512d3ecf2
vim-patch:9.0.0479: in :def function all closures in loop get the sam… (#20220)
vim-patch:9.0.0479: in :def function all closures in loop get the same variables

Problem:    In a :def function all closures in a loop get the same variables.
Solution:   Use a separate list of variables for LOADOUTER and SAVEOUTER.
1aea184a0d

(note: patch description is wrong)
2022-09-16 17:52:08 +02:00
Christian Clason
9ec4b20be6
fix(treesitter): return full metadata for get_captures_at_position (#20203)
fix(treesitter): get_captures_at_position returns metadata

Return the full `metadata` table for the capture instead of just the
priority.

Further cleanup of related docs.
2022-09-16 09:05:05 +02:00
Gregory Anders
982fef6018
fix(diagnostic): populate data key in DiagnosticChanged autocmd in reset (#20207)
Follow up to #20173.
2022-09-15 11:03:07 -06:00
Christian Clason
ddb762f401
docs(treesitter): clean up and update treesitter.txt (#20142)
* add type annotations to code
* clean up and expand static documentation
* consistent use of tags for static and generated docs
2022-09-14 11:08:31 +02:00
Mathias Fußenegger
a8c9e721d9
feat(fs): extend fs.find to accept predicate (#20193)
Makes it possible to use `vim.fs.find` to find files where only a
substring is known.
This is useful for `vim.lsp.start` to get the `root_dir` for languages
where the project-file is only known by its extension, not by the full
name.
For example in .NET projects there is usually a `<projectname>.csproj`
file in the project root.

Example:

    vim.fs.find(function(x) return vim.endswith(x, '.csproj') end, { upward = true })
2022-09-13 14:16:20 -06:00
Gregory Anders
1970d2ac43
feat(diagnostic): pass diagnostics as data to DiagnosticChanged autocmd (#20173) 2022-09-13 08:33:39 -06:00
Christian Clason
fd70e2bff2
Merge pull request #20141 from vigoux/ts-self-inherits
fix(treesitter): prevent endless loop on self-inheritence

docs(treesitter): suggest using extends to extend queries
2022-09-12 17:35:49 +02:00
Christian Clason
afe01842ef
vim-patch:9.0.0448: SubRip files are not recognized (#20167)
Problem:    SubRip files are not recognized.
Solution:   Add a pattern for SubRip. (closes vim/vim#11113)
5a4eb55122
2022-09-12 15:12:39 +02:00
Christian Clason
f98cff9575
vim-patch:9.0.0443: blueprint files are not recognized (#20155)
Problem:    Blueprint files are not recognized.
Solution:   Add a pattern for blueprint files. (Gabriele Musco, closes vim/vim#11107)
cce82a55b8
2022-09-11 16:07:54 +02:00
Thomas Vigouroux
1939518eba
fix(treesitter): prevent endless loop on self-inheritence
Fixes #20139
2022-09-11 08:16:50 +02:00
Gregory Anders
9b4cab0126
fix(lsp): schedule removal of client object (#20148)
The execution of the LspDetach autocommands in the LSP client's on_exit
function are scheduled on the event loop to avoid making API calls in a
fast context; however, this means that by the time the LspDetach
autocommands finally run the client object has already been deleted.

To address this, we also schedule the deletion of the client on the
event loop so that it is guaranteed to occur after all of the LspDetach
autocommands have fired.
2022-09-10 18:56:29 -06:00
Christian Clason
40f9f479b7
vim-patch:9.0.0434: gitignore files are not recognized (#20143)
Problem:    gitignore files are not recognized.
Solution:   Add patterns for the gitignore filetype. (closes vim/vim#11102)
9ba2786f15
2022-09-10 13:30:54 +02:00
Christian Clason
9b0e1256e2
vim-patch:9.0.0427: Drupal theme files are not recognized (#20138)
Problem:    Drupal theme files are not recognized.
Solution:   Use php filetype for Drupl theme files.  Remove trailing spaces.
            (Rodrigo Aguilera, closes vim/vim#11096)
8995c4cd4e
2022-09-09 18:48:12 +02:00
Christian Clason
ad2d6a624b
vim-patch:9.0.0424: gitattributes files are not recognized (#20134)
Problem:    gitattributes files are not recognized.
Solution:   Add patterns to match gitattributes files. (closes vim/vim#11085)
7d56cfc861
2022-09-09 17:53:15 +02:00
Lewis Russell
038c711539 refactor(vim.opt): de-nest code 2022-09-09 12:38:15 +01:00
Lewis Russell
9272d20ea4 refactor(vim.opt): use local function syntax 2022-09-09 12:38:15 +01:00
Lewis Russell
ad972990ad refactor(vim.opt): optimize append/prepend/remove 2022-09-09 12:38:15 +01:00
Lewis Russell
b364bc2c34 refactor(vim.opt): dry up and tidy 2022-09-09 12:38:10 +01:00
Lewis Russell
925a811990 refactor(vim.opt): remove value_mutator() 2022-09-09 09:54:54 +01:00
Lewis Russell
7533ceec13 refactor(vim.opt): unify vim.bo/wo building 2022-09-09 09:54:53 +01:00
Mathias Fußenegger
19a3b2c26e
docs(lsp): update rpc.start stdio limitations (#20120) 2022-09-08 10:25:16 -07:00
Lewis Russell
164752b380 refactor(vim.opt): remove make_meta_accessor() 2022-09-08 17:24:17 +01:00
Raphael
30ca6d23a9
fix(lsp): when buffer detach remove buffer from client attached buffers (#20081)
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
2022-09-08 17:09:32 +02:00
Lewis Russell
514a1679dc refactor(vim.opt): simplify get_option_metatype 2022-09-08 15:44:00 +01:00
Lewis Russell
b8de5ada80 refactor(vim.opt): replace _setup with lazy table 2022-09-08 15:42:17 +01:00
Lewis Russell
f21e2a51ba refactor(vim.opt): remove enums 2022-09-08 15:32:26 +01:00
Lewis Russell
bc88691dbd refactor(vim.opt): remove del arg 2022-09-08 15:32:26 +01:00
Christian Clason
08602ec1ab
vim-patch:9.0.0417: Jsonnet files are not recognized (#20119)
Problem:    Jsonnet files are not recognized.
Solution:   Add a pattern for Jsonnet files. (Cezary Drożak, closes vim/vim#11073,
            closes vim/vim#11081)
2a4c885d54
2022-09-08 16:06:00 +02:00
Mathias Fußenegger
11167ab6d5
feat(lsp): add range option to lsp.buf.format (#19998) 2022-09-08 11:33:04 +02:00
Christian Clason
8c59d7e6a7
Merge pull request #20093 from neovim/upstream-ts-util
* feat(treesitter): upstream get_{node,captures} utility functions
* refactor(treesitter): get_{nodes,captures}_at_{position,cursor}
2022-09-08 11:23:26 +02:00
bfredl
893b659e88
fix(treesitter): use the right loading order for base queries (#20117)
Use the first, not last, query for a language on runtimepath. Typically,
this implies that a user query will override a site plugin query, which 
will override a bundled runtime query.
2022-09-08 11:17:29 +02:00
Thomas Vigouroux
0405594399
feat(treesitter)!: do not merge queries by default (#20105)
Problem: Treesitter queries for a given language in runtime were merged together, 
leading to errors if they targeted different parser versions (e.g., bundled viml queries 
and those shipped by nvim-treesitter).
Solution:  Runtime queries now work as follows:
* The last query in the rtp without `; extends` in the header will be used as the base query
* All queries (without a specific order) with `; extends` are concatenated with the base query

BREAKING CHANGE: queries need to be updated if they are meant to extend other queries
2022-09-08 09:47:36 +02:00
zeertzjq
99e6e0f221 docs(treesitter): fix doxygen 2022-09-08 12:54:41 +08:00
ii14
4dc4cf3467
fix(options): mark winhighlight as list style (#19477)
Also add missing fcs, lcs and winhighlight to list of key-value options for `vim.opt`.

Co-authored-by: ii14 <ii14@users.noreply.github.com>
2022-09-07 17:59:27 +02:00
Christian Clason
9d1d3a6707
vim-patch:9.0.0402: javascript module files are not recoginzed (#20108)
Problem:    Javascript module files are not recoginzed.
Solution:   Recognize "*.jsm" files as Javascript. (Brett Holman,
            closes vim/vim#11069)
bb6c4073e7
2022-09-07 15:55:39 +02:00
Thomas Vigouroux
fd1595514b
Use weak tables in tree-sitter code (#17117)
feat(treesitter): use weak tables when possible

Also add the defaulttable function to create a table whose values are created when a key is missing.
2022-09-07 08:39:56 +02:00
Sean Dewar
f32fd19f1e
fix(diagnostic): remove buf from cache on BufWipeout (#20099)
Doing so on `BufDelete` has issues:
  - `BufDelete` is also fired for listed buffers that are made unlisted.
  - `BufDelete` is not fired for unlisted buffers that are deleted.

This means that diagnostics will be lost for a buffer that becomes unlisted.

It also means that if an entry exists for an unlisted buffer, deleting that
buffer later will not remove its entry from the cache (and you may see "Invalid
buffer id" errors when using diagnostic functions if it was wiped).

Instead, remove a buffer from the cache if it is wiped out.
This means simply `:bd`ing a buffer will not clear its diagnostics now.
2022-09-06 20:55:03 -06:00
Lewis Russell
707edfc9e6
fix(ts): do not clobber spelloptions (#20095) 2022-09-06 19:22:05 +01:00
Christian Clason
d01cadd82f fix(treesitter): don't support legacy syntax in start() 2022-09-06 17:33:44 +02:00
Thomas Vigouroux
75adfefc85 feat(extmarks,ts,spell): full support for spelling
- Added 'spell' option to extmarks:

  Extmarks with this set will have the region spellchecked.

- Added 'noplainbuffer' option to 'spelloptions':

  This is used to tell Neovim not to spellcheck the buffer. The old
  behaviour was to spell check the whole buffer unless :syntax was set.

- Added spelling support to the treesitter highlighter:

  @spell captures in highlights.scm are used to define regions which
  should be spell checked.

- Added support for navigating spell errors for extmarks:

  Works for both ephemeral and static extmarks

- Added '_on_spell_nav' callback for decoration providers:

  Since ephemeral callbacks are only drawn for the visible screen,
  providers must implement this callback to instruct Neovim which
  regions in the buffer need can be spell checked.

  The callback takes a start position and an end position.

  Note: this callback is subject to change hence the _ prefix.

- Added spell captures for built-in support languages

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
2022-09-06 10:14:11 +01:00
bfredl
05893aea39
Merge pull request #20039 from zeertzjq/cmod-tab
fix(api)!: correctly deal with number before :tab
2022-09-06 10:32:23 +02:00
Christian Clason
95fd1ad83e refactor(treesitter): get_{nodes,captures}_at_{position,cursor} 2022-09-06 10:15:23 +02:00
Quentin Rasmont
ffe98531b9 feat(treesitter): upstream get_node_at_cursor()
Util from the nvim-treesitter project.
2022-09-06 10:14:05 +02:00
Christian Clason
0822896efc feat(treesitter): add vim.treesitter.start(), enable for Lua
* Add vim.treesitter.start() for starting treesitter highlighting via
  ftplugin or autocommand (can be extended later for fold, indent,
  matchpairs, ...)
* Add vim.treesitter.stop() for manually stopping treesitter
  highlighting
* Enable treesitter highlighting for Lua if
  `vim.g.ts_highlight_lua = true` is set in `init.lua`
2022-09-06 08:08:29 +02:00
zeertzjq
1ef7720567 fix(api)!: correctly deal with number before :tab
Now nvim_parse_cmd and nvim_create_user_command use a "tab" value which
is the same as the number passed before :tab modifier instead of the
number plus 1, and "tab" value is -1 if :tab modifier is not used.
2022-09-02 22:28:57 +08:00
Lewis Russell
2afcdbd63a
feat(Man): port to Lua (#19912)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-02 15:20:29 +01:00
Jonas Strittmatter
ce80b8f50d
vim-patch:9.0.0349: filetype of *.sil files not well detected (#20050)
Problem:    Filetype of *.sil files not well detected.
Solution:   Inspect the file contents to guess the filetype.
be807d5824
2022-09-02 08:16:17 +02:00
Christian Clason
6b7eed1884
Vim 9.0.{0314,0319}: some filetypes are not recognized (#20005)
* vim-patch:9.0.0314: VDM files are not recognized

Problem:    VDM files are not recognized.
Solution:   Add patterns for VDM files. (Alessandro Pezzoni, closes vim/vim#11004)
bf26941f40

* vim-patch:9.0.0319: Godot shader files are not recognized

Problem:    Godot shader files are not recognized.
Solution:   Add patterns for "gdshader". (Maxim Kim, closes vim/vim#11006)
d5c8f11905
2022-08-30 21:16:03 +02:00
Mathias Fußenegger
981ae83fad
fix(docs): update lsp.rpc.start docs to match return value changes (#20003)
Follow up to https://github.com/neovim/neovim/pull/19916
2022-08-30 13:14:27 +02:00
Raphael
efacb6e974
fix(lsp): clean the diagnostic cache when buffer delete (#19449)
Co-authored-by: Gregory Anders <greg@gpanders.com>
2022-08-29 19:09:14 +02:00
Mathias Fussenegger
60ec6e34d5 feat(lsp): add tcp support 2022-08-28 14:07:53 +02:00
Mathias Fussenegger
46bb34e26b refactor(lsp): extract rpc client from rpc.start
Makes the previously inner functions re-usable for a TCP client
2022-08-28 14:07:53 +02:00
Mathias Fussenegger
7d3e4aee6a refactor(lsp): encapsulate rpc uv handle
To prepare for different transports like TCP where the handle won't have
a kill method.
2022-08-28 14:07:53 +02:00
Mathias Fussenegger
f9641d1ac6 refactor(lsp): factor out read_loop function 2022-08-28 14:07:53 +02:00
bfredl
b04ef7f6b9 fix(treesitter): make it get_captures_at_position 2022-08-26 13:57:31 +02:00
Quentin Rasmont
064ecb9ec5 feat(treesitter): upstream get_hl_groups_at_position()
Util from the nvim-treesitter project.
2022-08-26 13:57:31 +02:00
bfredl
030b422d1e feat(treesitter)!: use @foo.bar style highlight groups
This removes the support for defining links via
vim.treesitter.highlighter.hl_map (never documented, but plugins did
anyway), or the uppercase-only `@FooGroup.Bar` to `FooGroup` rule.

The fallback is now strictly `@foo.bar.lang` to `@foo.bar` to `@foo`,
and casing is irrelevant (as it already was outside of treesitter)

For compatibility, define default links to builting syntax groups
as defined by pre-existing color schemes
2022-08-26 13:57:31 +02:00
Quentin Rasmont
244a115e49 feat(treesitter): clarify similar 'get_node_range' functions
The private 'get_node_range' function from the languagetree module has
been renamed and remains private as it serve a purpose that is only
relevant inside the languagetree module.

The 'get_node_range' upstreamed from nvim-treesitter in the treesitter
module has been made public as it is in itself a utlity function.
2022-08-25 18:01:15 +02:00
Quentin Rasmont
133ff6e11e feat(treesitter): upstream node_contains()
Util from the nvim-treesitter project.
2022-08-25 18:01:15 +02:00
Quentin Rasmont
6b2d42eb03 feat(treesitter): add ability to retreive a tree/node given a range 2022-08-25 18:01:14 +02:00
Quentin Rasmont
733b2e12b8 feat(treesitter): add opts.concat to query.get_text_node
As part of the upstream of utility functions from nvim-treesitter, this
option when set to false allows to return a table (downstream behavior).
Effectively making the switch from the downstream to the upstream
function much easier.
2022-08-25 18:01:14 +02:00
Quentin Rasmont
3aba4ba378 feat(treesitter): upstream is_parent()
Util from the nvim-treesitter project.
Renamed is_parent to is_ancestor for clarity.
2022-08-25 18:01:14 +02:00
Thomas Vigouroux
9be4bfc5f4
Merge pull request #19496 from vigoux/ts_internal_lang
feat(treesitter): allow customizing language symbol name
2022-08-24 15:36:58 +02:00
Simon Wachter
e892b7b383
fix(inspect): escape identifiers that are lua keywords (#19898)
A lua keyword is not a valid table identifier
2022-08-23 13:02:55 +02:00
Thomas Vigouroux
3c1d70f20b
feat(treesitter): allow customizing language symbol name 2022-08-22 15:34:10 +02:00
Christian Clason
b2f979b30b
fix(filetype): only check first 100 and last line of buffer (#19819)
fix(filetype): only pass first 100 and last lines to contents check

sufficient for current content checks and avoids performance issues for
buffers with a large number of lines

fixes #19817
2022-08-19 19:30:35 +02:00
Mathias Fußenegger
341ef46d00
docs(lsp): remove lsp.buf_request from docs (#19738)
This starts a soft phase-out of `buf_request`.

`buf_request` is quite error prone:

- Positional `params` depend on the client because of the
  `offset_encoding`. Currently if there is one client using UTF-8 offset
  encoding and another using UTF-16, the positions in the request are
  wrong for one of the clients. To solve this the params would need to
  be created per client instead of once for all of them.

- `handler` is called *per* client but many users of it assume it is
  only called once.

  This can lead to a "select n + 1"
  kind of problem, where the handler makes another call to `buf_request`,
  multiplying the amount of requests.
  (There are in fact still some places where this happens in core)

  Or it leads to erratic behavior if called multiple times (E.g. the
  quicklist list flickering & being overwritten)
  (See hover or references implementation)

  `buf_request_all` returns an aggregate of the responses which is more
  sensible as it avoids this problem.

  For off-spec extensions it also has the problem that it sends requests to
  clients which cannot handle a given request.

Given that `buf_request` is in use by a lot of plugins this starts a
soft-phase out. Planned Steps:

- Remove from docs
- Provide an alternative, either `buf_request_all`, maybe with
  extensions (params being a function), or an entirely new method.
- Mark as deprecated in 0.9
- Remove in 0.10

To note:

- `buf_request_all` currently isn't ideal either because it suffers from
the `params` problem as well.

- This implies that the `vim.lsp.with` pattern will die, because the
  global handlers as they are don't fit a multi-client model, as most of
  the time an aggregate is needed.
2022-08-18 10:57:17 +02:00
Jonas Strittmatter
7a076306e4
docs(lsp): rename on-list-handler to lsp-on-list-handler (#19813)
This makes it easier to find documentation about the on-list-handler
when starting the search term with "lsp".
2022-08-17 12:39:38 +02:00
Antoine Cotten
5854103dad
docs(lua): clarify vim.keymap.set() opts (#19761) 2022-08-14 06:38:31 +08:00
Christian Clason
33b49d5f55
vim-patch:9.0.0197: astro files are not detected (#19755)
Problem:    Astro files are not detected.
Solution:   Add a pattern to match Astro files. (Emilia Zapata, closes vim/vim#10904)
6a76e84f55
2022-08-13 15:11:03 +02:00
Christian Clason
a850b15e19
vim-patch:9.0.0195: metafun files are not recogized (#19746)
Problem:    Metafun files are not recogized.
Solution:   Add filetype detection patterns.
9032b9ceb6
2022-08-13 10:26:12 +02:00
Mathias Fußenegger
02289ab898
fix(lsp): fix nil value error in get_group (#19735)
`server_capabilities` can be nil until the server is initialized.
Reproduced with:

    vim.lsp.stop_client(vim.lsp.start_client {
      cmd = { vim.v.progpath, '-es', '-u', 'NONE', '--headless' };
    })
2022-08-12 10:10:03 +02:00
Mathias Fußenegger
33b77eb728
fix(lsp): handle nil client in onexit callback (#19722)
Follow up to https://github.com/neovim/neovim/pull/19658
2022-08-11 19:21:57 +02:00
Mathias Fußenegger
996fc2256b
fix(lsp): avoid pipe leaks if lsp cmd isn't executable (#19717)
The `onexit` handler isn't called if `uv.spawn` doesn't return a handle.
2022-08-11 17:04:55 +02:00
Mathias Fußenegger
8b67f37798
fix(lsp): fix some type annotations in lsp.rpc (#19714) 2022-08-11 15:17:05 +02:00
Jonas Strittmatter
ff1266aaaa
vim-patch:9.0.0182: quarto files are not recognized (#19702)
Problem:    Quarto files are not recognized.
Solution:   Recognize quarto files by the extension. (Jonas Strittmatter,
            closes vim/vim#10880)
3a9687fb27
2022-08-10 13:44:57 +02:00
Mathias Fußenegger
bebfbfab3b
fix(lsp): handle multiple clients with incremental sync (#19658)
The change tracking used a single lines/lines_tmp table to track
changes to a buffer.

If multiple clients using incremental sync are connected to a buffer,
they both made changes to the same lines table. That resulted in an
inconsistent state.

This commit changes the didChange handling to group clients by
synchronization scheme and offset encoding.
This avoids computing the diff multiple times for clients using the
same scheme and resolves the lines/lines_tmp conflicts.

Fixes https://github.com/neovim/neovim/issues/19325
2022-08-09 22:20:40 +02:00
Christian Clason
a5e846b996
vim-patch:partial: 48c3f4e0bff7 (#19684)
vim-patch:partial:48c3f4e0bff7

Update runtime files
48c3f4e0bf

partially skip `options.txt` (needs 9.0.0138)
2022-08-09 10:43:28 +02:00
dundargoc
e6680ea7c3
docs(lua): add Lua 5.1 reference manual (#19663)
based on http://www.vim.org/scripts/script.php?script_id=1291
reformatted to match Nvim documentation style; removed irrelevant sections

Co-authored-by: dundargoc <gocundar@gmail.com>
Co-authored-by: Christian Clason <c.clason@uni-graz.at>
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2022-08-08 18:58:32 +02:00
Mathias Fußenegger
68c674af0f
feat(lsp): set formatexpr by default (#19677)
Follow up to https://github.com/neovim/neovim/pull/19003
2022-08-08 18:30:17 +02:00
Mathias Fußenegger
a46e6afb8b
fix(lsp): set end_col in formatexpr (#19676)
The last line was excluded from formatting via formatexpr because the
character in the params was set to 0 instead of the end of line.
2022-08-08 13:02:15 +02:00
Mathias Fußenegger
2d5fce2cdb
feat(lsp): disable exit_timeout by default (#19672)
The lsp client used to wait up to 500ms for a language server to
shutdown before sending a TERM signal.

The intention behind the 500ms grace period was to ensure the language
server exits to prevent stale processes, but it has the side-effect that
it can interrupt language-servers which are too slow to shutdown within
500ms. Language servers tend to write out index files or project files
on shutdown, and being interrupted during this process can cause
corruption of those files.

This changes the default to not wait at all, at the risk of leaving
stale processes around if the language server isn't well behaved.

An alternative would be to wait indefinitely, but that can cause neovim
to take several seconds to exit.
2022-08-08 12:34:37 +02:00
Cai.MY
85ad0e6b43
fix(lsp): avoid ^M character in hover window on Windows (#19640) 2022-08-05 15:23:01 +02:00
rhcher
7c997dbc5d
fix(lsp): prevent unexpected position jumps (#19370) 2022-08-03 21:44:33 +02:00
dundargoc
b8dcbcc732
docs: fix typos (#19588)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: notomo <notomo.motono@gmail.com>
2022-08-03 09:47:16 +08:00
zeertzjq
0a049c322f
test: improve mapping tests and docs (#19619) 2022-08-02 11:13:22 +08: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
db6e93c48d
feat(api): add replace_keycodes to nvim_set_keymap (#19598) 2022-08-01 21:35:08 +08:00
LaurenceWarne
9f5d5aa3da
Use Strings instead of Tables in vim.filetype.matchregex Doc (#19604)
docs: use strings instead of tables in vim.filetype.matchregex doc
2022-08-01 06:45:43 -06:00
dundargoc
abc087f4c6
docs: fix typos (#19024)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Valery Viktorovsky <viktorovsky@gmail.com>
2022-07-31 16:46:38 +08:00
Mathias Fußenegger
b25abbf4b8
docs(lsp): use direct link to formattingOptions in format docs (#19558)
Also changes `@see` to `See` to avoid the break to a dedicated "See
also" block in the generated vimdoc
2022-07-28 19:41:30 +02:00
Mathias Fußenegger
98915f88b2
feat(lsp): add range option to code_action; deprecate range_code_action (#19551)
`code_action` gained extra functions (`filter` and `apply`) which
`range_code_action` didn't have.

To close this gap, this adds a `range` option to `code_action` and
deprecates `range_code_action`.

The option defaults to the current selection if in visual mode.
This allows users to setup a mapping like `vim.keymap.set({'v', 'n'},
'<a-CR>', vim.lsp.buf.code_action)`

`range_code_action` used to use the `<` and `>` markers to get the
_last_ selection which required using a `<Esc><Cmd>lua
vim.lsp.buf.range_code_action()<CR>` (note the `<ESC>`) mapping.
2022-07-28 19:19:07 +02:00
Mathias Fußenegger
f5d558c8ea
feat(lsp): provide feedback if server can't compute rename result (#19546)
Without some form of feedback a user cannot easily tell if the server is
still computing the result (which can take a while in large projects),
or whether the server couldn't compute the rename result.
2022-07-27 18:56:27 +02:00
Mathias Fußenegger
888f12858a
fix(lsp): set workspace.configuration capability (#19548)
Neovim implements `workspace/configuration`
It should set the capability accordingly.

From https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#clientCapabilities:

    /**
     * The client supports `workspace/configuration` requests.
     *
     * @since 3.6.0
     */
    configuration?: boolean;
2022-07-27 18:55:44 +02:00
Christian Clason
4c3104819b
vim-patch:9.0.0093: sway config files are recognized as i3config (#19545)
Problem:    Sway config files are recognized as i3config.
Solution:   Recognize swayconfig separately. (James Eapen, closes vim/vim#10672)
7abd1c6d8e
2022-07-27 18:11:59 +02:00
Gregory Anders
9b447c7ce5
vim-patch:9.0.0088: pattern for detecting bitbake files is not sufficient (#19547)
Problem:    Pattern for detecting bitbake files is not sufficient.
Solution:   Adjust the pattern. (Gregory Anders, closes vim/vim#10743)
30e212dac1
2022-07-27 10:06:09 -06:00
Christian Clason
7e939ddb87
vim-patch:9.0.0084: using "terraform" filetype for .tfvars file is bad (#19526)
Problem:    Using "terraform" filetype for .tfvars file is bad.
Solution:   use "terraform-vars", so that different completion and other
            mechanisms can be used. (Radek Simko, closes vim/vim#10755)
15b87b6610
2022-07-26 23:08:48 +02:00
Christian Clason
2a9c9371bc
vim-patch:9.0.0073: too many files recognized as bsdl (#19504)
Problem:    Too many files recognized as bsdl.
Solution:   Use pattern "*.bsd" instead of "*bsd". (Martin Tournoij,
            closes vim/vim#10783)
1b67f07f76
2022-07-26 14:16:46 +02:00
Dalius Dobravolskas
3ded2ab55a
feat(lsp): allow passing custom list handler to LSP functions that return lists (#19213)
Currently LSP allows only using loclist or quickfix list window. I
normally prefer to review all quickfix items without opening quickfix
window. This fix allows passing `on_list` option which allows full
control what to do with list.

Here is example how to use it with quick fix list:

```lua
local function on_list(options)
  vim.fn.setqflist({}, ' ', options)
  vim.api.nvim_command('cfirst')
end

local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', '<leader>ad', function() vim.lsp.buf.declaration{on_list=on_list} end, bufopts)
vim.keymap.set('n', '<leader>d', function() vim.lsp.buf.definition{on_list=on_list} end, bufopts)
vim.keymap.set('n', '<leader>ai', function() vim.lsp.buf.implementation{on_list=on_list} end, bufopts)
vim.keymap.set('n', '<leader>at', function() vim.lsp.buf.type_definition{on_list=on_list} end, bufopts)
vim.keymap.set('n', '<leader>af', function() vim.lsp.buf.references(nil, {on_list=on_list}) end, bufopts)
```

If you prefer loclist do something like this:

```lua
local function on_list(options)
  vim.fn.setloclist(0, {}, ' ', options)
  vim.api.nvim_command('lopen')
end
```

close #19182

Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2022-07-25 23:02:51 +02:00
Lewis Russell
559ef3e903
feat(lua): allow vim.cmd to be indexed (#19238) 2022-07-20 12:29:24 +01:00
Javier Lopez
61302fb391
docs: fix vim.filetype.add by avoiding quotes (#19433)
* Problem

Quotes are special in doxygen, and should be escaped. *Sometimes* they
cause doc generation issues. Like in #17785

* Solution

Replace double quotes with single quotes
2022-07-19 09:12:10 -06:00
Raphael
776913e32e
fix: add group in autocmd api #19412
regression from PR #19283: custom close autocommands for the preview window were
not cleaned up after the window was closed.
2022-07-17 16:11:41 -07:00
ii14
9169fb8f07
fix(lua): double entries in :lua completion #19410
`:lua vim.ls<tab>` would list `lsp` twice.
2022-07-17 15:40:18 -07: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
Raphael
ff35d7a4b9
fix(lsp): move augroup define to if statement (#19406) 2022-07-17 19:11:05 +02:00
Gregory Anders
5ccdf6a88d
vim-patch:9.0.0055 (#19392)
vim-patch:9.0.0055: bitbake files are not detected

Problem:    Bitbake files are not detected.
Solution:   Add bitbake filetype detection by file name and contents. (Gregory
            Anders, closes vim/vim#10697)
fa49eb4827
2022-07-17 14:33:51 +02:00
matveyt
eb9b93b5e0
feat(defaults): mouse=nvi #19290
Problem:
Since right-click can now show a popup menu, we can provide messaging to
guide users who expect 'mouse' to be disabled by default. So 'mouse' can
now be enabled by default.

Solution:
Do it.
Closes #15521
2022-07-17 04:14:04 -07:00
ii14
f59c96903a refactor: use local api = vim.api 2022-07-15 18:26:47 +02:00
ii14
8bccefcb87 refactor: use npcall from vim.F 2022-07-15 17:55:00 +02:00
ii14
8a5c7e91f2 refactor(lsp): make the use of local aliases more consistent 2022-07-15 17:39:26 +02:00
Stephan Seitz
ddaef0618d
fix(treesitter): don't error when node argument of predicate is nil (#19355)
When the node mentioned in a predicate is not required for the query
then predicates putting restrictions on that node shouldn't run.

Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/2600
2022-07-14 12:18:03 +02:00
Nicolas Hillegeer
0f1b17788e
fix(lsp): account for initializing servers in vim.lsp.start (#19329)
Fixes #19326
2022-07-12 09:44:11 +02:00
Nicolas Hillegeer
034d28c705
fix(lsp): don't attach a client in lsp.start() if there is none (#19328)
vim.lsp.start_client() may fail (for example if the `cmd` is not
executable). It produces a nice error notification in this case. Passing
the `nil` value returned from an erroneous `vim.lsp.start_client()` call
into `vim.lsp.buf_attach_client()` causes a meaty param validate
exception message. Avoid this.
2022-07-11 19:37:01 -06:00
Rishikesh Vaishnav
ac10c0f418
fix(lsp): abort pending changes after flush when debouncing (#19314)
Issuing a server request triggers `changetracking.flush` so as to
make sure we're not operating on a stale state. This immediately
triggers notification of any pending changes (as a result of debouncing)
to the server. However, this happens in addition to the notification
that is waiting on the debounce delay. Because we `nil`
`buf_state.pending_change` when it is called, the fix is to
also check that this is non-`nil` when it is called and exit if it is,
as this being `nil` would mean that it originates from a pending change
that has already been flushed out.
2022-07-11 12:48:02 +02:00
Mathias Fußenegger
95c65a6b22
feat(lsp): defaults: tagfunc, omnifunc (#19003)
set `tagfunc` to `vim.lsp.tagfunc` and `omnifunc` to `vim.lsp.omnifunc` if empty when attaching a server
2022-07-10 17:26:43 +02:00
Christian Clason
2966cfe21f
fix(lsp): pcall nvim_del_augroup_by_name (#19302)
fixup for #19283
2022-07-10 11:19:26 +02:00
Christian Clason
d606c39a9c
vim-patch:9.0.0049: csv and tsv files are not recognized (#19300)
Problem:    Csv and tsv files are not recognized.
Solution:   Add patterns fo csv and tsv files. (Leandro Lourenci,
            closes vim/vim#10680)
99af91e582
2022-07-10 01:14:07 +02:00
Gregory Anders
782f726136
refactor: remove functions marked for deprecation in 0.8 (#19299) 2022-07-09 18:42:49 +02:00
Raphael
6b1a8f23d7
refactor(lua): replace vim.cmd use with API calls (#19283)
Signed-off-by: Raphael <glephunter@gmail.com>
2022-07-09 18:40:32 +02:00
Christian Clason
72877bb17d
feat(runtime)!: enable filetype.lua by default (#19216)
* revert to filetype.vim by setting `g:do_legacy_filetype`
* skip either filetype.lua or filetype.vim via `g:did_load_filetypes`

(Running both is no longer required and therefore no longer supported.)
2022-07-07 18:53:47 +02:00
Christian Clason
aa4f9c5341
refactor(lua): reformat with stylua 0.14.0 (#19264)
* reformat Lua runtime to make lint CI pass
* reduce max line length to 100
2022-07-07 18:27:18 +02:00
smjonas
f9683f2823 fix(filetype): remove call to vim.fn.resolve and pass filename to match function
For example on MacOS, /etc/hostname.file is symlinked to
/private/etc/hostname.file. We only care about the original file path though.
2022-07-06 16:25:51 +02:00
smjonas
f3c78a4465 fix(filetype): fix filetype patterns 2022-07-06 16:25:23 +02:00
smjonas
78300a1587 vim-patch:9.0.0042: missing change for filetype detection
Problem:    Missing change for filetype detection.
Solution:   Include change to detect guile from shebang line.
3244780379
2022-07-06 01:33:45 +02:00
smjonas
8b7399782e vim-patch:9.0.0041: a couple of filetype patterns do not have "*" before "/etc"
Problem:    A couple of filetype patterns do not have "*" before "/etc".
Solution:   Add the star. (Jonas Strittmatter, closes vim/vim#10662)
704988f0c3
2022-07-06 01:25:21 +02:00
Jonas Strittmatter
acb7a90281
refactor(runtime): port scripts.vim to lua (#18710) 2022-07-03 15:31:56 +02:00
Christian Clason
60604d6a99
vim-patch:9.0.0012: signature files not detected properly (#19172)
Problem:    Signature files not detected properly.
Solution:   Add a function to better detect signature files. (Doug Kearns)
cdbfc6dbab
2022-07-01 07:08:44 +02:00
Gregory Anders
3b1423bfa7
fix(filetype): update call sites of vim.filetype.match (#19171)
These were not updated in #18895.
2022-06-30 09:54:44 -06: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
Christian Clason
1eb9624666
vim-patch:9.0.0006: not all Visual Basic files are recognized (#19153)
Problem:    Not all Visual Basic files are recognized.
Solution:   Change detection of *.cls files. (Doug Kearns)
8b5901e2f9
2022-06-29 18:43:56 +02:00
Christian Clason
ba583f8206
vim-patch:9.0.0005: hare files are not recognized (#19151)
Problem:    Hare files are not recognized.
Solution:   Add a filetype pattern. (Hugo Osvaldo Barrera, closes vim/vim#10630)
040674129f
2022-06-29 16:21:04 +02:00
0x74696d6d79
ee6b21e843
fix(vim.ui.input): accept nil or empty "opts" #19109
Fix #18143
2022-06-28 02:53:15 -07:00
Christian Clason
f2fa11708c
fix(filetype): check for non-nil match in detect.rules (#19129) 2022-06-27 20:43:37 +02:00
Gregory Anders
6f3508f8ed
refactor(filetype): allow vim.filetype.match to accept buf and filename (#19114)
This is necessary in cases where filetype detection acts recursively.
For example, when matching files that end with .bak, the "root" of
the filename is matched again against the same buffer (e.g. a buffer
named "foo.c.bak" will be matched again with the filename "foo.c", using
the same underlying buffer).
2022-06-27 10:03:43 +02:00
Gregory Anders
f3ce06cfa1
refactor(filetype)!: allow vim.filetype.match to use different strategies (#18895)
This enables vim.filetype.match to match based on a buffer (most
accurate) or simply a filename or file contents, which are less accurate
but may still be useful for some scenarios.

When matching based on a buffer, the buffer's name and contents are both
used to do full filetype matching. When using a filename, if the file
exists the file is loaded into a buffer and full filetype detection is
performed. If the file does not exist then filetype matching is only
performed against the filename itself. Content-based matching does the
equivalent of scripts.vim, and matches solely based on file contents
without any information from the name of the file itself (e.g. for
shebangs).

BREAKING CHANGE: use `vim.filetype.match({buf = bufnr})` instead 
of `vim.filetype.match(name, bufnr)`
2022-06-26 18:41:20 +02:00
Hazel Weakly
35e89bf903
fix(filetype.lua): always return a string in getlines function (#19080)
This re-introduces the fix that the filetype.lua refactor inadvertently reverted.
The fix ensures that in the case when end_lnum is omitted, a string is always returned.
2022-06-24 19:53:44 +02:00
Jonas Strittmatter
e3b51d5842
refactor(runtime): refactor filetype.lua (#18813)
Move some filetype detection functions to detect.lua,
sort patterns by detected filetype.
2022-06-21 11:29:52 -06:00
Gregory Anders
87a68b6a3a refactor: use nvim_{get,set}_option_value for vim.{b,w}o
`nvim_get_option_value` and `nvim_set_option_value` better handle
unsetting local options. For instance, this is currently not possible:

    vim.bo.tagfunc = nil

This does not work because 'tagfunc' is marked as "local to buffer" and
does not have a fallback global option. However, using :setlocal *does*
work as expected

    :setlocal tagfunc=

`nvim_set_option_value` behaves more like :set and :setlocal (by
design), so using these as the underlying API functions beneath vim.bo
and vim.wo makes those two tables act more like :setlocal. Note that
vim.o *already* uses `nvim_set_option_value` under the hood, so that
vim.o behaves like :set.
2022-06-20 09:16:21 -06:00
kevinhwang91
8780076a78 fix(treesitter): new iter if folded 2022-06-16 17:38:10 +02:00
notomo
0e8186bdd8
fix(lua): highlight.on_yank can close timer in twice #18976
Steps to reproduce:

1. setting `vim.highlight.on_yank`
   ```
   vim.api.nvim_create_autocmd({ "TextYankPost" }, {
     pattern = { "*" },
     callback = function()
       vim.highlight.on_yank({ timeout = 200 })
     end,
   })
   ```
2. repeat typing `yeye` ...
3. causes the following error.
   ```
   Error executing vim.schedule lua callback: vim/_editor.lua:0: handle 0x01e96970 is already closing
   stack traceback:
           [C]: in function 'close'
           vim/_editor.lua: in function ''
           vim/_editor.lua: in function <vim/_editor.lua:0>
   ```

📝 Test result before fix:

    [----------] Global test environment setup.
    [----------] Running tests from test/functional/lua/highlight_spec.lua
    [ RUN      ] vim.highlight.on_yank does not show errors even if buffer is wiped before timeout: 15.07 ms OK
    [ RUN      ] vim.highlight.on_yank does not show errors even if executed between timeout and clearing highlight: 15.07 ms ERR
    test/helpers.lua:73: Expected objects to be the same.
    Passed in:
    (string) 'Error executing vim.schedule lua callback: vim/_editor.lua:0: handle 0x02025260 is already closing
    stack traceback:
            [C]: in function 'close'
            vim/_editor.lua: in function ''
            vim/_editor.lua: in function <vim/_editor.lua:0>'
    Expected:
    (string) ''
2022-06-15 19:39:55 -07:00
dundargoc
6de7f32d52
docs: fix typos (#18866)
docs: fix typos and similarly insignificant changes

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: smjonas <jonas.strittmatter@gmx.de>
Co-authored-by: kanreki <32443233+kanreki@users.noreply.github.com>
2022-06-15 08:49:54 +08:00
rhcher
7f8f8d6cb7
feat(lsp): sort codelens if multiple item per line (#18951) 2022-06-13 19:31:48 +02:00
Gregory Anders
58323b1fe2
feat(filetype): remove side effects from vim.filetype.match (#18894)
Many filetypes from filetype.vim set buffer-local variables, meaning
vim.filetype.match cannot be used without side effects. Instead of
setting these buffer-local variables in the filetype detection functions
themselves, have vim.filetype.match return an optional function value
that, when called, sets these variables. This allows vim.filetype.match
to work without side effects.
2022-06-09 13:12:36 -06:00
mohsen
94181ad7dc
fix(diagnostic): check for negative column value (#18868) 2022-06-08 12:55:39 -06:00
Jonas Strittmatter
41a49dd9c8
refactor(runtime): port remaining patterns from filetype.vim to filetype.lua (#18814) 2022-06-06 09:25:33 -06: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
bfredl
545dc82c1b perf(tests): don't invoke nvim_get_all_options_info until needed
This call alone is responible of 40 000 000 out of 80 000 000
individual alloc/free calls in the test suite.
2022-06-05 00:11:57 +02:00
zeertzjq
9961a9702e
fix(lsp): set buflisted before switching to buffer (#18854) 2022-06-04 10:23:43 +02:00
Christian Clason
e6fa4cca24
vim-patch:8.2.5054: no good filetype for conf files similar to dosini (#18851)
Problem:    No good filetype for conf files similar to dosini.
Solution:   Add the confini filetype. (closes vim/vim#10510)
635f48010d
2022-06-04 09:49:01 +02:00
dundargoc
ff20d40321
docs: fix typos (#18269)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Dan Sully <dan+github@sully.org>
Co-authored-by: saher <msaher.shair@gmail.com>
Co-authored-by: Stephan Seitz <stephan.seitz@fau.de>
Co-authored-by: Benedikt Müller <d12bb@posteo.de>
Co-authored-by: Andrey Mishchenko <mishchea@gmail.com>
Co-authored-by: Famiu Haque <famiuhaque@protonmail.com>
Co-authored-by: Oliver Marriott <hello@omarriott.com>
2022-06-04 11:56:36 +08:00
Gregory Anders
86cc33a464
fix(filetype): fix typo in starsetf function (#18856) 2022-06-03 21:52:59 -06: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
Mathias Fußenegger
69774e3179
feat(lsp): add a start function (#18631)
A alternative/subset of https://github.com/neovim/neovim/pull/18506  that should be forward compatible with a potential project system.

Configuration of LSP clients (without lspconfig) now looks like this:

    vim.lsp.start({
       name = 'my-server-name',
       cmd = {'name-of-language-server-executable'},
       root_dir = vim.fs.dirname(vim.fs.find({'setup.py', 'pyproject.toml'}, { upward = true })[1]),
    })
2022-06-03 14:59:19 +02:00
Christian Clason
26966688aa
fix(treesitter): correct region for string parser (#18794)
fixes injections for string parsers after eab4d03a32
2022-06-02 17:35:16 +02:00
Wsevolod
d5651a4183
fix(lua): stop pending highlight.on_yank timer, if any (#18824)
When yanking another range while previous yank is still highlighted, the
pending timer could clear the highlight almost immediately (especially
when using larger `timeout`, i.e. 2000)
2022-06-02 09:49:57 +02:00
Fredrik Ekre
209824ce2c
fix(lsp): adjust offset encoding in lsp.buf.rename() (#18829)
Fix a bug in lsp.buf.rename() where the range returned by the server in
textDocument/prepareRename was interpreted as a byte range directly,
instead of taking the negotiated offset encoding into account. This
caused the placeholder value in vim.ui.input to be incorrect in some
cases, for example when non-ascii characters are used earlier on the
same line.
2022-06-01 18:56:18 +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
Gregory Anders
046b4ed461 feat(fs): add vim.fs.normalize() 2022-05-31 13:30:10 -06:00
Gregory Anders
f271d70661 feat(fs): add vim.fs.find()
This is a pure Lua implementation of the Vim findfile() and finddir()
functions without the special syntax.
2022-05-31 13:04:41 -06:00
Gregory Anders
2a62bec37c feat(fs): add vim.fs.dir()
This function is modeled after the path.dir() function from Penlight and
the luafilesystem module.
2022-05-31 13:04:41 -06:00
Gregory Anders
b740709431 feat(fs): add vim.fs.basename() 2022-05-31 13:04:41 -06:00
Gregory Anders
c5526a27c3 feat(fs): add vim.fs.dirname() 2022-05-31 13:04:41 -06:00
Gregory Anders
67cbaf58c4 feat(fs): add vim.fs.parents()
vim.fs.parents() is a Lua iterator that returns the next parent
directory of the given file or directory on each iteration.
2022-05-31 13:04:40 -06:00
Javier Lopez
e6652821bd
refactor(checkhealth)!: rename to vim.health, move logic to Lua #18720
- Complete function:
  There was lots of unnecessary C code for the complete function, therefore
  moving it to Lua and use all the plumbing we have in place to retrieve the
  results.
- Moving the module:
  It's important we keep nvim lua modules name spaced, avoids conflict with
  plugins, luarocks, etc.
2022-05-31 11:10:18 -07:00
Gregory Anders
5d840fa7e6
Merge pull request #18219 from kessejones/filetype-lua
feat(filetype): add more filetype patterns to Lua
2022-05-31 07:58:51 -06:00
Chris Kipp
1a20aed3fb
fix(lsp): include cancellable in progress message table (#18809)
Currently the `title`, `message` and `percentage` is stored for a
progress, but there is also an optional `cancellable` that comes in with
both the `WorkDoneProgressBegin` and also `WorkDoneProgressReport`. This
change also stores that value so that a plugin can access it when they
do a lookup in `client.messages`.
2022-05-31 13:19:45 +02:00
Christian Clason
b66e9e0baa feat(filetype): convert more patterns to filetype.lua 2022-05-30 20:32:35 -03:00
Lewis Russell
eab4d03a32
fix(treesitter): offset directive associates range with capture (#18276)
Previously the `offset!` directive populated the metadata in such a way
that the new range could be attributed to a specific capture. #14046
made it so the directive simply stored just the new range in the
metadata and information about what capture the range is based from is
lost.

This change reverts that whilst also correcting the docs.
2022-05-28 19:22:18 +02:00
Mathias Fußenegger
e8ada41b63
feat(lsp): turn rename filter into a predicate (#18745)
Same as https://github.com/neovim/neovim/pull/18458 but for rename
2022-05-26 12:28:50 +02:00
dundargoc
068fb748e1
vim-patch:8.2.5015: Hoon and Moonscript files are not recognized (#18747)
Problem:    Hoon and Moonscript files are not recognized.
Solution:   Add filetype patterns. (Goc Dundar, closes vim/vim#10478)
bf82df0dd4
2022-05-25 18:07:58 -06:00
Gregory Anders
8c4e62351f
refactor(lsp): remove redundant client cleanup (#18744)
The client state is cleaned up both in client.stop() as well as in the
client.on_exit() handler. Technically, the client has not actually
stopped until the on_exit handler is called, so we should just do this
cleanup there and remove it from client.stop().
2022-05-25 11:45:45 -06:00
Mathias Fußenegger
fa3492c5f7
feat(lsp)!: turn format filter into predicate (#18458)
This makes the common use case easier.
If one really needs access to all clients, they can create a filter
function which manually calls `get_active_clients`.
2022-05-25 19:38:01 +02:00
Elton Leander Pinto
c6d6b8c7eb
fix(lsp): respect global syntax setting in open float preview (#15225) 2022-05-25 18:47:49 +02:00
notomo
5eaf9ef811
fix(filetype): correct vim.fn.did_filetype() handling (#18725) 2022-05-23 18:55:03 -06:00
Gregory Anders
378615b8ee
fix(lsp): do not detach LSP servers on Windows #18703
Detaching the process seems to have unintended side effects on Windows,
so only do it by default on non-Windows platforms.

Ref: https://github.com/neovim/nvim-lspconfig/issues/1907
Closes https://github.com/neovim/nvim-lspconfig/pull/1913
2022-05-22 12:21:44 -07:00
Jonas Strittmatter
52623ce935
refactor(runtime): convert the remaining dist#ft functions to lua (#18623) 2022-05-22 12:16:04 -06:00
dundargoc
976f32aa7a
refactor: add warnings for deprecated functions (#18662) 2022-05-21 09:51:03 +02:00
Fredrik Ekre
a4862cbb5f
fix(lsp): only send diagnostics from current buffer in code_action() (#18639)
Fix vim.lsp.buf.(range_)code_action() to only send diagnostics belonging
to the current buffer and not to other files in the workspace.
2022-05-20 13:11:23 +02:00
Christian Clason
d200ba654a
Merge pull request #18502 from drybalka/fix-languagetree-contains-description
treesitter: small improvements of languagetree.lua
2022-05-19 09:17:10 +02:00
Lewis Russell
3eea66d65a
feat(lsp): option to reuse_win for jump actions (#18577) 2022-05-18 21:03:24 +02:00
Denys
fec944142b
refactor: simple logic in tree_contains() 2022-05-18 19:28:49 +02:00
Denys
f66a60805d
docs: correct description of LanguageTree:contains() 2022-05-18 19:28:41 +02:00
Gregory Anders
ed93186ee2 feat(lsp): add filter to vim.lsp.get_active_clients()
Allow get_active_clients() to filter on client name, id, or buffer. This
(soft) deprecates lsp.buf_get_clients().
2022-05-18 11:21:00 -06: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
Noval Maulana
38cbca3eea
fix(health): handle non-existent log file #18610
Problem:
    vim.lsp: require("vim.lsp.health").check()
    ========================================================================
      - ERROR: Failed to run healthcheck for "vim.lsp" plugin. Exception:
        function health#check, line 20
        Vim(eval):E5108: Error executing lua ...m/HEAD-6613f58/share/nvim/runtime/lua/vim/lsp/health.lua:20: attempt to index a nil value
        stack traceback:
        ...m/HEAD-6613f58/share/nvim/runtime/lua/vim/lsp/health.lua:20: in function 'check'
        [string "luaeval()"]:1: in main chunk

Solution:
Check for nil.

fix #18602
2022-05-17 11:11:14 -07:00
Jonas Strittmatter
7ffa9073a3
refactor(runtime): convert more dist#ft functions to lua (#18430) 2022-05-17 19:48:45 +02:00
bfredl
8a39032fdd
Merge pull request #18554 from kevinhwang91/perf-timerstart
perf(_editor): no need to stop inside vim.defer_fn
2022-05-17 18:59:48 +02:00
ii14
e501e4ed4b
feat(lua): add traceback to vim.deprecate #18575 2022-05-15 18:07:36 -07:00
kevinhwang91
a33caf9b45 perf(_editor): no need to stop inside vim.defer_fn
uv_run:
1. remove timer handle from heap
2. will start again if repeat is not 0
2022-05-13 14:16:47 +08: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
Ivan
78a1e6bc00 feat(defaults): session data in $XDG_STATE_HOME #15583
See: 4f2884e16d

- Move session persistent data to $XDG_STATE_HOME Change 'directory',
  'backupdir', 'undodir', 'viewdir' and 'shadafile' default location to
  $XDG_STATE_HOME/nvim.
- Move logs to $XDG_STATE_HOME, too.
- Add stdpath('log') support.

Fixes: #14805
2022-05-12 07:13:45 -07:00
Famiu Haque
2bbd588e73
feat(lua): vim.cmd() with kwargs acts like nvim_cmd() #18523 2022-05-12 06:34:38 -07:00
adrian5
a6f4cfdefa
docs(api): improve shared lua functions docs (#17933) 2022-05-11 10:23:46 -06:00
Christian Clason
cb7ab98925
Merge pull request #18487 from clason/stylua
CI: format and lint runtime with Stylua
2022-05-11 08:54:24 +02:00
Fredrik Ekre
c55867b46d
docs(lsp): fix description of only in vim.lsp.buf.code_action() (#18492) 2022-05-09 18:08:04 +02:00
Christian Clason
aefdc6783c chore: format runtime with stylua 2022-05-09 16:31:55 +02:00
Gregory Anders
6cfb1d4c28
fix(lsp): detach spawned LSP server processes (#18477)
LSP servers should be daemonized (detached) so that they run in a
separate process group from Neovim's. Among other things, this ensures
the process does not inherit Neovim's TTY (#18475).

Make this configurable so that clients can explicitly opt-out of
detaching from Nvim.
2022-05-08 13:00:30 -06:00
Noval Maulana
d306210641
docs: change wrap_at type to number (#18456) 2022-05-07 10:35:08 +02:00
Mathias Fußenegger
44a4af0ed0
fix(lsp): skip clients without rename capability (#18449)
Follow up to https://github.com/neovim/neovim/pull/18441
This way rename should "just work" in most cases without having to
manually filter the client
2022-05-06 18:57:08 +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
James McCoy
c051ea83dd
refactor(lua): replace hard-coded gsub with vim.pesc() (#18407) 2022-05-04 08:13:01 +02:00
Gregory Anders
815b65d777
fix(filetype): fixup scd filetype detection (#18403) 2022-05-03 23:03:42 +02:00
Jonas Strittmatter
8ef03188e6
refactor(runtime): convert dist#ft functions to lua (#18247)
Co-authored-by: Christian Clason <christian.clason@uni-due.de>
2022-05-03 12:29:04 -06:00
ii14
70e2c5d10d
feat(lsp): add logging level "OFF" (#18379) 2022-05-03 08:49:23 -06:00
dundargoc
73741e9486
feat(lua): vim.deprecate() #18320
This is primarily intended to act as documentation for the developer so
they know exactly when and what to remove. This will help prevent the
situation of deprecated code lingering for far too long as developers
don't have to worry if a function is safe to remove.
2022-05-03 06:42:41 -07:00
Jose Alvarez
b5c15ba7e5
fix(lsp): add missing bufnr argument (#18382) 2022-05-03 08:54:49 -04:00
Christian Clason
46734cf7c1
vim-patch:8.2.4859: wget2 files are not recognized (#18385)
Problem:    wget2 files are not recognized.
Solution:   Add patterns to recognize wget2. (Doug Kearns)
3a974a8933
2022-05-03 10:23:11 +02:00
James McCoy
a1542b091d
Merge pull request #18353 from jamessan/ft-match-fix 2022-05-02 11:01:51 -04:00
James McCoy
88595fbb21
fix(filetype.lua): escape expansion of ~ when used as a pattern 2022-05-02 08:38:35 -04:00
Christian Clason
d23ce6ef76
vim-patch:8.2.4855: robot files are not recognized (#18364)
Problem:    Robot files are not recognized.
Solution:   Add patterns for robot files. (Zoe Roux, closes vim/vim#10339)
2096a5f128
2022-05-02 13:54:07 +02:00
William Boman
069da468d5
fix(shared): avoid indexing unindexable values in vim.tbl_get() (#18337) 2022-05-01 21:08:05 +02:00
ii14
039d60bd9c
fix(lsp): fix infinite loop in resolved_capabilities deprecation message (#18333)
Co-authored-by: ii14 <ii14@users.noreply.github.com>
2022-04-30 23:22:47 +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
Christian Clason
872622bcdb
vim-patch:8.2.4849: Gleam filetype not detected (#18326)
Problem:    Gleam filetype not detected.
Solution:   Add a pattern for Gleam files. (Mathias Jean Johansen,
            closes vim/vim#10326)
917c32c4f7
2022-04-30 17:31:53 +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
kylo252
eecc6535eb
fix(handlers): more specific error messages (#16772)
Specify which message, or request, was last received in case of an error
instead of the same generic message
2022-04-30 13:55:26 +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
Mathias Fußenegger
9a1920e223
feat(lsp): show feedback on empty hover response (#18308)
Without any feedback it gives the impression that the language server is
not working properly, which isn't the case.
2022-04-29 23:04:00 +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
Christian Clason
af82eab946
vim-patch:8.2.4826: .cshtml files are not recognized (#18259)
Problem:    .cshtml files are not recognized.
Solution:   Use html filetype for .cshtml files. (Julien Voisin, closes vim/vim#10212)
1f435dafff
2022-04-25 20:02:36 +02:00
Andrey Mishchenko
4e4914ab2e
fix(lua): don't mutate opts parameter of vim.keymap.del (#18227)
`vim.keymap.del` takes an `opts` parameter that lets caller refer to and
delete buffer-local mappings. For some reason the implementation of
`vim.keymap.del` mutates the table that is passed in, setting
`opts.buffer` to `nil`. This is wrong and also undocumented.
2022-04-23 08:01:08 +08:00