Commit Graph

1540 Commits

Author SHA1 Message Date
Gregory Anders
b587aff176
fix(health): fix tmux RGB capability detection (#26886) (#26887)
tmux indicates its RGB support via setrgbb and setrgbf. In modern tmux
code, Tc and RGB just set setrgbb and setrgbf, so we can just check for
them.

Link: 7eb496c00c

(cherry picked from commit 88eb0ad149)

Co-authored-by: Tristan Partin <tristan@partin.io>
2024-01-04 18:15:04 -06:00
Tom Blake
ea3966aac9 fix: checkhealth warning even if init.lua exists #25306
Problem:
`:checkhealth nvim` warns about missing vimrc if `init.lua` exists but
`init.vim` does not.

Solution:
Check for any of: init.vim, init.lua, $MYVIMRC.
Fix #25291

Backport of https://github.com/neovim/neovim/pull/25306
2024-01-03 13:47:40 +01:00
dundargoc
3a535ff496 feat(vim.deprecate): only issue warning if neovim version is high enough
As specified by MAINTAIN.md, features should be soft deprecated at first
(meaning no warnings) to give people a chance to adjust. The problem
with this approach is that deprecating a feature becomes harder than
usual as during the soft deprecation period you need to remember not to
issue a warning, and during the hard deprecation period you need to
remember to start issuing a warning.

This behavior is only enforced if the `plugin` parameter is `nil` as
plugins may not want this specific behavior.

(cherry picked from commit 0a598c13b1)
2024-01-03 13:28:47 +01:00
github-actions[bot]
8a4464cd14
[Backport release-0.9] fix: vim.treesitter.get_node() now correctly takes opts.lang (#26382)
[Backport release-0.9] fix(treesitter): allow passing lang to get_node()
2023-12-04 10:03:55 +01:00
Gregory Anders
7f74d9bd77
fix: remove nested for_each_tree in TSTreeView (#26331)
Problem:
`LanguageTree:for_each_tree` calls itself for child nodes, so when we
calls `for_each_tree` inside `for_each_tree`, this quickly leads to
exponential tree calls.

Solution:
Use `pairs(child:trees())` directly in this case, as we don't need the
extra callback for each children, this is already handled from the outer
`for_each_tree` call

(cherry picked from commit 0712a4c085)

Co-authored-by: Pham Huy Hoang <hoangtun0810@gmail.com>
2023-11-30 11:04:49 -06:00
Pham Huy Hoang
753f8bcaab fix: make InspectTree handle nested injection
fixup: Use `TSNode:byte_length` instead
(cherry picked from commit 757bcdda30)
2023-11-29 14:17:14 +00:00
altermo
1413f3a971 fix(lua): correct return value for on_key with no arguments
(cherry picked from commit 3edc8417f0)
2023-11-07 00:33:58 +00:00
Christian Clason
c5edfb16f9 fix(treesitter): foldexpr tweaks
(cherry-picked from 26cc946226)

Co-authored-by: rafikdraoui
2023-10-14 17:07:36 +02:00
zeertzjq
9ee75f4781 fix(lsp): handle NUL bytes in popup text
Fix #25610

(cherry picked from commit 762a9e138b)
2023-10-12 07:40:01 +00:00
Christian Clason
837f64f98a
[backport release-0.9] backport #25464 (#25560)
feat(lsp): fallback to code-action command on resolve failure
2023-10-09 16:39:30 +02:00
Phelipe Teles
3a5b46e6bb fix(lua): not using global value in vim.opt_global 2023-09-17 06:44:43 +08:00
Lewis Russell
68ae7ea529 refactor: rename _meta.lua to _options.lua 2023-09-17 06:44:14 +08:00
L Lllvvuu
f0898d438e [Backport release-0.9] fix(treesitter): language.add - only register parser if it exists
Backport of #25151.

Fixes: #24531
2023-09-15 10:10:37 +02:00
Lewis Russell
f0b1e46f91 fix(treesitter): fixup for InspectTree
Fixes #25120

(cherry picked from commit 040cba1faa)
2023-09-12 14:56:07 +00:00
Lewis Russell
5f8676c268 fix(treesitter): remove more double recursion
Do not call `for_each_child` in functions that are already recursive.

(cherry picked from commit e76ae3d232)
2023-09-12 11:23:31 +00:00
L Lllvvuu
64160bac5b
[Backport release-0.9] 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.

Fixes: #25104
2023-09-12 00:22:30 -07:00
Lewis Russell
3cca5449ac fix(editorconfig): only warn once on errors
(cherry picked from commit f3e8942ce2)
2023-08-27 21:04:32 +00:00
Bogdan Grigoruță
11cb728c35 fix(editorconfig): add missing root validation
(cherry picked from commit a94d35fcde)
2023-08-27 20:35:49 +00:00
Lewis Russell
9f928902c7 fix(editorconfig): do not set 'endofline'
Problem:
  'endofline' can be used to detect if a file ends of <EOL>, however
  editorconfig can break this.

Solution:
  Set 'endofline' during BufWritePre

Fixes: #24869
(cherry picked from commit 84376afc72)
2023-08-27 20:13:39 +00:00
Lewis Russell
ac2dff64a5 fix(treesitter): make sure injections don't return empty ranges (#24595)
When an injection has not set include children, make sure not to add
the injection if no ranges are determined.

This could happen when there is an injection with a child that has the
same range as itself. e.g. consider this Makefile snippet

```make
foo:
  $(VAR)
```

Line 2 has an injection for bash and a make variable reference. If
include-children isn't set (default), then there is no range on line 2
to inject since the variable reference needs to be excluded.

This caused the language tree to return an empty range, which the parser
now interprets to mean the full buffer. This caused makefiles to have
completely broken highlighting.
2023-08-10 18:08:54 +02:00
Sean Dewar
df63474930
fix(lsp): do not assume client capability exists in watchfiles check (#24558)
Backports #24550.

Adjusts test to expect that didChangeWatchedFiles is *not* registered if
client `capabilities` is nil (as it's not enabled by default for v0.9).
2023-08-04 10:16:54 +01:00
Mike
c0c6294123 fix(fs.lua): normalize slash truncation
Preserve last slash in windows' root drive directories

(cherry picked from commit 886996ff74)
2023-07-18 06:36:24 +00:00
github-actions[bot]
b9a513ae11
[Backport release-0.9] fix(fs): make normalize() work with '/' path (#24060)
fix(fs): make `normalize()` work with '/' path

Problem: Current implementation of "remove trailing /" doesn't
account for the case of literal '/' as path.
Solution: Remove trailing / only if it preceded by something else.

(cherry picked from commit 80ff66118a)

Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
2023-06-19 02:01:12 -07:00
github-actions[bot]
0f121fea81
[Backport release-0.9] fix(codelens): add buffer and line checks before displaying codelens (#24014)
fix(codelens): add buffer and line checks before displaying codelens

(cherry picked from commit 928dc33053)

Co-authored-by: Rohit Sukumaran <rohit.sukumaran@kredx.com>
2023-06-13 19:55:00 +02:00
zeertzjq
abed0acf56 fix(remote): restore previous --remote-expr output formatting
- Use tostring() as that's what print() uses internally.
- Do not append trailing new line.

(cherry picked from commit b6d89de60e)
2023-06-11 14:12:51 +00:00
zeertzjq
4dafd5341a fix(remote): make --remote-expr print to stdout
(cherry picked from commit 54a05558e6)
2023-06-11 07:30:08 +00:00
Gregory Anders
d7212c10e2 fix(editorconfig): check that buffer is valid
Fixes: https://github.com/neovim/neovim/issues/23921
(cherry picked from commit 1cf3184f95)
2023-06-05 16:53:33 +00:00
Christian Clason
c8d6d14f71
[Backport release-0.9] fix(treesitter): allow foldexpr without highlights (#23673)
fix(treesitter): allow foldexpr without highlights (#23672)

Ref nvim-treesitter/nvim-treesitter#4748

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-05-21 11:36:18 +02:00
github-actions[bot]
2be8c29406
[Backport release-0.9] fix(lsp): don't register didChangeWatchedFiles when capability not set (#23690)
fix(lsp): don't register didChangeWatchedFiles when capability not set

Some LSP servers (tailwindcss, rome) are known to request registration
for `workspace/didChangeWatchedFiles` even when the corresponding client
capability does not advertise support. This change adds an extra check
in the `client/registerCapability` handler not to start a watch unless
the client capability is set appropriately.

(cherry picked from commit 78510add5b)

Co-authored-by: Jon Huhn <huhnjon@gmail.com>
2023-05-20 08:01:52 +02:00
Christian Clason
17bdaeb79e vim-patch:9.0.1464: strace filetype detection is expensive
Problem:    Strace filetype detection is expensive.
Solution:   Match with a cheap pattern first. (Federico Mengozzi,
            closes vim/vim#12220)

6e5a9f9482

Co-authored-by: Federico Mengozzi <19249682+fedemengo@users.noreply.github.com>
(cherry picked from commit 9808866d57)
2023-05-10 07:05:51 +00:00
github-actions[bot]
1a104253df
[Backport release-0.9] fix(lsp): fix relative patterns for workspace/didChangeWatchedFiles (#23559)
fix(lsp): fix relative patterns for `workspace/didChangeWatchedFiles`

(cherry picked from commit 10f102a3a3)

Co-authored-by: Jon Huhn <huhnjon@gmail.com>
2023-05-09 18:23:22 +02:00
Vadim A. Misbakh-Soloviov
965f817ade fix(man.lua): return support of all sections
Current behaviour of `:Man` is to only work with "number" sections.
This is caused by wrong assumptions about man sections naming.

Also, there was similar assumption about length of section dirs
in `paths` variable.

fixes #23485

Signed-off-by: Vadim Misbakh-Soloviov <git@mva.name>
(cherry picked from commit 209ed16f57)
2023-05-08 08:09:54 +00:00
github-actions[bot]
c3d11208bc
[Backport release-0.9] perf(lsp): load buffer contents once when processing semantic tokens responses (#23505)
perf(lsp): load buffer contents once when processing semantic token responses

Using _get_line_byte_from_position() for each token's boundaries was a
pretty huge bottleneck, since that function would load individual buffer
lines via nvim_buf_get_lines() (plus a lot of extra overhead). So each
token caused two calls to nvim_buf_get_lines() (once for the start
position, and once for the end position).

For semantic tokens, we only attach to buffers that have already been
loaded, so we can safely just get all the lines for the entire buffer at
once, and lift the rest of the _get_line_byte_from_position()
implementation directly while bypassing the part that loads the buffer
line.

While I was looking at get_lines (used by _get_line_byte_from_position),
I noticed that we were checking for non-file URIs before we even looked
to see if we already had the buffer loaded. Moving the buffer-loaded
check to be the first thing done in get_lines() more than halved the
average time spent transforming the token list into highlight ranges vs
when it was still using _get_line_byte_from_position. I ended up
improving that loop more by not using get_lines, but figured the
performance improvement it provided was worth leaving in.

(cherry picked from commit dc38eafab5)

Co-authored-by: John Drouhard <john@drouhard.dev>
2023-05-06 12:10:49 +02:00
github-actions[bot]
fe261706a2
[Backport release-0.9] perf(treesitter): insert/remove items efficiently (#23504)
perf(treesitter): insert/remove items efficiently

(cherry picked from commit c8fdc57b88)

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-05-06 12:10:35 +02:00
github-actions[bot]
1b09bcef52
[Backport release-0.9] fix(treesitter): redraw added/removed injections properly (#23408)
fix(treesitter): redraw added/removed injections properly

When injections are added or removed make sure to:
- invoke 'changedtree' callbacks for when new trees are added.
- invoke 'changedtree' callbacks for when trees are invalidated
- redraw regions when languagetree children are removed

(cherry picked from commit b68157834a)

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-05-06 11:55:51 +02:00
github-actions[bot]
76dd0f81b0
[Backport release-0.9] fix(treesitter): do not calc folds on unloaded buffers (#23440)
fix(treesitter): do not calc folds on unloaded buffers

Fixes #23423

(cherry picked from commit 2e08228a16)

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-05-02 11:23:45 +01:00
github-actions[bot]
98a90abca9
[Backport release-0.9] perf(lsp): process semantic tokens response in a coroutine that yields every 5ms (#23414)
perf(lsp): process semantic tokens response in a coroutine that yields every 5ms

(cherry picked from commit 46cd1d957c)

Co-authored-by: John Drouhard <john@drouhard.dev>
2023-05-01 07:27:44 +02:00
Justin M. Keyes
127a483142 refactor(lua): simplify vim.gsplit impl
(cherry picked from commit 824766612d)
2023-04-21 12:05:39 +00:00
Justin M. Keyes
2363d44d5a fix(lua): vim.split may trim inner empty items
Problem:
`vim.split('a:::', ':', {trimempty=true})` trims inner empty items.
Regression from 9c49c10470

Solution:
Set `empty_start=false` when first non-empty item is found.
close #23212

(cherry picked from commit 622b1ae38a)
2023-04-21 12:05:39 +00:00
dundargoc
df3982e704
feat(checkhealth): add shims for health functions (#23241)
This is for plugins wanting to support many versions of neovim.
2023-04-21 13:39:03 +02:00
github-actions[bot]
ef7513c87f
[Backport release-0.9] fix(treesitter playground): fix the wrong range of a node displayed i… (#23220)
fix(treesitter playground): wrong range of a node displayed in playground

The call parameters order of the function `get_range_str` is flipped for the last two arguments compared to the declaration.

(cherry picked from commit 8613ba118c)

Co-authored-by: William <50717946+BIKA-C@users.noreply.github.com>
2023-04-20 18:30:56 +02:00
github-actions[bot]
a41930bcf0
[Backport release-0.9] fix(watchfiles): skip Created events when poll starts (#23197)
fix(watchfiles): skip Created events when poll starts

(cherry picked from commit 8ca1bae217)

Co-authored-by: Jon Huhn <huhnjon@gmail.com>
2023-04-19 16:55:06 +02:00
github-actions[bot]
535d8553c4
[Backport release-0.9] fix(loader): reset hashes when running the loader (#23181)
fix(loader): only keep hashes for the current loop iteration

(cherry picked from commit e12cfa567f)

Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-04-18 17:08:45 +02:00
Raphael
79ee63bc36 fix(lua): inspect_pos respect bufnr when get syntax info
(cherry picked from commit ee4d1f9c52)
2023-04-16 09:50:49 +00:00
github-actions[bot]
702621f058
[Backport release-0.9] fix(treesitter): Use the correct replacement args for #gsub! directive (#23018)
fix(treesitter): use the correct replacement args for #gsub! directive

(cherry picked from commit 07db1f7432)

Co-authored-by: scottming <therealscottming@gmail.com>
2023-04-11 10:40:43 +02:00
zeertzjq
14e3936871 fix(man.lua): don't continue on command error
Fix #21169

(cherry picked from commit 43648ebb69)
2023-04-11 01:35:19 +00:00
Lewis Russell
e29bc03c04
fix(treesitter): do not track ranges of the root tree (#22912)
Fixes #22911
2023-04-06 15:16:44 +01:00
Lewis Russell
34ac75b329
refactor: rename local API alias from a to api
Problem:
  Codebase inconsistently binds vim.api onto a or api.

Solution:
  Use api everywhere. a as an identifier is too short to have at the
  module level.
2023-04-05 17:19:53 +01:00
Michal Liszcz
999cb36c2b
refactor(lsp): do not parse verbose output when overwriting options (#22810) 2023-04-05 14:02:08 +02:00
dundargoc
e826d09c18
fix(windows): consistent normalization in fs.find
vim.fs.find(".luacheckrc")

```
c:\\projects\\neovim/.luacheckrc # before

c:/projects/neovim/.luacheckrc   # after
```

Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
2023-04-04 23:37:46 +02:00