Removes the `getoption_T` struct and also introduces the `OptVal` struct
to unify the methods of getting/setting different option value types.
This is the first of many PRs to reduce code duplication in the Vim
option code as well as to make options easier to maintain. It also
increases the flexibility and extensibility of options. Which opens the
door for things like Array and Dictionary options.
The options 'path', 'include', and 'define' all use C-specific default
values. This may have made sense a long time ago when Vim was mostly
used just for writing C, but this is no longer the case, and we have
ample support for filetype specific configuration. Make the default
values of these options empty and move the C-specific values into a
filetype plugin where they belong.
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
vim.version.range() couldn't parse them correctly.
For example, vim.version.range('<0.9.0'):has('0.9.0') returned `true`.
fix: range:has() accepts vim.version()
So that it's possible to compare a range with:
vim.version.range(spec):has(vim.version())
Problem: "skipcol" not reset when using multi-byte characters.
Solution: Compare with w_virtcol instead of w_cursor.col. (closesvim/vim#12457)
15d4747ffd
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Display is wrong when 'smoothscroll' is set and scrolling multiple
lines.
Solution: Redraw with UPD_NOT_VALID when "skipcol" is or was set.
(closesvim/vim#12490, closesvim/vim#12468)
d9a92dc70b
Problem: screenpos() returns wrong row with diff filler lines.
Solution: Only add filler lines when appropriate. Also don't add the
'smoothscroll' marker when w_skipcol is zero. (closesvim/vim#12485,
closesvim/vim#12484)
55daae3921
Problem: screenpos() does not take w_skipcol into account.
Solution: Subtract w_skipcol from column. (closesvim/vim#12486, closesvim/vim#12476)
f0e68c0e2a
PROBLEM:
Whenever any text edits are applied to the buffer, the `marks` part of those
lines will be lost. This is mostly problematic for code formatters that format
the whole buffer like `prettier`, `luafmt`, ...
When doing atomic changes inside a vim doc, vim keeps track of those changes and
can update the positions of marks accordingly, but in this case we have a whole
doc that changed. There's no simple way to update the positions of all marks
from the previous document state to the new document state.
SOLUTION:
* save marks right before `nvim_buf_set_lines` is called inside `apply_text_edits`
* check if any marks were lost after doing `nvim_buf_set_lines`
* restore those marks to the previous positions
TEST CASE:
* have a formatter enabled
* open any file
* create a couple of marks
* indent the whole file to the right
* save the file
Before this change: all marks will be removed.
After this change: they will be preserved.
Fixes#14307
Problem: Stray character is visible if 'smoothscroll' marker is displayed
on top of a double-wide character.
Solution: When overwriting a double-width character with the 'smoothscroll'
marker clear the second half. (closesvim/vim#12469)
ecb87dd7d3
Problem: Filetype detection fails for *.conf file without comments.
(Dmitrii Tcyganok)
Solution: Use "conf" filetype as a fallback for an empty .conf file.
(closesvim/vim#12487, closesvim/vim#12483)
664fd12aa2
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Problem: Cursor not adjusted when near top or bottom of window and
'splitkeep' is not "cursor".
Solution: Move boundary checks to outer cursor move functions, inner
functions should only return valid cursor positions. (Luuk van
Baal, closesvim/vim#12480)
a109f39ef5
Problem: Cursor ends up below the window after a put.
Solution: Mark w_crow and w_botline invalid when changing the cursor line.
(closesvim/vim#12465)
8509014add
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: screenchar(), screenchars() and screenstring() do not work
properly when 'encoding' is set to a double-byte encoding.
Solution: Fix the way the bytes of the characters are obtained.
(issue vim/vim#12469)
47eec6716b
If the server sends the positionEncoding capability in its
initialization response, automatically set the client's offset_encoding
to use the value provided.
Problem: Line pointer becomes invalid when using spell checking.
Solution: Call ml_get() at the right places. (Luuk van Baal, closesvim/vim#12456)
e84c773d42
Problem: :registers command does not work in sandbox.
Solution: Add flag to the command. (closesvim/vim#12473)
eb43b7f053
Co-authored-by: Julio B <julio.bacel@gmail.com>
BREAKING CHANGE: LspRequest is no longer a User autocmd but is now a
first class citizen.
LspRequest as a User autocmd had limited functionality. Namely, the only
thing you could do was use the notification to do a lookup on all the
clients' requests tables to figure out what changed.
Promoting the autocmd to a full autocmd lets us set the buffer the
request was initiated on (so people can set buffer-local autocmds for
listening to these events).
Additionally, when used from Lua, we can pass additional metadata about
the request along with the notification, including the client ID, the
request ID, and the actual request object stored on the client's
requests table. Users can now listen for these events and act on them
proactively instead of polling all of the requests tables and looking
for changes.
Problem: Incsearch not triggered when pasting clipboard register on the
command line.
Solution: Also set "literally" when using a clipboard register. (Ken Takata,
closesvim/vim#12460)
9cf6ab1332
Co-authored-by: K.Takata <kentkt@csc.jp>
Problem: Some "gomod" files are not recognized.
Solution: Check for "go.mod" file name before checking out the contents.
(Omar El Halabi, closesvim/vim#12462)
c9fbd2560f
- `client.dynamic_capabilities` is an object that tracks client register/unregister
- `client.supports_method` will additionally check if a dynamic capability supports the method, taking document filters into account. But only if the client enabled `dynamicRegistration` for the capability
- updated the default client capabilities to include dynamicRegistration for:
- formatting
- rangeFormatting
- hover
- codeAction
- hover
- rename
Problem: :stopinsert may not work in a popup close handler. (Ben Jackson)
Solution: Restore stop_insert_mode when appropriate. (closesvim/vim#12452,
closesvim/vim#12434)
a40c0bcc83
Problem: SpellCap highlight not always updated when needed.
Solution: Handle updating line below closed fold and other situations where
only part of the window is redrawn. (Luuk van Baal, closesvim/vim#12428,
closesvim/vim#12420)
2ac6497f0e
fixes#23734
Get rid of the weird attr_pri dance which always seemed like a kludge:
if (!attr_pri) {
wlv.char_attr = hl_combine_attr(wlv.char_attr, extmark_attr);
} else {
wlv.char_attr = hl_combine_attr(extmark_attr, wlv.char_attr);
}
Instead combine extmark attrs with (old-skool) syntax attrs in a consistent way and then combine that with attr_pri and the rest in an _unified_ code path
fixes#23722
Co-authored-by: luukvbaal <luukvbaal@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Problem: Bad redrawing with spell checking, using "C" and "$" in 'cpo'.
Solution: Do not redraw the next line when "$" is in 'cpo'. (closesvim/vim#11285)
f3ef026c98
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: With spell checking, deleting a full stop at the end of a line
does not update SpellCap at the start of the next line.
Solution: Update the next line when characters have been deleted. Also when
using undo.
26f09ea54b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: After exiting Insert mode spelling is not checked in the next
line.
Solution: When spelling is enabled redraw the next line after exiting Insert
mode in case the spell highlight needs updating.
ee09fcc9b6
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Spell checking for capital not working with trailing space.
Solution: Do not calculate cap_col at the end of the line. (Christian
Brabandt, closesvim/vim#10870, issue vim/vim#10838)
afa23d1b99
Co-authored-by: Christian Brabandt <cb@256bit.org>
It's not needed anymore as it does the exact same thing as
functionaltest. The functionaltest target will test the lua type neovim
was built with, which can be toggled with the PREFER_LUA option.
libvterm v0.3 supports reflow of terminal buffer when Nvim is resized
Since v0.3 is now a required dependency, enable it by default to find
(and fix) possible issues.
Note: Neovim's scrollback buffer does not support reflow (yet), so lines
vanishing into the buffer due to a too small window will be restored
without reflow.
This ensures that colorschemes in 'rtp' are tried before ones in 'pp',
because some colorschemes in 'pp' may not work if not added to 'rtp'.
This also match the current documentation better.
Problem: In diff mode virtual text is highlighted incorrectly. (Rick Howe)
Solution: Do not use diff attributes for virtual text. (closesvim/vim#11714)
d097af7779
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: 'cursorline' causes virtual text highlight to continue.
Solution: Save and restore line_attr. (closesvim/vim#11588)
6ac16f0c0f
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: With 'nowrap' virtual text "after" does not scroll left.
Solution: Skip part of the virtual text that is left of the window.
(closesvim/vim#11320) Fix going beyond the last column of the window.
cd105417a5
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cursor in wrong position when inserting after virtual text. (Ben
Jackson)
Solution: Put the cursor after the virtual text, where the text will be
inserted. (closesvim/vim#10914)
28c9f89571
Co-authored-by: Bram Moolenaar <Bram@vim.org>
vim-patch:9.0.0193: search and match highlgith interfere with virtual text
Problem: Search and match highlgith interfere with virtual text highlight.
(Ben Jackson)
Solution: Check for match highlight after text properties. Reset and
restore search highlight when showing virtual text.
(closesvim/vim#10892)
e38fc86180
vim-patch:9.0.0452: Visual highlighting extends into virtual text prop
Problem: Visual highlighting extends into virtual text prop.
Solution: Do not highlight what isn't actually selected. Fix ordering of
stored text props.
6eda17d881
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Extra space after virtual text when 'linebreak' is set.
Solution: Do not count virtual text when getting linebreak value.
(closesvim/vim#10884)
52de3a8d39
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cursor position wrong with virtual text before Tab.
Solution: Use the byte length, not the cell with, to compare the column.
Correct tab size after text prop. (closesvim/vim#10866)
e428fa04a7
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cursor position wrong with wrapping virtual text in empty line.
Solution: Adjust handling of an empty line. (closesvim/vim#10875)
49a90792d9
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This also fixes insert cursor position around virtual text
vim-patch:9.0.0132: multi-byte characters in virtual text not handled correctly
Problem: Multi-byte characters in virtual text not handled correctly.
Solution: Count screen cells instead of bytes.
09ff4b54fb
vim-patch9.0.0121: cannot put virtual text after or below a line
Problem: Cannot put virtual text after or below a line.
Solution: Add "text_align" and "text_wrap" arguments.
b7963df98f
This only patches the fix, not the whole thing.
vim-patch:9.0.0067: cannot show virtual text
Problem: Cannot show virtual text.
Solution: Initial changes for virtual text support, using text properties.
7f9969c559
vim-patch:9.0.0116: virtual text not displayed if 'signcolumn' is "yes"
Problem: Virtual text not displayed if 'signcolumn' is "yes".
Solution: Set c_extra and c_final to NUL.
711483cd13
Co-authored-by: bfredl <bjorn.linse@gmail.com>
Test colors were disabled in be7290d214
due to color codes interfering with the logs. I believe the solution to
disable colors is too aggressive. Reading raw logs isn't common compared
to reading CI results from the github UI. We should optimize the most
common use case.
It is also possible to interpret the colors codes in logs from neovim
with a plugin that interprets ansi escape sequences.
`nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
Problem: Multibyte characters may be wrapped at the end of a line
when 'statuscolumn' and 'spell' are set.
Solution: Update line pointerdiff "v" before fetching the line pointer
after evaluating 'statuscolumn'.
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.
Problem: Some tests are slow.
Solution: Make a few test cases faster.
bf63011a52
Cherry-pick related test_cmdline.vim changes from patch 9.0.0418.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: With 'smoothscroll' cursor may move below botline.
Solution: Call redraw_later() if needed, Compute cursor row with adjusted
condition. (Luuk van Baal, closesvim/vim#12415)
d49f646bf5
Problem: Display moves up and down with 'incsearch' and 'smoothscroll'.
Solution: Do not check if w_skipcol changed. (Luuk van Baal, closesvim/vim#12410,
closesvim/vim#12409)
0222c2d103
Uncrustify is sensitive to version changes, which causes friction for
contributors that doesn't have that exact version. It's also simpler to
download and install the correct version than to have bespoke version
checking.
Problem: Test fails because of changed error message.
Solution: Adjust the expected error message.
6b02b38ed0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Display wrong when moving cursor to above the top line and
'smoothscroll' is set.
Solution: Call adjust_skipcol() in more places and make it work better.
(Luuk van Baal, closesvim/vim#12395)
798fa76dbf
Problem: setcharsearch() does not clear last searched char properly.
Solution: Do not accept lastc_bytelen smaller than one. (closesvim/vim#12398)
e5d91ba1de
Problem: Position of marker for 'smoothscroll' not computed correctly.
Solution: Take 'list' and other options into account. (Luuk van Baal,
closesvim/vim#12393)
24b62ec825
Problem: Using negative array index with negative width window.
Solution: Make sure the window width does not become negative.
8279af514c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Using freed memory with cmdwin and BufEnter autocmd.
Solution: Make sure pointer to b_p_iminsert is still valid.
1c3dd8ddcb
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Reading before the start of the line.
Solution: When displaying "$" check the column is not negative.
e98c88c44c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Confusing error when using "q:" in command line window.
Solution: Check for the situation and give a better error message.
(closesvim/vim#10756)
c963ec31a0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: USD filetype is not recognized.
Solution: Add patterns for USD filetype. (Colin Kennedy, closesvim/vim#12370)
b848ce6b7e
Co-authored-by: Colin Kennedy <colinvfx@gmail.com>
Problem: Some commands for opening a file don't use 'switchbuf'.
Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan,
closesvim/vim#12383, closesvim/vim#12381)
54be5fb382
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Text not scrolled when cursor moved with "g0" and "h".
Solution: Adjust w_skipcol when needed. (Luuk van Baal, closesvim/vim#12387)
8667a5678f
Problem: Display errors when making topline shorter and 'smoothscroll' is
set.
Solution: Reset w_skipcol when the topline becomes shorter than its current
value. (Luuk van Baal, closesvim/vim#12367)
5d01f86d99
Problem: Line not fully displayed if it doesn't fit in the screen.
Solution: Do not reset s_skipcol if not needed. (Luuk van Baal,
closesvim/vim#12376)
6c018680be
Problem: :wqall does not trigger ExitPre. (Bart Libert)
Solution: Move preparations for :qall to a common function. (closesvim/vim#12374)
411da64e77
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cursor moves to wrong line when 'foldmethod' is "diff". (Rick
Howe)
Solution: Adjust logic for scrolling. (Luuk van Baal, closesvim/vim#12364,
closesvim/vim#12218)
aa6ba308a1
Problem: 'smoothscroll' does not always work properly.
Solution: Do not reset w_skipcol after it was intentionally set. (Luuk van
Baal, closesvim/vim#12360, closesvim/vim#12199, closesvim/vim#12323)
3ce8c38915
Problem: Some functions give two error messages.
Solution: Do not give a second error message. (closesvim/vim#12352)
e4098457ab
It seems that tv_get_bool() is actually not exactly the same as
tv_get_number(), so change it to a function instead.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cannot use special keys in <Cmd> mapping.
Solution: Do allow for special keys in <Cmd> and <ScriptCmd> mappings.
(closesvim/vim#12326)
3ab3a86481
Problem: Making a mapping work in all modes is complicated.
Solution: Add the <Cmd> special key. (Yegappan Lakshmanan, closesvim/vim#7282,
closes 4784, based on patch by Bjorn Linse)
957cf67d50
Change docs to match Vim if it's wording is better.
Change error numbers to match Vim.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Completion for option name includes all bool options.
Solution: Do not recognize the "noinv" prefix. Prefix "no" or "inv" when
appropriate.
048d9d2521
Co-authored-by: Bram Moolenaar <Bram@vim.org>