Commit Graph

399 Commits

Author SHA1 Message Date
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
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
bfredl
5be2cdd913
Merge pull request #17187 from lewis6991/master
feat(highlight): ns=0 to set :highlight namespace
2022-02-01 17:16:14 +01:00
Lewis Russell
4aa0cdd3aa feat(highlight): ns=0 to set :highlight namespace
Passing ns=0 to nvim_set_hl will alter the `:highlight` namespace.
2022-02-01 11:54:12 +00:00
zeertzjq
f4300985d3
Merge pull request #17113 from zeertzjq/vim-8.2.2569
feat(statusline): support multibyte fillchar
2022-02-01 17:57:01 +08:00
notomo
3d9ae9d2da feat(api): expose extmark right_gravity and end_right_gravity 2022-01-24 09:52:13 +09:00
bfredl
7e2ce35e3b
Merge pull request #17156 from zeertzjq/vim-8.2.3584
vim-patch:8.2.{3584,3586,3587}: :command "-keepscript" argument
2022-01-23 19:42:30 +01:00
bfredl
e07a4b97f6
Merge pull request #16936 from zeertzjq/no-escape-csi
input: never escape CSI bytes and clean up related names and comments
2022-01-21 18:04:40 +01:00
zeertzjq
8e84d1b930 vim-patch:8.2.3584: "verbose set efm" reports location of the :compiler command
Problem:    "verbose set efm" reports the location of the :compiler command.
            (Gary Johnson)
Solution:   Add the "-keepscript" argument to :command and use it when
            defining CompilerSet.
58ef8a31d7
2022-01-21 18:18:18 +08:00
zeertzjq
6e69a3c3e7 refactor: remove CSI unescaping and clean up related names and comments 2022-01-21 18:08:56 +08:00
notomo
5971b86338 feat(api): expose extmark more details 2022-01-20 13:25:46 +09:00
zeertzjq
be15ac06ba feat(statusline): support multibyte fillchar
This includes a partial port of Vim patch 8.2.2569 and some changes to
nvim_eval_statusline() to allow a multibyte fillchar. Literally every
line of C code touched by that patch has been refactored in Nvim, and
that patch contains some irrelevant foldcolumn tests I'm not sure how to
port (as Nvim's foldcolumn behavior has diverged from Vim's).
2022-01-16 19:54:27 +08:00
bfredl
f3193c7b54
Merge pull request #17001 from mjlbach/feat/non-strict-extmarks
feat(extmarks): add strict option
2022-01-15 21:06:04 +01:00
Michael Lingelbach
d8eec8e344 Hopefully last attempt 2022-01-15 09:00:01 -08:00
Michael Lingelbach
facd07bcf7 Address review r3 2022-01-15 08:37:44 -08:00
zeertzjq
42e5fd32b0 fix(completion): prevent K_LUA from closing pum 2022-01-10 21:30:32 +08:00
shadmansaleh
b411f436d3 feat(api): add support for lua function & description in keymap
Behavioral changes:

1. Added support for lua function in keymaps in
--------------------------------------------
- nvim_set_keymap
  Can set lua function as keymap rhs like following:
```lua
vim.api.nvim_{buf_}set_keymap('n', '<leader>lr', '', {callback = vim.lsp.buf.references})
```
  Note: lua function can only be set from lua . If api function being
  called from viml or over rpc this option isn't available.
- nvim_{buf_}get_keymap
  When called from lua, lua function is returned is `callback` key .
  But in other cases callback contains number of the function ref.
- :umap, nvim_del_keymap & nvim_buf_del_keymap clears lua keymaps correctly.
- :map commands for displaing rhs .
   For lua keymaps rhs is displayed as <Lua function ref_no>
   Note: lua keymap cannot be set through viml command / functions.
- mapargs()
  When dict is false it returns string in `<Lua function ref_no>`
  format (same format as :map commands).
  When dict is true it returns ref_no number in `callback` key.
- mapcheck()
  returns string in `<Lua function ref_no>` format (same format as :map commands).

2. Added support for keymap description
---------------------------------------
- nvim_{buf_}set_keymap: added `desc` option in opts table .
 ```lua
vim.api.nvim_set_keymap('n', '<leader>w', '<cmd>w<cr>', {desc='Save current file'})
```
- nvim_{buf_}get_keymap: contains `desc` in returned list.
- commands like `:nmap <leader>w` will show description in a new line below rhs.
- `maparg()` return dict contains `desc`.
2022-01-01 00:26:58 +06:00
Gregory Anders
eff11b3c3f feat(api): implement nvim_{add,del}_user_command
Add support for adding and removing custom user commands with the Nvim
API.
2021-12-28 14:08:44 -07:00
zeertzjq
ab1ceaaaa9 fix: do not save K_EVENT as lastc in Insert mode
I'm also gonna move some other K_EVENT-related tests to vim_spec.lua
2021-12-26 16:14:35 +08:00
Gregory Anders
33cd1ba00a
fix(api): make nil value in nvim_set_option_value clear local value (#16710)
For special options such as 'undolevels' and 'scrolloff', this sets the
local value to the special "unset" value (e.g. -12345 for 'undolevels').
2021-12-21 14:20:34 -07:00
zeertzjq
5b153f5d3d test: remove references to misc1.c 2021-12-11 07:10:01 +08:00
Gregory Anders
cf32053d60
fix(api): allow nvim_buf_set_extmark to accept end_row key (#16548)
nvim_buf_get_extmark uses "end_row" rather than "end_line" in its
'details' dict, which means callers must modify the key names if they
want to re-use the information. Change the parameter name in
nvim_buf_set_extmark to "end_row" and use "end_line" as an alias
to make this more consistent.
2021-12-08 08:44:48 -07:00
Gregory Anders
71ac00ccb5 feat(api): add nvim_get_option_value 2021-12-04 14:04:23 -07:00
James McCoy
4342b81e8d
test(api): mark "notify cancels stale events on channel close" fragile
This is already skipped in all CI environments, so it should also be
skipped in environments that don't like fragile tests.  Since there's no
convenient way to express these concisely, add the explicit fragile
skip.
2021-11-30 22:27:34 -05:00