Commit Graph

291 Commits

Author SHA1 Message Date
Justin M. Keyes
943bedfc86
event-loop: do not set CA_COMMAND_BUSY #9853
CA_COMMAND_BUSY in nv_event() was carried over from Vim nv_cursorhold()
(ref: e5165bae11). It prevents :startinsert from working during a RPC
call, so remove it.

Helped-by: glacambre <me@r4>
closes #7254
2019-04-08 02:33:00 +02:00
Björn Linse
f5d5da3917 buffer: use aucmd_prepbuf() instead of switch_to_win_for_buf() 2019-03-05 15:05:23 +01:00
Justin M. Keyes
aee29e51a6 API: nvim_create_buf: add scratch parameter
Creating a scratch buffer is a chore/ritual, and would be more
useful/common if formally exposed.
2019-02-17 06:58:03 +01:00
Björn Linse
51fc54325c ui: implement ext_messages
Co-Author: Dongdong Zhou <dzhou121@gmail.com>
2019-02-10 13:36:46 +01:00
Björn Linse
891ed14f13 api: add nvim_create_buf to create a new empty buffer.
Loading existing files into a buffer is non-trivial and requires a window.
Creating an unnamed emtpy buffer is trivial and safe though, thus worth a
special case.

Change nvim_buf_set_option to use aucmd_prepbuf. This is necessary
to allow some options to be set on a not yet displayed buffer, such
as 'buftype' option.

vim-patch:7.4.1858: Add BLN_NEW to enforce buflist_new creating new buffer
2019-02-09 11:48:45 +01:00
Björn Linse
baf93d9606 UI: always use contrete colors for default_colors_set
But add an escape hatch needed for external TUI, so it still can use
terminal emulator defaults.
2019-02-05 19:41:38 +01:00
Björn Linse
f7b174eb71 tests/lua: test for multiline error messages in lua 2019-01-23 19:34:13 +01:00
Justin M. Keyes
38b9256439 test/API: nvim_set_vvar() #9395 2019-01-14 00:50:29 +01:00
Björn Linse
1f8afe15a4 multigrid: add multigrid support to test infrastructure
make Screen explicitly tied to its session
2018-12-31 12:44:22 +01:00
Björn Linse
8b42249cdd RPC: turn errors from async calls into notifications
Previously, nvim sent a response with invalid request id (UINT64_MAX).
In functionaltests, catch unexpected error notifications in after_each().
2018-12-03 10:42:00 +01:00
Justin M. Keyes
30857030e8 doc
- develop.txt is for design/guidelines; architecture/concepts should
  live elsewhere (currently src/nvim/README.md)
- move dev-jargon to intro.txt
- replace https://neovim.io/community (deprecated) with
  https://neovim.io/#chat
- <Cmd> avoids CmdlineEnter/Leave
  https://github.com/vim/vim/issues/2889
2018-11-28 03:48:06 +01:00
Björn Linse
01dbf0951b api: implement object namespaces
Namespaces is a lightweight concept that should be used to group
objects for purposes of bulk operations and introspection. This is
initially used for highlights and virtual text in buffers, and is
planned to also be used for extended marks. There is no plan use them
for privileges or isolation, neither to introduce nanespace-level
options.
2018-11-24 11:01:37 +01:00
Jan Edmund Lazo
7ab0e8c8dd functionaltest: enable job channel test 2018-10-31 22:55:07 -04:00
Björn Linse
43823acae2 ui: rename ext_newgrid to ext_linegrid 2018-10-01 21:24:15 +02:00
Justin M. Keyes
608ff261ad test: API validation: assert exact string
expect_err() matches against a pattern. Terminate the pattern with "$"
to check against buffer overrun.

ref #8931
2018-09-05 08:04:15 +02:00
Justin M. Keyes
db17d2c0fa API: Avoid overrun when formatting error-message
msgpack_rpc_to_object (called by handle_request .. msgpack_rpc_to_array)
always NUL-terminates API Strings.
But handle_request .. msgpack_rpc_get_handler_for operates on a raw
msgpack_object, before preparation.
2018-09-05 08:04:15 +02:00
Björn Linse
1adb01c120 ui: use line-based rather than char-based updates in screen.c
Add ext_newgrid and ext_hlstate extensions. These use predefined
highlights and line-segment based updates, for efficiency and
simplicity.. The ext_hlstate extension in addition allows semantic
identification of builtin and syntax highlights.

Reimplement the old char-based updates in the remote UI layer, for
compatibility. For the moment, this is still the default. The bulitin
TUI uses the new line-based protocol.

cmdline uses curwin cursor position when ext_cmdline is active.
2018-07-21 13:21:58 +02:00
Justin M. Keyes
3abf17ae88
API: validation: mention invalid method name (#8489) 2018-06-07 10:56:44 +02:00
Björn Linse
5be3865ce7 nvim_list_uis: include channel id 2018-06-01 10:20:13 +02:00
Björn Linse
6da4548f0e api: list information about all channels/jobs.
Fire autocmd when channel opens or its info changes.
Add a way for API clients can describe themselves.
2018-05-23 18:18:16 +02:00
Justin M. Keyes
273d2cd5d5 Merge #8329 'API: Make nvim_set_option() update :verbose set …' 2018-05-11 10:08:09 +02:00
Justin M. Keyes
2326a4ac3a API: nvim_eval(): return non-generic VimL errors
Use the same pattern as nvim_call_function (_call_function).
2018-05-09 23:18:39 +02:00
Justin M. Keyes
c9f3174075 API: return non-generic VimL errors
- Return VimL errors instead of generic errors for:
  - nvim_call_function
  - nvim_call_dict_function
- Fix tests which were silently broken before this change.

This violates #6150 where we agreed not to translate API errors.  But
that can be fixed later.
2018-05-09 23:18:38 +02:00
Justin M. Keyes
cabffb0182 API: nvim_call_dict_function: expect actual function, not name 2018-05-06 14:52:21 +02:00
Justin M. Keyes
fe7ab60af7 API: nvim_call_dict_function: eliminate internal param
The `internal` param is difficult to explain, and will rarely be
anything but `true`.  To avoid it, use a hack: check if the resolved
dict value starts with "function(".
2018-05-06 14:38:26 +02:00
Justin M. Keyes
19c2ce1901 refactor: nvim_call_dict_function
- Add test coverage for errors.
- Rename, rearrange.
2018-05-06 14:38:26 +02:00
Sebastian Witte
124275dd58 API: nvim_call_dict_function #3032 2018-05-06 14:38:26 +02:00
Justin M. Keyes
f46f138fb6 test: nvim_call_function: verify "too many arguments" error 2018-05-06 14:38:26 +02:00
b-r-o-c-k
7170de1971 api: Make nvim_set_option() update :verbose set ...
Make `:verbose set ...` show when an option was last modified by an
API client or Lua script/chunk. In the case of an API client, the
channel ID is displayed.
2018-05-03 21:05:20 -05:00
Justin M. Keyes
1c3a849881
API/nvim_command_output: handle :echon capture (#8265)
ref https://github.com/neovim/python-client/pull/290
2018-04-13 00:49:37 +02:00
Björn Linse
98e7112390 msg: do not scroll entire screen (#8088) 2018-03-31 11:12:27 +02:00
geekodour
9f994bb699 api: nvim_list_uis #8004
ref #7438
closes #4842
2018-03-03 15:06:24 +01:00
Justin M. Keyes
352a51e831 test: :! print binary data, control chars
closes #5442
closes #4142
ref #6618
ref #4376
ref #7844
ref #2958
ref #4338
2018-02-07 09:25:51 +01:00
Björn Linse
4e7d85e635 shell: update execute('!cmd') test to new behavior
And similarly nvim_command_output test
2018-02-06 20:16:38 +01:00
ZyX
a2dfeb8a16
functests: Improve error reporting in _check_parsing function
May be needed for unit tests as well though.
2018-02-02 07:28:56 -05:00
Justin M. Keyes
5055d4a755 api: nvim_command_output: direct impl 2018-01-10 23:58:56 +01:00
Justin M. Keyes
c095f83116 api: change nvim_command_output behavior
Implement nvim_command_output with `execute({cmd},"silent")`.

Behavior changes:
- does not provoke any hit-enter prompt
- no longer prepends a newline char
- does not capture some noise (like the "[New File]" message, see the
  change to tabnewentered_spec.lua)

Technically ("bug-for-bug") this a breaking change.  But the previous
behavior of nvim_command_output meant that it probably wasn't used for
anything outside of tests.

Also remove the undocumented `v:command_output` variable which was
a hack introduced only for the purposes of nvim_command_output.

closes #7726
2018-01-10 23:45:44 +01:00
ZyX
5ab0f988ca *: Replace all occurrences of NVim with Nvim 2017-11-30 11:53:25 +03:00
ZyX
17077b6813 viml/parser/expressions: Make $ENV not depend on &isident 2017-11-26 16:08:53 +03:00
ZyX
ebb33eddd9 tests: Stabilize float format and %e in format_luav and format_string 2017-11-19 22:00:59 +03:00
ZyX
f20f97c936 *: Fix linter errors 2017-11-19 21:13:27 +03:00
ZyX
a94255a7ac tests: Use single test file for unit and functional parser tests 2017-11-19 20:20:06 +03:00
ZyX
ebb5977837 api/vim: Add “len” dictionary key
This allows determining where parsing ended which may be needed for e.g. parsing
`:echo` with that API function.
2017-11-06 01:17:39 +03:00
ZyX
7849070f99 tests: Add missing test cases 2017-11-06 01:17:39 +03:00
ZyX
7bc6de7526 api/vim,functests: Add tests for nvim_parse_expression, fix found bugs 2017-11-06 01:17:39 +03:00
ZyX
b9d5aea073 api/vim: Create part of nvim_parse_expression function 2017-11-06 01:17:38 +03:00
Justin M. Keyes
9d6bac3219 test: more coverage for RPC + op-pending #3732 2017-09-16 12:21:31 +02:00
Justin M. Keyes
ce852bab04 eventloop: K_EVENT does not finish mapping
The "mapping" tests added in 541dde36e3 were flawed:
- Unlike op-pending mode, RPCs are _blocked_ during map-pending. So
  a synchronous RPC like nvim_get_current_buf() waits until
  'timeoutlen', then the mapping is canceled.
- helpers.expect() also performs a blocking RPC, so again that must not
  intervene the two nvim_input() calls.

closes #6166
2017-09-04 22:51:04 +02:00
Justin M. Keyes
3922237b14 test: lint 2017-09-04 10:46:10 +02:00
Matthew Malcomson
541dde36e3 eventloop: K_EVENT should not finish operator
normal_finish_command() and normal_prepare() assume that any pending
operator needs to be finished after any subsequent key.

Set `finish_op = false` in nv_event() to indicate that the pending
operator shouldn't be finished in normal_execute().

This is how nv_visual() indicates that 'v' or 'V' in operator-pending
mode should not finish the current pending operator.

fixes #5398
fixes #6166 (partially; mappings are still interrupted)
2017-09-04 08:20:04 +02:00
Justin M. Keyes
0ea7e45bc1 'cpoptions': remove "<" flag; ignore <special>
Closes #6937 "nvim_get_keymap output is unreliable"
2017-07-08 16:34:35 +02:00
ZyX
a5a5c83608 api/vim: Fix nvim_list_runtimepaths
It used to

1. Always omit last component in runtimepath.
2. Always omit trailing empty item and leave uninitialized memory in place of 
   it.
2017-05-23 00:16:23 +03:00
Justin M. Keyes
bdd73fc07f api/nvim_replace_termcodes: Document keycodes behavior 2017-05-20 22:20:32 +02:00
Björn Linse
f424189093 api: execute lua directly from the remote api 2017-05-13 15:03:42 +02:00
ZyX
09f849b600 Merge branch 'master' into luaviml'/lua 2017-05-08 15:43:45 +03:00
Justin M. Keyes
acfd2a2a29 input.c: Process only safe events before blocking.
Introduce multiqueue_process_priority() to process only events at or
above a certain priority.
2017-04-28 19:19:51 +02:00
Justin M. Keyes
3ea1007753 api: nvim_get_mode()
Asynchronous API functions are served immediately, which means pending
input could change the state of Nvim shortly after an async API function
result is returned.

nvim_get_mode() is different:
  - If RPCs are known to be blocked, it responds immediately (without
    flushing the input/event queue)
  - else it is handled just-in-time before waiting for input, after
    pending input was processed. This makes the result more reliable
    (but not perfect).

Internally this is handled as a special case, but _semantically_ nothing
has changed: API users never know when input flushes, so this internal
special-case doesn't violate that. As far as API users are concerned,
nvim_get_mode() is just another asynchronous API function.

In all cases nvim_get_mode() never blocks for more than the time it
takes to flush the input/event queue (~µs).

Note: This doesn't address #6166; nvim_get_mode() will provoke #6166 if
e.g. `d` is operator-pending.

Closes #6159
2017-04-28 19:14:34 +02:00
Justin M. Keyes
086c354a0a api: Do not translate error messages.
Also re-word some error messages:
- "Key does not exist: %s"
- "Invalid channel: %<PRIu64>"
- "Request array size must be 4 (request) or 3 (notification)"
- "String cannot contain newlines"

References #6150
2017-04-24 00:11:27 +02:00
Justin M. Keyes
4524053874 test: api: Do not truncate errors <1 MB. 2017-04-23 23:24:16 +02:00
ZyX
043d8ff9f2 Merge branch 'master' into luaviml'/lua 2017-04-08 01:54:58 +03:00
Jakob Schnitzer
eb0e94f71b api: {get,set}_option should {get,set} global value of local options (#6405)
- nvim_get_option should return the global default of a local option.
- nvim_set_option should set the global default of a local option.
2017-03-30 22:03:52 +02:00
ZyX
ba2f615cd4 functests: Test for error conditions
During testing found the following bugs:

1. msgpack-gen.lua script is completely unprepared for Float values either in 
   return type or in arguments. Specifically:

   1. At the time of writing relevant code FLOAT_OBJ did not exist as well as 
      FLOATING_OBJ, but it would be used by msgpack-gen.lua should return type 
      be Float. I added FLOATING_OBJ macros later because did not know that 
      msgpack-gen.lua uses these _OBJ macros, otherwise it would be FLOAT_OBJ.
   2. msgpack-gen.lua should use .data.floating in place of .data.float. But it 
      did not expect that .data subattribute may have name different from 
      lowercased type name.

2. vim_replace_termcodes returned its argument as-is if it receives an empty 
   string (as well as _vim_id*() functions did). But if something in returned 
   argument lives in an allocated memory such action will cause double free: 
   once when freeing arguments, then when freeing return value. It did not cause 
   problems yet because msgpack bindings return empty string as {NULL, 0} and 
   nothing was actually allocated.
3. New code in msgpack-gen.lua popped arguments in reversed order, making lua 
   bindings’ signatures be different from API ones.
2017-03-27 00:11:28 +03:00
ZyX
858ac9d8e5 api: Make sure dict_set_var doesn’t edit read-only values
Fixes #6147
2017-02-23 19:48:41 +03:00
ZyX
6550caee50 functests: Destroy accidental folds in api/vim_spec 2017-02-23 19:48:41 +03:00
Justin M. Keyes
43309d1993 test/api: Specify handling of VimL errors, v:errmsg.
TODO: Also spec behavior of Press-Enter prompt for these API functions.
2016-10-24 01:10:23 +02:00
Björn Linse
f6968dc0f7 api: call multiple methods atomically (useful in async contexts)
remove unused response_id parameter of handle_nvim_... helpers
2016-10-22 10:51:32 +02:00
Justin M. Keyes
dc6cc4787c api: Establish API naming convention. (#5344)
old name:                   new name:
  --------------------------------------------------
  nvim_name_to_color          nvim_get_color_by_name
  nvim_get_current_buffer     nvim_get_current_buf
  nvim_get_current_window     nvim_get_current_win
  nvim_get_buffers            nvim_list_bufs
  nvim_get_tabpages           nvim_list_tabpages
  nvim_get_windows            nvim_list_wins
  nvim_set_current_buffer     nvim_set_current_buf
  nvim_set_current_window     nvim_set_current_win
  nvim_change_directory       nvim_set_current_dir
  nvim_tabpage_get_window     nvim_tabpage_get_win
  nvim_tabpage_get_windows    nvim_tabpage_list_wins
  nvim_win_get_buffer         nvim_win_get_buf
  nvim_report_error           nvim_err_writeln

Helped-by: Björn Linse <bjorn.linse@gmail.com>
Helped-by: ZyX <kp-pav@yandex.ru>
Helped-by: James McCoy <jamessan@jamessan.com>
2016-09-17 06:30:36 +02:00
Björn Linse
cd08e6cf72 api: make nvim[_obj]_set_var and _del_var not return the old value 2016-09-15 10:44:38 +02:00
Björn Linse
acb7c826b3 api: fix leak when a api function is incorrectly called with a list.
This applies both to msgpack-rpc and eval.
2016-08-31 21:57:06 +02:00
Björn Linse
1c22cab2fd api: consistently use nvim_ prefix and update documentation 2016-08-31 21:57:06 +02:00
Rui Abreu Ferreira
9ce81f7b2b functionaltest: Create lua helper for os.tmpname()
In Windows Lua's os.tmpname() returns relative paths starting with \s,
prepend them with $TEMP to generate a valid path.

In OS X os.tmpname() returns paths in '/tmp' but they should be in
'/private/tmp'. We cannot use os_name() for platform detection because
some tests use tempname() before nvim is spawned, instead use one of the
following:

1. Set SYSTEM_NAME environment variable before calling the tests, it
   is set from CMAKE_SYSTEM_NAME(i.e. uname -s or 'Windows')
2. Call uname -s
3. Assume windows
2016-08-31 11:32:28 +01:00
Björn Linse
f282b8ecac tests: don't ignore highlights in various tests 2016-08-14 21:53:02 +02:00
ZyX
ff470bb853 functests: Check logs in lua code
It is otherwise impossible to determine which test failed sanitizer/valgrind
check. test/functional/helpers.lua module return was changed so that tests which
do not provide after_each function to get new check will automatically fail.
2016-06-10 21:50:49 +03:00
KillTheMule
360d0513d1 Satisfy testlint.
For that, make luatest ignore the preload.lua files.
2016-04-28 19:30:17 +02:00
ZyX
a64114eba0 functests: Make json_functions_spec use new NIL where appropriate 2016-04-18 02:48:20 +03:00
ZyX
f1ced96c28 api: Replace set_var(name, NIL) with del_var(name) 2016-04-18 02:47:13 +03:00
Thiago de Arruda
c18d5917e3 Update lua client to 0.0.1-24
The new version of the lua client uses libmpack as a backend, and some test
scripts had to be updated to reflect that.
2016-04-13 09:21:32 -03:00
Thiago de Arruda
35d8d10a6a Remove dependency on ffi module 2016-03-07 03:58:29 -03:00
Justin M. Keyes
99d4c8c29c keymap: Support <D-...> (super/command key).
Adds support for:
  - api:vim_input("<D-a>")
  - ":nnoremap <C-D-S-...>" and permutations thereof

UIs must capture the modifier and send it as "<D-...>" to vim_input().

Note: Before this commit, any arbitrary ":nnoremap <{foo}-{bar}>"
mapping could already be invoked with feedkeys("\<{foo}-{bar}>"). This
commit supports "D-" as a modifier that can be combined with "C-", "A-",
"S-" in any order.

For non-GUI (terminal) support, user must:
  :set <D-a>={CSI sequence}
then send the {CSI sequence} from their terminal. But this does not work
yet (regression #2204).

Closes #2190
2016-02-22 02:41:40 -05:00
Rui Abreu Ferreira
a48508de0d test/functional: Fix api/vim_spec.lua.
On Windows the default file format is DOS i.e. newlines are \r\n
instead of \n.
2015-12-31 23:28:55 -05:00
Marco Hinz
d9fbc1865b test/functional: clean up according to luacheck (part 2) 2015-11-23 13:57:21 +01:00
Thiago de Arruda
e5165bae11 input: Remove CURSORHOLD key
Refactor input.c, normal.c and edit.c to use the K_EVENT special key to trigger
the CURSORHOLD event. In normal and edit mode, K_EVENT is treated as
K_CURSORHOLD, which enables better handling of arbitrary actions in those
states(eg: In normal mode the previous operator counts will be restored).

Also fix a test in vim_spec.lua. The test had a wrong assumption: cmdheight is
only used to determine when the press enter screen will be shown, not to limit
how many lines or control pagination.
2015-10-26 10:52:01 -03:00
Björn Linse
c8aaabc09c api: vim_err_write: add tests for multiline handling 2015-09-16 21:42:57 +02:00
Sebastian Witte
fcb79ffc40 Implement API function to call functions #2979
Remove static modifier from func_call
Move MAX_FUNC_ARGS definnition from eval.c to eval.h
2015-07-19 17:18:31 +02:00
Justin M. Keyes
f78bf64771 api: vim_set_var() should return the old value #2899
Closes #2816
2015-06-25 01:26:17 -04:00
Björn Linse
f56d1dc838 test: NULL-initialized vimscript strings should eval to empty strings 2015-02-16 20:13:53 -05:00
Thiago de Arruda
5b65ac2ca7 test: Make it possible to run functional tests with plain lua
Replace the hexadecimal escape sequences, which are only supported by luajit
2015-01-22 08:54:42 -03:00
Scott Prager
cea5092f40 api: Add tests for when not to handle NULs. 2014-12-06 17:29:39 -05:00
Rui Abreu Ferreira
84eb118f62 Functional tests for feedkeys CSI escaping
- tests for vim_feedkeys and replace_termcodes
2014-11-27 08:33:53 -03:00
Thiago de Arruda
d696fa51f8 test: verify that msgpacks-rpc exceptions are working 2014-10-23 21:46:09 -03:00
Thiago de Arruda
0c2ec77ae0 test: Use lua to perform sanity API checks
Sanity API checks made by the python-client in the api-python travis target were
converted to lua and will now live in this repository. This will simplify
performing breaking changes to the API as it won't be necessary to send parallel
PRs the python-client.
2014-10-16 14:06:54 -03:00