Commit Graph

138 Commits

Author SHA1 Message Date
Justin M. Keyes
c8e3618e0e fix(test): "tempdir not a directory" in CI logs
$NVIM_LOG_FILE: /Users/runner/work/neovim/neovim/build/.nvimlog
    WRN 2024-09-08T21:48:13.279 ?.21134    vim_mktempdir:3281: $TMPDIR tempdir not a directory (or does not exist): TMPDIR-should-be-ignored
    WRN 2024-09-08T21:48:13.312 ?.21137    vim_mktempdir:3281: $TMPDIR tempdir not a directory (or does not exist): TMPDIR-should-be-ignored
2024-09-09 12:23:54 +02:00
Justin M. Keyes
ed832b9ddf refactor(test): rename alter_slashes, invert its behavior
- `alter_slashes` belongs in `testutil.lua`, not `testnvim.lua`.
- `alter_slashes` is an unusual name. Rename it to `fix_slashes`.
- invert its behavior, to emphasize that `/` slashes are the preferred,
  pervasive convention, not `\` slashes.
2024-09-09 12:23:54 +02:00
Justin M. Keyes
8a2aec9974
fix(startup): server fails if $NVIM_APPNAME is relative dir #30310
Problem:
If $NVIM_APPNAME is a relative dir path, Nvim fails to start its
primary/default server, and `v:servername` is empty.
Root cause is d34c64e342, but this wasn't
noticed until 96128a5076 started reporting the error more loudly.

Solution:
- `server_address_new`: replace slashes "/" in the appname before using
  it as a servername.
- `vim_mktempdir`: always prefer the system-wide top-level "nvim.user/"
  directory. That isn't intended to be specific to NVIM_APPNAME; rather,
  each *subdirectory* ("nvim.user/xxx") is owned by each Nvim instance.
  Nvim "apps" can be identified by the server socket(s) stored in those
  per-Nvim subdirs.

fix #30256
2024-09-08 12:48:32 -07:00
Justin M. Keyes
76aa3e52be
feat(defaults): popupmenu "Open in browser", "Go to definition" #30261
- Use the popup to expose more features such as LSP and gx.
- Move the copy/paste items lower in the menu, they are lower priority.
2024-09-05 05:56:00 -07:00
Justin M. Keyes
96128a5076 feat(startup): validate --listen address
Problem:
`nvim --listen` does not error on EADDRINUSE. #30123

Solution:
Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead
of the old, ambiguous situation where it was both an input *and* an
output), we can be fail fast instead of trying to "recover". This
reverts the "recovery" behavior of
704ba4151e, but that was basically
a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
2024-09-02 22:41:41 +02:00
dundargoc
052498ed42 test: improve test conventions
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.

Closes https://github.com/neovim/neovim/issues/27004.
2024-04-23 18:17:04 +02:00
Lewis Russell
81fc27124b refactor(test): inject after_each differently 2024-04-10 15:53:50 +01:00
dundargoc
7035125b2b test: improve test conventions
Work on https://github.com/neovim/neovim/issues/27004.
2024-04-08 22:51:00 +02:00
zeertzjq
ae28ef327e
fix: adjust error message for error in UI event callback (#28200)
Also close Nvim instance before removing log file, otherwise the Nvim
instance will still write to the log file.

Also adjust log level in libuv_process_spawn(). Ref #27660
2024-04-06 11:18:43 +08:00
Raphael
dbc0fa9bd6
fix(stdpath): remove duplicate directories (#26653) 2024-04-03 18:44:57 +08:00
dundargoc
ffe3002568 test: silence expected errors
This will remove unrelated errors in .nvimlog at the end of test output.
2024-04-02 17:07:44 +02:00
bfredl
0c59771e31 refactor(tests): all screen tests should use highlights
This is the first installment of a multi-PR series significantly
refactoring how highlights are being specified.

The end goal is to have a base set of 20 ish most common highlights,
and then specific files only need to add more groups to that as needed.

As a complicating factor, we also want to migrate to the new default
color scheme eventually. But by sharing a base set, that future PR
will hopefully be a lot smaller since a lot of tests will be migrated
just simply by updating the base set in place.

As a first step, fix the anti-pattern than Screen defaults to ignoring
highlights. Highlights are integral part of the screen state, not
something "extra" which we only test "sometimes". For now, we still
allow opt-out via the intentionally ugly

  screen._default_attr_ids = nil

The end goal is to get rid of all of these eventually (which will be
easier as part of the color scheme migration)
2024-03-23 13:44:35 +01:00
Famiu Haque
58cc66ee1f
test(options): add test for 'modified' 2024-03-21 19:40:13 +06:00
zeertzjq
1da0f3494e
test: correct order of arguments to eq() (#27816) 2024-03-11 22:23:14 +08:00
Colin Kennedy
141182d6c6 vim-patch:9.1.0147: Cannot keep a buffer focused in a window
Problem:  Cannot keep a buffer focused in a window
          (Amit Levy)
Solution: Add the 'winfixbuf' window-local option
          (Colin Kennedy)

fixes:  vim/vim#6445
closes: vim/vim#13903

2157035637

N/A patch:
vim-patch:58f1e5c0893a
2024-03-11 11:38:13 +08:00
Evgeni Chasnovski
85cb0b0ddc
fix(defaults): make terminal autoclose not block other events (#27581)
Problem: When terminal is autocloses, it blocks other events, like
  `BufEnter`.

Solution: Use `nested = true`.
2024-02-22 13:54:21 -06:00
zeertzjq
780dd88b68
vim-patch:9.1.0039: too vague errors for 'listchars'/'fillchars' (#27070)
Problem:  too vague errors for 'listchars'/'fillchars'
Solution: Include the field name in error message.
          (zeertzjq)

related: #27050
closes: vim/vim#13877

6a8d2e1634

Co-authored-by: Cole Frankenhoff <cole.nhf@gmail.com>
2024-01-18 07:14:12 +08:00
Lewis Russell
795f896a57 test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
Lewis Russell
4f81f506f9 test: normalise nvim bridge functions
- remove helpers.cur*meths
- remove helpers.nvim
2024-01-12 17:53:27 +00:00
Lewis Russell
c30f2e3182 test: typing for helpers.meths 2024-01-12 13:01:06 +00:00
Lewis Russell
284e0ad26d test: use vim.mpack and vim.uv directly 2024-01-12 12:04:20 +00:00
Lewis Russell
d33e1da9b7 test: do not inject vim module into global helpers 2024-01-12 12:04:18 +00:00
bfredl
aeb053907d refactor(options): use schar_T representation for fillchars and listchars
A bit big, but practically it was a lot simpler to change over all
fillchars and all listchars at once, to not need to maintain two
parallel implementations.

This is mostly an internal refactor, but it also removes an arbitrary
limitation: that 'fillchars' and 'listchars' values can only be
single-codepoint characters. Now any character which fits into a single
screen cell can be used.
2024-01-08 14:37:55 +01:00
Justin M. Keyes
04f2f864e2 refactor: format test/* 2024-01-03 02:09:29 +01:00
zeertzjq
49efdf8413
test: "diff" flag of 'fillchars' (#26657) 2023-12-19 22:46:38 +08:00
zeertzjq
1037ce2e46 test: avoid repeated screen lines in expected states
This is the command invoked repeatedly to make the changes:

    :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
2023-12-09 22:15:02 +08:00
zeertzjq
272ef27115
vim-patch:9.0.2035: [security] use-after-free with wildmenu (#25687)
Problem:  [security] use-after-free with wildmenu
Solution: properly clean up the wildmenu when exiting

Fix wildchar/wildmenu/pum memory corruption with special wildchar's

Currently, using `wildchar=<Esc>` or `wildchar=<C-\>` can lead to a
memory corruption if using wildmenu+pum, or wrong states if only using
wildmenu. This is due to the code only using one single place inside the
cmdline process loop to perform wild menu clean up (by checking
`end_wildmenu`) but there are other odd situations where the loop could
have exited and we need a post-loop clean up just to be sure. If the
clean up was not done you would have a stale popup menu referring to
invalid memory, or if not using popup menu, incorrect status line (if
`laststatus=0`).

For example, if you hit `<Esc>` two times when it's wildchar, there's a
hard-coded behavior to exit command-line as a failsafe for user, and if
you hit `<C-\><C-\><C-N>` it will also exit command-line, but the clean
up code would not have hit because of specialized `<C-\>` handling.

Fix Ctrl-E / Ctrl-Y to not cancel/accept wildmenu if they are also
used for 'wildchar'/'wildcharm'. Currently they don't behave properly,
and also have potentially memory unsafe behavior as the logic is
currently not accounting for this situation and try to do both.
(Previous patch that addressed this: vim/vim#11677)

Also, correctly document Escape key behavior (double-hit it to escape)
in wildchar docs as it's previously undocumented.

In addition, block known invalid chars to be set in `wildchar` option,
such as Ctrl-C and `<CR>`. This is just to make it clear to the user
they shouldn't be set, and is not required for this bug fix.

closes: vim/vim#13361

8f4fb007e4

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-17 22:43:42 +08:00
Rory Nesbitt
a66b0fdfaa
feat: NVIM_APPNAME supports relative paths #25233
Problem:
NVIM_APPNAME does not allow path separators in the name, so relative
paths can't be used:

    NVIM_APPNAME="neovim-configs/first-config" nvim
    NVIM_APPNAME="neovim-configs/second-config" nvim

Solution:
Let NVIM_APPNAME be a relative path. Absolute paths are not supported.

fix #23056
fix #24966
2023-09-27 10:09:55 -07:00
zeertzjq
3d3ec27d51
test(options/defaults_spec): fix NVIM_APPNAME test flakiness (#24553)
Also avoid leaving directories behind.
2023-08-04 10:37:47 +08:00
Ghjuvan Lacambre
5a3752889c
fix(NVIM_APPNAME): show error message if $NVIM_APPNAME is invalid
Closes https://github.com/neovim/neovim/issues/23056.
2023-05-28 16:04:54 +02:00
Lewis Russell
1fe1bb084d refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: famiu <famiuhaque@protonmail.com>
2023-05-21 15:14:01 +06:00
zeertzjq
b8d5586d5b refactor: using a different error number for 'mousescroll'
Because E548 is linked to 'guicursor' in help.
2023-05-05 09:19:06 +08:00
zeertzjq
75119fcc86 vim-patch:8.2.3135: Vim9: builtin function arguments not checked at compile time
Problem:    Vim9: builtin function arguments not checked at compile time.
Solution:   Add more type checks. (Yegappan Lakshmanan, closes vim/vim#8539)

5b73992d8f

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-05-05 09:19:05 +08: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
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
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
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
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
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
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
dundargoc
5eb5f49488
test: simplify platform detection (#21020)
Extend the capabilities of is_os to detect more platforms such as
freebsd and openbsd. Also remove `iswin()` helper function as it can be
replaced by `is_os("win")`.
2022-11-22 08:13:30 +08:00
zeertzjq
23080a4d7a
fix(mouse): ensure no scrolling with "ver:0" in 'mousescroll' (#20861) 2022-10-30 07:10:39 +08:00
dundargoc
df646572c5
docs: fix typos (#20394)
Co-authored-by: Raphael <glephunter@gmail.com>
Co-authored-by: smjonas <jonas.strittmatter@gmx.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-30 09:53:52 +02:00
Justin M. Keyes
16336c486e feat(gen_help_html.lua): adapt to new parser
- adapt to parser changes from https://github.com/vigoux/tree-sitter-vimdoc/pull/16
- numerous other generator improvements
2022-09-28 18:34:20 +02:00
zeertzjq
603f7bd253 fix(fillchars): change fallback after setcellwidths() 2022-08-08 20:03:40 +08:00
Jay
93c8fe77cb
feat: add 'mousescroll' option (#12355)
Add 'mousescroll' option to control how many lines to scroll by when a
mouse wheel keycode is received. The mousescroll option controls both
horizontal and vertical scrolling. The option is a string in the format:

    set mousescroll=direction:count,direction:count

Where direction is either "ver" or "hor", and count is a non negative
integer. If a direction is omitted, a default value is used. The default
values remain unchanged, that is 3 for vertical scrolling, and 6 for
horizontal scrolling. As such, the mousescroll default is "ver:3,hor:6".

Add mousescroll documentation
 - Add option documentation in options.txt
 - Add brief summary in quickref.txt

Update :help scroll-mouse-wheel
 - Mention mousescroll option as a means of controlling scrolling.
 - Remove obsolete suggestion to map scroll wheel keys to <C-U> to
   scroll by a single line -- users should prefer the mousescroll option.
 - Add some information about the consequences of remapping scroll wheel
   keys (they lose their magic ability to affect inactive windows).

Update :help vim-differences
 - Add brief mousescroll summary under Options

Add mousescroll tests
 - Test option validation
 - Test default mousescroll value and behavior
 - Test fallback to default values
 - Test mouse vertical and horizontal scrolling in normal mode
 - Test mouse vertical and horizontal scrolling in insert mode
2022-07-06 19:34:24 +08:00
Justin M. Keyes
f50135a32e
feat: stdpath('run'), /tmp/nvim.user/ #18993
Problem:
- Since c57f6b28d7 #8519, sockets are created in ~/.local/… but XDG
  spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which
  implies that XDG_STATE_DIR is potentially non-local.
- Not easy to inspect Nvim-created temp files (for debugging etc).

Solution:
- Store sockets in stdpath('run') ($XDG_RUNTIME_DIR).
- Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims.
- Make ok() actually useful.
- Introduce assert_nolog().

closes #3517
closes #17093
2022-06-30 04:16:46 -07:00
Shougo
663cbe2620
feat: cmdheight=0 #16251
Fix https://github.com/neovim/neovim/issues/1004

Limitation: All outputs need hit-enter prompt.

Related:
https://github.com/neovim/neovim/pull/6732
https://github.com/neovim/neovim/pull/4382
2022-06-13 02:40:51 -07:00
bfredl
e3281d992e fix(tests): check for EOF on exit of nvim properly 2022-06-13 10:15:44 +02:00