Problem:
Many decoration providers (treesitter injection highlighting, semantic
token highlighting, inlay hint) rely on the correctness of the `botline`
argument of `on_win` callback. However, `botline` can be smaller than
the actual line number of the last displayed line if some lines are
folded. In such cases, some decorations will be missing in the lines not
covered by `botline`.
Solution:
Validate `botline` when invoking `on_win`.
NOTE:
It seems that the old code was deliberately avoiding this presumably due
to performance reasons. However, I haven't experienced noticeable lag
after this change, and I believe the cost of botline computation would
be much smaller than the cost of decoration providers.
runtime(vim): Add support for <ScriptCmd> syntax (vim/vim#10686)
Adding `<ScriptCmd>` to list of angle-bracket notation syntax, just like `<Cmd>`
`<Cmd>` is already highlighted.
```vim
nnoremap <leader>o <Cmd>Oldfiles()<CR>
```
`<ScriptCmd>` is not.
80beeef0c6
Co-authored-by: dezza <402927+dezza@users.noreply.github.com>
Avoid `prevwin == curwin` when closing `curwin`
Problem: When closing the current window (or when moving it to a tabpage), the
previous window may refer to the new current window
(`winnr() == winnr('#')`) if that window is selected as the
new current window.
Solution: Set `prevwin = NULL` when switching away from an invalid `curwin` and
the target window was the `prevwin`.
(Sean Dewar)
related: vim/vim#4537closes: vim/vim#13762bf44b69d1f
Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
Problem: reloading colorscheme when not changing 'background'
Solution: Check, if the background option value actually changed,
if not, return early.
Only reload colorscheme when bg is changed
Currently the highlight groups are re-initialized and the colorscheme
(if any) is reloaded anytime 'background' is set, even if it is not
changed. This is unnecessary, because if the value was not changed then
there is no need to change highlight groups or do anything with the
colorscheme. Instead, only reload the colorscheme if the value of
'background' was actually changed.
closes: vim/vim#1370083ad2726ff
Co-authored-by: Gregory Anders <greg@gpanders.com>
Problem: a closing fold expression may unexpectedly start a new fold
when it should end a fold
(reported by Shota Nozaki)
Solution: if a fold hasn't started yet, do not immediately
start a new fold with level 1
(Shota Nozaki)
fixes: vim/vim#12768closes: vim/vim#137480689b87059
Co-authored-by: Shota Nozaki <emonkak@gmail.com>
Problem:
Currently `deepcopy` hashes every single tables it copies so it can be
reused. For tables of mostly unique items that are non recursive, this
hashing is unnecessarily expensive
Solution:
Port the `noref` argument from Vimscripts `deepcopy()`.
The below benchmark demonstrates the results for two extreme cases of
tables of different sizes. One table that uses the same table lots of
times and one with all unique tables.
| test | `noref=false` (ms) | `noref=true` (ms) |
| -------------------- | ------------------ | ----------------- |
| unique tables (50) | 6.59 | 2.62 |
| shared tables (50) | 3.24 | 6.40 |
| unique tables (2000) | 23381.48 | 2884.53 |
| shared tables (2000) | 3505.54 | 14038.80 |
The results are basically the inverse of each other where `noref` is
much more performance on tables with unique fields, and `not noref` is
more performant on tables that reuse fields.
Problem:
Not all Lua code is checked by stylua. Automating code-style is an
important mechanism for reducing time spent on accidental
(non-essential) complexity.
Solution:
- Enable stylua for entire `test/` directory.
- Exclude these high-churn files until this issue is resolved: https://github.com/JohnnyMorganz/StyLua/issues/829
```
test/functional/ui/decorations_spec.lua | 3560 ++++++++++++++++++++++++++++++++++++----------------
test/functional/ui/float_spec.lua | 5826 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
test/functional/ui/multigrid_spec.lua | 1349 ++++++++++++++------
```
- Make surgical changes to these files (or add `stylua: ignore` in some
small scopes) to improve the result:
```
test/functional/vimscript/msgpack_functions_spec.lua | 1414 +++++++++++++++------
test/functional/api/buffer_spec.lua | 1389 +++++++++++----------
test/functional/api/vim_spec.lua | 2740 +++++++++++++++++++++++-----------------
```
- These "high churn" files are NOT excluded because the changes are
largely an improvement:
```
test/functional/plugin/lsp_spec.lua | 2198 ++++++++++++++++++---------------
test/functional/plugin/shada_spec.lua | 4078 +++++++++++++++++++++++++++++++++++-------------------------
test/functional/ui/cmdline_spec.lua | 1199 +++++++++++-------
test/functional/ui/popupmenu_spec.lua | 1267 +++++++++++--------
test/functional/ui/messages_spec.lua | 1643 +++++++++++++++---------
```
- TODO: how to check "all directories"? With `GLOB_DIRS *` and `/.deps/` (or
`.deps/`) in `.styluaignore`, Lua code in `.deps/` is still checked...
buf_ensure_loaded already checks `(buf->b_ml.ml_mfp != NULL)`. #25823
TODO:
- #10070#13201 All buffer-related API functions except
`nvim_buf_is_loaded` (and `nvim_buf_is_valid`?) should always call
`buf_ensure_loaded`. Because the _common case_ is that plugins expect
the buffer to "just work"—and for the uncomon, performance-sensitive
case, the script can check `nvim_buf_is_loaded` to avoid implicitly
loading a buffer.
- Update documentation to clarify the above semantics.
Since some point INCLUDE_DEPRECATED stopped working as it is usually
turned off when generating an actual vimdoc. This commit fixes this
hidden feature back again (used for devel purposes only).
Problem: main() has too much logic implemented there, too difficult to
read.
Solution: Do more OOP, introduce `Section` dataclass that stores
information about a "section", with documentation and concrete examples
about what each field and variable would mean. Extract all the lines for
rendering a section into `section.render()` pulled out of `main()`.
Problem:
For function definitions to be included in the vimdoc (formatted) and
to be exported as mpack data (unformatted), we had two internal
representations of the same function/API metadata in duplicate;
one is FunctionDoc (which was previously a dict), and the other is
doxygen XML DOM from which vimdoc (functions sections) was generated.
Solution:
We should have a single path and unified data representation
(i.e. FunctionDoc) that contains all the metadata and information about
function APIs, from which both of mpack export and vimdoc are generated.
I.e., vimdocs are no longer generated directly from doxygen XML nodes,
but generated via:
(XML DOM Nodes) ------------> FunctionDoc ------> mpack (unformatted)
Recursive Internal |
Formatting Metadata +---> vimdoc (formatted)
This refactoring eliminates the hacky and ugly use of `fmt_vimhelp` in
`fmt_node_as_vimhelp()` and all other helper functions! This way,
`fmt_node_as_vimhelp()` can simplified as it no longer needs to handle
generating of function docs, which needs to be done only in the topmost
level of recursion.
runtime(dist/ft): improve filetype detection for *.v (V/Verilog/Coq)
Patch provided by Dan Alt
closes: vim/vim#1379310b4f75d4c
Co-authored-by: Christian Brabandt <cb@256bit.org>
runtime(sh): Update sh syntax and add local keyword for bash (vim/vim#13806)
add `local` in shStatement
b16fc98055
Co-authored-by: Lucien Grondin <grondilu@yahoo.fr>
feat(diagnostic): add `vim.diagnostic.count()`
Problem: Getting diagnostic count based on the output of
`vim.diagnostic.get()` might become costly as number of diagnostic
entries grows. This is because it returns a copy of diagnostic cache
entries (so as to not allow users to change them in place).
Getting information about diagnostic count is frequently used in
statusline, so it is important to be as fast as reasonbly possible.
Solution: Add `vim.diagnostic.count()` which computes severity
counts without making copies.
Problem: Commits backport-merged to release branches are cherry-picked
from the original commits in the PR from a fork repository, NOT the
actual commit that are merged to neovim/neovim (HEAD). Therefore the
commit reference in the commit message `cherry picked from commit ...`
usually refers to a commit that does NOT exist in the repository,
given that our preferred way of merging PR (rebasing, squashing, etc.)
would rewrite commits.
Solution: Turn on new feature 'detect_merge_method' of backport-action
workflow.
Adding a file to `OUTPUT` in `add_custom_command` marks that file as
`GENERATED` in cmake, and will thus be removed when running the `clean`
target. As cmake doesn't have a good way to mark that certain files
should not be removed, we instead "lie" to it by omitting the files we
want to keep from `OUTPUT`. This hack only works as long as there aren't
any other files that depend on the generated files we want to keep,
which currently seems to be the case. If this assumption changes in the
future, then we need to separate the parts that are generated and the
parts that are not as to prevent an infinite dependency chain.
Problem: `functional/vimscript/api_functions_spec` skips a test if the
runtime files are not generated, but this check was broken in a
refactor.
Solution: Since runtime files are now generated for all test targets, do
not skip this test.
- Use `#pragma once` for `cmake.config/config.h.in`
- Remove unused variable `CACHED_GENERATED_DIR`
- Reorganize and sort variables
- Introduce `STYLUA_DIRS` variable to ensure the `formatlua` and
`lintlua-stylua` operates on the same files.
- Adjust variable scope to avoid using hacky directory properties.
- Add more necessary runtime files as test dependencies