Commit Graph

1201 Commits

Author SHA1 Message Date
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
Chinmay Dalal
116a3f4683
fix(treesitter): create new parser if language is not the same as cached parser (#18149) 2022-04-22 16:15:28 +02:00
bfredl
f4f593b333
Merge pull request #18211 from clason/update-inspect
chore: update inspect.lua to 3.1.3
2022-04-22 10:53:00 +02:00
Christian Clason
6c8a3013ac
docs(lua): explain and link to lua patterns (#18206)
also correct explanation of when it's allowed to omit parens in Lua function calls
2022-04-21 21:46:07 +02:00
Christian Clason
64784dccb5 chore: update inspect.lua to 3.1.3 2022-04-21 16:23:10 +02:00
atusy
5ecbbba6ee docs: vim.keymap.set can specify buffer as an option 2022-04-21 10:45:39 +09:00
Christian Clason
bfd6eb4404
Merge pull request #18185 from clason/vim-8.2.4781
vim-patch:8.2.{4781,4793}: maxima files are not recognized
2022-04-20 21:45:22 +02:00
runiq
7e7fdca163
fix(lsp): unify progress message handling (#18040)
The LSP progress handler would put non-progress messages (such as from
clangd or pyls; not part of the LSP spec) directly into
`client.messages`, while `vim.lsp.util.get_progress_messages()` would
try to fetch them from `client.messages.messages` instead (and come up
empty everytime). This would result in these messages never being
cleaned up by `get_progress_messages()`.

This commit fixes that by treating those messages like show-once
progress messages (by setting `done=true` immediately).
2022-04-20 18:40:52 +02:00
Gregory Anders
6b0d3ae6a8
fix(diagnostic): use nvim_exec_autocmds to trigger DiagnosticChanged (#18188)
Use nvim_exec_autocmds to issue the DiagnosticChanged autocommand,
rather than nvim_buf_call, which has some side effects when drawing
statuslines.
2022-04-20 08:16:47 -06:00
Christian Clason
63eb7e865b vim-patch:8.2.4793: recognizing Maxima filetype even though it might be another
Problem:    Recognizing Maxima filetype even though it might be another.
Solution:   Remove *.mc and *.dem patterns from Maxima files
928a131356
2022-04-20 09:52:31 +02:00
Christian Clason
a391cd517b
vim-patch:8.2.4790: lilypond filetype not recognized (#18174)
Problem:    Lilypond filetype not recognized.
Solution:   Add patterns for lilypond. (Doug Kearns)
c448e9c950
2022-04-20 08:35:22 +02:00
Christian Clason
1facad2347
vim-patch:8.2.4778: pacman files use dosini filetype (#18152)
Problem:    Pacman files use dosini filetype.
Solution:   Use conf instead. (Chaoren Lin, closes vim/vim#10213)
35cff32dd8
2022-04-17 23:30:13 +02:00
Christian Clason
6e6f5a7833
vim-patch:8.2.4767: openscad files are not recognized (#18138)
Problem:    Openscad files are not recognized.
Solution:   Add a filetype pattern. (Niklas Adam, closes vim/vim#10199)
c360b2566c
2022-04-17 10:15:55 +02:00
Eden Zhang
813ecdac79
fix(paste): ignore mappings in Cmdline mode (#18114) 2022-04-17 08:11:53 +08:00
dundargoc
e63e5d1dbd
docs: typo fixes (#17859)
Co-authored-by: Elias Alves Moura <eliamoura.alves@gmail.com>
Co-authored-by: venkatesh <shariharanvenkatesh@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Vikas Raj <24727447+numToStr@users.noreply.github.com>
Co-authored-by: Steve Vermeulen <sfvermeulen@gmail.com>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: rwxd <rwxd@pm.me>
Co-authored-by: casswedson <58050969+casswedson@users.noreply.github.com>
2022-04-15 12:35:06 +02:00
Fredrik Ekre
6160973f36
fix(lsp): fix lookup of boolean values in workspace/configuration (#18026) 2022-04-15 11:12:41 +02:00
Christian Clason
9938740ca6
vim-patch:8.2.4746: supercollider filetype not recognized (#18102)
Problem:    Supercollider filetype not recognized.
Solution:   Match file extentions and check file contents to detect
            supercollider. (closes vim/vim#10142)
8cac20ed42
2022-04-13 17:04:38 +02:00
Tony Fettes
392cb7ac0c
fix(lsp): pass offset_encoding in formatexpr() (#18084) 2022-04-11 12:44:31 -07:00
zeertzjq
2dc86ef3b2 vim-patch:8.2.4733: HEEx and Surface do need a separate filetype
Problem:    HEEx and Surface do need a separate filetype.
Solution:   Revert 8.2.4729. (closes vim/vim#10147)
4232dff815
2022-04-11 18:40:46 +08:00
Christian Clason
b438bb4343
vim-patch:8.2.4729: HEEx and Surface templates do not need a separate filetype (#18065)
Problem:    HEEx and Surface templates do not need a separate filetype.
Solution:   Use Eelixir for the similar filetypes. (Aaron Tinio, closes vim/vim#10124)
fa76a24109
2022-04-10 13:53:33 +02:00
Christian Clason
61bd5426f4
vim-patch:8.2.4721: cooklang files are not recognized (#18058)
Problem:    Cooklang files are not recognized.
Solution:   recognize *.cook files. (Goc Dundar, closes vim/vim#10120)
36951ed1da
2022-04-09 17:43:33 +02:00
Christian Clason
3280dc2b60
vim-patch:8.2.4720: ABB Rapid files are not recognized properly (#18057)
Problem:    ABB Rapid files are not recognized properly.
Solution:   Add checks for ABB Rapid files. (Patrick Meiser-Knosowski,
            closes #10104)
b09c320039
2022-04-09 17:42:46 +02:00
Christian Clason
8055f9857b
vim-patch:8.2.4715: Vagrantfile not recognized (#18052)
Problem:    Vagrantfile not recognized.
Solution:   Recognize Vagrantfile as ruby. (Julien Voisin, closes vim/vim#10119)
5e1792270a
2022-04-09 11:19:18 +02:00
Christian Clason
8c25dbff46
vim-patch:8.2.4708: PHP test files are not recognized (#18025)
Problem:    PHP test files are not recognized.
Solution:   Add the *.phpt pattern. (Julien Voisin, closes vim/vim#10112)
177847e67a
2022-04-07 20:24:55 +02:00
Christian Clason
f85f4e25d2
vim-patch:8.2.4701: Kuka Robot Language files not recognized (#18012)
Problem:    Kuka Robot Language files not recognized.
Solution:   Recognize *.src and *.dat files. (Patrick Meiser-Knosowski,
            closes vim/vim#10096)
3ad2090316
2022-04-07 09:09:08 +02:00
Christian Clason
e45d141e28
vim-patch:8.2.4664: Elvish files are not recognized (#17963)
Problem:    Elvish files are not recognized.
Solution:   Recognize .elv files. (Bruno Roque, closes vim/vim#10058)
c1658a196b
2022-04-02 13:36:19 +02:00
Lewis Russell
3cc29b7f0d fix(keymap): don't coerce false to '' 2022-04-01 09:09:30 +01:00
bfredl
dc48330b9d
Merge pull request #17842 from lewis6991/keymap
feat(keymap): return nil from an expr keymap
2022-04-01 00:48:46 +02:00
Christian Clason
38ba2a75fc
vim-patch:8.2.4658: org-mode files are not recognized (#17939)
Problem:    Org-mode files are not recognized.
Solution:   Add patterns to recognize "org" files. (closes vim/vim#10046)
3a6f952cc8
2022-03-31 22:16:25 +02:00
Christian Clason
2e85af47d2
feat(runtime): add query filetype (#17905)
used for Tree-sitter queries
uses Lisp runtime files

(in Lua to distinguish from upstream runtime files)
2022-03-31 08:46:45 -06:00
Gregory Anders
6d648f5594
feat(treesitter): add more default groups to highlight map (#17835)
This covers some default groups listed in :h group-name.
2022-03-30 22:14:20 +02:00
Andrea Cappuccio
a18c9ba2da
docs(lsp): remove outdated offset_encoding default value for apply_text_edits 2022-03-30 21:04:17 +02:00
Jaehwang Jung
4d3acd6beb
fix(lsp): use "text" filetype for plaintext (#17898) 2022-03-28 09:16:11 -07:00
Smitesh Patil
a8e2c45b94
fix(diagnostic): make open_float respect global diagnostic options (#17879)
* make `open_float` respect `scope` option set in `vim.diagnostic.config`
* Closes #17878
2022-03-27 08:10:03 -06:00
Jared Weakly
5e64d65df6
fix(filetype.lua): always return a string in getline helper function (#17852)
Uses of `getline` in `filetype.lua` currently assume it always returns a
string. However, if the buffer is unloaded when filetype detection runs,
`getline` returns `nil`. Fixing this prevents errors when filetype
detection is run on unloaded buffers.
2022-03-25 12:12:00 -06:00
Michael Lingelbach
69f1de86dc
feat: add vim.tbl_get (#17831)
vim.tbl_get takes a table with subsequent string arguments (variadic) that
index into the table. If the value pointed to by the set of keys exists,
the function returns the value. If the set of keys does not exist, the
function returns nil.
2022-03-24 12:01:04 -07:00
Lewis Russell
58140a9428 feat(keymap): return nil from an expr keymap
For Lua callback expr keymaps, returning `nil` or `false` is equivalent
to an empty string
2022-03-24 13:59:20 +00:00
bfredl
e7391191e2
Merge pull request #17776 from bfredl/tsconceal
feat(ui): allow conceal to be defined in decorations
2022-03-20 18:59:20 +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
bfredl
6eca9b69c4 feat(ui): allow conceal to be defined in decorations
Unlike syntax conceal, change highlight of concealed char

Can be used in tree-sitter using "conceal" metadata.
2022-03-20 18:02:41 +01:00
dundargoc
d238b8f600
chore: fix typos (#17670)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-03-17 13:21:24 +08:00
Jade Lovelace
5a8bf31d32
vim-patch:8.2.4571: not all gdb files are recognized (#17727)
Problem:    Not all gdb files are recognized.
Solution:   Add a few more patterns for gdb.
            (closes https://github.com/vim/vim/pull/9956)
8d5e514d77
2022-03-15 22:46:32 +01:00
zeertzjq
e263afc0e9 fix(paste): escape control characters in Cmdline mode 2022-03-15 18:15:18 +08:00
zeertzjq
a6eafc77ce fix(paste): deal with trailing new line in chunk 2022-03-15 18:15:18 +08:00
zeertzjq
fcc6f66cf2 fix(paste): avoid edges cases caused by empty chunk 2022-03-15 18:15:18 +08:00
zeertzjq
21ba2d81a8 refactor(paste): do not print dots in cmdline mode 2022-03-15 18:15:18 +08:00
zeertzjq
bfb7754442 fix(paste): deal with eol and eof in Visual mode 2022-03-15 18:15:18 +08:00
zeertzjq
2601e0873f fix(paste): don't move cursor past the end of pasted text in Normal mode 2022-03-15 18:15:18 +08:00
zeertzjq
9b1e1fbc9f fix(paste): use getcmdtype() to determine whether in cmdline mode 2022-03-15 18:15:18 +08:00
Charlie Groves
1dbf8675c7 fix(remote): respect silent in error reporting 2022-03-11 11:16:46 -05:00
Charlie Groves
29c3632285 fix(remote): report on missing wait commands, typecheck lua results
Clean up lint errors, too
2022-03-11 11:16:46 -05:00
Charlie Groves
039e94f491 test(remote): add tests for --remote
This also fixes a fair number of issues found in running the tests
2022-03-11 11:16:46 -05:00
Charlie Groves
5862176764 feat(remote): add basic --remote support
This is starting from @geekodour's work at
https://github.com/neovim/neovim/pull/8326
2022-03-11 11:16:46 -05:00
bfredl
6170574d2f
Merge pull request #17660 from bfredl/luacomplete
feat(lua): handle lazy submodules in `:lua vim.` wildmenu completion
2022-03-10 15:46:18 +01:00
dundargoc
a7b1c8893c
chore: fix typos (#17331)
Co-authored-by: Hongyi Lyu <hongyi.lyu95@gmail.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: notomo <notomo.motono@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-03-10 14:34:55 +08:00
bfredl
5ed60804fe feat(lua): handle lazy submodules in :lua vim. wildmenu completion 2022-03-09 15:25:06 +01:00
bfredl
f39a12d629 refactor(lua): make vim submodule lazy loading declarative
This will allow us to also use the same logic for lua threads and
processes, later.
2022-03-07 09:59:22 +01:00
Michael Lingelbach
3800615da9
fix(lsp): handle insertion of previous line (#17618) 2022-03-06 07:52:11 -08:00
zeertzjq
80e6f81862 docs(lua): reference runtime/lua/vim/_editor.lua 2022-03-06 22:32:22 +08:00
bfredl
2de4d3c7ac
Merge pull request #17603 from bfredl/luaworld
refactor(lua): move only runtime lua file in src/ to runtime/lua
2022-03-05 19:21:34 +01: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
bfredl
186a559818 refactor(lua): move only runtime lua file in src/ to runtime/lua
reorganize so that initialization is done in lua
2022-03-04 19:07:42 +01:00
bfredl
f9faba88fd refactor(lua): reorganize builtin modules, phase 1 2022-03-03 20:03:30 +01:00
David Shen
5d6006f9bf
feat(diagnostic): add "code" to the diagnostic structure (#17510) 2022-03-02 18:42:27 -07:00
Tim Pope
d477788cd5
fix(lsp): respect all of 'fixeol', 'eol', and 'binary' applying edits (#17574) 2022-03-02 11:33:02 -08:00
bfredl
c65d93e60a
Merge pull request #16969 from shadmansaleh/enhance/ingore_nore_on_plug_keymaps
feat: ignore nore on <Plug> maps
2022-02-27 16:47:55 +01:00
shadmansaleh
c031e038df chore: remove <Plug> detection from vim.keymap 2022-02-27 08:21:21 +06:00
bfredl
850b3e19c9 refactor(lua): cleanup and docs for threads 2022-02-26 15:00:13 +01:00
erw7
b87867e69e feat(lua): add proper support of luv threads 2022-02-26 14:01:38 +01:00
Christian Clason
d0f8f76224
vim-patch:8.2.4464: Dtrace files are recognized as filetype D (#17518)
Problem:    Dtrace files are recognized as filetype D.
Solution:   Add a pattern for Dtrace files. (Teubel György, closes vim/vim#9841)
            Add some more testing.
4d56b971cb
2022-02-26 14:01:37 +01:00
Christian Clason
10a46a20ce
refactor(highlight)!: optional arguments for highlight.range as table (#17462)
also update documentation

BREAKING CHANGE: signature of highlight.range is now
     vim.highlight.range(bufnr, ns, hlgroup, start, finish,
         { regtype = regtype, inclusive = inclusive, priority = priority })

Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2022-02-21 21:21:42 +01:00
Michael Lingelbach
d80c9b9259
fix(diagnostic): use botright copen for qflist (#17475)
This matches the LSP handlers, and forces the qflist for diagnostics to
span across the horizontal space, below all open windows.
2022-02-20 13:44:14 -08:00
Michael Lingelbach
6a3acccd8b
fix(lsp): use botright copen for all handlers (#17471) 2022-02-20 11:09:01 -08:00
Christian Clason
439a843b80
vim-patch:8.2.4424: ".gts" and ".gjs" files are not recognized (#17464)
Problem:    ".gts" and ".gjs" files are not recognized.
Solution:   Recognize Glimmer flavored typescript and javascript.
            (closes vim/vim#9799)
cdf717283c
2022-02-19 23:41:11 +01:00
Michael Lingelbach
791e400858
fix: lsp and diagnostic highlight priority (#17461)
Closes https://github.com/neovim/neovim/issues/17456

* treesitter uses the default highlight priority of 50
* diagnostic highlights have a priority of 150
* lsp reference highlights have a priority of 200

This ensures proper ordering.
2022-02-19 08:38:14 -08:00
Christian Clason
36362ef0ae
vim-patch:8.2.4414: solidity files are not recognized (#17451)
Problem:    Solidity files are not recognized.
Solution:   Add the *.sol pattern. (Dundar Goc, closes vim/vim#9792)
97b231541d
2022-02-18 17:08:43 +01:00
Christian Clason
1fd106ca88
vim-patch:8.2.4411: bicep files are not recognized (#17447)
Problem:    Bicep files are not recognized.
Solution:   Match *.bicep files. (Dundar Goc, closes vim/vim#9791)
8e5ba693ad
2022-02-17 23:05:48 +01:00
Stephan Seitz
8ab5ec4aaa
feat(tree-sitter): allow Atom-style capture fallbacks (#14196)
This allows falling back to `@definition` when we have no mapping
`@definition.fancy-specialization`.

This behavior is described in tree-sitter's documentation
(https://tree-sitter.github.io/tree-sitter/syntax-highlighting#theme).

Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/738
2022-02-16 19:38:19 +01:00
Chinmay Dalal
e481901748
docs: treesitter.txt - fix overflowing lines, document minimum_language_version (#17286) 2022-02-13 14:43:25 +01:00
Christian Clason
3b13c7fc8b vim-patch:8.2.4352: ReScript files are not recognized
Problem:    ReScript files are not recognized.
Solution:   Add the *.res and *.resi patterns. (Ananda Umamil, closes vim/vim#9752)
0c3cc2fec3
2022-02-12 12:04:09 +01:00
Christian Clason
4761dd4fc2
Merge pull request #17365 from kevinhwang91/fix-ts-empty-lines
fix(query.lua): check empty table for lines
2022-02-11 15:19:19 +01:00
Lajos Koszti
f6329ea137
fix(lsp): correct prefix when filterText is present (#17051)
LSP server might return an item which would replace a token to another.
For example in typescript for a `jest.Mock` object `getProductsMock.`
text I get the following response:
```
{
    commitCharacters = {
        ".",
        ",",
        "("
    },
    data = {
        entryNames = {
            "Symbol"
        },
        file = "/foo/bar/baz.service.spec.ts",
        line = 268,
        offset = 17
    },
    filterText = ".Symbol",
    kind = 6,
    label = "Symbol",
    sortText = "11",
    textEdit = {
        newText = "[Symbol]",
        range = {
            end = {
                character = 16,
                line = 267
            },
            start = {
                character = 15,
                line = 267
            }
        }
    }
},
```

In `lsp.omnifunc` to get a `prefix` we call the `adjust_start_col` which
then returns the `textEdit.range.start.character`.
Th `prefix` then be the `.` character. Then when filter the items with
`remove_unmatch_completion_items`, every item will be filtered out,
since no completion word starts `.`.

To fix we return the `end.character`, which in that particular case will
be the position after the `.`.
2022-02-11 14:04:15 +01:00
kevinhwang91
afcf64479c fix(query.lua): check empty table for lines
The range of node may make `nvim_buf_get_lines` return an empty table.
2022-02-11 14:44:37 +08:00
dundargoc
64116d7850
chore: fix typos (#17250)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Dani Dickstein <daniel.dickstein@gmail.com>
Co-authored-by: Axel Dahlberg <git@valleymnt.com>
2022-02-08 08:19:06 +08:00
Christian Clason
a562b5771e
vim-patch:8.2.4274: Basic and form filetype detection is incomplete (#17259)
Problem:    Basic and form filetype detection is incomplete.
Solution:   Add a separate function for .frm files. (Doug Kearns, closes vim/vim#9675)
c570e9cf68
2022-02-01 08:35:28 +01:00
Christian Clason
bddce4b0ff
vim-patch:c4573eb12dba (#17258)
Update runtime files
c4573eb12d
2022-01-31 18:09:51 +01:00
dundargoc
abde91ecaf
docs: add example to vim.ui.select (#17241)
Closes https://github.com/neovim/neovim/issues/17137
2022-01-30 13:32:55 +01:00
Gregory Anders
4458413bc0
feat(filetype): convert patterns for mail buffers (#17238) 2022-01-29 12:43:06 -07:00
Christian Clason
b2f77c354a
vim-patch:8.2.4251: vala files are not recognized (#17235)
Problem:    Vala files are not recognized.
Solution:   Add the *.vala pattern. (closes vim/vim#9654)
97c554d514
2022-01-29 15:40:29 +01:00
Christian Clason
5b9980f01e vim-patch:8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Problem:    *.tf file could be fileytpe "tf" or "terraform".
Solution:   Detect the type from the file contents. (closes vim/vim#9642)
bd8168c770
2022-01-28 17:01:13 +01:00
Thomas Vigouroux
8c140be31f
feat(ts): expose minimum language version to lua (#17186) 2022-01-27 12:46:56 +01:00
Lewis Russell
f9080b24c4
fix(ts): escape lang when loading parsers (#16668)
When trying to load a language parser, escape the value of
the language.

With language injection, the language might be picked up from the
buffer. If this value is erroneous it can cause `nvim_get_runtime_file`
to hard error.

E.g., the markdown expression `~~~{` will extract '{' as a language and
then try to get the parser using `parser/{*` as the pattern.
2022-01-27 10:42:59 +01:00
dundargoc
ecec957125
vim-patch:8.2.4196: various file types not recognized (#17182)
Problem:    Various file types not recognized.
Solution:   Add patterns to recognize more file types (closes vim/vim#9607)
428058ab32
2022-01-25 08:22:15 +01:00
Christian Clason
28352dc6e5
vim-patch:8.2.4188: not all gitconfig files are recognized (#17178)
Problem:    Not all gitconfig files are recognized.
Solution:   Add a few more patterns. (Tim Pope, closes vim/vim#9597)
bcfa11b7df
2022-01-23 17:50:45 +01:00
dundargoc
ffd9551aa2
vim-patch:8.2.4191: json5 files are not recognized (#17180)
Problem:    json5 files are not recognized.
Solution:   Add a pattern for json5 files. (closes vim/vim#9601)
e15ebeffb3
2022-01-23 16:19:48 +01:00
Christian Clason
3d62dd2077
vim-patch:8.2.4187: gnuplot file not recognized (#17177)
Problem:    Gnuplot file not recognized.
Solution:   Recognize ".gnuplot". (closes vim/vim#9588)
ff5cbe8133
2022-01-23 13:52:37 +01:00
Christian Clason
9d02fc4c00
vim-patch:8.2.4172: filetype detection for BASIC is not optimal (#17161)
Problem:    Filetype detection for BASIC is not optimal.
Solution:   Improve BASIC filetype detection. (Doug Kearns)
6517f14165
2022-01-21 16:45:32 +01:00
xnmet
c977d8b43c
docs(lsp): fix on_publish_diagnostics example (#17146) 2022-01-21 08:40:48 +01:00
Michael Lingelbach
8e702c14ac
feat(lsp): add handler for workspace/workspaceFolders (#17149) 2022-01-21 07:51:34 +01:00
Michael Lingelbach
9055ec5792
perf(lsp): request only changed portions of the buffer in changetracking (#17118)
This commits introduces two performance improvements in incremental sync:

* avoiding expensive lua string reallocations on each on_lines call by requesting
only the changed chunk of the buffer as reported by firstline and new_lastline
parameters of on_lines
* re-using already allocated tables for storing the resulting lines to reduce the load on
the garbage collector

The majority of the performance improvement is from requesting only changed chunks
of the buffer.

Benchmark:

The following code measures the time required to perform a buffer edit to
that operates individually on each line, common to plugins such as vim-commentary.

    set rtp+=~/.config/nvim/plugged/nvim-lspconfig
    set rtp+=~/.config/nvim/plugged/vim-commentary
    lua require('lspconfig')['ccls'].setup({})
    function! Benchmark(tries) abort
        let results_comment = []
        let results_undo = []
        for i in range(a:tries)
            echo printf('run %d', i+1)
            let begin = reltime()
            normal gggcG
            call add(results_comment, reltimefloat(reltime(begin)))
            let begin = reltime()
            silent! undo
            call add(results_undo, reltimefloat(reltime(begin)))
            redraw
        endfor
        let avg_comment = 0.0
        let avg_undo = 0.0
        for i in range(a:tries)
            echomsg printf('run %3d: comment=%fs undo=%fs', i+1, results_comment[i], results_undo[i])
            let avg_comment += results_comment[i]
            let avg_undo += results_undo[i]
        endfor
        echomsg printf('average: comment=%fs undo=%fs', avg_comment / a:tries, avg_undo / a:tries)
    endfunction
    command! -bar Benchmark call Benchmark(10)

All text changes will be recorded within a single undo operation. Both the
comment operation itself and the undo operation will generate an on_lines event
for each changed line. Formatter plugins using setline() have also been found
to exhibit the same problem (neoformat, :RustFmt in rust.vim), as this function
too generates an on_lines event for every line it changes.

Using the neovim codebase as an example (commit 2ecf0a4)
with neovim itself built at 2ecf0a4 with
CMAKE_BUILD_TYPE=Release shows the following performance improvement:

src/nvim/lua/executor.c, 1432 lines:
  - baseline, no optimizations:             comment=0.540587s undo=0.440249s
  - without double-buffering optimization:  comment=0.183314s undo=0.060663s
  - all optimizations in this commit:       comment=0.174850s undo=0.052789s

src/nvim/search.c, 5467 lines:
  - baseline, no optimizations:             comment=7.420446s undo=7.656624s
  - without double-buffering optimization:  comment=0.889048s undo=0.486026s
  - all optimizations in this commit:       comment=0.662899s undo=0.243628s

src/nvim/eval.c, 11355 lines:
  - baseline, no optimizations:             comment=41.775695s undo=44.583374s
  - without double-buffering optimization:  comment=3.643933s undo=2.817158s
  - all optimizations in this commit:       comment=1.510886s undo=0.707928s

Co-authored-by: Dmytro Meleshko <dmytro.meleshko@gmail.com>
2022-01-17 08:19:33 -08:00
Daniel Steinberg
7085e5b0c8
fix(lsp): avoid nil workspace/symbol query (#17107) 2022-01-15 23:08:35 -08:00
Michael Lingelbach
a0201b6ed3
fix(lsp): fetch offset_encoding from client in references (#17104) 2022-01-15 15:49:29 -08:00
Michael Lingelbach
b455e0179b
feat: use nvim_buf_set_extmark for vim.highlight (#16963)
Closes https://github.com/neovim/neovim/issues/13647

This allows customizing the priority of the highlights.

* Add default priority of 50
* Use priority of 200 for highlight on yank
* use priority of 40 for highlight references (LSP)
2022-01-15 14:19:20 -08:00
Gregory Anders
574a582202
feat(lsp): dynamically generate list title in response_to_list (#17081)
This gives quickfix/location lists created by handlers which use
'response_to_list' (textDocument/documentSymbols and workspace/symbol by
default) the ability to set a more useful list title. This commit gives
lists created for documentSymbols a title of the form:

    Symbols in <filename>

and lists for workspace/symbol a title of the form:

    Symbols matching '<query>'

These are more informative than a standard "Language Server" list title
and can help disambiguate results when users have multiple quickfix
lists that they cycle through with `:colder` and `:cnewer`.
2022-01-14 14:20:50 -07:00
Gregory Anders
59ea8fa322
fix(filetype): expand tildes in filetype patterns (#17091)
This allows patterns like

  ["~/.config/foo"] = "fooscript"

to work.
2022-01-14 14:20:17 -07:00
Michael Lingelbach
b72aae85fd
fix(lsp): always split text edits on \r, \r\n, and \n (#17087)
Closes: https://github.com/neovim/neovim/issues/17053

Servers can return a mix of line endings per the language server
protocol. See:

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

All should be equally treated as line endings.
2022-01-14 08:02:44 -08:00
Gregory Anders
6e04c8653c fix(filetype): fix foam pattern detection 2022-01-13 15:32:20 -07:00
rhcher
c38d602b88 feat(filetype.lua): fix .cc file not detected 2022-01-13 15:32:20 -07:00
Sanchayan Maity
7a574e54f2 feat(filetype.lua): add support for files under .git 2022-01-13 15:32:18 -07:00
Sanchayan Maity
27b664a2de feat(filetype.lua): add support for patch files 2022-01-13 15:31:59 -07:00
Gary Sentosa
94d5358922 feat(filetype.lua): add support for tmux.conf files 2022-01-13 15:31:59 -07:00
Gary Sentosa
19864bd995 feat(filetype.lua): fix .env file not detected 2022-01-13 15:31:59 -07:00
Christian Clason
596c55756a
vim-patch:8.2.4077: not all Libsensors files are recognized (#17080)
Problem:    Not all Libsensors files are recognized.
Solution:   Add "sensors.d/*" pattern. (Doug Kearns)
8d9e470aa9
2022-01-13 18:31:15 +01:00
Michael Lingelbach
8066abcd65
fix(lsp): forward offset_encoding in rename handler (#17079) 2022-01-13 18:28:27 +01:00
Michael Lingelbach
9304ee3874
fix(lsp): forward offset_encoding to apply_text_edits (#17075) 2022-01-13 06:47:35 -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
Thomas Vigouroux
f9b3b2dcfc
Merge pull request #16945 from theHamsta/cached-queries
perf(treesitter): cache query parsing
2022-01-13 08:50:01 +00:00
Gregory Anders
c915571b99 feat(diagnostic): allow retrieving current diagnostic config 2022-01-11 16:46:42 -07:00
Gregory Anders
8a27205d09 fix(diagnostic): only set default handler config if unset 2022-01-11 16:44:07 -07:00
Gregory Anders
984270c09f fix(diagnostic): allow setting arbitrary config values 2022-01-11 16:43:47 -07:00
Gregory Anders
fc8af96888 fix(diagnostic): resolve nil opts tables
In functions which allow opts to be optional, ensure that the value
actually resolves to a non-nil value.
2022-01-11 16:39:15 -07:00
Christian Clason
70fe3ce004
vim-patch:8.2.4064: foam files are not detected (#17041)
* vim-patch:8.2.4064: foam files are not detected

Problem:    Foam files are not detected.
Solution:   Detect the foam filetype by the path and file contents. (Mohammed
            Elwardi Fadeli, closes vim/vim#9501)
2284f6cca3

* Port foam ft detection to filetype.lua

Co-authored-by: Gregory Anders <greg@gpanders.com>
2022-01-11 21:02:58 +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
Mathias Fußenegger
3f2fbb824e
fix(lsp): ensure pending changes are flushed on skipped debounce (#17015)
Follow up to https://github.com/neovim/neovim/pull/16881

Document changes could get sent out of order to the server:

    1. on_lines: debounce > 0; add to pending changes; setup timer
    2. on_lines: debounce = 0; send new changes immediately
    3. timer triggers, sending changes from 1.
2022-01-10 17:33:36 +01:00
Michael Lingelbach
e41e8b3fda
fix(lsp): only send valid params in executeCommand (#16987) 2022-01-08 10:15:41 -08:00
Michael Lingelbach
b65a23a13a
fix(lsp): resolve bufnr for get_lines (#16986)
Closes https://github.com/neovim/neovim/issues/16985

* get_lines checks if buf_loaded using bufnr 0, which is
  typically used as a sentinel value, but here must be resolved
  to the true bufnr
2022-01-08 11:30:59 +01:00
Gregory Anders
e92b816336
fix(filetype): match negative priority patterns after extensions (#16980)
Negative priority patterns are those that act as catch-alls when all
other attempts at matching have failed (typically the patterns that use
the StarSetf functions).
2022-01-07 19:17:07 -07:00
Mathias Fußenegger
b680392687
feat(lsp): skip or reduce debounce after idle (#16881)
The idea of the debounce is to avoid overloading a server with didChange
notifications. So far this used a constant value to group changes within
an interval together and send a single notification. A side effect of
this is that when you were idle, notifications are still delayed.

This commit changes the logic to take the time the last notification
happened into consideration, if it has been greater than the debounce
interval, the debouncing is skipped or at least reduced.
2022-01-07 11:56:09 +01:00
Christian Clason
bba679c431
vim-patch:8.2.4014: git and gitcommit file types not properly recognized (#16953)
Problem:    Git and gitcommit file types not properly recognized.
Solution:   Adjust filetype detection. (Tim Pope, closes vim/vim#9477)
c689f8c3d9
2022-01-07 10:27:34 +01:00
Gregory Anders
d78e46679d
feat(lua): add notify_once() (#16956)
Like vim.notify(), but only displays the notification once.
2022-01-06 11:10:56 -07:00
Björn Linse
2f779e3361
Merge pull request #16591 from shadmansaleh/feat/lua_keymaps2
feat(lua): add support for lua keymaps
2022-01-06 18:35:31 +01:00
Stephan Seitz
9c26939f75 perf(treesitter): cache query parsing 2022-01-06 13:20:22 +01:00
Gregory Anders
6c86079fa0 fix(filetype): normalize slashes in file paths 2022-01-05 12:26:43 -07:00
Gregory Anders
f1590717ac test(filetype): port test_filetype to Lua
Because filetype.lua is gated behind an opt-in variable, it's not tested
during the "standard" test_filetype.vim test. So port the test into
filetype_spec where we enable the opt-in variable.

This means runtime Vim patches will need to update test_filetype in two
places. This can eventually be removed if/when filetype.lua is made
opt-out rather than opt-in.
2022-01-05 10:41:25 -07:00
Gregory Anders
f40ce34563
fix(filetype): match on <afile> rather than <abuf> (#16943)
Filetype detection runs on BufRead and BufNewFile autocommands, both of
which can fire without an underlying buffer, so it's incorrect to use
<abuf> to determine the file path. Instead, match on <afile> and assume
that the buffer we're operating on is the current buffer. This is the
same assumption that filetype.vim makes, so it should be safe.
2022-01-05 09:50:54 -07:00
Michael Lingelbach
55a59e56ed
feat(lsp): enable default debounce of 150 ms (#16908) 2022-01-05 08:36:35 -08:00
KillTheMule
a45b578dbe
feat(filetype.lua): add support for txt files (#16926) 2022-01-04 16:06:57 -07:00
Gregory Anders
74a90cf098
chore: ignore unused args in filetype functions (#16927)
Also mark the 'getline' helper function as private to avoid docgen.
2022-01-04 15:24:14 -07:00
Robin Gagnon
8ade8009ee
feat(filetype.lua): Add typescript extension to filetype detection (#16923)
port from `filetype.vim`; also add `getline` convenience function
2022-01-04 22:34:55 +01:00
dundargoc
0b0c4f7dfa
chore: fix typos (#16816)
Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Sebastian Volland <seb@baunz.net>
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-01-04 11:07:40 -07:00
Sam McCall
d6f0c9539c
fix(lsp): suppress ContentModified errors from UI (#16904)
Fixes https://github.com/neovim/neovim/issues/16900

If clients receive a ContentModified error, it generally should not
show it in the UI for the end-user. Clients can resend the request if
they know how to do so.

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#implementationConsiderations
2022-01-04 09:28:13 -08:00
shadmansaleh
6d41f65aa4 feat(lua): add vim.keymap
This introduces two new functions `vim.keymap.set` & `vim.keymap.del`

differences compared to regular set_keymap:
- remap is used as opposite of noremap. By default it's true for <Plug> keymaps and false for others.
- rhs can be lua function.
- mode can be a list of modes.
- replace_keycodes option for lua function expr maps. (Default: true)
- handles buffer specific keymaps

Examples:
```lua
vim.keymap.set('n', 'asdf', function() print("real lua function") end)
vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, {buffer=true})
vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", {silent = true, buffer = 5 })
vim.keymap.set('i', '<Tab>', function()
  return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>"
end, {expr = true})
vim.keymap.set('n', '[%', '<Plug>(MatchitNormalMultiBackward)')

vim.keymap.del('n', 'asdf')
vim.keymap.del({'n', 'i', 'v'}, '<leader>w', {buffer = 5 })
```
2022-01-04 22:31:59 +06:00
Gregory Anders
3fd454bd4a
feat: filetype.lua (#16600)
Adds a new vim.filetype module that provides support for filetype detection in
Lua.
2022-01-04 07:28:29 -07:00
Michael Lingelbach
207307d0fa
fix(lsp): explicitly pass bufnr in didSave handler (#16906)
Addresses a regression introduced by the stricter type checking
in lua api functions from https://github.com/neovim/neovim/pull/16745
2022-01-03 21:03:16 -05:00
Gregory Anders
e6c1545b19
fix(lsp): resolve nil bufnr (#16902)
Related: #16889, #16745
2022-01-03 12:40:09 -07:00
Gregory Anders
36662c9612
fix: resolve nil arguments to API functions (#16889)
As revealed by #16745, some functions pass a nil value to API functions,
which have been implicitly converted to 0. #16745 breaks this implicit
conversion, so explicitly pass a resolved buffer number to these API
functions.
2022-01-03 06:48:01 -07:00
Michael Lingelbach
e42c906597
fix(lsp): always use target bufnr in location handler (#16876) 2022-01-02 07:55:16 +01:00
Gregory Anders
838631e29e
fix(diagnostic): improve validation for list arguments (#16855)
Function arguments that expect a list should explicitly use tbl_islist
rather than just checking for a table. This helps catch some simple
errors where a single table item is passed as an argument, which passes
validation (since it's a table), but causes other errors later on.
2022-01-01 12:58:34 -07:00
Shadman
55c4393e9f
feat(lua): add support for multiple optional types in vim.validate (#16864) 2022-01-01 12:35:15 -07:00
dundargoc
08616571f4
chore: fix typos (#16506)
Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Christoph Hasse <hassec@users.noreply.github.com>
Co-authored-by: Alef Pereira <ealefpereira@gmail.com>
Co-authored-by: AusCyber <willp@outlook.com.au>
Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
2021-12-28 18:15:16 +01:00
Dmytro Meleshko
56f3c41f5f
fix(uri): change scheme pattern to not include the comma character (#16797) 2021-12-26 16:36:14 -05: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