Commit Graph

27906 Commits

Author SHA1 Message Date
dundargoc
cc38086039
docs: small fixes (#26243)
Co-authored-by: umlx5h <umlx5h21@protonmail.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Evan Farrar <evan@evanfarrar.com>
2023-12-06 08:04:21 +08:00
zeertzjq
06ff540e1c
vim-patch:9.0.2151: 'breakindent' is not drawn after diff filler lines (#26412)
Problem:  'breakindent' is not drawn after diff filler lines.
Solution: Correct check for whether 'breakindent' should be drawn.

closes: vim/vim#13624

588f20dece

Cherry-pick Test_diff_with_syntax() change from patch 9.0.1257.
2023-12-06 07:16:02 +08:00
zeertzjq
4a1abc91a0
vim-patch:2103a56eab5a (#26411)
runtime(doc): remove non-existent parameter in shift-command (vim/vim#13626)

The variant with the {count} parameter is explained in the next item.

2103a56eab

N/A patches:
vim-patch:9.0.2150: Using int for errbuflen in option funcs
vim-patch:3f7855a6123c

Co-authored-by: Roy Orbitson <Roy-Orbison@users.noreply.github.com>
2023-12-06 06:44:37 +08:00
Justin M. Keyes
27501d3b6a
test: fileio_spec is unreliable/flaky #26404
Problem:
CI sometimes fails. Something is triggering an extra fsync().

    FAILED   test/functional/core/fileio_spec.lua @ 52: fileio fsync() codepaths #8304
    test/functional/core/fileio_spec.lua:87: Expected objects to be the same.
    Passed in:
    (number) 3
    Expected:
    (number) 2
    stack traceback:
            test/functional/core/fileio_spec.lua:87: in function <test/functional/core/fileio_spec.lua:52>

Solution:
Relax the assertion to `fsync >= 2` instead of exactly 2.

(Note this is not a behavior change: the next assertion has always
checked `fsync == 4`, it's just that the intermediate 3rd fsync was
never explicitly asserted.)
2023-12-05 12:52:06 -08:00
bfredl
ca4fe083e5
Merge pull request #26361 from luukvbaal/invalid
fix(extmarks): restore old position before revalidating
2023-12-05 16:13:39 +01:00
zeertzjq
1457272726
refactor(IWYU): move marktree types to marktree_defs.h (#26402) 2023-12-05 20:05:12 +08:00
Riccardo Mazzarini
0b74ad0a64
refactor(api): complete conversion from Dictionary to Dict(opts) (#26365) 2023-12-05 19:33:57 +08:00
dundargoc
32c8f951bb ci: use the latest stylua version
Using `jq` is not needed as github provides a "latest" shortcut to do
what download the latest release.
2023-12-05 09:43:06 +00:00
Christian Clason
c9828200ac vim-patch:9.0.2148: Vim does not detect pacman.log file
Problem:  Vim does not detect pacman.log file
Solution: Detect pacmanlogs and add syntax highlighting

pacman.log is a filetype common to Arch Liux and related distributions.
Add some simple syntax highlighting for the pacmanlog filetype.

closes: vim/vim#13618

1e5d66408e

Co-authored-by: Ronan Pigott <ronan@rjp.ie>
2023-12-05 09:45:13 +01:00
Jaehwang Jung
3159a2c28f
fix(change): update fold after on_bytes (#26364)
Problem:
With vim.treesitter.foldexpr, `o`-ing two lines above a folded region
opens the fold. This does not happen with legacy foldexprs. For example,
make a markdown file with the following text (without indentation),
enable treesitter fold, and follow the instruction in the text.

    put cursor on this line and type zoo<Esc>
    initially folded, revealed by zo
    # then this fold will be opened
    initially folded, revealed by o<Esc>

Analysis:
* `o` updates folds first (done in `changed_lines`), evaluating
  foldexpr, and then invokes `on_bytes` (done in `extmark_splice`).
* Treesitter fold allocates the foldinfo for added lines (`add_range`)
  on `on_bytes`.
* Therefore, when treesitter foldexpr is invoked while running `o`, it
  sees outdated foldinfo.

Solution:
`extmark_splice`, and then `changed_lines`. This seems to be the
standard order in other places, e.g., `nvim_buf_set_lines`.
2023-12-05 08:40:48 +08:00
Justin M. Keyes
c3836e40a2
build: enable lintlua for test/unit/ dir #26396
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 lintlua for `test/unit/` directory.
- TODO: only `test/functional/` remains unchecked.

previous: 45fe4d11ad
previous: 517f0cc634
2023-12-04 14:32:39 -08:00
Justin M. Keyes
45fe4d11ad
build: enable lintlua for src/ dir #26395
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 lintlua for `src/` directory.

followup to 517f0cc634
2023-12-04 13:31:57 -08:00
Justin M. Keyes
517f0cc634
build: enable lintlua for scripts/ dir #26391
Problem:
We don't enable stylua for many Lua scripts. Automating code-style is an
important tool for reducing time spent on accidental (non-essential)
complexity.

Solution:
- Enable lintlua for `scripts/` directory.
- Specify `call_parentheses = "Input"`, we should allow kwargs-style
  function invocations.
2023-12-04 12:38:31 -08:00
dundargoc
e5d7003b02
build: rework formatting to use add_glob_target
This will ensure that we can pass flags and make adjustments from the
top level cmake file instead of digging through the cmake directory.
More importantly, this will only format files that have been changed.
This has a slightly higher initial cost compared to previous solution as
all files must be initially formatted, but the gained speed up should
more than make up for it quickly.

`make formatlua` is always run due to a quirk of stylua of always changing
modification time of the file regardless if there were any changes. This is not
a major blocker as stylua is very fast.
2023-12-04 20:21:38 +01:00
zeertzjq
66f1563c7a
refactor(terminal): only remove const qualifier when necessary (#26386) 2023-12-04 20:29:51 +08:00
Jongwook Choi
cf612c64b0
fix(treesitter): allow passing lang to vim.treesitter.get_node() now correctly takes opts.lang (#26360)
PROBLEM: `vim.treesitter.get_node()` does not recognize the `lang` in
the option table. This option was used in somewhere else, for instance,
`vim.treesitter.dev` (for `inspect_tree`) but was never implemented.

SOLUTION: Make `get_node()` correctly use `opts.lang` when getting a
treesitter parser.
2023-12-04 10:00:49 +01:00
Raphael
589f4761ee
refactor(completion): use an inline function to free cptext (#26380) 2023-12-04 15:49:31 +08:00
zeertzjq
5651c1ff27
vim-patch:9.0.2145: wrong scrolling in insert mode with smoothscroll (#26375)
Problem:  Wrong scrolling in Insert mode with 'smoothscroll' at the
          bottom of the window.
Solution: Don't use set_topline() when 'smoothscroll' is set.

fixes: vim/vim#13612
closes: vim/vim#13613

5b4d1fcbf0
2023-12-04 06:42:47 +08:00
Christian Clason
988b472d90
feat(treesitter): highlight help files by default (#26347) 2023-12-03 15:58:27 +01:00
zeertzjq
0d885247b0
Merge pull request #26334 from echasnovski/default-colorscheme
feat(highlight): update default color scheme
2023-12-03 11:59:00 +08:00
dundargoc
481a315886 refactor: remove unused file ringbuf.h 2023-12-02 19:02:20 +01:00
Evgeni Chasnovski
64a14026d7
feat(highlight): update default color scheme
Problem: Default color scheme is suboptimal.

Solution: Start using new color scheme. Introduce new `vim` color scheme
for opt-in backward compatibility.

------
Main design ideas
- Be "Neovim branded".
- Be minimal for 256 colors with a bit more shades for true colors.
- Be accessible through high enough contrast ratios.
- Be suitable for dark and light backgrounds via exchange of dark and
  light palettes.

------
Palettes

- Have dark and light variants. Implemented through exporeted
  `NvimDark*` and `NvimLight*` hex colors.

- Palettes have 4 shades of grey for UI elements and 6 colors (red,
  yellow, green, cyan, blue, magenta).

- Actual values are computed procedurally in Oklch color space based on
  a handful of hyperparameters.

- Each color has a 256 colors variant with perceptually closest color.

------
Highlight groups

Use:

- Grey shades for general UI according to their design.

- Bold text for keywords (`Statement` highlight group). This is an
  important choice to increase accessibility for people with color
  deficiencies, as it doesn't rely on actual color.

- Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some
  minor text UI elements.

- Cyan as main syntax color, i.e. for function usage (`Function`
  highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI
  elements.

- Red to generally mean high user attention, i.e. errors; in particular
  for `ErrorMsg`, `DiffDelete`, `DiagnosticError`.

- Yellow very sparingly only with true colors to mean mild user
  attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`.

- Blue very sparingly only with true colors as `DiagnosticHint` and some
  additional important syntax group (like `Identifier`).

- Magenta very carefully (if at all).

------
Notes

- To make tests work without relatively larege updates, each one is
  prepended with an equivalent of the call `:colorscheme vim`.

  Plus some tests which spawn new Neovim instances also now use 'vim'
  color scheme.

  In some cases tests are updated to fit new default color scheme.
2023-12-02 18:53:19 +02:00
José Luis Lafuente
17f3a3ae31 build(nix): update flake.lock
Flake lock file updates:
• Updated input 'flake-utils':
    'github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef' (2023-05-31)
  → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/a64b73e07d4aa65cfcbda29ecf78eaf9e72e44bd' (2023-06-08)
  → 'github:nixos/nixpkgs/e92039b55bcd58469325ded85d4f58dd5a4eaf58' (2023-11-29)
2023-12-02 12:50:15 +01:00
Luuk van Baal
1cc358aed6 fix(extmarks): restore old position before revalidating 2023-12-02 12:35:52 +01:00
zeertzjq
c45d1e32a9
Merge pull request #26358 from zeertzjq/vim-9.0.2140
vim-patch:9.0.{2140,2141,2142,2143}
2023-12-02 10:56:40 +08:00
zeertzjq
9d7544ac4c vim-patch:9.0.2143: [security]: buffer-overflow in ex_substitute
Problem:  [security]: buffer-overflow in ex_substitute
Solution: clear memory after allocating

When allocating the new_start pointer in ex_substitute() the memory
pointer points to some garbage that the following for loop in
ex_cmds.c:4743 confuses and causes it to accessing the new_start pointer
beyond it's size, leading to a buffer-overlow.

So fix this by using alloc_clear() instead of alloc(), which will
clear the memory by NUL and therefore cause the loop to terminate
correctly.

Reported by @henices, thanks!

closes: vim/vim#13596

abfa13ebe9

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
9cc346119b vim-patch:9.0.2142: [security]: stack-buffer-overflow in option callback functions
Problem:  [security]: stack-buffer-overflow in option callback functions
Solution: pass size of errbuf down the call stack, use snprintf()
          instead of sprintf()

We pass the error buffer down to the option callback functions, but in
some parts of the code, we simply use sprintf(buf) to write into the error
buffer, which can overflow.

So let's pass down the length of the error buffer and use sprintf(buf, size)
instead.

Reported by @henices, thanks!

b39b240c38

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
01edcd6db8 vim-patch:9.0.2141: [security]: buffer-overflow in suggest_trie_walk
Problem:  [security]: buffer-overflow in suggest_trie_walk
Solution: Check n before using it as index into byts array

Basically, n as an index into the byts array, can point to beyond the byts
array. So let's double check, that n is within the expected range after
incrementing it from sp->ts_curi and bail out if it would be invalid.

Reported by @henices, thanks!

0fb375aae6

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
7402655132 vim-patch:9.0.2140: [security]: use-after-free in win-enter
Problem:  [security]: use-after-free in win-enter
Solution: validate window pointer before calling win_enter()

win_goto() may stop visual mode, if it is active. However, this may in
turn trigger the ModeChanged autocommand, which could potentially free
the wp pointer which was valid before now became stale and points to now
freed memory.

So before calling win_enter(), let's verify one more time, that the
wp pointer still points to a valid window structure.

Reported by @henices, thanks!

eec0c2b3a4

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 10:41:31 +08:00
zeertzjq
387c5ba3de
revert: "memory: Free buffers after freeing variables" (#26356)
This reverts commit fe30d8ccef.

The original commit intends to prevent heap-use-after-free with EXITFREE
caused by changedtick_di, which is no longer a problem.

Freeing buffers after freeing variables will cause heap-use-after-free
with EXITFREE when a partial is used as prompt callback.
2023-12-02 09:55:11 +08:00
zeertzjq
fedbf32250
vim-patch:9.0.2139: html.angular ft is problematic (#26357)
Problem:  html.angular ft is problematic
Solution: partly revert v9.0.2137

The html.angular filetype causes issues and does not trigger FileType
autocommands for the html or angular filetypes.

So let's roll back that particular change and detect this only as html
file

related: https://github.com/vim/vim/pull/13594#issuecomment-1834465890

closes: vim/vim#13604

4f3480c943

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 09:42:16 +08:00
zeertzjq
f6e5366d00
refactor: free more reachable memory with EXITFREE (#26349)
Discovered using __sanitizer_print_memory_profile().
2023-12-02 07:55:44 +08:00
dundargoc
983defd284 refactor: remove kbtree.h 2023-12-01 20:46:07 +01:00
dundargoc
c58b2ee58e refactor: remove SIZEOF_INT check
I have not seen any indication that this is a problem tha can occur with
cmake.
2023-12-01 19:44:40 +01:00
dundargoc
ce6fefbab9 ci: create setup action
This deduplicates common operations.
2023-12-01 16:59:23 +01:00
zeertzjq
76a30f2bd0
refactor: move float_relative_str[] to nvim_win_get_config() (#26344)
It's only used in one place, as it's usually conveyed as non-string.
2023-12-01 16:37:09 +08:00
zeertzjq
548f03c66c
refactor: change event_create() to a macro (#26343)
A varargs functions can never be inlined, so a macro is faster.
2023-12-01 15:22:22 +08:00
zeertzjq
130cb4815a
fix(api): use a conditional stack for nvim_cmd (#26341) 2023-12-01 13:56:04 +08:00
zeertzjq
0bbe8e7fc2
refactor(IWYU): fix includes for highlight_group.h (#26340) 2023-12-01 09:38:04 +08:00
zeertzjq
09e93d7c4d
refactor(IWYU): create {ex_getln,rbuffer,os/fileio}_defs.h (#26338) 2023-12-01 08:06:37 +08:00
Gregory Anders
b32b5b2711
fix: use BEL to terminate OSC 11 request (#26335) 2023-11-30 16:17:38 -06:00
Gregory Anders
5e1ff4302f
Merge pull request #25870 from dundargoc/build/libtermkey
build: vendor libtermkey
2023-11-30 13:56:54 -06:00
Gregory Anders
5d3562d810 docs: update MAINTAIN.md 2023-11-30 13:50:51 -06:00
Gregory Anders
50f5864dd2 fix(termkey): include IO header on Windows 2023-11-30 12:22:53 -06:00
Gregory Anders
5999214c24 fix(termkey): accept BEL (0x07) as OSC terminator 2023-11-30 12:02:10 -06:00
Gregory Anders
ce2f770aaa fix(termkey): do not sign extend mode value 2023-11-30 12:02:10 -06:00
dundargoc
404043e74c build: vendor libtermkey
This is a proof of concept/WIP to evaluate the viability of vendoring
libtermkey as it's been deprecated.
2023-11-30 12:02:10 -06:00
ObserverOfTime
307d5bcc79 vim-patch:9.0.2137: Can't detect angular & mustache filetypes
Problem:  Can't detect angular & mustache filetypes
Solution: Detect *.mustache as Mustache filetype;
          detect *.component.html as html.angular filetype

closes: vim/vim#13594

7bed263c34
2023-11-30 18:40:27 +01:00
Gregory Anders
7feed6ccb7
refactor: explicitly abort on OOM condition (#26330)
assert() would not abort in release builds, meaning an OOM condition
would be undetected.
2023-11-30 11:05:33 -06:00
Pham Huy Hoang
f5573fba3d
fix: Remove nested for_each_tree in TSTreeView (#26328)
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
2023-11-30 10:37:42 -06:00