Commit Graph

813 Commits

Author SHA1 Message Date
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