Commit Graph

20188 Commits

Author SHA1 Message Date
James McCoy
d224957d30
fix(coverity/188749): nullify pointer to fix use-after-free 2022-01-19 22:47:09 -05:00
James McCoy
e850a92986
fix(coverity/340720): error if nvim_eval_statusline given invalid winid 2022-01-19 21:54:06 -05:00
James McCoy
8f241e535f
refactor(coverity/345583): assert fp is non-NULL
Since we already have a typval, we know the lookup will succeed.
2022-01-19 21:43:09 -05:00
James McCoy
0c541ab1f6
refactor(coverity/345582): assert fp is non-NULL
Since we already have a typval, we know the lookup will succeed.
2022-01-19 21:42:23 -05:00
zeertzjq
431915fe6a
test(put_spec): correctly order parameters to eq() (#17134)
The first parameter to eq() should be the expected value, and the second
parameter should be the actual value.
2022-01-19 13:53:39 -07:00
Thomas Vigouroux
96aa7dd097
Merge pull request #17130 from clason/bump-treesitter
build(deps): bump tree-sitter
2022-01-19 09:24:20 +01:00
Gregory Anders
de6f9233ee
refactor: source ftplugin.vim separately from filetype.vim (#17129)
This is a follow-on to #17040. The real benefit of #17040 was ensuring
that the ftplugin FileType autocommand was defined first and thus always
fired first. A side effect of the implementation in #17040 was that
setting variables that modified the state of filetype detection (such as
g:did_load_filetypes or g:do_filetype_lua) could no longer be set in the
user's init file. Filetype detection can also no longer be prevented
from loading by using `:filetype off`.

This PR addresses both of those side effects by unconditionally sourcing
ftplugin.vim and indent.vim before the user's init file (which ensures
that these autocommands run first) and sourcing filetype.vim *after* the
user's init file (thus allowing it to be blocked or modified).
2022-01-18 12:46:41 -07:00
Sean Dewar
1ae73e2d1c
vim-patch:8.2.0175: crash when removing list element in map()
Problem:    Crash when removing list element in map().
Solution:   Lock the list. (closes vim/vim#2652)
db661fb95d
2022-01-18 12:49:30 +00:00
f380cedric
5e81687d9a vim-patch:8.2.3402: invalid memory access when using :retab with large value
Problem:    Invalid memory access when using :retab with large value.
Solution:   Check the number is positive.
b7081e135a
2022-01-18 10:04:32 +01:00
Christian Clason
45f7fc9b06 build(deps): bump tree-sitter
update tree-sitter to
2346570901
which includes a massive performance improvement to query construction
(bumping ABI compatibility to 14; parsers need to be generated with a
flag to take advantage of this)
2022-01-18 09:07:12 +01:00
zeertzjq
dda1c8edda vim-patch:8.2.3613: :find test fails
Problem:    :find test fails.
Solution:   Put length check inside if block.
e015d99abb
2022-01-18 10:05:31 +08:00
zeertzjq
ec39e1e421 vim-patch:8.2.3611: crash when using CTRL-W f without finding a file name
Problem:    Crash when using CTRL-W f without finding a file name.
Solution:   Bail out when the file name length is zero.
615ddd5342
2022-01-18 10:05:31 +08:00
zeertzjq
0a65d821fc vim-patch:8.2.3494: illegal memory access in utf_head_off
Problem:    Illegal memory access in utf_head_off.
Solution:   Check cursor position when reselecting the Visual area.
            (closes vim/vim#8963)
b07626d4af

Including the XTest_beval -> XTest_block from patch 8.2.3096.
2022-01-18 10:05:31 +08:00
zeertzjq
176df92bd7 vim-patch:8.2.3580: gj does not move properly with a wide character
Problem:    gj does not move properly with a wide character.
Solution:   Move one to the right. (Christian Brabandt, closes vim/vim#8702)
aaec1d4fb1
2022-01-18 07:46:46 +08:00
Gregory Anders
fcf5dd34fd
refactor: enable filetype detection before user startup scripts (#17040) 2022-01-17 14:11:59 -07:00
zeertzjq
ad2dbd4b5f
fix(man.vim): support calling :Man without a section again (#17119)
When `man -w` is called with an empty string as section name, it may
fail with an error code, which causes :Man to no longer work without a
section. Just remove that argument when no section is specified.
2022-01-17 11:45:46 -07:00
James McCoy
70db972e5f
Merge pull request #16813 from neovim/marvim/api-doc-update/master
docs: regenerate
2022-01-17 13:37:28 -05:00
James McCoy
64b906a3fa
Merge pull request #17125 from jamessan/auto-prs-as-draft
ci: create automated PRs as draft PRs
2022-01-17 13:37:19 -05:00
James McCoy
66076e5e1b
ci: create automated PRs as draft PRs
GH workflows aren't allowed to trigger other GH workflows.  Since
commitlint is a required check now, we need something manual to happen
for it to run on vim-patch/api-doc PRs.

Creating these PRs as drafts and then marking them as "ready to review"
when we want to merge them will provide the manual trigger to run
commitlint.

[skip ci]
2022-01-17 13:36:01 -05:00
marvim
2c94b75eac docs: regenerate [skip ci] 2022-01-17 18:28:23 +00:00
James McCoy
8f54b88a5e
Merge pull request #17122 from dundargoc/ci/remove-non-working-job
ci: remove non-working add-reviewer job
2022-01-17 13:11:46 -05:00
James McCoy
50eabe1c47
Merge pull request #17106 from jamessan/always-run-commitlint
Always run commitlint check
2022-01-17 13:08:27 -05:00
Dundar Göc
6c1d6f3dd6 ci: remove non-working add-reviewer job 2022-01-17 18:48:08 +01:00
James McCoy
69b2dd175c
ci(api-docs): avoid running ci for doc commits 2022-01-17 12:21:16 -05:00
James McCoy
d7e2229b41
ci(commitlint): use pull_request_target to avoid "skip ci" 2022-01-17 12:21:09 -05: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
Christian Clason
3906b2d4fc
vim-patch:fd31be29b822 (#17114)
Update runtime files
fd31be29b8
2022-01-17 11:58:36 +01:00
bfredl
0c0469c4f5
Merge pull request #15242 from dundargoc/docs/vim-patch/move-outsite-of-getting-started
docs: deprioritize vim-patch as a good beginner task
2022-01-16 23:39:38 +01:00
Dundar Göc
4388793799 docs: deprioritize vim-patch as a good beginner task
Also add a disclaimer where familiarity with vim is strongly suggested.
2022-01-16 22:10:22 +01:00
zeertzjq
658ef9c01e vim-patch:8.2.3663: using %S in printf() does not work correctly
Problem:    Using %S in printf() does not work correctly.
Solution:   Fix the problem and add more tests. (closes vim/vim#9208)
1f2453fec6
2022-01-16 17:37:06 +08:00
zeertzjq
9afefd32d3 vim-patch:8.2.3630: printf() with %S does not handle multi-byte correctly
Problem:    Printf() with %S does not handle multi-byte correctly.
Solution:   Count cells instead of bytes. (closes vim/vim#9169, closes vim/vim#7486)
d85fccdfed
2022-01-16 17:37:06 +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
bfredl
561df30981
Merge pull request #16836 from bfredl/mark2
refactor(marks): use a more efficient representation with less pointer indirection
2022-01-15 23:59:40 +01: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
Björn Linse
95ab979fde refactor(extmarks): use a more efficient representation
marktree.c was originally constructed as a "generic" datatype,
to make the prototyping of its internal logic as simple as possible
and also as the usecases for various kinds of extmarks/decorations was not yet decided.
As a consequence of this, various extra indirections and allocations was
needed to use marktree to implement extmarks (ns/id pairs) and
decorations of different kinds (some which is just a single highlight
id, other an allocated list of virtual text/lines)

This change removes a lot of indirection, by making Marktree specialized
for the usecase. In particular, the namespace id and mark id is stored
directly, instead of the 64-bit global id particular to the Marktree
struct. This removes the two maps needed to convert between global and
per-ns ids.

Also, "small" decorations are stored inline, i.e. those who
doesn't refer to external heap memory anyway. That is highlights (with
priority+flags) are stored inline, while virtual text, which anyway
occurs a lot of heap allocations, do not. (previously a hack was used
to elide heap allocations for highlights with standard prio+flags)

TODO(bfredl): the functionaltest-lua CI version of gcc is having
severe issues with uint16_t bitfields, so splitting up compound
assignments and redundant casts are needed. Clean this up once we switch
to a working compiler version.
2022-01-15 22:08:12 +01:00
bfredl
f3193c7b54
Merge pull request #17001 from mjlbach/feat/non-strict-extmarks
feat(extmarks): add strict option
2022-01-15 21:06:04 +01:00
Michael Lingelbach
d8eec8e344 Hopefully last attempt 2022-01-15 09:00:01 -08:00
Michael Lingelbach
facd07bcf7 Address review r3 2022-01-15 08:37:44 -08:00
zeertzjq
8e945c2524 vim-patch:8.2.1762: when a timer uses :stopinsert completion isn't stopped
Problem:    When a timer uses :stopinsert Insert mode completion isn't
            stopped. (Stanley Chan)
Solution:   Call ins_compl_prep(ESC).
d0e1b7103c
2022-01-15 22:33:16 +08:00
Christian Clason
c09147aad9
vim-patch:8.2.4095: sed script not recognized by the first line (#17101)
Problem:    Sed script not recognized by the first line.
Solution:   Recognize a sed script starting with "#n". (Doug Kearns)
e3ce17a3ca
2022-01-15 14:47:25 +01:00
zeertzjq
6c22e5fd1a vim-patch:8.2.4094: 'virtualedit' is window-local but using buffer-local enum
Problem:    'virtualedit' is window-local but using buffer-local enum.
Solution:   Use window-local enum. (closes vim/vim#9529)
e1833bfd01
2022-01-15 19:21:17 +08:00
zeertzjq
87e54f123a vim-patch:8.2.3280: 'virtualedit' local to buffer is not the best solution
Problem:    'virtualedit' local to buffer is not the best solution.
Solution:   Make it window-local. (Gary Johnson, closes vim/vim#8685)
51ad850f5f
2022-01-15 19:21:17 +08:00
zeertzjq
d391940b9a vim-patch:8.2.3227: 'virtualedit' can only be set globally
Problem:    'virtualedit' can only be set globally.
Solution:   Make 'virtualedit' global-local. (Gary Johnson, closes vim/vim#8638)
53ba05b090

I changed some macros to unsigned integer literals to avoid compiler warnings.
2022-01-15 19:21:17 +08:00
zeertzjq
147f65373e vim-patch:8.2.4091: virtcol is recomputed for statusline unnecessarily
Problem:    Virtcol is recomputed for statusline unnecessarily.
Solution:   Just use "w_virtcol". (closes vim/vim#9523)
0f112052ac
2022-01-15 07:47:13 +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
bfredl
bac4bb1900
Merge pull request #16998 from zeertzjq/lua-vim-var-funcref
feat(api, lua): more conversions between LuaRef and Vim Funcref
2022-01-14 18:00:20 +01: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
James McCoy
a88046fe2d
Merge pull request #17086 from zeertzjq/vim-8.1.2375
vim-patch:8.1.2375: no suffucient testing for registers
2022-01-13 21:43:58 -05:00