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).
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)
Problem: Illegal memory access in utf_head_off.
Solution: Check cursor position when reselecting the Visual area.
(closesvim/vim#8963)
b07626d4af
Including the XTest_beval -> XTest_block from patch 8.2.3096.
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.
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]
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>
Problem: Printf() with %S does not handle multi-byte correctly.
Solution: Count cells instead of bytes. (closesvim/vim#9169, closesvim/vim#7486)
d85fccdfed
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)
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.
Problem: 'virtualedit' can only be set globally.
Solution: Make 'virtualedit' global-local. (Gary Johnson, closesvim/vim#8638)
53ba05b090
I changed some macros to unsigned integer literals to avoid compiler warnings.
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`.