Commit Graph

621 Commits

Author SHA1 Message Date
Jlll1
fedf002cb3
fix(api): nvim_win_set_cursor redraw cursorcolumn for non-current window (#21072)
fix #19063
this fixes the cursorcolumn not being redrawn for non-current windows in `nvim_win_set_cursor()`
2022-11-17 07:18:31 +08:00
Lewis Russell
fa7e1e2601
fix(api): nvim_buf_get_text regression (#21071) 2022-11-15 21:27:42 +00:00
Lewis Russell
f8c6718277
feat(lua-api): avoid unnecessary allocations (#19877)
Lua makes (or reuses) an internal copy of strings, so we can safely push
buf pointers onto the stack.
2022-11-14 18:04:36 +00:00
Lewis Russell
e8cc489acc
feat(test): add Lua forms for API methods (#20152) 2022-11-14 10:01:35 +00:00
dundargoc
5c5187c6f8
test: remove skip for 32-bit MSVC (#21030)
We don't support 32-bit windows anymore so it's not needed.
2022-11-14 16:28:30 +08:00
dundargoc
736c36c02f
test: introduce skip() #21010
This is essentially a convenience wrapper around the `pending()`
function, similar to `skip_fragile()` but more general-purpose.

Also remove `pending_win32` function as it can be replaced by
`skip(iswin())`.
2022-11-13 05:52:19 -08:00
Famiu Haque
c022140ec6 feat(api): add command name to Lua command callback opts
Adds a `name` key to the opts dict passed to Lua command callbacks
created using `nvim_create_user_command()`. This is useful for when
multiple commands use the same callback.

Note that this kind of behavior is not as strange as one might think,
even some internal Neovim commands reuse the same internal C function,
differing their behavior by checking the command name. `substitute`,
`smagic` and `snomagic` are examples of that.

This will also be useful for generalized Lua command preview functions
that can preview a wide range of commands, in which case knowing the
command name is necessary for the preview function to actually be able
to execute the command that it's supposed to preview.
2022-11-07 22:27:37 +06:00
zeertzjq
850d7146fc
fix(paste): feed keys as typed in cmdline mode (#20959) 2022-11-06 12:43:05 +08:00
dundargoc
4716a578ae docs: fix typos 2022-11-02 21:45:26 +08:00
dundargoc
5046b4b4ad
ci: add cirrus to isCI function to skip tests (#20526)
The environment variable CIRRUS_CI is manually passed to RunTests.cmake
as it doesn't get passed when using cmake script mode.
2022-10-17 17:16:31 +02:00
Justin M. Keyes
09dffb9db7
docs: various #12823
- increase python line-length limit from 88 => 100.
- gen_help_html: fix bug in "tag" case (tbl_count => tbl_contains)

ref #15632
fix #18215
fix #18479
fix #20527
fix #20532

Co-authored-by: Ben Weedon <ben@weedon.email>
2022-10-09 05:21:52 -07:00
zeertzjq
2a12faaec1
fix(api): dynamically allocate line buffer for nvim_out_write (#20537) 2022-10-08 20:10:00 +08:00
bfredl
fc1f84c4c5 test(api): migrate screenchar() test in in window API to screen test
This produces actual output in case of regressions.
2022-10-05 11:32:13 +02:00
bfredl
b414e9fdbb
Merge pull request #20364 from zeertzjq/parse-cmd-omit
fix(api)!: nvim_parse_cmd omit "count" "range" "reg" if not supported
2022-09-30 09:59:45 +02: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
zeertzjq
cb62592bcb fix(api)!: nvim_parse_cmd omit "count" "range" "reg" if not supported 2022-09-30 11:24:23 +08:00
Famiu Haque
e46eef75ac feat(nvim_cmd): allow using first argument as count
Allows `nvim_cmd` to use the first argument as count for applicable
commands. Also adds support for non-String arguments to `nvim_cmd`.
2022-09-29 19:31:40 +06:00
zeertzjq
45707c1eae
fix(api): fix nvim_cmd crash with filename expansion (#20397) 2022-09-29 16:04:14 +08:00
zeertzjq
35e2c4a2ed
fix(lua): fix architecture-dependent behavior in usercmd "reg" (#20384)
I don't think using an integer as a NUL-terminated string can work on
big-endian systems, at least.

This is also not tested. Add a test.

Also fix a mistake in the docs of nvim_parse_cmd.
2022-09-28 18:27:59 +08:00
dundargoc
2d6735d8ce
ci: move BSD jobs from sourcehut to Cirrus CI #19616
dispatch.sr.ht is being deprecated, meaning that using sourcehut CI
won't be possible (see https://github.com/neovim/neovim/issues/19609).
Since Github Actions doesn't provide any BSD runners an external service
is required and Cirrus CI seems like a good replacement for sourcehut.

Initially experimented with using FreeBSD and OpenBSD virtual machines
in GitHub Actions, but Cirrus has been a much better fit with better
performance, logs and overall experience.

Failing tests are automatically skipped on FreeBSD regardless if it's on
CI or not. Ideally these tests should only be skipped in CI with the
help of `isCI` helper function. Unfortunately, the tests don't recognize
the environment variable CIRRUS_CI even if it's set manually. This
workaround is good enough for the time being, but we might want to only
skip tests when using the CI (or even better, fix the failing tests).

Closes: https://github.com/neovim/neovim/issues/19609
2022-09-08 15:12:42 -07:00
ii14
4dc4cf3467
fix(options): mark winhighlight as list style (#19477)
Also add missing fcs, lcs and winhighlight to list of key-value options for `vim.opt`.

Co-authored-by: ii14 <ii14@users.noreply.github.com>
2022-09-07 17:59:27 +02:00
zeertzjq
1ef7720567 fix(api)!: correctly deal with number before :tab
Now nvim_parse_cmd and nvim_create_user_command use a "tab" value which
is the same as the number passed before :tab modifier instead of the
number plus 1, and "tab" value is -1 if :tab modifier is not used.
2022-09-02 22:28:57 +08:00
zeertzjq
689f5d604e feat(api): add support for :horizontal modifier 2022-09-01 20:53:43 +08:00
zeertzjq
933c80e8f9
refactor(mappings)!: mapblock_fill_dict() use API Dictionary (#20020)
This introduces the following breaking changes:
- nvim_get_keymap now always returns a LuaRef object as "callback" for a
  Lua mapping regardless of how it is called. The LuaRef object can be
  called from Lua and Vim script, but is lost over RPC.
- maparg() now returns a Funcref instead of a ref number as "callback"
  for a Lua mapping. The Funcref can be called from Lua and Vim script,
  but is lost over RPC.

This may also make nvim_get_keymap faster, but make maparg() slower.
2022-08-31 21:14:14 +08:00
zeertzjq
fa747d004a
fix(api): nvim_set_hl bail out on invalid group name (#20021) 2022-08-31 19:47:10 +08:00
zeertzjq
274e1122ad
fix(usercmd): also check for whitespace after escaped character (#19942) 2022-08-25 17:57:32 +08:00
zeertzjq
15a768eeb0
fix(api): avoid side effects with nvim_parse_cmd (#19890)
Save and restore the cursor and last search pattern and do not change
search history.
2022-08-22 18:06:18 +08:00
Javier Lopez
dde90f0ca4
fix(api/command): fargs behavior when no arguments are passed (#19862)
Problem: A command defined with `nargs="?"` returns `fargs={""}` to
a Lua callback when executed with no arguments, which is inconsistent
with how`nargs="*"` behaves.

Solution: Pass `fargs={}` for no argument with `nargs="?"` as well.
2022-08-21 15:19:29 +02:00
bfredl
d879331b0d feat(ui): allow to set the highlight namespace per window
- reimplement 'winhl' in terms of highlight namespaces
- check for EOF in screen tests (to indicate a likely crash)
2022-08-17 16:20:39 +02:00
zeertzjq
03fddfd928
fix(api): nvim_exec and nvim_cmd restore msg_col when capturing output (#19789)
This matches the code in execute_common(), preventing messages after the
API call from being printed at the wrong column.
2022-08-16 17:30:39 +08:00
Famiu Haque
78658ef383
fix(api): vim.cmd.make crashes when argument count isn't 1 (#19701)
Closes #19696
2022-08-10 18:37:59 +08:00
Lewis Russell
0fdf59ac9d
fix(api): nvim_cmd handle 0 range (#19655)
Fixes #19608
2022-08-06 13:53:37 +01:00
zeertzjq
a308f53525
fix(api): fix nvim_buf_set_text heap-use-after-free (#19644)
The line returned but ml_get_buf() may be freed by another call to
ml_get_buf(), so it is necessary to make a copy.
2022-08-06 06:22:01 +08:00
ii14
3df8d9b8c5
feat(lua): print source locations of lua callbacks (#19597)
Co-authored-by: ii14 <ii14@users.noreply.github.com>
2022-08-03 13:41:17 +01:00
zeertzjq
0a049c322f
test: improve mapping tests and docs (#19619) 2022-08-02 11:13:22 +08:00
zeertzjq
cabb23ea4d test: fix api/keymap_spec.lua tests 2022-08-01 21:54:18 +08:00
ii14
db6e93c48d
feat(api): add replace_keycodes to nvim_set_keymap (#19598) 2022-08-01 21:35:08 +08:00
Munif Tanjim
86110ec933
fix(highlight): add missing 'nocombine' to nvim_get_hl_* apis (#19586) 2022-07-31 13:38:00 +02:00
notomo
46e3e1c728
fix(api): make nvim_cmd mods.silent work correctly (#19489) 2022-07-25 09:43:39 +08:00
zeertzjq
9f837a5dcf
fix(api): fix nvim_parse_cmd interfere with printing line in Ex mode (#19400) 2022-07-17 09:59:32 +08:00
zeertzjq
73526abbbd
fix(api): do not switch win/buf if getting option in current win/buf (#19383) 2022-07-16 09:31:05 +08:00
zeertzjq
7a907c3314 feat(api): add unsilent to command APIs 2022-07-03 04:34:28 +08:00
zeertzjq
610cf9f950 vim-patch:8.0.1570: can't use :popup for a menu in the terminal
Problem:    Can't use :popup for a menu in the terminal. (Wei Zhang)
Solution:   Make :popup work in the terminal.  Also fix that entries were
            included that don't work in the current state.
29a2c08d79
2022-07-01 10:17:39 +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
zeertzjq
995e487915
refactor(highlight)!: rename attributes to match Vim (#19159)
Ref: 84f5463630
Rename:
- `underlineline` to `underdouble`
- `underdot` to `underdotted`
- `underdash` to `underdashed`

`underdouble` also now takes higher precedence than `undercurl`.
2022-06-30 16:57:44 +08:00
Famiu Haque
606ec8b708 feat(api): make nvim_parse_cmd and nvim_cmd support :filter
Also fixes a memory leak in `parse_cmdline`.

Closes #18954.
2022-06-28 17:31:04 +06:00
zeertzjq
cf23695dd7
fix(api): nvim_parse_cmd check for ambiguous user command (#19116) 2022-06-27 14:10:13 +08:00
Christian Clason
da358d4521 feat(api): support pattern array for exec_autocmds 2022-06-26 13:04:45 +02:00
zeertzjq
3c85fd817e
fix(api): check for inclusive buffer line index out of bounds correctly (#19056) 2022-06-23 21:38:00 +08:00
bfredl
374e0b6678 perf(highlight): don't allocate duplicates for color names 2022-06-21 18:40:33 +02:00
Gregory Anders
58d028f64b feat(api): add "buf" and "win" to nvim_get_option_value
These mirror their counterparts in nvim_set_option_value.
2022-06-20 09:16:21 -06:00
Oliver Marriott
98e2da7d50
fix(hl): return cterm fg/bg even if they match Normal #18981
Fixes #18980

- 831fa45ad8 is related but this doesn't regress that
- The `cterm_normal_fg_color != ae.cterm_fg_color` comparison is originally
  carried from patch to patch starting all the way back in 29bc6dfabd where it
  was avoiding setting a HL attr. But `hlattrs2dict()` now is just
  informational.
2022-06-16 18:33:58 -07:00
Justin M. Keyes
8f06520594 feat(logging): include test-id in log messages
Problem:
1. Log messages (especially in CI) are hard to correlate with tests.
2. Since b353a5c05f #11886, dumplog() prints the logs next to test
   failures. This is noisy and gets in the way of the test results.

Solution:
1. Associate an incrementing id with each test and include it in log
   messages.
    - FUTURE: add v:name so Nvim instances can be formally "named"?
2. Mention "child" in log messages if the current Nvim is a child (based
   on the presence of $NVIM).

BEFORE:

    DBG … 12345      UI: event
    DBG … 12345      log_server_msg:722: RPC ->ch 1: …
    DBG … 12345      UI: flush
    DBG … 12345      inbuf_poll:444: blocking... events_enabled=1 events_pending=0
    DBG … 23454      UI: stop
    INF … 23454      os_exit:594: Nvim exit: 0

AFTER:

    DBG … T57        UI: event
    DBG … T57        log_server_msg:722: RPC ->ch 1: …
    DBG … T57        UI: flush
    DBG … T57        inbuf_poll:444: blocking... events_enabled=1 events_pending=0
    DBG … T57/child  UI: stop
    INF … T57/child  os_exit:594: Nvim exit: 0
2022-06-15 19:23:10 -07:00
kylo252
837360868b
fix(tests): missing clear() #18927
This was caught in #18674 since it allows test isolation
2022-06-13 04:05:17 -07:00
bfredl
e3281d992e fix(tests): check for EOF on exit of nvim properly 2022-06-13 10:15:44 +02:00
kylo252
3da3cfc864
feat(autocmds): retrieve lua callback (#18642)
add a new `callback` field to `nvim_get_autocmds`
2022-06-09 07:18:56 -06:00
Famiu Haque
c84bd9e21f fix(nvim_create_user_command): make smods work with nvim_cmd
Closes #18876.
2022-06-08 15:24:52 +06:00
dundargoc
ff20d40321
docs: fix typos (#18269)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Dan Sully <dan+github@sully.org>
Co-authored-by: saher <msaher.shair@gmail.com>
Co-authored-by: Stephan Seitz <stephan.seitz@fau.de>
Co-authored-by: Benedikt Müller <d12bb@posteo.de>
Co-authored-by: Andrey Mishchenko <mishchea@gmail.com>
Co-authored-by: Famiu Haque <famiuhaque@protonmail.com>
Co-authored-by: Oliver Marriott <hello@omarriott.com>
2022-06-04 11:56:36 +08:00
Oliver Marriott
9aba204335
fix(hl): set Normal hl group sg_attr value #18820
fix #18024
2022-06-03 08:29:49 -07:00
zeertzjq
96c494dec3
refactor: correct comments and assertions about mapping rhs <Nop> (#18821)
Also avoid referring to mappings as "keymaps" in commands and docs.

						*map_empty_rhs* *map-empty-rhs*
You can create an empty {rhs} by typing nothing after a single CTRL-V (you
have to type CTRL-V two times).  Unfortunately, you cannot do this in a vimrc
file.
2022-06-01 21:37:01 +08:00
Famiu Haque
46536f53e8 feat: add preview functionality to user commands
Adds a Lua-only `preview` flag to user commands which allows the command to be incrementally previewed like `:substitute` when 'inccommand' is set.
2022-05-31 20:55:05 +06:00
Famiu Haque
9988d2f214 feat(nvim_create_user_command): pass structured modifiers to commands
Adds an `smods` key to `nvim_create_user_command` Lua command callbacks,
which has command modifiers but in a structured format. This removes the
need to manually parse command modifiers. It also reduces friction in
using `nvim_cmd` inside a Lua command callback.
2022-05-29 10:52:30 +06:00
bfredl
24352cba01
Merge pull request #18528 from lewis6991/setwinopt
feat(api): add `win` and `buf` to `nvim_set_option_value`
2022-05-25 17:05:28 +02:00
kylo252
55246d44f9
fix(autocmds): separate command from desc (#18617) 2022-05-21 15:55:48 +02:00
Famiu Haque
fb8fa004d8 fix: make nvim_cmd not suppress errors inside key mapping
Closes #18632
2022-05-19 22:23:14 +06:00
Gregory Anders
8a9ab88945
feat(api): enable nvim_exec_autocmds to pass arbitrary data (#18613)
Add a "data" key to nvim_exec_autocmds that passes arbitrary data (API
objects) to autocommand callbacks.
2022-05-18 09:51:26 -06:00
bfredl
d7dd600716
Merge pull request #18562 from famiu/feat/ui/winbar
feat(ui): add `'winbar'`
2022-05-18 13:08:07 +02:00
zeertzjq
6e414b698c
test: unskip tests on Windows (#18600)
Remove the command('qall!') from mksession_spec.lua because it prevents
helpers.rmdir() from retrying.

Allow extra trailing spaces when matching terminal lines.
2022-05-18 12:57:04 +08:00
Famiu Haque
e1bdb2a258 feat(ui): add 'winbar'
Adds support for a bar at the top of each window, enabled through the
`'winbar'` option.

Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
2022-05-18 09:27:08 +06:00
Lewis Russell
6219331c4d feat(api): add win and buf to nvim_set_option_value
Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
2022-05-17 14:48:10 +01:00
zeertzjq
f49699737c
fix(terminal): do not trim whitespace that is actually in the terminal (#16423) 2022-05-17 21:09:28 +08:00
deforde
0a3d615b1c
fix(api): nvim_eval_statusline should validate input #18347
Fix #18112

Make an exception for strings starting with "%!".
2022-05-15 13:06:23 -07:00
Famiu Haque
bbf58e6bbc refactor(ui)!: link VertSplit to Normal by default
Avoids using `gui=reverse` on `VertSplit` and makes window separators
look much nicer by default.
2022-05-15 22:37:35 +06:00
Famiu Haque
cf68f0a512
fix(api): make nvim_cmd work correctly with empty arguments list (#18527)
Closes #18526.
2022-05-11 10:51:53 -06:00
Famiu Haque
dfcc584665 feat(api): add nvim_cmd
Adds the API function `nvim_cmd` which allows executing an Ex-command through a Dictionary which can have the same values as the return value of `nvim_parse_cmd()`. This makes it much easier to do things like passing arguments with a space to commands that otherwise may not allow it, or to make commands interpret certain characters literally when they otherwise would not.
2022-05-11 13:12:16 +06:00
Famiu Haque
14f3383c0d fix(api): make nvim_parse_cmd work correctly with both range and count
It seems range and count can be used together in commands. This PR fixes
the behavior of `nvim_parse_cmd` for those cases by removing the mutual
exclusivity of "range" and "count". It also removes range line number
validation for `nvim_parse_cmd` as it's not its job to validate the
command.
2022-05-07 12:26:49 +06:00
bfredl
e3edcd06e3
Merge pull request #18438 from famiu/feat/api/nvim_parse_cmd
fix(api): make `nvim_parse_cmd` propagate errors
2022-05-06 10:30:48 +02:00
bfredl
d14d308ce8
Merge pull request #18431 from famiu/feat/api/nvim_get_autocmds/group_name
feat(api): add `group_name` to `nvim_get_autocmds`
2022-05-05 20:17:11 +02:00
Famiu Haque
96289f2416 feat(api): add group_name to nvim_get_autocmds 2022-05-05 23:17:36 +06:00
Famiu Haque
511f06a56e fix(api): make nvim_parse_cmd propagate errors
Makes `nvim_parse_cmd` propagate any errors that occur while parsing to
give the user a better idea of what's wrong with the command.
2022-05-05 23:11:57 +06:00
Famiu Haque
7aedcd8feb refactor(api): make range in nvim_parse_cmd an array
Changes the `range` value in `nvim_parse_cmd` into an array to describe
range information more concisely. Also makes `range` and `count` be
mutually exclusive by making count `-1` when command takes a range
instead of a count. Additionally corrects the behavior of `count` for
built-in commands by making the default count `0`.
2022-05-05 20:35:14 +06:00
bfredl
e6c71574a0
Merge pull request #18386 from ii14/version_dict_prerelease
feat: add "prerelease" to version dict
2022-05-04 18:49:05 +02:00
Famiu Haque
3ec93ca92c
feat(nvim_parse_cmd): add range, count, reg #18383
Adds range, count and reg to the return values of nvim_parse_cmd. Also makes
line1 and line2 be -1 if the command does not take a range. Also moves
nvim_parse_cmd to vimscript.c because it fits better there.
2022-05-04 05:04:01 -07:00
Yatao Li
29a6cda3ff feat(api/ui): win_extmarks 2022-05-03 22:26:02 +08:00
ii14
b2c92f36e1 feat: add "prerelease" to version dict 2022-05-03 11:33:55 +02:00
Famiu Haque
8dbb11ebf6 feat(api): add nvim_parse_cmdline
Adds an API function to parse a command line string and get command information from it.
2022-04-30 21:04:51 +06:00
zeertzjq
c8e45366b9 fix(mappings): fix double-free when unmapping simplifiable Lua mapping 2022-04-29 17:39:24 +08:00
zeertzjq
dde4f09f51 vim-patch:8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Problem:    Cannot map <C-H> when modifyOtherKeys is enabled.
Solution:   Add the <C-H> mapping twice, both with modifier and as 0x08.  Use
            only the first one when modifyOtherKeys has been detected.
459fd785e4

Add REPTERM_NO_SPECIAL instead of REPTERM_SPECIAL because the meaning of
"special" is different between Vim and Nvim.
Omit seenModifyOtherKeys as Nvim supports attaching multiple UIs.
Omit tests as they send terminal codes.
Keep the behavior of API functions.
2022-04-29 15:51:03 +08:00
zeertzjq
519e4c4472 test: correct order of arguments to eq() and neq() 2022-04-26 11:38:58 +08:00
Eden Zhang
813ecdac79
fix(paste): ignore mappings in Cmdline mode (#18114) 2022-04-17 08:11:53 +08:00
dundargoc
e63e5d1dbd
docs: typo fixes (#17859)
Co-authored-by: Elias Alves Moura <eliamoura.alves@gmail.com>
Co-authored-by: venkatesh <shariharanvenkatesh@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Vikas Raj <24727447+numToStr@users.noreply.github.com>
Co-authored-by: Steve Vermeulen <sfvermeulen@gmail.com>
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Co-authored-by: rwxd <rwxd@pm.me>
Co-authored-by: casswedson <58050969+casswedson@users.noreply.github.com>
2022-04-15 12:35:06 +02:00
Gregory Anders
e463eb8146
fix(api): correctly pass f-args for nvim_create_user_command (#18098)
Skip runs of whitespace and do not include `\` characters when
followed by another `\` or whitespace. This matches the behavior
of <f-args> when used with `:command`.
2022-04-13 08:04:56 -06:00
Gregory Anders
f94f75dc05 refactor!: rename nvim_add_user_command to nvim_create_user_command 2022-04-10 20:18:41 -06:00
Gregory Anders
30bc02c636 feat(api)!: pass args table to autocommand callbacks 2022-04-08 15:12:54 +02:00
bfredl
80d4d6b486
Merge pull request #17938 from ggandor/autocmd-api-names
refactor(api)!: use singular/plural consistently in the autocmd API
2022-04-01 00:35:21 +02:00
György Andorka
9d40b2fda9 refactor(api)!: use singular/plural consistently in the autocmd API 2022-03-31 23:58:47 +02:00
bfredl
4a89812d85
Merge pull request #17929 from lewis6991/autocmd
fix(api): improve autocmd error handling
2022-03-31 19:28:06 +02:00
Lewis Russell
929293815b fix(api): improve autocmd error handling
- nvim_del_augroup_* now works with pcall
- nvim_del_autocmd now errors for invalid ids
2022-03-31 14:23:53 +01:00
TJ DeVries
b80651eda9 feat(api): nvim_clear_autocmd
Co-authored-by: Christian Clason <christian.clason@uni-due.de>
2022-03-31 14:30:42 +02:00
TJ DeVries
7fb2310edb
fix: set nested before executing callback (#17801) 2022-03-30 17:59:36 +02:00
zeertzjq
a9665bb12c
fix(event-loop): duplicate display updating logic in vgetorpeek() (#17913) 2022-03-30 05:25:00 +08:00
Justin M. Keyes
72652cbc46
feat(test): use nvim_exec in helpers.source() #16064
helpers.source() was a hack to work around the lack of anonymous
:source. Its "create tempfile" behavior is not a required part of most
tests that use it.

Some tests still need the old "create tempfile" behavior either because
they test SID behavior, or because of missing nvim_exec features: #16071
2022-03-27 10:25:55 -07:00
Javier Lopez
a490db5ba8
refactor!: rename nvim_do_autocmd to nvim_exec_autocmd (#17854)
according to established code standards (`:h dev-api`)
2022-03-26 15:34:56 +01:00
Gregory Anders
be35d3c5ad
feat(api): remove Lua autocommand callbacks when they return true (#17784)
This copies the semantics of nvim_buf_attach callbacks, and is a
convenient way to create oneshot autocommands gated by some condition.
2022-03-19 18:57:58 -06:00
zeertzjq
77eb6f9dc7
fix(api, lua): return NIL on failure to find converted function (#17779) 2022-03-20 08:08:50 +08:00
zeertzjq
e263afc0e9 fix(paste): escape control characters in Cmdline mode 2022-03-15 18:15:18 +08:00
zeertzjq
3470a9c3de test(paste): add tests with virtualedit=onemore 2022-03-15 18:15:18 +08:00
zeertzjq
e4ec8d7d50 test(paste): reorganize tests and add tests for linewise Visual mode 2022-03-15 18:15:18 +08:00
zeertzjq
a6eafc77ce fix(paste): deal with trailing new line in chunk 2022-03-15 18:15:18 +08:00
zeertzjq
fcc6f66cf2 fix(paste): avoid edges cases caused by empty chunk 2022-03-15 18:15:18 +08:00
zeertzjq
bfb7754442 fix(paste): deal with eol and eof in Visual mode 2022-03-15 18:15:18 +08:00
zeertzjq
2601e0873f fix(paste): don't move cursor past the end of pasted text in Normal mode 2022-03-15 18:15:18 +08:00
zeertzjq
9b1e1fbc9f fix(paste): use getcmdtype() to determine whether in cmdline mode 2022-03-15 18:15:18 +08:00
zeertzjq
3011794c86 feat(api): relax statusline fillchar width check
Treat fillchar as single-width even if it isn't.
2022-03-10 07:40:52 +08:00
Dhruv Manilawala
2783f4cc4a
feat(api): autocmd group can be either name or id (#17559)
* feat(api): `group` can be either string or int

This affects the following API functions:
- `vim.api.nvim_create_autocmd`
- `vim.api.nvim_get_autocmds`
- `vim.api.nvim_do_autocmd`

closes #17552

* refactor: add two maps for fast lookups

* fix: delete augroup info from id->name map

When in "stupid_legacy_mode", the value in name->id map would be updated
to `AUGROUP_DELETED`, but the entry would still remain in id->name. This
would create a problem in `augroup_name` function which would return the
name of the augroup instead of `--DELETED--`.

The id->name map is only used for fast loopup in `augroup_name` function
so there's no point in keeping the entry of deleted augroup in it.

Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
2022-03-07 23:15:43 -05:00
Gregory Anders
92349b1db0
feat(api): add 'buffer' argument to nvim_get_autocmds (#17594)
This enables retrieving autocommands defined in the given buffers. Under
the hood this simply translates the buffer numbers into '<buffer=%d>'
patterns.
2022-03-06 12:35:14 -07:00
Kirill Chibisov
f89fb41a7a
feat(tui): add support for CSI 4 : [2,4,5] m
This commit finishes support for colored and styled underlines adding
`CSI 4 : [2,4,5] m` support providing double, dashed, and dotted
underlines

Fixes #17362.
2022-03-03 23:35:36 +03:00
zeertzjq
f8b3a1691f test: use helpers.pending_win32(pending) in buffer_updates_spec 2022-03-03 16:07:39 +08:00
zeertzjq
9a5a3c699e test: move two mapping tests to ex_cmds/map_spec.lua 2022-03-02 08:15:29 +08:00
bfredl
0a9b00913f
Merge pull request #15079 from shadmansaleh/feat/verbose_lua
feat(lua): add :verbose support for lua config
2022-03-01 13:13:11 +01:00
Christian Clason
37a86a2f96
fix(api): include event in get_autocmds (#17553) 2022-03-01 09:07:41 +01:00
TJ DeVries
0f613482b3 feat(lua): add missing changes to autocmds lost in the rebase
Note: some of these changes are breaking, like change of API signatures
2022-02-28 19:53:50 +01:00
shadmansaleh
ebfe083337 feat(lua): show proper verbose output for lua configuration
`:verbose` didn't work properly with lua configs (For example:
    options or keymaps are set from lua, just say that they were set
    from lua, doesn't say where they were set at.

This fixes that issue. Now `:verbose` will provide filename and line no
when option/keymap is set from lua.

Changes:
  - compiles lua/vim/keymap.lua as vim/keymap.lua
 - When souring a lua file current_sctx.sc_sid is set to SID_LUA
 - Moved finding scripts SID out of `do_source()` to `get_current_script_id()`.
   So it can be reused for lua files.
 - Added new function `nlua_get_sctx` that extracts current lua scripts
   name and line no with debug library. And creates a sctx for it.
     NOTE: This function ignores C functions and blacklist which
     currently contains only vim/_meta.lua so vim.o/opt wrappers aren't
     targeted.
 - Added function `nlua_set_sctx` that changes provided sctx to current
   lua scripts sctx if a lua file is being executed.
 - Added tests in tests/functional/lua/verbose_spec.lua
 - add primary support for additional types (:autocmd, :function, :syntax) to lua verbose
    Note: These can't yet be directly set from lua but once that's possible
    :verbose should work for them hopefully :D
 - add :verbose support for nvim_exec & nvim_command within lua
    Currently auto commands/commands/functions ... can only be defined
    by nvim_exec/nvim_command this adds support for them. Means if those
    Are defined within lua with vim.cmd/nvim_exec :verbose will show their
    location . Though note it'll show the line no on which nvim_exec call was made.
2022-02-28 19:18:49 +06:00
TJ DeVries
991e472881 feat(lua): add api and lua autocmds 2022-02-27 22:04:55 +01:00
Javier Lopez
1b5767aa34
feat(lua): add <f-args> to user commands callback (#17522)
Works similar to ex <f-args>. It only splits the arguments if the
command has more than one posible argument. In cases were the command
can only have 1 argument opts.fargs = { opts.args }
2022-02-27 12:35:06 -07:00
bfredl
4b834a9f7c
Merge pull request #17414 from zeertzjq/api-set-cursor-redraw
fix(api): nvim_win_set_cursor() redraw for cursorline and statusline
2022-02-26 14:52:24 +01:00
zeertzjq
0545bd2180 test: use helpers.pending_win32(pending) instead of iswin() 2022-02-26 19:40:11 +08:00
James McCoy
005a7aa167
Merge pull request #17467 from dundargoc/ci/remove-failing-windows
ci: remove failing windows CI tests
2022-02-25 07:10:29 -05:00
Lewis Russell
b5bf4877c0
feat(highlight): support for blend in nvim_set_hl (#17516) 2022-02-24 09:50:05 -07:00
Gregory Anders
15004473b5
fix(api)!: correctly handle negative line numbers for nvim_buf_set_text (#17498)
nvim_buf_set_text does not handle negative row numbers correctly: for
example,

    nvim_buf_set_text(0, -2, 0, -1, 20, {"Hello", "world"})

should replace the 2nd to last line in the buffer with "Hello" and the
first 20 characters of the last line with "world". Instead, it reports
"start_row out of bounds". This happens because when negative line
numbers are used, they are incremented by one additional number to make
the non-negative line numbers end-exclusive. However, the line numbers
for nvim_buf_set_text should be end-inclusive.

In #15181 we handled this for nvim_buf_get_text by adding a new
parameter to `normalize_index`. We can solve the problem with
nvim_buf_set_text by simply availing ourselves of this new argument.

This is a breaking change, but makes the semantics of negative line
numbers much clearer and more obvious (as well as matching
nvim_buf_get_text).

BREAKING CHANGE: Existing usages of nvim_buf_set_text that use negative
line numbers will be off-by-one.
2022-02-23 22:19:47 +00:00
Gregory Anders
11f7aeed7a
feat(api): implement nvim_buf_get_text (#15181)
nvim_buf_get_text is the mirror of nvim_buf_set_text. It differs from
nvim_buf_get_lines in that it allows retrieving only portions of lines.

While this can typically be done easily enough by API clients,
implementing this function provides symmetry between the get/set
text/lines APIs, and also provides a nice convenience that saves API
clients the work of having to slice the result of nvim_buf_get_lines
themselves.
2022-02-22 20:19:21 +00:00
Lewis Russell
1e7cb2dcd9
fix(highlight): accept NONE as a color name (#17487)
... for when `ns=0`.

Also update the documentation of nvim_set_hl to clarify the set
behaviour.

Fixes #17478
2022-02-21 13:17:36 -07:00
Dundar Göc
82c5a02050 ci: skip tests that fail on windows 2022-02-20 10:22:39 +01:00
James McCoy
df0fae2ff7
Merge pull request #17430 from dundargoc/test/remove-travis 2022-02-17 17:25:58 -05:00
Dundar Göc
f3e6cc1a23 test: remove checks to see if current CI job is travis or appveyor 2022-02-17 22:43:48 +01:00
Christian Clason
e35a2d86fc fix(api): allow empty list for cterm in nvim_set_hl
Problem: when accessing `nvim_set_hl` from Lua, empty tables are converted
to empty lists, not dictionaries, resulting in an error for

    :lua vim.api.nvim_set_hl(0, "Comment", { cterm = {} })

Workaround: add an empty array as a special case when checking
`dict->cterm.type` and just set `cterm_mask_provided`.

(Proper solution: handle this in `gen_api_dispatch.lua`.)
2022-02-17 18:07:11 +01:00
bfredl
f4e24f1eab
Merge pull request #17421 from lewis6991/hl0_clear
fix(highlight): global ns improvements
2022-02-17 14:07:42 +01:00
Lewis Russell
dc24eeb9fe feat(highlight): support color names for cterm 2022-02-16 22:48:34 +00:00
Lewis Russell
876aaf2003 fix(highlight): allow globals to be cleared
- and reduce heap allocations

Fixes #17420
2022-02-16 20:22:09 +00:00
bfredl
9fe8d2c9df
Merge pull request #16678 from lewis6991/runtime_file_err
fix(api): re-route nvim_get_runtime_file errors
2022-02-16 10:52:38 +01:00
Shadman
9a74c2b04a
feat(mappings): considering map description when filtering (#17423) 2022-02-16 16:39:50 +08:00
zeertzjq
deb33a9775
Merge pull request #17422 from shadmansaleh/enhance/maps
fix: <Nop> not shown in :map commands
2022-02-16 16:01:17 +08:00
shadmansaleh
07a98b1a75 fix: <Nop> not shown in :map commands 2022-02-16 13:12:46 +06:00
Lewis Russell
d512be55a2 fix(api): re-route nvim_get_runtime_file errors
This allows nvim_get_runtime_file to be properly used via pcall
2022-02-15 23:00:28 +00:00
Gregory Anders
238b944e58
fix(api): validate command names in nvim_add_user_command (#17406)
This uses the same validation used when defining commands with
`:command`.
2022-02-15 13:08:40 -07:00
zeertzjq
f92e74900f fix(api): nvim_win_set_cursor() redraw for cursorline and statusline 2022-02-15 11:53:12 +08:00
shadmansaleh
f292dd2126 fix: autoload variables not loaded with vim.g & nvim_get_var 2022-02-13 01:23:23 +06:00
Christian Clason
cb18545253 feat(api): add strikethrough, nocombine to set_hl 2022-02-12 12:05:41 +01:00
zeertzjq
23c3f7f572 fix(api): use changedir_func() in nvim_set_current_dir()
Co-Authored-By: smolck <46855713+smolck@users.noreply.github.com>
2022-02-10 09:45:20 +08:00
glacambre
5b34c2ab73 fix(--headless): do not block on press-enter prompts when no UI
This commit fixes #9358, where emitting multiple messages with 'echo' or
a single one with 'echom' or 'echoerr' would result in a press-enter
prompt that couldn't be dismissed by pressing enter.

This requires adapting a few tests to spawn a UI before testing whether
press-enter prompts are blocking.

It also fixes #11718, as when combined with #15910 it enables making
sure that neovim never blocks and emits messages on startup.
2022-02-05 13:02:33 +01:00