Commit Graph

5958 Commits

Author SHA1 Message Date
Lewis Russell
7a76fb8547 fix(treesitter): remove more double recursion
Do not call `for_each_child` in functions that are already recursive.
2023-09-12 12:21:42 +01:00
bfredl
b04286a187 feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions

The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.

Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).

Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.

Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2023-09-12 10:38:23 +02:00
L Lllvvuu
6b5f44817e fix(languagetree): remove double recursion in LanguageTree:parse
`LanguageTree:parse` is recursive, and calls
`LanguageTree:for_each_child`, which is also recursive.

That means that, starting from the third level (child of child of root),
nodes will be parsed twice.

Which then means that if the tree is N layers deep, there will be ~2^N
parses even if the branching factor is 1.

Now, why was the tree deepening with each character inserted? And why
did this only regress in #24647? These are mysteries for another time.

Fixes: #25104
2023-09-12 09:12:53 +02:00
Christian Clason
a9369e4b65 vim-patch:62145db91b10
syntax(i3config): improved i3config highlighting (vim/vim#13054)

62145db91b

Co-authored-by: Josef Litoš <54900518+JosefLitos@users.noreply.github.com>
2023-09-12 08:19:22 +02:00
zeertzjq
aab06edc63
vim-patch:f787ee8451a1 (#25103)
runtime(doc): Add g:c_syntax_for_h to filetype-overrule docs

closes: vim/vim#13074

f787ee8451

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-09-12 07:48:40 +08:00
zeertzjq
4b6023be7c
vim-patch:596ad66d1ddb (#25102)
runtime(doc): documentation updates

This is a collection of various improvements to the help pages

closes vim/vim#12790

596ad66d1d

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Houl <anwoku@yahoo.de>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl>
2023-09-12 07:37:05 +08:00
Jaehwang Jung
65738202f8
fix(decorations): better approximation of botline #24794
Problem:
* The guessed botline might be smaller than the actual botline e.g. when
  there are folds and the user is typing in insert mode. This may result
  in incorrect treesitter highlights for injections.
* botline can be larger than the last line number of the buffer, which
  results in errors when placing extmarks.

Solution:
* Take a more conservative approximation. I am not sure if it is
  sufficient to guarantee correctness, but it seems to be good enough
  for the case mentioned above.
* Clamp it to the last line number.

Co-authored-by: Lewis Russell <me@lewisr.dev>
2023-09-11 12:29:39 -07:00
bfredl
616a9bac32
Merge pull request #24901 from faergeek/more-intuitive-cursor-update
fix(api): more intuitive cursor updates in nvim_buf_set_text
2023-09-11 10:45:45 +02:00
Christian Clason
60e5d0fbcc vim-patch:9.0.1891: No runtime support for Mojo
Problem:  No runtime support for Mojo
Solution: Add basic filetype and syntax plugins

closes: vim/vim#13062
closes: vim/vim#13063

0ce2c594d0

Co-authored-by: Mahmoud Abduljawad <mahmoud@masaar.com>
2023-09-11 10:05:54 +02:00
Christian Clason
60a39ada1b vim-patch:e7833e73471a
runtime(masm): add support for AVX-2 and AVX-512 (vim/vim#13061)

e7833e7347

Co-authored-by: Wu Yongwei <wuyongwei@gmail.com>
2023-09-11 10:05:54 +02:00
Christian Clason
ba1db8751c vim-patch:066103307534
runtime(scala): Fix Scala highlighting string literal as type param (vim/vim#13070)

Since https://docs.scala-lang.org/sips/42.type.html which is implemented
in Scala 2.13 and in Scala 3 it possible to use string literals as
singleton types. So code like
```
someFunc["abc"]
```
is valid. Currently this code is not hightlighted correctly and worse if
there is an unclosed `(` in the string it breaks the formating in the
rest of the file.

I also submitted this patch to the mentioned project for this runtime
file: https://github.com/derekwyatt/vim-scala/pull/173 But there are no
commits there over the last 2 years and no response in the week since I
created it. Also the last change to the Scala syntax file:
https://github.com/vim/vim/pull/9594 is yet to be backported to that
repo. Therefore I am opening this PR as well to get some feedback on how
to proceed to get this fixed.

0661033075

Co-authored-by: Emil Ejbyfeldt <eejbyfeldt@liveintent.com>
2023-09-11 10:05:54 +02:00
Sergey Slipchenko
d22172f36b
fix(api): more intuitive cursor updates in nvim_buf_set_text
Fixes #22526
2023-09-11 08:16:03 +04:00
bfredl
59d9f2413b
Merge pull request #25071 from bfredl/coxpcall
build(lua): vendor coxpcall
2023-09-10 12:35:32 +02:00
Christian Clason
1027b2881a vim-patch:733bbcde776e
runtime(nasm): updated syntax file

733bbcde77

Co-authored-by: Andrii Sokolov <andriy145@gmail.com>
2023-09-10 11:52:48 +02:00
bfredl
25e51d393a build(lua): vendor coxpcall
Do not require luarocks on PUC lua CI just because of this single lua file
2023-09-10 11:43:37 +02:00
Grace Petryk
5e3cf9fb4b
feat(lsp): improve control over placement of floating windows (#24494) 2023-09-10 10:02:23 +02:00
bfredl
d4e80a051e
Merge pull request #25039 from glepnir/fix_hl
fix(highlight): add create param in nvim_get_hl api function
2023-09-09 13:01:40 +02:00
zeertzjq
b9d9cd7742 vim-patch:partial:9.0.1886: Various Typos
Problem:  Various Typos
Solution: Fix Typos

This is a collection of typo related commits.

closes: vim/vim#12753
closes: vim/vim#13016

ee17b6f70d

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl>
Co-authored-by: Viktor Szépe <viktor@szepe.net>
Co-authored-by: nuid64 <lvkuzvesov@proton.me>
Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com>
Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
2023-09-09 17:58:32 +08:00
glepnir
8afb3a49c0 fix(highlight): add create param in nvim_get_hl 2023-09-09 17:15:58 +08:00
Christian Clason
294ded9cf2 vim-patch:86cfb39030eb
runtime(tohtml): Update TOhtml to version 9.0v2 (vim/vim#13050)

Modified behavior:
  - Change default value of g:html_use_input_for_pc from "fallback" to
    "none". This means with default settings, only the standards-based
    method to make special text unselectable is used. The old method
    relying on unspecified browser behavior for <input> tags is now only
    used if a user specifically enables it.
  - Officially deprecate g:use_xhtml option (in favor of
    g:html_use_xhtml) by issuing a warning message when used.

Bugfixes:
  - Fix issue vim/vim#8547: LineNr and other special highlight groups did not
    get proper style rules defined when using "hi link".
  - Fix that diff filler was not properly added for deleted lines at the
    end of a buffer.

Other:
  - Refactored function definitions from long lists of strings to use
    :let-heredoc variable assignment instead.
  - Corrected deprecated "." string concatenation operator to ".."
    operator in more places.

86cfb39030

Co-authored-by: fritzophrenic <fritzophrenic@gmail.com>
2023-09-09 08:29:50 +02:00
Christian Clason
0bee75818e vim-patch:4e554d282c50
runtime(perl): Update ftplugin and indent files (vim/vim#13052)

4e554d282c

Co-authored-by: dkearns <dougkearns@gmail.com>
2023-09-09 08:29:50 +02:00
zeertzjq
d0d4160dd1
feat(runtime): highlight hl groups in syntax.txt (#25050)
- Add runtime/lua/vim/vimhelp.lua, which is a translation of Vim's
  runtime/import/dist/vimhelp.vim.
- Unlike Vim, run the highlighting from an ftplugin file instead of a
  syntax file, so that it is run even if using treesitter.
2023-09-08 21:05:35 +08:00
Tom Praschan
131a1ee82d
feat(lsp): add original LSP Location as item's user_data in locations_to_items (#23743) 2023-09-07 10:12:02 +02:00
Christian Clason
ec753cf40d vim-patch:f7ac0ef50988
runtime: don't execute external commands when loading ftplugins

This is a followup to 816fbcc262687b81fc46f82f7bbeb1453addfe0c (patch
9.0.1833: [security] runtime file fixes)

It basically disables that external commands are run on loading of the
filetype plugin, **unless** the user has set the `g:plugin_exec = 1`
global variable in their configuration or for a specific filetype the
variable g:<filetype>_exec=1.

There are a few more plugins, that may execute system commands like
debchangelog, gitcommit, sh, racket, zsh, ps1 but those do at least
do not run those commands by default during loading of the filetype plugin
(there the command is mostly run as convenience for auto-completion or
to provide documentation lookup).

closes: vim/vim#13034

f7ac0ef509

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Tim Pope <vim@tpope.org>
2023-09-07 09:06:35 +02:00
Christian Clason
5d1c1da3c9 vim-patch:67c951df4c95
runtime(ftplugin): allow to exec if curdir is in PATH

In case the current directory is present as valid $PATH entry, it is OK
to call the program from it, even if vim curdir is in that same
directory.

(Without that patch, for instance, you will not be able to open .zip
files while your current directory is /bin)

closes: vim/vim#13027

67c951df4c

Co-authored-by: Anton Sharonov <anton.sharonov@gmail.com>
2023-09-07 09:06:35 +02:00
Evgeni Chasnovski
d272143318
fix(diagnostic): always return copies of diagnostic items (#25010) 2023-09-06 12:54:18 -05:00
Lewis Russell
be8b15200d fix: windows timeouts have exit code 1 2023-09-05 17:10:04 +01:00
Lewis Russell
80d1333b73 refactor(vim.system): factor out on_exit handling 2023-09-05 17:10:04 +01:00
Lewis Russell
6d5f12efd2 fix(vim.system): make timeout work properly
Mimic the behaviour of timeout(1) from coreutils.
2023-09-05 17:10:01 +01:00
Lewis Russell
a44521f46e fix(vim.system): let on_exit handle cleanup after kill
Fixes #25000
2023-09-05 10:18:26 +01:00
Christian Clason
6abc608445 vim-patch:282a94be990f
runtime: Fix problem of checking wrong cwd for ruby ftplugin (vim/vim#13026)

282a94be99

Co-authored-by: Anton Sharonov (ant0sha) <109120102+ant0sha@users.noreply.github.com>
Co-authored-by: Anton Sharonov <anton.sharonov@gmail.com>
2023-09-05 08:48:47 +02:00
Christian Clason
109ff0a73f vim-patch:3170342af304
runtime(php): Update the php indent script to the 1.75 (from 1.70) (vim/vim#13025)

Changes:

1.75:
- Fix 2072/PHP-Indenting-for-VImvim/vim#87: The indent optimization was causing wrong indentation of lines
  preceded by a line ending with '}' when preceded by non white characters.
- Fix long standing non-reported regex escaping issue in cleaning end of line
  comments function. This should help fixing some other unreported issues when
  parts of codes are commented out at ends of lines...

1.74:
- Fix 2072/PHP-Indenting-for-VImvim/vim#86: Add support for `match` expression.

1.73:
- Fix 2072/PHP-Indenting-for-VImvim/vim#77 where multi line strings and true/false keywords at beginning of a
  line would cause indentation failures.

1.72:
- Fix vim/vimvim/vim#5722 where it was reported that the option PHP_BracesAtCodeLevel
  had not been working for the last 6 years.

1.71:
- Fix 2072/PHP-Indenting-for-VImvim/vim#75 where the indent script would hang on some multi-line quoted strings.

3170342af3

Co-authored-by: John Wellesz <john.wellesz@gmail.com>
2023-09-05 08:48:47 +02:00
dundargoc
54d357dce0
build: bump lpeg to 1.1.0 (#25016)
Release notes indicates it has better UTF8 handling which is relevant
for us.
2023-09-04 22:42:47 +02:00
zeertzjq
c431d820e7
vim-patch:9.0.1856: issues with formatting positional arguments (#25013)
Problem:  issues with formatting positional arguments
Solution: fix them, add tests and documentation

closes: vim/vim#12140
closes: vim/vim#12985

Tentatively fix message_test. Check NULL ptr.

aa90d4f031

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-09-04 08:49:50 +08:00
Christian Clason
4ea4d72af8 docs(luv): correct uv.spawn options.args docs about the first argument
045bf29b6f
2023-09-02 16:58:19 +02:00
Christian Clason
f02bfb6a2a vim-patch:acb91d3905cf
runtime(zserio): add zserio syntax (vim/vim#13005)

acb91d3905

Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
2023-09-02 11:08:29 +02:00
Christian Clason
61ccdb2db6 vim-patch:da16a1b471aa
runtime(ruby): Update syntax, indent and ftplugin files

While making changes to the ruby ftplugin, slightly change the exepath()
conditional from patch 9.0.1833 and move it after the :cd invocation.

closes: 12981
closes: 12994

da16a1b471

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Co-authored-by: Tim Pope <code@tpope.net>
2023-09-02 11:08:29 +02:00
TheBlob42
597355deae
fix(lsp): wrong iterator in registerCapability handler (#24971) 2023-09-01 13:31:05 +02:00
zeertzjq
7bf0963d48
vim-patch:9.0.1833: [security] runtime file fixes (#24969)
Problem:  runtime files may execute code in current dir
Solution: only execute, if not run from current directory

The perl, zig and ruby filetype plugins and the zip and gzip autoload
plugins may try to load malicious executable files from the current
working directory.  This is especially a problem on windows, where the
current directory is implicitly in your $PATH and windows may even run a
file with the extension `.bat` because of $PATHEXT.

So make sure that we are not trying to execute a file from the current
directory. If this would be the case, error out (for the zip and gzip)
plugins or silently do not run those commands (for the ftplugins).

This assumes, that only the current working directory is bad. For all
other directories, it is assumed that those directories were
intentionally set to the $PATH by the user.

816fbcc262

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-01 11:38:31 +08:00
Amaan Qureshi
845d5b8b64 feat(treesitter): improve query error message 2023-08-31 13:33:40 +01:00
Christian Clason
4afd33e69f vim-patch:0b8b145bf8bf
runtime(optwin): Fix for 'splitkeep' option (vim/vim#12974)

'spk' was used as a boolean, rather than a string option.

0b8b145bf8

Co-authored-by: xrandomname <141588647+xrandomname@users.noreply.github.com>
2023-08-31 10:58:54 +02:00
Christian Clason
2fad4c0b39 vim-patch:1610528cc305
runtime(forth): Update syntax and ftplugin files (vim/vim#12976)

1610528cc3

Co-authored-by: dkearns <dougkearns@gmail.com>
2023-08-31 10:58:54 +02:00
Jongwook Choi
0e7e25af20
refactor(lsp): add type annotation for lsp.Client.server_capabilities (#24925)
The class `lsp.Client` has a public member `server_capabilities`,
which is assumed to be non-nil once initialized, as documented in
`:help vim.lsp.client`. Due to the possibility that it may be nil
before initialization, `lsp.Client` was not having a proper lua type
annotations on the field `server_capabilities`.

Instead of having a nil `server_capabilities` until initialized in
the RPC response callback, we can have an initial value of empty table.
This CHANGES the behavior of the `server_capabilities` field in a way
that it is no longer `nil` until initialization. Note that, as
already documented, `server_capabilities` should never be nil when
it is once initialized and thus ready to be used in user configs.
2023-08-31 10:14:20 +02:00
Chris AtLee
c235959fd9
fix(lsp): only disable inlay hints / diagnostics if no other clients are connected (#24535)
This fixes the issue where the LspNotify handlers for inlay_hint /
diagnostics would end up refreshing all attached clients.

The handler would call util._refresh, which called
vim.lsp.buf_request, which calls the method on all attached clients.

Now util._refresh takes an optional client_id parameter, which is used
to specify a specific client to update.

This commit also fixes util._refresh's handling of the `only_visible`
flag. Previously if `only_visible` was false, two requests would be made
to the server: one for the visible region, and one for the entire file.

Co-authored-by: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com>
Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2023-08-31 10:00:24 +02:00
David Moberg
67fba9affa
fix(runtime/tutor): don't try to close fold when there is none (#24953)
Problem: When double clicking a line starting with a #, the code assumes
there is a fold there and tries to close it, resulting in an error if
there isn't a fold.
Solution: Check foldlevel before performing "zc".
2023-08-31 09:18:39 +08:00
zeertzjq
5d49542b56
vim-patch:9.0.1820: Rexx files may not be recognised (#24956)
Problem:  Rexx files may not be recognised
Solution: Add shebang detection and improve disambiguation of *.cls
	  files

closes: vim/vim#12951

e06afb7860

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 08:20:00 +08:00
zeertzjq
7914881356
vim-patch:9.0.1797: Vimball/Visual Basic filetype detection conflict (#24947)
Problem:  Vimball/Visual Basic filetype detection conflict
Solution: runtime(vb): Improve Vimball and Visual Basic detection logic

Only run Vimball Archiver's BufEnter autocommand on Vimball archives.
Fixes vim/vim#2694.

closes: vim/vim#12899

f97f6bbf56

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 07:44:33 +08:00
zeertzjq
6463116818
vim-patch:9.0.1807: runtime: crystal scripts not recognised (#24949)
Problem:  runtime: crystal scripts not recognised
Solution: Filetype detect Crystal scripts by shebang line

closes: vim/vim#12935

9b73902dbe

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 04:38:28 +08:00
zeertzjq
497cf996eb
vim-patch:9.0.1803: runtime(filetype): Add norg language detection (#24948)
runtime(filetype): Add norg markup language detection

closes: vim/vim#12913

03e44a1d70

Co-authored-by: NTBBloodbath <bloodbathalchemist@protonmail.com>
2023-08-31 04:38:01 +08:00
Christian Clason
b2c3e9c72e vim-patch:9d8ef7cc4340
runtime: cleanup :Sman command via the undo_ftplugin mechanism (vim/vim#12967)

Regards to @dkearns as noticed in
2ac708b548

9d8ef7cc43

Co-authored-by: Enno <Konfekt@users.noreply.github.com>
2023-08-30 18:46:52 +02:00