Commit Graph

17539 Commits

Author SHA1 Message Date
Lewis Russell
597d4c63bd refactor(treesitter): reorder functions 2024-03-19 18:40:08 +00:00
Lewis Russell
aca6c93002 refactor(treesitter): simplify argument checks for userdata 2024-03-19 16:16:54 +00:00
Lewis Russell
aca2048bcd refactor(treesitter): redesign query iterating
Problem:

  `TSNode:_rawquery()` is complicated, has known issues and the Lua and
  C code is awkwardly coupled (see logic with `active`).

Solution:

  - Add `TSQueryCursor` and `TSQueryMatch` bindings.
  - Replace `TSNode:_rawquery()` with `TSQueryCursor:next_capture()` and `TSQueryCursor:next_match()`
  - Do more stuff in Lua
  - API for `Query:iter_captures()` and `Query:iter_matches()` remains the same.
  - `treesitter.c` no longer contains any logic related to predicates.
  - Add `match_limit` option to `iter_matches()`. Default is still 256.
2024-03-19 14:24:59 +00:00
zeertzjq
16a416cb3c
fix(terminal): don't pass incomplete UTF-8 sequence to libvterm (#27922) 2024-03-19 16:56:51 +08:00
Christian Clason
c30ebb17f6 fix(treesitter): document more standard highlight groups
Problem: Not all standard treesitter groups are documented.

Solution: Document them all (without relying on fallback); add default
link for new `*.builtin` groups to `Special` and `@keyword.type` to
`Structure`. Remove `@markup.environment.*` which only made sense for
LaTeX.
2024-03-19 09:41:16 +01:00
zeertzjq
e3bd04f2af
fix(pager): handle consecutive newlines properly (#27913) 2024-03-18 22:25:55 +08:00
zeertzjq
66945e11b3
refactor(messages): remove condition that is always true (#27909)
After #25470 the `s` pointer is advanced before calling store_sb_text()
when a newline character is found, and store_sb_text() sets `sb_str` to
`s`, so it's not possible for `s == sb_str + 1` and `*sb_str == '\n'` to
be satisfied at the same time.
2024-03-18 19:01:01 +08:00
zeertzjq
9d315fb8b7
vim-patch:9.1.0186: cursor pos wrong on mouse click after eol with 'rl', 've' and conceal (#27903)
Problem:  Wrong cursor position when clicking after end of line with
          'rightleft', 'virtualedit' and conceal.
Solution: Set values in ScreenCols[] also with SLF_RIGHTLEFT.  Also fix
          off-by-one cursor position with 'colorcolumn' (zeertzjq).

closes: vim/vim#14218

deb2204bff
2024-03-18 10:35:41 +08:00
zeertzjq
eabf9de1dc
fix(messages): allow more prompt in headless mode with UI (#27905)
Problem:  More prompt is not shown in headless mode even if there is a
          UI attached.
Solution: Don't skip more prompt when there is a UI active.
2024-03-18 10:34:27 +08:00
zeertzjq
091eb4c8c7
fix(mouse): click after eol with conceal and virtual text (#27897)
Problem:  Wrong cursor position when clicking after end of line with
          'virtualedit', conceal and virtual text.
Solution: Always fill linebuf_vcol[] for the columns to clear.
2024-03-17 17:54:18 +08:00
zeertzjq
54db75e995
refactor(drawline): integrate terminal hl with eol loop (#27893)
There is no test for using 'cursorline' in Normal mode in a terminal
buffer, so add a test and fix 'cursorcolumn' remaining when entering
Terminal mode.

Also move synIDattr() tests to ui/highlight_spec.lua.
2024-03-17 17:24:03 +08:00
zeertzjq
c52dfb6e84
fix(normal): don't check conceal when pressing 'r' (#27892)
Problem:  Cursor line is unconcealed when pressing 'r' in Normal mode
          when 'concealcursor' contains 'n' but not 'i'.
Solution: Don't check conceal when pressing 'r' in Normal mode.

Vim doesn't have this problem because it doesn't call redrawWinline() in
conceal_check_cursor_line() and instead sets a global variable.
2024-03-17 09:44:10 +08:00
zeertzjq
d114dbe9f7
vim-patch:9.1.0184: Cursor pos wrong when clicking with conceal and wrap (#27890)
Problem:  Cursor position wrong when clicking with conceal and wrap.
Solution: Use the virtual column of the last char for ScreenCols[] in
          boguscols.  Remove use of MAXCOL in ScreenCols[].  Rename
          third argument of wlv_screen_line() to "clear_end" as that's
          clearer what it does (zeertzjq).

related: 14192
closes: vim/vim#14200

d0c1b7723f

Rename win_put_linebuf() to wlv_put_linebuf().
2024-03-17 07:26:39 +08:00
zeertzjq
34b57508a7
fix(drawline): check filler_todo in place of removed draw_state (#27889)
The only place it matters is the conceal wcol check, but it can avoid
unnecessary computations at other places.
2024-03-17 05:43:14 +08:00
Caleb Marshall
542c910a1d fix(lsp): add missing LSP semantic token highlight links
Added the following LSP semantic token types to be linked to highlight
groups by default:

* @lsp.type.event
* @lsp.type.keyword
* @lsp.type.modifier
* @lsp.type.number
* @lsp.type.operator
* @lsp.type.regexp
* @lsp.type.string
2024-03-16 20:37:56 +08:00
zeertzjq
ee89ba1d75
vim-patch:9.1.0182: Can define function with invalid name inside 'formatexpr' (#27883)
Problem:  Can define function with invalid name inside 'formatexpr'.
Solution: Use goto instead of checking for did_emsg later.
          (zeertzjq)

closes: vim/vim#14209

6a04bf5ee5
2024-03-16 17:26:14 +08:00
zeertzjq
c0daea3afd
vim-patch:9.1.0183: Wrong display or screenpos() result when toggling diff mode (#27882)
Problem:  Wrong display or screenpos() result when toggling diff mode.
Solution: Reset w_skipcol when disabling 'wrap'.  Reset w_leftcol when
          enabling 'wrap' (zeertzjq).

fixes: vim/vim#14210
closes: vim/vim#14211

9e7f1fc2f1
2024-03-16 17:10:20 +08:00
zeertzjq
ead3a1bd7a
vim-patch:8.2.3782: Vim9: no error if a function shadows a script variable (#27881)
Problem:    Vim9: no error if a function shadows a script variable.
Solution:   Check the function doesn't shadow a variable. (closes vim/vim#9310)

052ff291d7

Omit EVAL_VAR_NO_FUNC: Vim9 script only.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-03-16 17:05:59 +08:00
bfredl
9c2fdfe6e7
Merge pull request #27877 from bfredl/pseudorandom
fix(intro): redrawing intro exposing pseudo-randomness
2024-03-16 09:32:52 +01:00
bfredl
d1a30221fc fix(intro): redrawing intro exposing pseudo-randomness
problem:  redrawing intro exposes pseudo-randomness
solution: remove pseudo-randomness
2024-03-16 08:40:45 +01:00
bfredl
c0549b9c47
Merge pull request #27871 from bfredl/ui_flush_fix
fix(ui): edge case around flushing in grid_line
2024-03-16 08:36:37 +01:00
ite-usagi
4447cefa48
fix(l10n): update Japanese translations (#27856) 2024-03-16 14:50:52 +08:00
bfredl
b7779c5146
Merge pull request #27867 from bfredl/intro_multigrid
fix(ui): startup intro message should be visible with ext_multigrid
2024-03-15 13:27:58 +01:00
bfredl
e0707d3529 fix(ui): fix edge case around flushing
ui_flush_buf() doesn't know about `lenpos` so `remote_ui_raw_line`
needs to always handle it before flushing
2024-03-15 12:07:04 +01:00
bfredl
f1c9228bba
Merge pull request #27858 from luukvbaal/nvim_set_cursor
fix(ui): issues controlling cursor position with ext_cmdline
2024-03-15 10:02:26 +01:00
bfredl
a8522f02e9 fix(ui): startup intro message should be visible with ext_multigrid
As this message is literally drawn on top of the EOB area of the first
window, the simple solution is to just draw the message on top of the
grid of the first window.

We still want #24764 (msg_intro event) but now only for ext_messages.
2024-03-15 09:48:31 +01:00
Luuk van Baal
d41b8d4758 fix(ui): ext_cmdline should not move cursor to curwin
Problem:  The ext_cmdline cursor position on the screen seems to rely on
          an implicit assumption that the event listener implements a
          cmdline window that is made the current window which is
          problematic (e.g. breaks 'incsearch' in the actual current
          window).
Solution: Remove this assumption and allow nvim_win_set_cursor() to move
          the cursor on the screen to a non-current window (previous
          commit).
2024-03-15 09:15:56 +01:00
Luuk van Baal
c971f538ab fix(api): update grid cursor in nvim_win_set_cursor()
Problem:  Cursor position set by nvim_win_set_cursor() is not reflected
          on the screen when followed by a blocking call like getchar().
Solution: Immediately update the cursor position on the grid.
2024-03-15 09:15:50 +01:00
zeertzjq
062c0245e3
refactor: remove unused "coloff" argument of win_put_linebuf() (#27866)
It isn't really used, and is always passed 0.
Also rename "start_col" to "startcol" for consistency with "endcol".
2024-03-15 14:45:58 +08:00
zeertzjq
d326e04860
vim-patch:9.1.0181: no overflow check for string formatting (#27863)
Problem:  no overflow check for string formatting
Solution: Check message formatting function for overflow.
          (Chris van Willegen)

closes: vim/vim#13799

c35fc03dbd

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2024-03-15 08:05:59 +08:00
zeertzjq
60491466f9
vim-patch:9.1.0180: Cursor pos wrong when double-width chars are concealed (#27862)
Problem:  Cursor pos wrong when double-width chars are concealed.
Solution: Advance one more virtual column for a double-width char.
          Run some tests with both 'wrap' and 'nowrap' (zeertzjq).

closes: vim/vim#14197

010e1539d6
2024-03-15 06:56:45 +08:00
zeertzjq
ca7dd33fa7
fix(highlight): don't show CursorColumn on current line (#27848)
Problem:
CursorColumn highlight behavior is inconsistent with 'virtualedit' set:
- If cursor is on the text, CursorColumn is not shown.
- If cursor is after end of line, CursorColumn is shown.

Solution:
Don't shown CursorColumn on current line if cursor is after end of line.

Vim doesn't have this problem because in most cases it uses the code
path for drawing buffer text when CursorColumn highlight is needed.
2024-03-15 05:54:22 +08:00
bfredl
4de4f13eb3
Merge pull request #27852 from bfredl/persistent_intro
fix(intro): make intro explicitly stateful
2024-03-14 20:00:07 +01:00
bfredl
0570a19c8a fix(intro): make intro explicitly stateful
Instead of randomly disappearing because some random event might have
caused mid_start or bot_scroll_start to randomly take a low value, treat
intro message as a _first class stateful_ thing.

This means that intro message will kept being _redrawn_ as long as we
are in the state it should be shown. This also includes screen resizes.
you will not lose the intro message because there was a delay in
detecting terminal features.
2024-03-14 14:39:08 +01:00
zeertzjq
a6b6d036b1
refactor(drawline): rename vcol_off to vcol_off_co (#27857)
It is clearing that it's for conceal and matches the change from Vim
patch 9.0.1325.
Also correct some comments related to fix_for_boguscols().
2024-03-14 19:33:14 +08:00
bfredl
cdd0788c70
Merge pull request #27854 from bfredl/boogalo_lines
fix(api): fix set_lines viewport adjustment, but this time good
2024-03-14 12:24:33 +01:00
Christian Clason
120c4ec855 fix(terminal): disable reflow again
reverts c855eee919

This setting introduces constant CI failures on macos
(see https://github.com/neovim/neovim/issues/23762).
2024-03-14 19:22:16 +08:00
bfredl
fc2a56fe61 fix(api): fix set_lines viewport adjustment, but this time good
fixes #27720
2024-03-14 10:56:24 +01:00
zeertzjq
61b48e91b9 vim-patch:9.1.0177: Coverity reports dead code
Problem:  Coverity reports dead code.
Solution: Remove the dead code. Also fix a mistake in ml_get_pos_len()
          and update some comments (zeertzjq).

closes: vim/vim#14189

8c55d60658
2024-03-14 13:09:57 +08:00
zeertzjq
090d1fd0b8 vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Problem:  More code can use ml_get_buf_len() instead of STRLEN().
Solution: Change more STRLEN() calls to ml_get_buf_len().  Also do not
          set ml_line_textlen in ml_replace_len() if "has_props" is set,
          because "len_arg" also includes the size of text properties in
          that case. (zeertzjq)

closes: vim/vim#14183

94b7c3233e
2024-03-14 13:09:54 +08:00
zeertzjq
3502aa63f0
vim-patch:8.2.4950: text properties position wrong after shifting text (#27849)
Problem:    Text properties position wrong after shifting text.
Solution:   Adjust the text properties when shifting a block of text.
            (closes vim/vim#10418)

4b93674159

Most of the patch is already merged. Add an assertion in place of "added".

Co-authored-by: LemonBoy <thatlemon@gmail.com>
2024-03-14 12:40:17 +08:00
zeertzjq
2af1dc0116 vim-patch:9.1.0176: Cursor column wrong with 'virtualedit' and conceal
Problem:  Cursor column wrong with 'virtualedit' and conceal.
Solution: Correct cursor column at end of line if never reached.
          (zeertzjq)

closes: vim/vim#14190

253ff4dece
2024-03-14 06:55:10 +08:00
zeertzjq
9599e5d28d vim-patch:9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrap
Problem:  'cursorline' and 'wincolor' highlight missing with concealed and
          wrapped lines.
Solution: Apply 'cursorline' and 'wincolor' highlight to boguscols.
          (zeertzjq)

Since 'cursorline' and 'wincolor' highlight apply after the end of the
line, it is more consistent to have them also apply to boguscols.

Assigning MAXCOL to values in ScreenCols[] make mouse click behave the
same with 'cursorline' and 'nocursorline', but such behavior may be
incorrect, as it puts the cursor on the next screen line.  That may be
fixed in a future PR.

closes: vim/vim#14192

21b0a3df8c
2024-03-14 06:55:08 +08:00
zeertzjq
b17be231a6
vim-patch:9.1.0178: E1513 might be confusing (#27846)
Problem:  E1513 might be confusing
          (Christoph Thoma)
Solution: reword error message, fix test to not
          depend on the actual message

fixes: vim/vim#14189

0a32b8854b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-03-14 06:44:50 +08:00
Sean Dewar
bbb68e2a03
vim-patch:9.1.0175: wrong window positions with 'winfix{width,height}' (#27845)
Problem:  winframe functions incorrectly recompute window positions if
          the altframe wasn't adjacent to the closed frame, which is
          possible if adjacent windows had 'winfix{width,height}' set.

Solution: recompute for windows within the parent of the altframe and
          closed frame. Skip this (as before) if the altframe was
          top/left, but only if adjacent to the closed frame, as
          positions won't change in that case. Also correct the return
          value documentation for win_screenpos. (Sean Dewar)

The issue revealed itself after removing the win_comp_pos call below
winframe_restore in win_splitmove. Similarly, wrong positions could result from
windows closed in other tabpages, as win_free_mem uses winframe_remove (at least
until it is entered later, where enter_tabpage calls win_comp_pos).

NOTE: As win_comp_pos handles only curtab, it's possible via other means for
positions in non-current tabpages to be wrong (e.g: after changing 'laststatus',
'showtabline', etc.). Given enter_tabpage recomputes it, maybe it's intentional
as an optimization? Should probably be documented in win_screenpos then, but I
won't address that here.

closes: vim/vim#14191

Nvim: don't reuse "wp" for "topleft" in winframe_remove, so the change
integrates better with the call to winframe_find_altwin before it.

5866bc3a0f
2024-03-13 22:06:39 +00:00
bfredl
08fc1ebbaa fix(api/buffer): fix handling of viewport of non-current buffer
A lot of functions in move.c only worked for curwin, alternatively
took a `wp` arg but still only work if that happens to be curwin.

Refactor those that are needed for update_topline(wp) to work
for any window.

fixes #27723
fixes #27720
2024-03-13 07:19:59 +01:00
zeertzjq
d5488633f6
fix(drawline): initialize linebuf_attr to 0 instead of -1 (#27840)
This also obviates the end-of-line loop when there is virtual text.
2024-03-13 11:36:41 +08:00
zeertzjq
93c93a0e36
refactor: remove "once" argument of loop_uv_run() (#27841)
It is always set to true when used, and makes the code a bit confusing.
2024-03-13 11:27:04 +08:00
Sean Dewar
c048beef6c
vim-patch:9a660d2883f9
runtime(doc): add reference to matchbufline() at :h search()

related: vim/vim#14173

9a660d2883

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-03-12 21:42:47 +00:00
Sean Dewar
6bbb02d9ba
vim-patch:9.1.0171: Small split-move related improvements
Problem:  small improvements can be made to split-move related
          functions.
Solution: apply them (Sean Dewar):

Some of these changes were already applied to Nvim.
Here are the ones which were missing:

- Improve some doc comments (frame_flatten should still work for non-current
  tabpages, despite the topframe check, which looks benign, though I'm unsure if
  it's still needed; see vim/vim#2467).

- f_win_splitmove should check_split_disallowed on wp, not targetwin, as that's
  what win_splitmove checks (though it's probably unnecessary to check
  b_locked_split at all; see vim/vim#14109, which I hope to get around to
  finishing at some point).

- Apply the winframe_restore comment changes, and remove win_comp_pos from after
  winframe_restore in win_splitmove, as it shouldn't be necessary (no need to
  remove it from nvim_win_set_config too, as it was already omitted).
  Move win_append after winframe_restore in win_splitmove to match Vim.

closes: vim/vim#14185

5cac1a9bee
2024-03-12 21:38:39 +00:00