Commit Graph

3701 Commits

Author SHA1 Message Date
zeertzjq
543e0256c1
build: don't define FUNC_ATTR_* as empty in headers (#26317)
FUNC_ATTR_* should only be used in .c files with generated headers.
Defining FUNC_ATTR_* as empty in headers causes misuses of them to be
silently ignored. Instead don't define them by default, and only define
them as empty after a .c file has included its generated header.
2023-11-30 15:51:05 +08:00
Gregory Anders
18c1fd8e9d
docs: document TSNode:byte_length() (#26287)
Also update the type annotation of TSNode:id(), which returns a string,
not an integer.
2023-11-29 08:59:36 -06:00
zeertzjq
a6cba103ce
refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
zeertzjq
aa9d9cafd0
vim-patch:9.0.2135: No test for mode() when executing Ex commands (#26282)
Problem:  No test for mode() when executing Ex commands
Solution: Add some test cases and simplify several other test cases.
          Also add a few more test cases for ModeChanged.

closes: vim/vim#13588

fcaeb3d42b
2023-11-29 06:51:00 +08:00
bfredl
ba564442ae
Merge pull request #26249 from bfredl/concealchar
feat(decoration): allow conceal_char to be a composing char
2023-11-28 11:01:21 +01:00
bfredl
ae3685798d feat(decoration): allow conceal_char to be a composing char
decor->text.str pointer must go. This removes it for conceal char,
in preparation for a larger PR which will also handle the sign case.

By actually allowing composing chars for a conceal chars, this
becomes a feature and not just a refactor, as a bonus.
2023-11-28 10:35:25 +01:00
zeertzjq
e6d38c7dac
vim-patch:9.0.2133: Cannot detect overstrike mode in Cmdline mode (#26263)
Problem:  Cannot detect overstrike mode in Cmdline mode
Solution: Make mode() return "cr" for overstrike

closes: vim/vim#13569

d1c3ef1f47
2023-11-28 11:46:20 +08:00
LW
9fa9b3cad9
docs: support @since for api level #25574
close #25416
2023-11-27 08:23:04 -08:00
dundargoc
2c16c6a6c4
docs: small fixes (#26154) 2023-11-27 17:43:13 +08:00
Lewis Russell
84bbe4b0ca fix(lua): disallow vim.wait() in fast contexts
`vim.wait()` cannot be called in a fast callback since the main loop
cannot be run in that context as it is not reentrant

Fixes #26122
2023-11-27 09:09:21 +00:00
Justin M. Keyes
fc4385ad94
docs: vim.iter #26169
closes #24141
closes #24746
2023-11-25 06:35:31 -08:00
zeertzjq
73c7a0d58e
docs(starting.txt): correct step number (#26185) 2023-11-24 07:19:06 +08:00
Luuk van Baal
c249058758 feat(extmarks): add sign name to extmark "details" array
Problem:  Unable to identify legacy signs when fetching extmarks with
          `nvim_buf_get_extmarks()`.
Solution: Add "sign_name" to the extmark detail array.

Add some misc. changes as follow-up to #25724
2023-11-22 12:43:59 +01:00
zeertzjq
820823c76d
vim-patch:596a9f29c83a (#26146)
runtime(doc): Fix whitespace and formatting of some help files (vim/vim#13549)

596a9f29c8

N/A patch:
vim-patch:aabca259fa48

Co-authored-by: h_east <h.east.727@gmail.com>
2023-11-22 10:46:11 +08:00
zeertzjq
fec5e3ab24
fix(vim.region): handle multibyte inclusive selection properly (#26129) 2023-11-21 14:25:45 +08:00
bfredl
df87266b23
Merge pull request #25724 from luukvbaal/signmerge
refactor(sign): move legacy signs to extmarks
2023-11-18 15:04:14 +01:00
Luuk van Baal
c4afb9788c refactor(sign): move legacy signs to extmarks
Problem:  The legacy signlist data structures and associated functions are
          redundant since the introduction of extmark signs.
Solution: Store signs defined through the legacy commands in a hashmap, placed
          signs in the extmark tree. Replace signlist associated functions.

Usage of the legacy sign commands should yield no change in behavior with the
exception of:
  - "orphaned signs" are now always removed when the line it is placed on is
    deleted. This used to depend on the value of 'signcolumn'.
  - It is no longer possible to place multiple signs with the same identifier
    in a single group on multiple lines. This will now move the sign instead.

Moreover, both signs placed through the legacy sign commands and through
|nvim_buf_set_extmark()|:
  - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|.
  - Are displayed by increasing sign identifier, left to right.
    Extmark signs used to be ordered decreasingly as opposed to legacy signs.
2023-11-17 15:10:15 +01:00
Gregory Anders
677be4bdd2
docs: document breaking change of cursor blink behavior (#26075) 2023-11-17 08:07:35 -06:00
bfredl
b522cb1ac3 refactor(grid): make screen rendering more multibyte than ever before
Problem: buffer text with composing chars are converted from UTF-8
to an array of up to seven UTF-32 values and then converted back
to UTF-8 strings.

Solution: Convert buffer text directly to UTF-8 based schar_T values.

The limit of the text size is now in schar_T bytes, which is currently
31+1 but easily could be raised as it no longer multiplies the size
of the entire screen grid when not used, the full size is only required
for temporary scratch buffers.

Also does some general cleanup to win_line text handling, which was
unnecessarily complicated due to multibyte rendering being an "opt-in"
feature long ago. Nowadays, a char is just a char, regardless if it consists
of one ASCII byte or multiple bytes.
2023-11-17 12:58:57 +01:00
zeertzjq
a4c111ae69 vim-patch:9.0.2108: [security]: overflow with count for :s command
Problem:  [security]: overflow with count for :s command
Solution: Abort the :s command if the count is too large

If the count after the :s command is larger than what fits into a
(signed) long variable, abort with e_value_too_large.

Adds a test with INT_MAX as count and verify it correctly fails.

It seems the return value on Windows using mingw compiler wraps around,
so the initial test using :s/./b/9999999999999999999999999990 doesn't
fail there, since the count is wrapping around several times and finally
is no longer larger than 2147483647. So let's just use 2147483647 in the
test, which hopefully will always cause a failure

ac63787734

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-17 07:06:52 +08:00
Gregory Anders
5d75d9aef2
fix(osc52): enable OSC 52 by default in tmux sessions (#26072)
tmux has a set-clipboard option which, when set to 'on', allows
applications to set the system clipboard using the usual OSC 52 escape
sequence.
2023-11-16 13:56:05 -06:00
Gregory Anders
db57df04b6
feat(clipboard): enable OSC 52 clipboard provider by default (#26064)
Use the XTGETTCAP sequence to determine if the host terminal supports
the OSC 52 sequence and, if it does, enable the OSC 52 clipboard
provider by default.

This is only done automatically when all of the following are true:

  1. Nvim is running in the TUI
  2. 'clipboard' is not set to unnamed or unnamedplus
  3. g:clipboard is unset
  4. Nvim is running in an SSH connection ($SSH_TTY is set)
  5. Nvim is not running inside tmux ($TMUX is unset)
2023-11-16 12:21:24 -06:00
Gregory Anders
4bf47222c9
feat: add vim.text module (#26069) 2023-11-16 11:35:54 -06:00
Gregory Anders
b4b7ca2d54
feat(tui): support DCS responses in TermResponse event (#26061) 2023-11-16 11:12:42 -06:00
Gregory Anders
dc3f84bf4f
docs: fix vim.snippet help tags (#26068) 2023-11-16 10:53:25 -06:00
Christian Clason
7e0f6211af vim-patch:30c762d99ac8
runtime(doc): fix typo in pi_gzip.txt

30c762d99a

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-14 23:29:09 +01:00
Gregory Anders
ac8ed77afb
feat(tui): add 'termsync' option (#25871)
The 'termsync' option enables a mode (provided the underlying terminal
supports it) where all screen updates during a redraw cycle are buffered
and drawn together when the redraw is complete. This eliminates tearing
or flickering in cases where Nvim redraws slower than the terminal
redraws the screen.
2023-11-14 08:53:58 -06:00
Justin M. Keyes
b73a829837
refactor: vim.ui.clipboard #26040
Problem:
Platform-specific UI providers should live in `vim.ui.*`. #24164

Solution:
- Move `vim.clipboard.osc52` module to `vim.ui.clipboard.osc52`.
- TODO: move all of `clipboard.vim` to `vim.ui.clipboard`.

ref #25872
2023-11-14 05:15:45 -08:00
Ploum
5b45efbee6
fix(defaults): set 'fsync' #26034
Problem:
'nofsync' may lose data if the system has a hard shutdown. #9888

Solution:
Change default to 'fsync'. This may be revisited in the future when
'nofsync' can be made safer.
2023-11-14 02:56:50 -08:00
Gregory Anders
8d9789a0f3 docs: deprecate the "term_background" UI field 2023-11-13 19:04:47 -06:00
zeertzjq
6d14f3ddab
vim-patch:9.0.2103: recursive callback may cause issues on some archs (#26013)
Problem:  recursive callback may cause issues on some archs
Solution: Decrease the limit drastically to 20

Recursive callback limit causes problems on some architectures

Since commit 47510f3d6598a1218958c03ed11337a43b73f48d we have a test
that causes a recursive popup callback function to be executed. However
it seems the current limit of 'maxfuncdepth' option value is still too
recursive for some 32bit architectures (e.g. 32bit ARM).

So instead of allowing a default limit of 100 (default value for
'maxfuncdepth'), let's reduce this limit to 20. I don't think there is a
use case where one would need such a high recursive callback limit and a
limit of 20 seems reasonable (although it is currently hard-coded).

closes: vim/vim#13495
closes: vim/vim#13502

2076463e38

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-13 06:33:34 +08:00
zeertzjq
74e23b3b2a
vim-patch:2dd613f57bf1 (#26009)
runtime(termdebug): improve the breakpoint sign label (vim/vim#13525)

// related vim/vim#12589
// that should be the last chat (I) with Bram, r.i.p

2dd613f57b

Co-authored-by: Shane-XB-Qian <shane.qian@foxmail.com>
2023-11-13 05:44:30 +08:00
dundargoc
4f8941c1a5 refactor: replace manual header guards with #pragma once
It is less error-prone than manually defining header guards. Pretty much
all compilers support it even if it's not part of the C standard.
2023-11-12 22:01:28 +01:00
LW
448907f65d
feat(lsp)!: vim.lsp.inlay_hint.get(), enable(), is_enabled() #25512
refactor!: `vim.lsp.inlay_hint()` -> `vim.lsp.inlay_hint.enable()`

Problem:
The LSP specification allows inlay hints to include tooltips, clickable
label parts, and code actions; but Neovim provides no API to query for
these.

Solution:
Add minimal viable extension point from which plugins can query for
inlay hints in a range, in order to build functionality on top of.

Possible Next Steps
---

- Add `virt_text_idx` field to `vim.fn.getmousepos()` return value, for
  usage in mappings of `<LeftMouse>`, `<C-LeftMouse>`, etc
2023-11-12 04:54:27 -08:00
zeertzjq
2494009885
vim-patch:1b08d2cd0789 (#25993)
runtime(doc): clarify when formatoptions applies

closes: vim/vim#13503

1b08d2cd07

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-12 07:49:57 +08:00
zeertzjq
04d299c170 vim-patch:8.2.4932: not easy to filter the output of maplist()
Problem:    Not easy to filter the output of maplist().
Solution:   Add mode_bits to the dictionary. (Ernie Rael, closes vim/vim#10356)

d8f5f76621

Co-authored-by: Ernie Rael <errael@raelity.com>
2023-11-09 21:34:04 +08:00
zeertzjq
f748a73a35 vim-patch:8.2.4861: it is not easy to restore saved mappings
Problem:    It is not easy to restore saved mappings.
Solution:   Make mapset() accept a dict argument. (Ernie Rael, closes vim/vim#10295)

51d04d16f2

Co-authored-by: Ernie Rael <errael@raelity.com>
2023-11-09 21:34:04 +08:00
zeertzjq
d4dbfb092b vim-patch:8.2.4825: can only get a list of mappings
Problem:    Can only get a list of mappings.
Solution:   Add the optional {abbr} argument. (Ernie Rael, closes vim/vim#10277)
            Rename to maplist().  Rename test file.

09661203ec

Co-authored-by: Ernie Rael <errael@raelity.com>
2023-11-09 21:34:04 +08:00
zeertzjq
2dfcd5a22b vim-patch:8.2.4820: not simple programmatic way to find a specific mapping
Problem:    Not simple programmatic way to find a specific mapping.
Solution:   Add getmappings(). (Ernie Rael, closes vim/vim#10273)

659c240cf7

Co-authored-by: Ernie Rael <errael@raelity.com>
2023-11-09 21:34:04 +08:00
zeertzjq
a4b80c71ea vim-patch:8.2.4140: maparg() does not indicate the type of script
Problem:    maparg() does not indicate the type of script where it was defined.
Solution:   Add "scriptversion".

a9528b39a6

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-11-09 21:34:02 +08:00
zeertzjq
610f50ddaf
vim-patch:20a94f44b3cd (#25946)
runtime(doc): fix grammar in termdebug doc, remove trailing spaces (vim/vim#13505)

20a94f44b3
2023-11-09 15:46:14 +08:00
zeertzjq
77bb69d7b0
vim-patch:7fbbd7fdc6df (#25944)
runtime(termdebug):  handle buffer-local mappings properly

closes: vim/vim#13475

7fbbd7fdc6

Co-authored-by: shane.xb.qian <shane.qian@foxmail.com>
2023-11-09 08:38:25 +08:00
zeertzjq
89d785e530 vim-patch:ca48202b6f46
runtime(termdebug): improve window handling, shorten var types

closes vim/vim#13474

ca48202b6f

Co-authored-by: shane.xb.qian <shane.qian@foxmail.com>
2023-11-09 07:24:31 +08:00
zeertzjq
f7b2ea59a6
vim-patch:9.0.2095: statusline may look different than expected (#25941)
Problem:  statusline may look different than expected
Solution: do not check for highlighting of stl and stlnc characters

statusline fillchar may be different than expected

If the highlighting group for the statusline for the current window
|hl-StatusLine| or the non-current window |hl-StatusLineNC| are cleared
(or do not differ from each other), than Vim will use the hard-coded
fallback values '^' (for the non-current windows) or '=' (for the
current window).  I believe this was done, to make sure the statusline
will always be visible and be distinguishable from the rest of the
window.

However, this may be unexpected, if a user explicitly defined those
fillchar characters just to notice that those values are then not used
by Vim.

So, let's assume users know what they are doing and just always return
the configured stl and stlnc values.  And if they want the statusline to
be non-distinguishable from the rest of the window space, so be it.  It
is their responsibility and Vim shall not know better what to use.

fixes: vim/vim#13366
closes: vim/vim#13488

6a650bf696

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-09 06:34:34 +08:00
bfredl
1b0fd377ab
Merge pull request #25767 from luukvbaal/signdel
feat(extmarks): add 'invalidate' property
2023-11-08 12:17:25 +01:00
Luuk van Baal
4e6f559b8c feat(extmarks): add 'invalidate' property to extmarks
Problem:  No way to have extmarks automatically removed when the range it
          is attached to is deleted.
Solution: Add new 'invalidate' property that will hide a mark when the
          entirety of its range is deleted. When "undo_restore" is set
          to false, delete the mark from the buffer instead.
2023-11-08 02:53:49 +01:00
Gregory Anders
748bc4d22d feat(clipboard): add OSC 52 clipboard support
This is opt-in as not all terminal emulators support OSC 52, so it is up
to the user to enable it explicitly.
2023-11-07 08:25:33 -06:00
Gregory Anders
56627ca242
feat(tui): use TermResponse event for OSC responses (#25868)
When the terminal emulator sends an OSC sequence to Nvim (as a response
to another OSC sequence that was first sent by Nvim), populate the OSC
sequence in the v:termresponse variable and fire the TermResponse event.
The escape sequence is also included in the "data" field of the
autocommand callback when the autocommand is defined in Lua.

This makes use of the already documented but unimplemented TermResponse
event. This event exists in Vim but is only fired when Vim receives a
primary device attributes response.

Fixes: https://github.com/neovim/neovim/issues/25856
2023-11-06 12:42:40 -06:00
zeertzjq
0774d0cfe1
vim-patch:da4e433dc3be (#25912)
runtime(doc): document vim-script library function

da4e433dc3

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-11-06 19:03:08 +08:00
bfredl
68cb4a7405 feat(extmarks): add "undo_restore" flag to opt out of undo-restoring
It is a design goal of extmarks that they allow precise tracking
of changes across undo/redo, including restore the exact positions
after a do/undo or undo/redo cycle. However this behavior is not useful
for all usecases. Many plugins won't keep marks around for long after
text changes, but uses them more like a cache until some external source
(like LSP semantic highlights) has fully updated to changed text and
then will explicitly readjust/replace extmarks as needed.

Add a "undo_restore" flag which is true by default (matches existing
behavior) but can be set to false to opt-out of this behavior.

Delete dead u_extmark_set() code.
2023-11-05 12:18:29 +01:00