Commit Graph

5011 Commits

Author SHA1 Message Date
Brandon Simmons
824639c7c1
fix(folds): handle visual blockwise indent insertion correctly (#22898)
Previously, the fold information was incorrect because it wasn't
being updated during the blockwise insertion.
(Solution by zeertzjq)
2023-04-07 00:08:46 +08:00
bfredl
dd80ee0ca9
Merge pull request #22910 from bfredl/nonormal
fix(highlight): use winhl=Foo:Bar even when Bar is empty
2023-04-06 17:38:16 +02:00
bfredl
0f42aa1f2a fix(highlight): use winhl=Foo:Bar even when Bar is empty
fixes #22906
2023-04-06 17:15:16 +02: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
dundargoc
fd32a98752
test(vim.fs.normalize): enable test on Windows 2023-04-05 23:56:33 +02: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
Luuk van Baal
f0ac91c58b feat(api): evaluate 'statuscolumn' with nvim_eval_statusline() 2023-04-05 12:36:47 +02:00
dundargoc
743860de40
test: replace lfs with luv and vim.fs
test: replace lfs with luv

luv already pretty much does everything lfs does, so this duplication
of dependencies isn't needed.
2023-04-04 21:59:06 +02:00
dundargoc
a5c572bd44
docs: fix typos
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Raphael <glephunter@gmail.com>
Co-authored-by: C.D. MacEachern <craig.daniel.maceachern@gmail.com>
Co-authored-by: himanoa <matsunoappy@gmail.com>
2023-04-04 19:07:33 +02:00
zeertzjq
7c8c155073
fix(api): avoid double hit-enter prompt with nvim_err_writeln (#22879) 2023-04-04 08:59:11 +08:00
bfredl
f34b849a22
Merge pull request #22847 from luukvbaal/redrstatus
fix(ui): ruler is not redrawn in cmdline with redrawstatus
2023-04-03 16:02:44 +02:00
bfredl
f28da92b46
Merge pull request #22783 from luukvbaal/inspect
refactor(lua): get all extmarks instead of iterating over namespaces
2023-04-03 13:08:28 +02:00
zeertzjq
10baf89712
vim-patch:9.0.1439: start Insert mode when accessing a hidden prompt buffer (#22867)
Problem:    Start Insert mode when accessing a hidden prompt buffer.
Solution:   Call leaving_window() in aucmd_restbuf(). (Thorben Tröbst,
            closes vim/vim#12148, closes vim/vim#12147)

cde8de0345

Cherry-pick test_prompt_buffer.vim changes from patch 9.0.0631.

Co-authored-by: orbital <orbital@holgerines.de>
2023-04-03 08:36:14 +08:00
Luuk van Baal
a930245557 refactor(lua): get all marks instead of iterating over namespaces
Inspector now also includes highlights set in anonymous namespaces.

Close #22732
2023-04-02 19:14:23 +02:00
zeertzjq
269dd747b6
refactor(defaults)!: change default 'commentstring' value to empty (#22862) 2023-04-02 23:01:48 +08:00
Luuk van Baal
c8a28b847e fix(ui): ruler is not redrawn in cmdline with redrawstatus 2023-04-02 15:24:55 +02:00
bfredl
3a4db8154f
Merge pull request #22844 from luukvbaal/stlrecording
fix(ui): recording change doesn't trigger statusline redraw
2023-04-02 13:37:24 +02:00
bfredl
da6a42cdaf
Merge pull request #22778 from luukvbaal/getext
feat(extmarks): extend nvim_buf_get_extmarks()
2023-04-02 12:00:32 +02:00
dundargoc
d510bfbc8e
refactor: remove char_u (#22829)
Closes https://github.com/neovim/neovim/issues/459
2023-04-02 16:11:42 +08:00
Gregory Anders
643c0ed571
feat: allow function passed to defaulttable to take an argument (#22839)
Pass the value of the key being accessed to the create function, to
allow users to dynamically generate default values.
2023-04-01 08:02:58 -06:00
Luuk van Baal
2a10f64e25 feat(extmarks): extend nvim_buf_get_extmarks()
Problem:    Can not get all extmarks in a buffer. Properties are missing
            from the details array.
Solution:   Allow getting all extmarks in a buffer by supplying a -1
            "ns_id". Add missing properties to the details array.
2023-04-01 13:59:03 +02:00
Christian Clason
90fdaf55c9 fix(tests): adapt treesitter/highlight_spec priority test
Still relied on the old `@Foo`->`Foo` capture to highlight mechanism;
use capture with default highlight instead.
2023-04-01 12:19:15 +02:00
Luuk van Baal
e3a3d30063 fix(ui): recording change doesn't trigger statusline redraw 2023-04-01 04:23:25 +02:00
Sindre T. Strøm
b34097fe6d
fix(api): return both link and attributes with nvim_get_hl (#22824)
Problem: No way to get the actual highlight attributes for a linked
group through |nvim_get_hl()| (not the attributes from the link target).
Solution: Return the actual attributes as well as the link target name.
2023-03-31 12:52:53 +02:00
Lewis Russell
226a6c3eae
feat(diagnostic): add support for tags
The LSP spec supports two tags that can be added to diagnostics:
unnecessary and deprecated. Extend vim.diagnostic to be able to handle
these.
2023-03-30 14:49:58 +01:00
Michal Liszcz
b7748662ed
fix(api): Use local LastSet structure in nvim_get_option_info (#22741)
fix(api): use local LastSet structure in nvim_get_option_info

* nvim_get_option_info is deprecated.
  It is always using the global LastSet information as reported in #15232.
* nvim_get_option_info2 is added.
  The new function additionally accepts an 'opts' table {scope, buf, win}
  allowing to specify the option scope and query local options from another
  buffer or window.
2023-03-29 09:59:01 +02:00
Jon Huhn
6a6191174a
test: fix flaky watchfiles tests (#22637) 2023-03-26 10:41:27 +01:00
zeertzjq
4863ca6b89
test: use exec_capture() in more places (#22787)
Problem:
Using `meths.exec2("code", { output = true })` is too verbose.

Solution:
Use exec_capture() in more places.
2023-03-26 10:49:32 +08:00
zeertzjq
4eef5ac453
vim-patch:9.0.1428: cursor in wrong position when leaving insert mode (#22786)
Problem:    Cursor in wrong position when leaving insert mode.
Solution:   Update the w_valid flags.  Position the cursor also when not
            redrawing. (closes vim/vim#12137)

c174c2e58c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-03-26 09:24:04 +08:00
bfredl
13eb6c2554
Merge pull request #22762 from bfredl/hl2cterm
fix(api): make nvim_get_hl return 'cterm' attrs properly
2023-03-25 19:26:45 +01:00
Evgeni Chasnovski
fe9cbcb3a5
feat(api): nvim_exec2(), deprecate nvim_exec() #19032
Problem:
The signature of nvim_exec() is not extensible per ":help api-contract".

Solution:
Introduce nvim_exec2() and deprecate nvim_exec().
2023-03-25 09:58:48 -07:00
Roberto Pommella Alegro
257d894d75
feat(lsp): render markdown in docs hover #22766
Problem:
LSP docs hover (textDocument/hover) doesn't handle HTML escape seqs in markdown.

Solution:
Convert common HTML escape seqs to a nicer form, to display in the float.
closees #22757

Signed-off-by: Kasama <robertoaall@gmail.com>
2023-03-25 12:46:07 -04:00
Lewis Russell
cbbf8bd666
feat(treesitter)!: deprecate top level indexes to modules (#22761)
The following top level Treesitter functions have been moved:
  - vim.treesitter.inspect_language() -> vim.treesitter.language.inspect()
  - vim.treesitter.get_query_files() -> vim.treesitter.query.get_files()
  - vim.treesitter.set_query() -> vim.treesitter.query.set()
  - vim.treesitter.query.set_query() -> vim.treesitter.query.set()
  - vim.treesitter.get_query() -> vim.treesitter.query.get()
  - vim.treesitter.query.get_query() -> vim.treesitter.query.get()
  - vim.treesitter.parse_query() -> vim.treesitter.query.parse()
  - vim.treesitter.query.parse_query() -> vim.treesitter.query.parse()
  - vim.treesitter.add_predicate() -> vim.treesitter.query.add_predicate()
  - vim.treesitter.add_directive() -> vim.treesitter.query.add_directive()
  - vim.treesitter.list_predicates() -> vim.treesitter.query.list_predicates()
  - vim.treesitter.list_directives() -> vim.treesitter.query.list_directives()
  - vim.treesitter.query.get_range() -> vim.treesitter.get_range()
  - vim.treesitter.query.get_node_text() -> vim.treesitter.get_node_text()
2023-03-24 14:43:14 +00:00
bfredl
6d267ad30c fix(api): make nvim_get_hl return 'cterm' attrs properly 2023-03-23 13:42:00 +01:00
luukvbaal
b02880593e
build(win): export extern symbols for use in FFI #22756
Makes `extern` variables accessible through ffi on Windows.

Follow-up to https://github.com/neovim/neovim/pull/15999
2023-03-23 04:58:50 -07:00
Null Chilly
c0fe6c040e
feat(api): add nvim_get_hl (#22693)
Problem: no way of getting all highlight group definitions in a namespace.

Solution: add `nvim_get_hl()`, deprecate `nvim_get_hl_by_name()` and `nvim_get_hl_by_id()`.
2023-03-23 10:31:39 +01:00
Justin M. Keyes
e51139f5c1 refactor(vim.gsplit): remove "keepsep"
string.gmatch() is superior, use that instead.
2023-03-22 17:46:01 +01:00
Justin M. Keyes
8a70adbde0 fix(vim.version): prerelease compare
Problem:
semver specifies that digit sequences in a prerelease string should be
compared as numbers, not lexically: https://semver.org/#spec-item-11
> Precedence for two pre-release versions with the same major, minor,
> and patch version MUST be determined by comparing each dot separated
> identifier from left to right until a difference is found as follows:
> 1. Identifiers consisting of only digits are compared numerically.
> 2. Identifiers with letters or hyphens are compared lexically in ASCII sort order.
> 3. Numeric identifiers always have lower precedence than non-numeric identifiers.
> 4. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
Example:
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.

Solution:
cmp_prerel() treats all digit sequences in a prerelease string as
numbers. This doesn't _exactly_ match the spec, which specifies that
only dot-delimited digit sequences should be treated as numbers...
2023-03-22 17:46:01 +01:00
Justin M. Keyes
9c49c10470 feat(vim.gsplit): gain features of vim.split
Problem:
- vim.split has more features than vim.gsplit.
- Cannot inspect the "separator" segments of vim.split or vim.gsplit.

Solution:
- Move common implementation from vim.split into vim.gsplit.
  - TODO: deprecate vim.split in favor of vim.totable(vim.gsplit())?
- Introduce `keepsep` parameter.

Related: 84f66909e4
2023-03-22 17:46:01 +01:00
bfredl
a92b38934a feat(lua): allow :=expr as a shorter version of :lua =expr
existing behavior of
  :=
and
  :[range]=

are unchanged. `|` is still allowed with this usage.

However,
   :=p
and similar are changed in a way which could be construed as a breaking
change. Allowing |ex-flags| for := in the first place was a mistake as
any form of := DOES NOT MOVE THE CURSOR. So it would print one line number
and then print a completely different line contents after that.
2023-03-22 09:10:04 +01:00
Justin M. Keyes
a40eb7cc99 feat(vim.version): more coercion with strict=false
Problem:
"tmux 3.2a" (output from "tmux -V") is not parsed easily.

Solution:
With `strict=false`, discard everything before the first digit.

- rename Semver => Version
- rename vim.version.version() => vim.version._version()
- rename matches() => has()
- remove `opts` from cmp()
2023-03-20 13:40:38 +01:00
Justin M. Keyes
a715e6f87e refactor(vim.version): use lazy.nvim semver module
Now the Nvim version string "v0.9.0-dev-1233+g210120dde81e" parses
correctly.
2023-03-20 13:40:38 +01:00
Justin M. Keyes
990c481551 refactor(vim.version): use lazy.nvim semver module
Use semver code from https://github.com/folke/lazy.nvim
License: Apache License 2.0

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2023-03-20 13:36:55 +01:00
Lewis Russell
e5641df6d3 feat: add vim.filetype.get_option() 2023-03-20 10:06:32 +00:00
Enan Ajmain
ecc4d0e435
fix(shell): on Windows :make does not echo #22728
Problem:
On Windows, :make does not display the output of the program it runs.
The cause is the default 'shellpipe'.  On Linux, nvim uses `tee` to redirect the
output to both stdout and the error file.  In Windows, for both cmd.exe and
powershell, the output is only redirected to the error file.

Solution:
- On Windows, change the 'shellpipe' default to "2>&1| tee".
    - Nvim includes `tee` in its Windows package.
- Document recommended defaults for powershell.

Fixes #12910
2023-03-19 14:25:12 -07:00
Enan Ajmain
8786b2066d
fix: pasting in terminal buffer on windows #22566
Problem:
On Windows, pasting multiple lines on a terminal buffer cause all the
lines to appear on the same line, i.e., the line breaks are lost.

Cause:
Windows shells expect "\r\n" as line break but "terminal_paste" function
uses "\n".

Solution:
Use "\r\n" as line break for pasting in terminal buffer on Windows.

Note:
Although this issue was reported with powershell set as 'shell', it
occurs in cmd too.

Fixes #14621
2023-03-19 10:23:34 -07:00
Patrick McFarland
3b28fb4cd9 fix(float): remove -1 in height clamp
Problem: Clamp for height in floating windows enforced no more than
editor height - 1, disallowing full editor height floating windows when
using cmdheight=0

Solution: Clamp to full height, removing the -1. Tested to give the
intended results with cmdheight=0, 1, or more than 1. This also
inadvertently fixes a rendering error with cmdheight >1 where the
bottom border would be overlapped by the cmdline.
2023-03-19 08:15:04 -04:00
luukvbaal
204a8b17c8
fix(column): rebuild status column when sign column is invalidated (#22690)
* fix(column): rebuild status column when sign column is invalidated

Problem:    When implementing a custom sign column through
            `'statuscolumn'`, the status column is not properly rebuilt
            when the sign column width changes.
Solution:   Force a rebuild of the status column when the sign column
            width is invalidated.

* test(column): 'statuscolumn' has correct width when (un)placing signs
2023-03-18 11:44:44 +00:00
zeertzjq
8916669d50
test(statuscolumn_spec): remove unnecessary feed('lh')
It is no longer needed after #22706.
2023-03-18 19:06:24 +08:00
zeertzjq
8bdcc91dc8
test(highlight_spec): fix warning in Visual highlight test (#22719)
Problem:    Warning in Visual highlight test.
Solution:   Don't move cursor back and forth.
2023-03-18 16:50:22 +08:00
zeertzjq
c6f8af36e1
fix(spell): properly source spell/LANG.{vim,lua} (#22716)
Using regexp doesn't work here because there are no wildcards.
2023-03-18 09:55:08 +08:00
zeertzjq
eb3fcf652b
vim-patch:9.0.0194: cursor displayed in wrong position after removing text prop (#22706)
Problem:    Cursor displayed in wrong position after removing text prop. (Ben
            Jackson)
Solution:   Invalidate the cursor position. (closes vim/vim#10898)

326c5d36e7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-03-17 21:19:34 +08:00
Justin M. Keyes
210120dde8
fix(lua): vim.deprecate() shows ":help deprecated" #22677
Problem:
vim.deprecate() shows ":help deprecated" for third-party plugins. ":help
deprecated" only describes deprecations in Nvim, and is unrelated to any
3rd party deprecations.

Solution:
If `plugin` is specified, don't show  ":help deprecated".

fix #22235
2023-03-15 05:56:13 -07:00
Ivan
4f7879dff0
fix(lsp): kill buffers after renaming a directory #22618
Problem:

When LSP client renames a directory, opened buffers in the edfitor are not
renamed or closed. Then `:wall` shows errors.

https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/util.lua#L776
works correctly if you try to rename a single file, but doesn't delete old
buffers with `old_fname` is a dir.

Solution:
Update the logic in runtime/lua/vim/lsp/util.lua:rename()

Fixes #22617
2023-03-14 05:08:37 -07:00
hrsh7th
8dde7c907c
fix(lsp): vim.lsp.util.apply_text_edits cursor validation #22636
Problem
Using wrong variable when checking the cursor position is valid or not in
vim.lsp.util.apply_text_edits.

Solution
Use the correct variable.
2023-03-14 04:59:43 -07:00
bfredl
ef31444ccc
Merge pull request #22659 from bfredl/floatruler
fix(screen): redraw the ruler for a current floating window
2023-03-14 11:28:48 +01:00
bfredl
0f1e2b6686 fix(screen): redraw the ruler for a current floating window
Semi-regression. The "ruler" behavior for a floating window
was never really specified but in practice followed the users
cursor movements in normal mode in a focused float, which seems
like a reasonable behavior to now specify.
2023-03-14 11:01:45 +01:00
dundargoc
3e8955094a
test: re-bundle cat on windows (#21255)
The builtin cat was removed in 4bc9229ecb
as it is not used during runtime but only for tests. However, it is a
very small and useful utility program that we need for a lot of our
tests, so there's no harm in bundling it, and it helps us avoid
complicating our build system by having two versions of neovim (neovim
for users and neovim for testing).

Also skip tests if "grep" or "sleep" isn't available.
2023-03-14 09:12:26 +08:00
dundargoc
b466e1d289
test: unskip working Windows tests (#22537)
Some tests that were previously not working have started to work again
for unspecified reasons, so let's enable them.
2023-03-13 11:15:24 +08:00
ii14
2daf0b37db
feat(options)!: deprecate paste, remove pastetoggle (#22647)
we cannot remove 'paste'. It is very common in plugins and configs.

'pastetoggle' can and should be removed though, it's a total waste of everyone's time because it generates bug reports and doesn't work well, and is useless because bracketed-paste works better.
2023-03-13 10:29:11 +08:00
Justin M. Keyes
673d2b52fa refactor!: rename vim.pretty_print => vim.print
Problem:
The function name `vim.pretty_print`:
1. is verbose, which partially defeats its purpose as sugar
2. does not draw from existing precedent or any sort of convention
   (except external projects like penlight or python?), which reduces
   discoverability, and degrades signaling about best practices.

Solution:
- Rename to `vim.print`.
- Change the behavior so that
  1. strings are printed without quotes
  2. each arg is printed on its own line
  3. tables are indented with 2 instead of 4 spaces
- Example:
  :lua ='a', 'b', 42, {a=3}
  a
  b
  42
  {
    a = 3
  }

Comparison of alternatives:
- `vim.print`:
  - pro: consistent with Lua's `print()`
  - pro: aligns with potential `nvim_print` API function which will
    replace nvim_echo, nvim_notify, etc.
  - con: behaves differently than Lua's `print()`, slightly misleading?
- `vim.echo`:
  - pro: `:echo` has similar "pretty print" behavior.
  - con: inconsistent with Lua idioms.
- `vim.p`:
  - pro: very short, fits with `vim.o`, etc.
  - con: not as discoverable as "echo"
  - con: less opportunity for `local p = vim.p` because of potential shadowing.
2023-03-13 01:25:09 +01:00
zeertzjq
5aec611469
test(float_spec): add missing sum_scroll_delta #22648 2023-03-12 17:14:02 -07:00
Matthias Deiml
fd2ece278b
feat(ui): add scroll_delta to win_viewport event #19270
scroll_delta contains how much the top line of a window moved since the
last time win_viewport was emitted. It is expected to be used to
implement smooth scrolling. For this purpose it only counts "virtual" or
"displayed" so folds should count as one line. Because of this it
adds extra information that cannot be computed from the topline
parameter.

Fixes #19227
2023-03-12 15:58:46 -07:00
bfredl
846a056744 refactor(redraw): make cursor position redraw use the "redraw later" pattern 2023-03-12 10:18:57 +01:00
Mathias Fußenegger
d15abd1be4
fix(lsp): use line start/end for visual line selection (#22632)
Fixes https://github.com/neovim/neovim/issues/22629
2023-03-12 09:45:28 +01:00
zeertzjq
314f20a44f
test: use a wider screen in the rightleft winhl test (#22641)
With a wide screen this actually previously caused an overflow.
2023-03-12 15:41:39 +08:00
zeertzjq
172227a446
fix(screen): correctly draw background and eob with 'rightleft' (#22640) 2023-03-12 12:10:27 +08:00
zeertzjq
1c4b3d41b5
fix(sleep): correct cursor placement (#22639)
Just setcursor_mayforce(true) is enough as Nvim uses msg_grid.
2023-03-12 10:40:27 +08:00
dundargoc
9d574f8dd7
ci: bump to windows 2022
Skip failing funcitonaltests. Use jobstart() instead termopen() for
oldtests to prevent CI freezing.
2023-03-11 22:56:16 +01:00
Lewis Russell
b55b8ddf81
Merge pull request #22613 from lewis6991/feat/tsqueryutil 2023-03-11 17:13:20 +00:00
Lewis Russell
58bbc2ea0b refactor(treesitter): add Range type aliase for Range4|Range6 2023-03-11 16:38:18 +00:00
Mathias Fußenegger
23dc2a59b6
fix(lsp): send didClose on buffer rename (#22623)
Subset of https://github.com/neovim/neovim/pull/22407 that was reverted
in https://github.com/neovim/neovim/pull/22604

If a buffer is renamed sending `didClose` for the old buffer helps
ensure the language server doesn't keep a stale document in memory.
2023-03-11 14:50:14 +01:00
zeertzjq
6d0c61d90d
fix(api): set script context when setting usercmd or option (#22624) 2023-03-11 21:09:11 +08:00
zeertzjq
8065fc9aae
fix(edit): don't subtract msg_scrolled when removing double quote (#22630)
With msg_grid there is no need to subtract msg_scrolled.
2023-03-11 20:12:58 +08:00
Jaehwang Jung
2748202e0e fix(diff): trigger on_bytes only once after diffget/diffput
Problem: The fix from b50ee4a8dc may
adjust extmark twice, triggering on_bytes callback twice.

Solution: Don't let mark_adjust adjust extmark.
2023-03-11 18:22:00 +09:00
Mathias Fußenegger
236c20795e
revert: "fix(lsp): use buffer scheme for files not stored on disk" (#22604)
Although using `buffer://` for unsaved file buffers fixes issues with
language servers like eclipse.jdt.ls or ansible-language-server, it
breaks completion and signature help for clangd.

A regression is worse than a fix for something else, so this reverts
commit 896d672736.

The spec change is also still in dicussion, see
https://github.com/microsoft/language-server-protocol/pull/1679#discussion_r1130704886
2023-03-11 07:35:23 +01:00
zeertzjq
8cb5b995b6
vim-patch:9.0.1397: highlight for popupmenu kind and extra cannot be set (#22619)
Problem:    Highlight for popupmenu kind and extra cannot be set.
Solution:   Add PmenuKind, PmenuKindSel, PmenuExtra and PmenuExtraSel
            highlight groups and use them. (Gianmaria Bajo, closes vim/vim#12114)

6a7c774920

Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
2023-03-11 10:05:47 +08:00
Mathias Fußenegger
d3c8d104bc
fix(lsp): prevent lsp tests from picking up local user config (#22606)
Sets `NVIM_APPNAME` for the lsp server instances and also for the
`exec_lua` environment to ensure local user config doesn't interfere
with the test cases.

My local `ftplugin/xml.lua` broke the LSP test cases about setting
`omnifunc` defaults.
2023-03-10 17:30:40 +01:00
Lewis Russell
46b73bf22c perf(treesitter): more efficient foldexpr 2023-03-10 11:51:33 +00:00
Lewis Russell
c5b9643bf1 fix(treesitter): better lang handling of get_parser() 2023-03-10 10:43:35 +00:00
Lewis Russell
adfa9de8eb fix(treesitter): do not error on empty filetype
Ignore instead
2023-03-10 10:41:19 +00:00
Michal Liszcz
9ef7297ef1
feat(lsp): overwrite omnifunc/tagfunc set by ftplugin #22267
Problem:
Some built-in ftplugins set omnifunc/tagfunc/formatexpr which causes
lsp.lua:set_defaults() to skip setup of defaults for those filetypes.
For example the C++ ftplugin has:
    omnifunc=ccomplete#Complete
          Last set from /usr/share/nvim/runtime/ftplugin/c.vim line 30
so the changes done in #95c65a6b221fe6e1cf91e8322e7d7571dc511a71
will always be skipped for C++ files.

Solution:
Overwrite omnifunc/tagfunc/formatexpr options that were set by stock
ftplugin.

Fixes #21001
2023-03-09 06:12:56 -08:00
Justin M. Keyes
ce0fddf5ae
feat: try to recover from missing tempdir #22573
Problem:
If vim_tempdir mysteriously goes missing (typically by "antivirus" on
Windows), any plugins using tempname() will be broken for the rest of
the session. #1432 #9833 https://groups.google.com/g/vim_use/c/ef55jNm5czI
Steps:
    mkdir foo
    TMPDIR=./foo nvim
    :echo tempname()
    !rm -r foo
    :echo tempname()
    tempname() still uses the foo path even though it was deleted.

Solution:
- Don't assume that vim_tempdir exists.
- If it goes missing once, retry vim_mktempdir and log (silently) an error.
- If it goes missing again, retry vim_mktempdir and show an error.

Rejected in Vim for performance reasons:
  https://groups.google.com/g/vim_use/c/qgRob9SWDv8/m/FAOFVVcDTv0J
  https://groups.google.com/g/vim_dev/c/cogp-Vye4oo/m/d_SVFXBbnnoJ
But, logging shows that `vim_gettempdir` is not called frequently.

Fixes #1432
Fixes #9833
Fixes #11250
Related: stdpath("run") f50135a32e
2023-03-09 05:07:36 -08:00
bfredl
46d4d420e5
Merge pull request #22547 from luukvbaal/statusline
perf(statusline): UI elements are always redrawn on K_EVENT
2023-03-09 11:06:47 +01:00
zeertzjq
89a525de9f
fix(buffer_updates): save and restore current window cursor (#16732)
When a buffer update callback is called, textlock is active so buffer
text cannot be changed, but cursor can still be moved. This can cause
problems when the buffer update is in the middle of an operator, like
the one mentioned in #16729. The solution is to save cursor position and
restore it afterwards, like how cursor is saved and restored when
evaluating an <expr> mapping.
2023-03-09 10:19:00 +08:00
Lewis Russell
be0461e3c2
fix(treesitter): is_in_node_range (#22582)
TS ranges are end column exclusive, so fix is_in_node_range
to account for that.
2023-03-08 23:45:43 +00:00
Luuk van Baal
1fb585a9db test(statusline): UI elements are not redrawn on K_EVENT unnecessarily 2023-03-08 12:35:33 +01:00
Justin M. Keyes
304477ff35 fix(man.lua): tests, naming 2023-03-07 15:23:06 +01:00
Eriks Muhins
160a019ffa feat(man.lua): support spaces in manpage names
Problem:
:Man command errors if given more than two arguments. Thus, it is
impossible to open man pages that contain spaces in their names.

Solution:
Adjust :Man so that it tries variants with spaces and underscores, and
uses the first found.
2023-03-07 15:19:24 +01:00
dundargoc
af23d17388
test: move oldtests to test directory (#22536)
The new oldtest directory is in test/old/testdir. The reason for this is
that many tests have hardcoded the parent directory name to be
'testdir'.
2023-03-07 11:13:04 +08:00
luukvbaal
bf4eada2c8
fix(column): issues with 'statuscolumn' width (#22542)
Problem:    'statuscolumn' width can be incorrect when toggling 'number'
            or setting 'statuscolumn'.
Solution:   Make sure the width is reset and re-estimated when
            'statuscolumn' and 'number' are set. (When 'relativenumber'
            is set this already happens because it always changes
            "nrwidth_line_count".)
2023-03-07 08:45:08 +08:00
bfredl
39096f48f0
Merge pull request #13834 from bfredl/omnilua
omnifunc for builtin lua
2023-03-07 00:28:53 +01:00
Björn Linse
79571b92ce feat(lua): omnifunc for builting lua interpreter
also make implicit submodules "uri" and "_inspector" work with completion

this is needed for `:lua=vim.uri_<tab>` wildmenu completion
to work even before uri or _inspector functions are used.
2023-03-06 23:12:21 +01:00
swarn
1cc23e1109
feat(lsp)!: add rule-based sem token highlighting (#22022)
feat(lsp)!: change semantic token highlighting

Change the default highlights used, and add more highlights per token.

Add an LspTokenUpdate event and a highlight_token function.

:Inspect now shows any highlights applied by token highlighting rules,
default or user-defined.

BREAKING CHANGE: change the default highlight groups used by semantic
token highlighting.
2023-03-06 19:03:13 +01:00
Justin M. Keyes
74ffebf8ec fix(vim.version): incorrect version.cmp()
Problem:
If major<major but minor>minor, cmp_version_core returns 1

Solution:
- Fix logic in cmp_version_core
- Delete most eq()/gt()/lt() tests, they are redundant.
2023-03-06 15:36:25 +01:00
Justin M. Keyes
e31e49a8e3 refactor(vim.version): cleanup
- version.cmp(): assert valid version
- add test for loading vim.version (the other tests use shared.lua in
  the test runner)
- reduce test scopes, reword test descriptions
2023-03-06 14:51:56 +01:00
Kelly Lin
0e7196438d feat(lua): add semver api 2023-03-06 13:45:59 +01:00
zeertzjq
e389b18902
vim-patch:9.0.1385: g'Esc is considered an error (#22544)
Problem:    g'Esc is considered an error.
Solution:   Make g'Esc silently abandon the command. (closes vim/vim#12110)

f86dea8119
2023-03-06 07:52:11 +08:00
dundargoc
ba38f35d3e
test: don't search entire repo for files
Searching the entire repo for a directory named "contrib" causes failure
if there happens to be another subdirectory with the name "contrib".
Instead, point directly to the correct contrib directory.
2023-03-05 11:21:37 +01:00
Jon Huhn
ac69ba5fa0
feat(lsp): implement workspace/didChangeWatchedFiles (#22405) 2023-03-05 07:52:27 +01:00
zeertzjq
39842be8cd
fix(extmarks): don't leak memory on error (#22507) 2023-03-05 07:09:28 +08:00
zeertzjq
b7d59649ac fix(redraw): get the line again after evaluating something 2023-03-04 13:53:09 +08:00
Lewis Russell
6d4f481821
fix(treesitter): disallow empty filetypes
Fixes #22473
2023-03-03 09:44:02 +00:00
zeertzjq
fb1db80f5a
test(treesitter/parser_spec): correct time unit (#22471) 2023-03-02 14:42:15 +08:00
Mike
bc15b075d1
feat(vim.fs): pass path to find() predicate, lazy evaluate #22378
Problem:
No easy way to find files under certain directories (ex: grab all files under
`test/`) or exclude the content of certain paths (ex. `build/`, `.git/`)

Solution:
Pass the full `path` as an arg to the predicate.
2023-03-01 08:51:22 -08:00
Mathias Fußenegger
896d672736
fix(lsp): use buffer scheme for files not stored on disk (#22407)
Sending `didOpen` with a `file` scheme causes problems with some
language servers because they expect the file to exist on disk.

See https://github.com/microsoft/language-server-protocol/pull/1679
2023-03-01 15:33:13 +01:00
zeertzjq
d66832c76d
test(ui): wait for another success with failure after success
Problem:
In a success-failure-success situation, if minimal timeout is reached
between the failure and the second success, the session is stopped
without waiting for the second success, causing the test to fail.

Solution:
Wait for another success if a failure is seen after a success.

Ref #22155 #22464
2023-03-01 20:16:57 +08:00
zeertzjq
aa840ab566
test(termxx_spec): fix TermClose bdelete test flakiness (#22463)
Problem:
If shell-test finishes before the next RPC call, TermClose has already
been triggered, so the test fails.

Solution:
Add INTERACT argument so that shell-test keeps running.
2023-03-01 09:56:25 +08:00
bfredl
df1d15a255
Merge pull request #22454 from bfredl/lspredraw
perf(lsp): only redraw the windows containing LSP tokens
2023-02-28 14:11:27 +01:00
bfredl
7e19cabeb1 perf(lsp): only redraw the windows containing LSP tokens
redraw! redraws the entire screen instead of just the windows with
the buffer which were actually changed.

I considered trying to calculating the range for the delta
but it looks tricky. Could a follow-up.
2023-02-28 13:11:36 +01:00
Justin M. Keyes
3b92776226
Merge #22382 has('gui_running') 2023-02-28 06:24:23 -05:00
luukvbaal
9a271f6afd
fix(column): cmdwin cursor is offset with 'statuscolumn' (#22445) 2023-02-28 10:19:58 +08:00
zeertzjq
2630341db6
fix(tui): avoid stack-use-after-scope with cursor color (#22435) 2023-02-28 07:19:03 +08:00
Justin M. Keyes
ce597235a2 feat(ui): restore has('gui_running')
Problem:
has('gui_running') is still common in the wild and our answer has
changed over time, causing frustration.
95a6ccbe9f

Solution:
Use stdin_tty/stdout_tty to decide if a UI is (not) a GUI.
2023-02-27 19:50:59 +01:00
Justin M. Keyes
7f424e2b65 feat(api): more fields in nvim_list_uis
Problem:
nvim_list_uis does not report all ":help ui-option" fields.

Solution:
Store ":help ui-option" fields on the `UI` object and update ui_array.
2023-02-27 19:50:59 +01:00
Mathias Fussenegger
f0f27e9aef Revert "feat(lsp): implement workspace/didChangeWatchedFiles (#21293)"
This reverts commit 5732aa706c.

Causes editor to freeze in projects with many watcher registrations
2023-02-25 11:17:28 +01:00
Jon Huhn
5732aa706c
feat(lsp): implement workspace/didChangeWatchedFiles (#21293) 2023-02-25 10:07:18 +01:00
Lewis Russell
c57af5d41c
feat(treesitter)!: remove silent option from language.add()
Simply use `pcall` if you want to silence an error.
2023-02-24 09:50:59 +00:00
Lewis Russell
1df3f5ec6a
feat(treesitter): upstream foldexpr from nvim-treesitter 2023-02-23 17:05:20 +00:00
Lewis Russell
75e53341f3
perf(treesitter): smarter languagetree invalidation
Problem:
  Treesitter injections are slow because all injected trees are invalidated on every change.

Solution:
    Implement smarter invalidation to avoid reparsing injected regions.

    - In on_bytes, try and update self._regions as best we can. This PR just offsets any regions after the change.
    - Add valid flags for each region in self._regions.
    - Call on_bytes recursively for all children.
       - We still need to run the query every time for the top level tree. I don't know how to avoid this. However, if the new injection ranges don't change, then we re-use the old trees and avoid reparsing children.

This should result in roughly a 2-3x reduction in tree parsing when the comment injections are enabled.
2023-02-23 15:19:52 +00:00
Christian Clason
1c37553476 test(help): drop treesitter parse error to 0
All parser errors have been fixed; make sure we don't introduce new
ones.
2023-02-23 10:24:15 +01:00
zeertzjq
524e1a0643
fix(highlight): avoid ORing underline flags (#22372)
When combining attributes use the one that takes priority.
For :highlight command use the last one specified.
For API use a hard-coded order same as the order in docs.
2023-02-23 16:15:04 +08:00
bfredl
799edca18a feat(lua): make sure require'bit' always works, even with PUC lua 5.1 2023-02-22 22:15:19 +01:00
Lewis Russell
8714a4009c
feat(treesitter): add filetype -> lang API
Problem:

  vim.treesitter does not know how to map a specific filetype to a parser.

  This creates problems since in a few places (including in vim.treesitter itself), the filetype is incorrectly used in place of lang.

Solution:

  Add an API to enable this:

  - Add vim.treesitter.language.add() as a replacement for vim.treesitter.language.require_language().
    - Optional arguments are now passed via an opts table.
    - Also takes a filetype (or list of filetypes) so we can keep track of what filetypes are associated with which langs.
    - Deprecated vim.treesitter.language.require_language().
  - Add vim.treesitter.language.get_lang() which returns the associated lang for a given filetype.
  - Add vim.treesitter.language.register() to associate filetypes to a lang without loading the parser.
2023-02-21 17:09:18 +00:00
zeertzjq
fec1181ecd
test(legacy/prompt_buffer_spec): align script with oldtest more (#22354) 2023-02-21 17:43:53 +08:00
Eduard Baturin
f43fa301c1
fix(lsp): check if the buffer is a directory before w! it (#22289) 2023-02-18 07:43:59 +01:00
zeertzjq
9381d08e29 test(tui_spec): use RPC request to setup autocommands
This avoids changing cmdline and fixes a warning.
2023-02-18 10:44:35 +08:00
zeertzjq
9b9f8dfcc4 test: make {MATCH:} behave less unexpectedly in screen:expect()
Include the rest of the line and allow multiple {MATCH:} patterns.
2023-02-18 10:44:35 +08:00
Justin M. Keyes
09b3432eaf
fix(api): allow empty Lua table for nested dicts #22268
Problem:
The Lua-API bridge allows Dict params to be empty Lua (list) tables at
the function-signature level. But not for _nested_ Dicts, because they
are not modeled:
fae7540732/src/nvim/api/keysets.lua (L184)
Some API functions like nvim_cmd check for kObjectTypeDictionary and
don't handle the case of empty Lua tables (treated as "Array").

Solution:
Introduce VALIDATE_T_DICT and use it in places where
kObjectTypeDictionary was being checked directly.

fixes #21005
2023-02-16 07:07:18 -08:00
Ghjuvan Lacambre
d34c64e342
feat: $NVIM_APPNAME #22128
This commit implements the ability to control all of the XDG paths
Neovim should use. This is done by setting an environment variable named
NVIM_APPNAME. For example, setting $NVIM_APPNAME makes Neovim look for
its configuration directory in $XDG_CONFIG_HOME/$NVIM_APPNAME instead of
$XDG_CONFIG_HOME/nvim.

If NVIM_APPNAME is not set or is an empty string, "nvim" will be used as
default.

The usecase for this feature is to enable an easy way to switch from
configuration to configuration. One might argue that the various $XDG
environment variables can already be used for this usecase. However,
setting $XDG environment variables also affects tools spawned by Neovim.
For example, while setting $XDG_CONFIG_HOME will enable Neovim to use a
different configuration directory, it will also prevent Git from finding
its "default" configuration.

Closes https://github.com/neovim/neovim/issues/21691
2023-02-16 04:15:02 -08:00
zeertzjq
968cd1ed93 vim-patch:9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Problem:    Scrolling two lines with even line count and 'scrolloff' set.
Solution:   Adjust how the topline is computed. (closes vim/vim#10545)

1d6539cf36

Cherry-pick test_scroll_opt.vim changes from patch 8.2.1432.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-02-16 08:09:41 +08:00
Justin M. Keyes
1539f71363
Merge #22214 move init_default_autocmds to lua 2023-02-14 19:13:12 -05:00
zeertzjq
05faa8f30a
test: make expect_unchanged() less confusing (#22255)
Problem:
The sleep before collecting the initial screen state is confusing and
may lead to unexpected success if it comes after a blocking RPC call.

Solution:
Remove that sleep and add an "intermediate" argument.
2023-02-15 07:26:55 +08:00
Justin M. Keyes
556f8646c0
refactor(api): consistent VALIDATE messages #22262
Problem:
Validation messages are not consistently formatted.
- Parameter names sometimes are NOT quoted.
- Descriptive names (non-parameters) sometimes ARE quoted.

Solution:
Always quote the `name` value passed to a VALIDATE macro _unless_ the
value has whitespace.
2023-02-14 11:19:28 -08:00
bfredl
9a9a4d38a8
Merge pull request #11756 from bfredl/crashfix
custom statusline crash containing unprintable unicode
2023-02-14 18:51:56 +01:00
Björn Linse
39f8aaeb81 fix(status): handle unprintable chars in the statusline 2023-02-14 15:56:14 +01:00
Lewis Russell
00c0a52f94
Merge pull request #22108 from luukvbaal/statuscolumn
perf(column): only build fold/sign column when present in 'statuscolumn'
2023-02-14 14:36:12 +00:00
Justin M. Keyes
ff3d04b75b
refactor(api): VALIDATE macros #22256
- VALIDATE() takes a format string
- deduplicate check_string_array
- VALIDATE_RANGE
- validate UI args
2023-02-14 05:07:38 -08:00
zeertzjq
3a6a7add57
test: remove unused field ext_float (#22243) 2023-02-14 18:26:22 +08:00
Justin M. Keyes
46a87a5d2b
refactor(api): VALIDATE macros #22187
Problem:
- API validation involves too much boilerplate.
- API validation errors are not consistently worded.

Solution:
Introduce some macros. Currently these are clumsy, but they at least
help with consistency and avoid some nesting.
2023-02-14 02:19:04 -08:00
luukvbaal
5396808267
fix(folds): cursorline highlight is not always applied on closed folds (#22242)
Problem:    The cursorline highlight logic checks for `w_cursor.lnum`
            which may be different from the line number passed to
            `win_line()` even when the cursor is actually on that line.
Solution:   Update cursor line highlight logic to check for the line
            number of the start of a closed fold if necessary.
2023-02-14 15:52:22 +08:00
zeertzjq
820430dc0b fix(tui): exit on input eof 2023-02-14 07:49:31 +08:00
zeertzjq
5a8039a0cb test(tui_spec): remove unnecessary arguments for remote UI 2023-02-14 07:49:31 +08:00
Jonas Strittmatter
b518aceaa8
feat(filetype): fall back to file extension when matching from hashbang (#22140)
If nothing matched in match_from_hashbang, also check the file extension table.
For a hashbang like '#!/bin/env foo', this will set the filetype to 'fooscript'
assuming the filetype for the 'foo' extension is 'fooscript' in the extension
table.
2023-02-13 16:04:16 -07:00
Lewis Russell
d359f7a533
Merge pull request #22191 from lewis6991/feat/playground_imp
feat(treesitter): playground improvements
2023-02-13 10:54:03 +00:00
zeertzjq
c2375efe56 fix(ui): make sure screen is valid after resizing
Problem:
When not inside an Ex command, screen_resize() calls update_screen(),
which calls screenclear() and set the screen as valid. However, when
inside an Ex command, redrawing is postponed so update_screen() screen
doesn't do anything, and the screen is still invalid after the resize,
causing ui_comp_raw_line() to be no-op until update_screen() is called
on the main loop.

Solution:
Restore the call to screenclear() inside screen_resize() so that the
screen is invalid after screen_resize(). Since screenclear() changes
redraw type from UPD_CLEAR to UPD_NOT_VALID, it is called at most once
for each resize, so this shouldn't change how much code is run in the
common (not inside an Ex command) case.
2023-02-13 08:50:54 +08:00
Jonas Strittmatter
9668c166e8
fix(filetype): make vim.filetype.match() work with contents only (#22181)
Co-authored-by: Gregory Anders <greg@gpanders.com>
2023-02-11 08:08:33 -07:00
glacambre
c5b34fa554 refactor: move init_default_autocmds to lua
The original motivation for this change came from developping
https://github.com/neovim/neovim/pull/22159, which will require adding
more autocommand creation to Neovim's startup sequence.

This change requires lightly editing a test that expected no autocommand
to have been created from lua.
2023-02-11 14:02:17 +01:00
zeertzjq
9437800d28 vim-patch:9.0.1298: inserting register on the cmdline does not trigger incsearch
Problem:    Inserting a register on the command line does not trigger
            incsearch or update hlsearch.
Solution:   Have cmdline_insert_reg() return CMDLINE_CHANGED when appropriate
            and handle it correctly. (Ken Takata, closes vim/vim#11960)

c4b7dec382

Co-authored-by: K.Takata <kentkt@csc.jp>
2023-02-11 19:04:27 +08:00
zeertzjq
7d58de11f4
fix(rpc)!: preseve files when stdio channel is closed (#22137)
BREAKING CHANGE: Unsaved changes are now preserved rather than discarded
when stdio channel is closed.
2023-02-11 18:25:01 +08:00
bfredl
f8f82901cd fix(tests): fixes for using vim.mpack and more ASAN 2023-02-10 20:19:04 +01:00
bfredl
d6279f9392 refactor(tests): move lua-client into core and use it for functionaltests
Eliminates lua-client and non-static libluv as test time dependencies

Note: the API for a public lua-client is not yet finished.
The interface needs to be adjusted to work in the embedded loop
of a nvim instance (to use it to talk between instances)
2023-02-10 20:19:04 +01:00
Lewis Russell
8a985d12dd fix(treesitter): don't trample parsers when filetype!=lang
This allows vim.treesitter.show_tree() to work on buffers where the
filetype does not match the parser language name e.g, bash/sh.
2023-02-10 16:15:56 +00:00
zeertzjq
1b379ce430
test(exit_spec): make sure that autocommands are triggered (#22188)
Previously, if the autocommands are not triggered, the tests may still
pass because no assertion is done. Add an assertion so that the tests
will fail if the autocommands aren't triggered.
2023-02-09 19:48:17 +08:00
zeertzjq
b2b82ff142
fix(rpc): ignore redraw events when exiting (#22184)
When a TUI client has already stopped, handling UI events will cause a
heap-use-after-free, so ignore them.
2023-02-09 14:36:17 +08:00
zeertzjq
ecc40660d1
fix(rpc): ignore redraw events when not in UI client (#21892)
Otherwise it will crash.
2023-02-09 10:53:47 +08:00
Lewis Russell
228684d2fb
fix(decoration): don't show signcolumn for non-sign_text extmark (#22135)
Fixes: #22127
2023-02-05 23:49:43 +00:00
figsoda
e1d5ad1cb8 feat(treesitter): add metadata option for get_node_text 2023-02-04 21:15:03 -05:00
figsoda
bb8845340b feat(treesitter): allow capture text to be transformed
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-02-04 21:04:45 -05:00
zeertzjq
5c4b503d3c
vim-patch:9.0.1279: display shows lines scrolled down erroneously (#22126)
Problem:    Display shows lines scrolled down erroneously. (Yishai Lerner)
Solution:   Do not change "wl_lnum" at index zero. (closes vim/vim#11938)

61fdbfa1e3

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-02-05 09:37:12 +08:00
Luuk van Baal
08fb3b5309 perf(column): only build fold/sign column when present in 'statuscolumn'
Problem:    The fold and sign column is built and stored regardless of
            whether the corresponding item is present in 'statuscolumn'.
Solution:   Since the 'statuscolumn' parses itself, we can defer
            building the columns until the corresponding item is
            actually encountered.
2023-02-04 11:04:43 +01:00
bfredl
cbf9199d65
Merge pull request #21331 from LiadOz/LiadOz/prompt-insert-extmark
fix(extmarks): adjust extmarks when inserting prompt prefix
2023-02-02 15:23:09 +01:00
luukvbaal
64fa75a86a
fix(column): estimate 'statuscolumn' width appropriately
Problem:    The 'statuscolumn' width is being estimated without the
            proper context. In particular, this resulted in the fact
            that a custom fold column could be included in the estimated
            `number_width()`, and doubly added when actually drawing the
            statuscolumn due to `win_col_off()` also adding the
            `'foldcolumn'` width. Resulting in a status column that is
            `'foldcolumn'` cells wider than necessary.
Solution:   Estimate 'statuscolumn' width in `get_statuscol_str()` when
            a buffer's line count has changed.
2023-02-02 09:35:51 +00:00
zeertzjq
2c5906b55b
fix(exit): skip unnecessary steps in TUI preserve_exit() (#21897)
This prevents the TUI from doing unexpected things when receiving a
deadly signal or running out of memory.
2023-02-02 10:05:03 +08:00
Lewis Russell
9ce44a750c
fix(man): use italics for <bs>_ (#22086)
fix(man): use italics for <bs>_

Even though underline is strictly what this should be. <bs>_ was used by
nroff to indicate italics which wasn't possible on old typewriters so
underline was used. Modern terminals now support italics so lets use
that now.

See:
- https://unix.stackexchange.com/questions/274658/purpose-of-ascii-text-with-overstriking-file-format/274795#274795
- https://cmd.inp.nsk.su/old/cmd2/manuals/unix/UNIX_Unleashed/ch08.htm
2023-02-01 17:21:42 +00:00
bfredl
8376486e8f
Merge pull request #17537 from bfredl/neolua
refactor(tests): run unittests using main nvim binary - delete separate nvim-test build
2023-01-31 19:58:33 +01:00
bfredl
13aa23b62a refactor(tests): run unittests using main nvim binary in interpreter mode
This allows us to get rid of the separate "nvim-test" target
2023-01-31 19:28:26 +01:00
Christian Clason
8b11cf5092
Merge pull request #22005 from clason/sanitize-lang
fix(treesitter): validate language name
2023-01-31 17:28:32 +01:00
bfredl
50b256d515 fix(tests): use -l mode for lsp tests
This fixes "fake server" from leaking memory, which makes ASAN very
upset, except on current ASAN CI for some reason.
2023-01-31 13:15:23 +01:00
zeertzjq
860fea1a3f
fix(highlight): properly deal with underline mask when listing (#22057) 2023-01-31 07:08:23 +08:00
Christian Clason
c032e83b22 fix(treesitter): validate language name
Problem: Some injections (like markdown) allow specifying arbitrary
language names for code blocks, which may be lead to errors when
looking for a corresponding parser in runtime path.

Solution: Validate that the language name only contains alphanumeric
characters and `_` (e.g., for `c_sharp`) and error otherwise.
2023-01-28 11:28:52 +01:00
Anton Kriese
3544082f46
test: exepath() returns correct path with cmd.exe, powershell #21928
test(exepath): test if exepath returns correct path with multiple
Windows shells

This test covers the changes from #21175 where exepath() is set to
prefer file extensions in powershell.exe aswell as in cmd.exe.

In both shells, the file with a valid extension should be returned
instead of the extensionless file.
2023-01-26 03:06:29 -08:00
zeertzjq
62f09017e0 test: add test for :runtime completion for .lua 2023-01-26 11:55:34 +08:00
Paul "LeoNerd" Evans
f3039ce531 feat(highlight): define the concept of altfont as a (c)term rendering attribute 2023-01-24 11:27:50 +00:00
Paul "LeoNerd" Evans
f5d357de55 refactor(highlight): reshape the HL_UNDER* bits into a 3-bit integer mask
Saves two bits for reuse for new features
2023-01-24 11:27:50 +00:00
zeertzjq
c6ab8dfc15
revert: "refactor(win_close): remove "force", don't pass on "free_buf" (#21921)" (#21979)
This reverts commit 0371d0f7af.

> 'bufhidden' option exists. I don't think we should assume autoclosing
windows are fine just because 'hidden' is set.
2023-01-24 18:31:07 +08:00
zeertzjq
fca39eeabb
fix(api): don't allow hiding aucmd_win from another tabpage (#21975) 2023-01-24 15:39:43 +08:00
Sean Dewar
bcdbf77537
fix(lsp): check method is supported when range formatting (#21970)
`vim.lsp.buf.format()` silently did nothing if no servers supported
`textDocument/rangeFormatting` when formatting with a range.

Issue found by `@hwrd:matrix.org` in the Matrix chat.
2023-01-24 07:15:43 +01:00
zeertzjq
3b75485043
revert: "shada/context: fully remove jumplist duplicates #10898" (#21874)
This reverts commit 8b8ecf44f2.
It is causing performance problems on exit.
Fix #21082.
2023-01-23 19:32:27 +08:00
zeertzjq
0371d0f7af
refactor(win_close): remove "force", don't pass on "free_buf" (#21921)
Problem:
The "force" flag of win_close() complicates the code and adds edge cases
where it is not clear what the correct behavior should be.
The "free_buf" flag of win_close() is passed on to float windows when
closing the last window of a tabpage, which doesn't make much sense.

Solution:
Remove the "force" flag and always close float windows as if :close! is
used when closing the last window of a tabpage, and set the "free_buf"
flag for a float window based on whether its buffer can be freed.
As 'hidden' is on by default, this change shouldn't affect many people.
2023-01-23 18:55:11 +08:00
Arnout Engelen
cb757f2663
build: make generated source files reproducible #21586
Problem:
Build is not reproducible, because generated source files (.c/.h/) are not
deterministic, mostly because Lua pairs() is unordered by design (for security).

https://github.com/LuaJIT/LuaJIT/issues/626#issuecomment-707005671
https://www.lua.org/manual/5.1/manual.html#pdf-next
> The order in which the indices are enumerated is not specified [...]
>
>> The hardening of the VM deliberately randomizes string hashes. This in
>> turn randomizes the iteration order of tables with string keys.

Solution:
- Update the code generation scripts to be deterministic.
    - That is only a partial solution: the exported function
      (funcs_metadata.generated.h) and ui event
      (ui_events_metadata.generated.h) metadata have some mpack'ed
      tables, which are not serialized deterministically.
    - As a workaround, introduce `PRG_GEN_LUA` cmake setting, so you can
      inject a modified build of luajit (with LUAJIT_SECURITY_PRN=0)
      that preserves table order.
    - Longer-term we should change the mpack'ed data structure so it no
      longer uses tables keyed by strings.

Closes #20124

Co-Authored-By: dundargoc <gocdundar@gmail.com>
Co-Authored-By: Arnout Engelen <arnout@bzzt.net>
2023-01-23 01:26:46 -08:00
luukvbaal
323ea17a19
fix(extmarks): problems with folded virtual lines (#21930)
Problem:    When a folded line has virtual lines attached, the following
            problems occur:
              - The virtual lines are drawn empty.
              - The 'foldtext' line is drawn empty.
              - The cursor is drawn incorrectly.
Solution:   Check whether virtual lines belong to a folded line.

Fix #17027
Fix #19557
Fix #21837

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-01-23 07:43:04 +08:00
Matthieu Coudron
151b9fc52e
feat(treesitter): show filetype associated with parser (#17633)
to ease debug. At one point I had an empty filetype and the current message was not helpful enough
2023-01-22 16:51:17 +01:00
zeertzjq
18fb669b9b
fix(completion): include lua syntaxes in :ownsyntax completion (#21941)
This just removes DIP_LUA and always executes its branches.
Also add tests for cmdline completion for other lua runtime files.
2023-01-22 11:19:58 +08:00
zeertzjq
0f52e2c849
vim-patch:8.2.0382: some tests fail when run under valgrind (#21936)
Problem:    Some tests fail when run under valgrind.
Solution:   Increase timeouts.

353c351bd2

Cherry-pick Test_pum_with_preview_win() from patch 8.2.0011.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-01-21 20:50:46 +08:00
zeertzjq
fb805bb8b7
fix(remote): don't leak memory on failure to connect to server (#21931)
Also fix the race between output and resize in the test for this.
2023-01-21 18:54:17 +08:00
zeertzjq
eec979ca81
test(tui_spec): don't expect exact screen in rapid resize test (#21935)
There may be a race between resizes, so don't expect exact screen.
Expect window width instead.
2023-01-21 18:15:38 +08:00
zeertzjq
e336251f2b
test(tui_spec): make rapid resize test test what it wants to test (#21933)
Actually execute the command.
Don't use assert_alive() as it checks the host session instead of the
child session. Use screen:expect() instead.
2023-01-21 17:11:02 +08:00
zeertzjq
0481f04ec9
test(syn_attr_spec): add more information (#21912)
This makes it clear on test failure what the attributes are.
2023-01-20 10:03:29 +08:00
luukvbaal
999bb983f0
perf(statuscolumn): only fill click defs array once per redraw (#21884)
Problem:    'statuscolumn' click definitions are cleared, evaluated,
            allocated and filled each redraw for every row in a window.
            This despite the fact that we only store a single click
            definition array for the entire column as opposed to one
            for each row.
Solution:   Only fill the 'statuscolumn' click definition array once per
            window per redraw.

Resolve https://github.com/neovim/neovim/issues/21767.
2023-01-20 07:47:02 +08:00
zeertzjq
6e3890f4ce
vim-patch:8.2.4655: cmdline completion popup menu positioned wrong (#21894)
Problem:    Command line completion popup menu positioned wrong when using a
            terminal window.
Solution:   Position the popup menu differently when editing the command line.
            (Yegappan Lakshmanan, closes vim/vim#10050, closes vim/vim#10035)

1104a6d0c2

The test in the patch looks a bit hard to understand.
Add a Lua test that is more straightforward.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-01-19 15:13:27 +08:00
zeertzjq
01ddc09747 fix(statusline): don't leak memory with truncated click labels 2023-01-19 10:36:29 +08:00
zeertzjq
295a264b65 fix(statusline): don't leak memory with zero-width click labels
A zero-width click label isn't assigned to any click definition, so its
function name should be freed when filling click definitions.
2023-01-19 10:36:29 +08:00
zeertzjq
f8669e8a18
vim-patch:8.2.1698: cannot lock a variable in legacy Vim script like in Vim9 (#21883)
Problem:    Cannot lock a variable in legacy Vim script like in Vim9.
Solution:   Make ":lockvar 0" work.

a187c43cfe

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-01-19 08:03:13 +08:00
zeertzjq
36555730da
fix(statuscolumn): always fill click defs array (#21878)
Click definitions are always filled for tabline, statusline and winbar,
so they should also be always filled for statuscolumn, otherwise it will
leak memory.

Note: this doesn't actually change the existing code much, because of a
typo in the existing code.
2023-01-18 17:55:03 +08:00
zeertzjq
d512678739 fix(completion): correct what modes support fuzzy completion 2023-01-17 15:55:58 +08:00
luukvbaal
f6929ea51d
fix(tabline): avoid memory leak in tabline click definitions (#21847)
Problem:    Memory is leaked in tabline click definitions since
            https://github.com/neovim/neovim/pull/21008.
Solution:   Add back a call to `stl_clear_click_defs()` that was lost in
            the refactor PR.
2023-01-17 09:51:01 +08:00
Justin M. Keyes
6c2f02cbd0 fix: failing XDG test on Windows CI
Problem:
Failing Windows CI:
    FAILED   test/functional\options\defaults_spec.lua @ 361: XDG defaults with too long XDG variables are correctly set
    test\helpers.lua:134: Pattern "Failed to start server: no such file or directory: /X/X/X" not found in log (last 10 lines): Xtest-defaults-log:
    FAILED   test/functional\options\defaults_spec.lua @ 435: XDG defaults with XDG variables that can be expanded are not expanded
    test\helpers.lua:134: Pattern "Failed to start server: no such file or directory: %$XDG_RUNTIME_DIR%/" not found in log (last 10 lines): Xtest-defaults-log:

Solution:
The assert_log() statements are not relevant on Windows, because there
XDG_RUNTIME_DIR is not used for creating servers, it uses \\.pipe\….
2023-01-17 01:57:52 +01:00
Brian Koropoff
bbdded5cf7
test(statuscolumn): %l should follow default wrap behavior (#21766) 2023-01-17 08:02:33 +08:00
Justin M. Keyes
7ebb1cf28f
Merge #21844 test: avoid noise in test logs 2023-01-16 18:38:20 -05:00
luukvbaal
da3460562e
fix(api): avoid memory leak with click functions in nvim_eval_statusline() (#21845)
Problem:    Allocated click function memory is lost due to
            `nvim_eval_statusline()` not passing in a `StlClickRecord`.
Solution:   Do not allocate click function memory if `tabtab == NULL`.

Resolve #21764, supersede #21842.
2023-01-17 07:31:36 +08:00
Justin M. Keyes
665a7dafaf refactor(tests): lift retry() into assert_log() 2023-01-17 00:19:30 +01:00
Justin M. Keyes
6ec7bcb618 test: avoid noise in NVIM_LOG_FILE
Problem:
Tests that _intentionally_ fail certain conditions cause noise in
$NVIM_LOG_FILE:

    $NVIM_LOG_FILE: /home/runner/work/neovim/neovim/build/.nvimlog
    (last 100 lines)
    WRN 2023-01-16T18:26:27.673 T599.7799.0 unsubscribe:519: RPC: ch 1: tried to unsubscribe unknown event 'doesnotexist'
    WRN 2023-01-16T18:29:00.557 ?.11151    server_start:163: Failed to start server: no such file or directory: /X/X/X/...
    WRN 2023-01-16T18:33:07.269 127.0.0.1:12345 server_start:163: Failed to start server: address already in use: 127.0.0.1
    ...
    -- Output to stderr:
    module 'vim.shared' not found:
    	no field package.preload['vim.shared']
    	no file './vim/shared.lua'
    	no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared.lua'
    	no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared/init.lua'
    	no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared.lua'
    	no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared/init.lua'
    	no file './vim/shared.so'
    	...
    E970: Failed to initialize builtin lua modules

Solution:
- Log to a private $NVIM_LOG_FILE in tests that intentionally fail and
  cause ERR log messages.
- Assert that the expected messages are actually logged.
2023-01-16 23:56:56 +01:00
zeertzjq
9ccc6de8d3
Merge pull request #21768 from luukvbaal/test-virtline
fix(column)!: ensure 'statuscolumn' works with virtual and wrapped lines

BREAKING CHANGE: In 'statuscolumn' evaluation, `v:wrap` has been
replaced by `v:virtnum`. `v:virtnum` is negative when drawing
virtual lines, zero when drawing the actual buffer line, and
positive when drawing the wrapped part of a buffer line.
2023-01-17 06:24:52 +08:00
Christian Clason
d8eb99e363
Merge pull request #21828 from clason/bump-libvterm
build(deps): bump libvterm to v0.3.1
2023-01-16 19:04:24 +01:00
Christian Clason
7295ed1f6f build(deps): bump libvterm to v0.3.1
Included patches:

821. By Paul "LeoNerd" Evans on 2022-12-29
Don't bother to emit the unrecognised sequence in DECRQSS response as it provides an echo roundtrip possibility

820. By Paul "LeoNerd" Evans on 2022-11-26
erase_internal() should only set fg/bg colour, resetting other attributes (especially RV)

819. By Paul "LeoNerd" Evans on 2022-11-09
Added vterm_screen_set_default_colors(), which repaints the cells in the buffer(s)

818. By Paul "LeoNerd" Evans on 2022-11-09
Permit either colour argument to be NULL to vterm_state_set_default_colors()

817. By Paul "LeoNerd" Evans on 2022-10-01
Delete the mk_wcswidth functions as they're not used; guard the CJK-wide one with an ifdef as by default we don't use it

816. By Paul "LeoNerd" Evans on 2022-10-01
Make sure to supply empty (void) prototype to functions that take no arguments in bin/vterm-ctrl.c
2023-01-16 18:40:19 +01:00
Luuk van Baal
54470336ff fix(column): avoid drawing columns for virt_lines_leftcol
Problem:    The default fold column, as well as the 'statuscolumn', were
            drawn unnecessarily/unexpectedly for virtual lines placed
            with `virt_lines_leftcol` set.
Solution:   Skip the column states if a virtual line with
            `virt_lines_leftcol` set will be drawn.
2023-01-16 15:09:12 +01:00
Luuk van Baal
85111ca0f4 fix(column)!: ensure 'statuscolumn' works with virtual and wrapped lines
Problem:    The `'statuscolumn'` was not re-evaluated for wrapped lines,
            when preceded by virtual/filler lines. There was also no way
            to distinguish virtual and wrapped lines in the status column.
Solution:   Make sure to rebuild the statuscolumn, and replace variable
            `v:wrap` with `v:virtnum`. `v:virtnum` is negative when drawing
            virtual lines, zero when drawing the actual buffer line, and
            positive when drawing the wrapped part of a buffer line.
2023-01-16 14:03:09 +01:00
zeertzjq
61d5bd561a refactor: remove E5500, adjust tests
Now with try_end() including more exception info, E5500 looks like
redundant information.
Adjust tests for more exception information.
2023-01-16 18:03:08 +08:00
erw7
ce66f158b5 feat(api): show more exception info 2023-01-16 17:58:57 +08:00
bfredl
43feb973e3
Merge pull request #21731 from tk-shirasaka/fix/builtin_popup_on_ext_popupmenu
fix: properly close builtin popup in ext_popupmenu
2023-01-15 13:40:55 +01:00
zeertzjq
6134c1e8a3
test(fileio_spec): avoid expect_exit() without calling clear() (#21810)
Since before_each() doesn't call clear() in these tests, after_each()
may call expect_exit() without calling clear() if a test is skipped,
causing frequent test failures on Cirrus CI. Close the session instead.
2023-01-15 09:34:21 +08:00
zeertzjq
066a1a069b vim-patch:8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Problem:    Cannot use page-up and page-down in the command line completion
            popup menu.
Solution:   Check for to page-up and page-down keys. (Yegappan Lakshmanan,
            closes vim/vim#9960)

5cffa8df7e

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-01-15 07:36:58 +08:00
Liad Oz
da70c39405 fix(extmarks): adjust extmarks when inserting prompt prefix 2023-01-14 20:11:03 +02:00
zeertzjq
d98e4e4b2e vim-patch:9.0.1195: restoring KeyTyped when building statusline not tested
Problem:    Restoring KeyTyped when building statusline not tested.
Solution:   Add a test.  Clean up and fix other tests. (closes vim/vim#11815)

378e6c03f9
2023-01-14 20:27:40 +08:00
zeertzjq
d1183b48ad
vim-patch:8.2.4341: command line not redrawn when finishing popup menu (#21792)
Problem:    Command line not redrawn when finishing popup menu and the screen
            has scrolled up.
Solution:   Redraw the command line after updating the screen. (closes vim/vim#9722)

414acd342f

Code change is N/A as Nvim doesn't call update_screen() here.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-01-14 18:36:59 +08:00
luukvbaal
4a12372ccf
fix(statuscolumn): make %l/%r respect 'number'/'relativenumber' (#21747)
Resolve https://github.com/neovim/neovim/issues/21745.
2023-01-13 09:41:19 +00:00
zeertzjq
449c0762d3
test: avoid consecutive mouse input at different positions (#21781)
The seconds call's position may override the first call if the first
call isn't processed yet, defeating the purpose of the first call.
2023-01-13 12:25:19 +08:00
luukvbaal
1097d239c3
fix(ui): command line issues with external messages (#21709)
* fix: don't truncate external messages
* fix: avoid resizing command line with external messages
2023-01-13 11:47:55 +08:00
luukvbaal
4876654d4c
fix(mouse): statusline click registered as statuscolumn (#21748)
fix(statuscolumn): statusline click registered as statuscolumn

Problem:  Status line click is registered as status status column click.
Solution: Check that mouse is not on the status line.

Resolve https://github.com/luukvbaal/statuscol.nvim/issues/4.
2023-01-13 07:36:59 +08:00
Enan Ajmain
2f1fd15554
fix(powershell): wrong length allocation for ":%w !" #20530
Problem:
The calculation of `len` in `make_filter_cmd` for powershell falls short
by one character for the following ex command:
  :%w !sort
This command satisfies these conditions:
  - `itmp` is not null
  - `otmp` is null
__NOTE__ that other shells circumvent this bug only because of `len`
allocation for six extra characters: a pair of curly braces and four
spaces:
  cfdb4cbada/src/nvim/ex_cmds.c (L1551-L1554)
If allocation for these six characters are removed, then bash also faces
the same bug.

Solution:
Add allocation for 6 extra bytes. 1 would do, but let's keep powershell
in sync with other shells as much as possible.
2023-01-12 09:25:29 -08:00
Raphael
572cd8031d
feat(diagnostic): vim.diagnostic.is_disabled() #21527 2023-01-12 08:57:39 -08:00
ii14
921e634119
fix(api): nvim_create_autocmd crash on invalid types inside pattern array
Co-authored-by: ii14 <ii14@users.noreply.github.com>
2023-01-12 15:25:44 +00:00
luukvbaal
0fd59f0121
fix(statuscolumn): foldcolumn buffer is too small (#21761)
Resolve https://github.com/neovim/neovim/issues/21759.
2023-01-12 23:04:43 +08:00
luukvbaal
93d99aefd3
fix(statuscolumn): fix sign column highlights (#21727)
Resolve #21726.
2023-01-11 09:52:11 +08:00
shirasaka
b603d6f9e7 fix: properly close builtin popup in ext_popupmenu 2023-01-11 08:52:12 +09:00
dundargoc
438b4361cc
build: use modern cmake (#21589)
Replace old-school cmake with the so-called "Modern CMake", meaning
preferring using targets and properties over directory settings and
variables. This allows greater flexibility, robustness and clarity over
how the code works.

The following deprecated commands will be replaced with their modern
alternatives that operates on a specific target, rather than all targets
in the current directory:

- add_compile_options -> target_compile_options
- include_directories -> target_include_directories
- link_libraries -> target_link_libraries
- add_definitions -> target_compile_definitions

There are mainly four main targets that we currently use: nvim, libnvim,
nvim-test (used by unittests) and ${texe} (used by
check-single-includes). The goal is to explicitly define the
dependencies of each target fully, rather than having everything be
dependent on everything else.
2023-01-10 18:49:57 +01:00
zeertzjq
9b1112cf48
fix(statuscolumn): fix crashes and clang/PVS warnings (#21725) 2023-01-10 21:18:12 +08:00
Sebastian Lyng Johansen
870ca1de52
feat(float): open float relative to mouse #21531
Problem:
No easy way to position a LSP hover window relative to mouse.

Solution:
Introduce another option to the `relative` key in `nvim_open_win()`.

With this PR it should be possible to override the handler and do something
similar to this https://github.com/neovim/neovim/pull/19481#issuecomment-1193248674
to have hover information displayed from the mouse.

Test case:

    ```lua
    local util = require('vim.lsp.util')

    local function make_position_param(window, offset_encoding)
        window = window or 0
        local buf = vim.api.nvim_win_get_buf(window)
        local row, col

        local mouse = vim.fn.getmousepos()
        row = mouse.line
        col = mouse.column

        offset_encoding = offset_encoding or util._get_offset_encoding(buf)
        row = row - 1
        local line = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1]
        if not line then
            return { line = 0, character = 0 }
        end
        if #line < col then
            return { line = 0, character = 0 }
        end

        col = util._str_utfindex_enc(line, col, offset_encoding)

        return { line = row, character = col }
    end

    local make_params = function(window, offset_encoding)
        window = window or 0
        local buf = vim.api.nvim_win_get_buf(window)
        offset_encoding = offset_encoding or util._get_offset_encoding(buf)
        return {
            textDocument = util.make_text_document_params(buf),
            position = make_position_param(window, offset_encoding),
        }
    end

    local hover_timer = nil
    vim.o.mousemoveevent = true

    vim.keymap.set({ '', 'i' }, '<MouseMove>', function()
        if hover_timer then
            hover_timer:close()
        end
        hover_timer = vim.defer_fn(function()
            hover_timer = nil
            local params = make_params()
            vim.lsp.buf_request(
                0,
                'textDocument/hover',
                params,
                vim.lsp.with(vim.lsp.handlers.hover, {
                    silent = true,
                    focusable = false,
                    relative = 'mouse',
                })
            )
        end, 500)
        return '<MouseMove>'
    end, { expr = true })
    ```
2023-01-10 02:22:41 -08:00
Raphael
87cfe50944
fix(ui): set stc to empty in floatwin with minimal style (#21720)
fix(ui): set stc to emtpy in floatwin with minimal style
2023-01-10 10:36:48 +01:00
zeertzjq
1df2db0bc4
test(statuscolumn): add more tests for wrapped lines (#21718)
test(statuscolumn): add more tests more wrapped lines

Also initialize a "relnum" variable to suppress a Coverity warning.
The uninitialized value wasn't actually used by build_statuscol_str().
2023-01-10 11:30:45 +08:00
luukvbaal
364b131f42
feat(ui): add 'statuscolumn' option
Problem:    Unable to customize the column next to a window ('gutter').
Solution:   Add 'statuscolumn' option that follows the 'statusline' syntax,
	    allowing to customize the status column. Also supporting the %@
	    click execute function label. Adds new items @C and @s which
	    will print the fold and sign columns. Line numbers and signs
	    can be clicked, highlighted, aligned, transformed, margined etc.
2023-01-09 17:12:06 +00:00
bfredl
fc2cd28547
Merge pull request #21702 from glepnir/fix_2
fix(api): convert title_pos string in nvim_win_get_config
2023-01-09 12:33:08 +01:00
zeertzjq
7ba39b4378 test: add more tests for Unicode 2023-01-09 17:11:39 +08:00
zeertzjq
53adccb6e0
test(tui_spec): doesn't use Unicode in cursor_address test (#21703)
Using Unicode makes the test flaky because of #16245.
2023-01-09 17:02:45 +08:00
Raphael
e351ab179b fix(ui): add test case 2023-01-09 14:17:32 +08:00
zeertzjq
c19bd47c0a
test(tui_spec): improve cursor_address test (#21700) 2023-01-09 12:20:50 +08:00
TJ DeVries
904c13e6b5
dist: transpile cfilter.vim => cfilter.lua #21662
Vim has changed cfilter.vim from vimscript to vim9script.
Nvim supports only vimscript, not vim9script.
2023-01-08 12:31:38 -08:00
Gregory Anders
6ffa434f0b refactor(editorconfig)!: change editorconfig_enable to editorconfig 2023-01-07 08:19:37 -07:00
Gregory Anders
34d1eaa792 feat(editorconfig): allow editorconfig to be toggled dynamically
Rather than only check `editorconfig_enable` when the plugin is loaded,
check it each time the autocommand fires, so that users may enable or
disable it dynamically.

Also check for a buffer local version of the variable, so that
editorconfig can be enabled or disabled per-buffer.
2023-01-07 08:19:12 -07:00
Justin M. Keyes
e17430c1cd feat(lua): store "nvim -l" scriptname in _G.arg[0] 2023-01-07 03:03:38 +01:00
bfredl
b303ab9a7d fix(tui): do not invoke loop recursively for pad()
fixes #21610
2023-01-06 11:01:02 +01:00
Justin M. Keyes
f43de742e8 feat(lua): execute stdin ("-") as Lua 2023-01-05 17:10:02 +01:00
Justin M. Keyes
adef308a59 feat(lua): exit 1 on Lua "-l" script error 2023-01-05 17:10:02 +01:00
Justin M. Keyes
45549f031e feat(lua): send "--" literally to Lua "-l" script
Problem:
When "-l" is followed by "--", we stop sending args to the Lua script
and treat "--" in the usual way. This was for flexibility but didn't
have a strong use-case, and has these problems:
- prevents Lua "-l" scripts from handling "--" in their own way.
- complicates the startup logic (must call nlua_init before command_line_scan)

Solution:
Don't treat "--" specially if it follows "-l".
2023-01-05 17:10:02 +01:00
Justin M. Keyes
7c94bcd2d7 feat(lua)!: execute Lua with "nvim -l"
Problem:
Nvim has Lua but the "nvim" CLI can't easily be used to execute Lua
scripts, especially scripts that take arguments or produce output.

Solution:
- support "nvim -l [args...]" for running scripts. closes #15749
- exit without +q
- remove lua2dox_filter
- remove Doxyfile. This wasn't used anyway, because the doxygen config
  is inlined in gen_vimdoc.py (`Doxyfile` variable).
- use "nvim -l" in docs-gen CI job

Examples:

    $ nvim -l scripts/lua2dox.lua --help
    Lua2DoX (0.2 20130128)
    ...

    $ echo "print(vim.inspect(_G.arg))" | nvim -l - --arg1 --arg2
    $ echo 'print(vim.inspect(vim.api.nvim_buf_get_text(1,0,0,-1,-1,{})))' | nvim +"put ='text'" -l -

TODO?
  -e executes Lua code
  -l loads a module
  -i enters REPL _after running the other arguments_.
2023-01-05 17:10:02 +01:00
TJ DeVries
39d70fcafd
dist: generated version of ccomplete.vim (#21623)
This is the first PR featuring a conversion of an upstream vim9script file
into a Lua file.

The generated file can be found in `runtime/autoload/ccomplete.vim` in
the vim repository. Below is a limited history of the changes of that file
at the time of conversion.

```
❯ git log --format=oneline runtime/autoload/ccomplete.vim
c4573eb12dba6a062af28ee0b8938d1521934ce4 Update runtime files
a4d131d11052cafcc5baad2273ef48e0dd4d09c5 Update runtime files
4466ad6baa22485abb1147aca3340cced4778a66 Update runtime files
d1caa941d876181aae0ebebc6ea954045bf0da24 Update runtime files
20aac6c1126988339611576d425965a25a777658 Update runtime files.
30b658179962cc3c9f0a98f071b36b09a36c2b94 Updated runtime files.
b6b046b281fac168a78b3eafdea9274bef06882f Updated runtime files.
00a927d62b68a3523cb1c4f9aa3f7683345c8182 Updated runtime files.
8c8de839325eda0bed68917d18179d2003b344d1 (tag: v7.2a) updated for version 7.2a
...
```

The file runtime/lua/_vim9script.lua only needs to be updated when vim9jit is updated
(for any bug fixes or new features, like implementing class and interface, the latest in vim9script).

Further PRs will improve the DX of generated the converted lua and
tracking which files in the neovim's code base have been generated.
2023-01-05 11:00:32 -05:00
zeertzjq
ae64772a88
fix(diff): avoid restoring invalid 'foldcolumn' value (#21650)
Use "0" for 'foldcolumn' when w_p_fdc_save is empty, like how
"manual" is used for 'foldmethod' when w_p_fdm_save is empty.
2023-01-05 07:12:02 +08:00
zeertzjq
89232b8b48
fix(tui): make a copy of data->params before unibi_format() (#21643)
Problem:    When unibi_format() modifies params and data->buf overflows,
            unibi_format() is called again, causing the params to be
            modified twice. This can happen for escapes sequences that
            use the %i terminfo format specifier (e.g. cursor_address),
            which makes unibi_format() increase the param by 1.
Solution:   Make a copy of data->params before calling unibi_format().
2023-01-05 00:25:25 +08:00
zeertzjq
ef18c9f9b0
test(tui_spec): avoid race between nvim_paste and nvim_input (#21639)
Now that the TUI calls nvim_paste and nvim_input through RPC, the data
race is much more likely, as nvim_paste is deferred while nvim_input is
not. Add an expect_child_buf_lines() call to avoid the race.
2023-01-04 08:39:20 +08:00