diff options
-rw-r--r-- | runtime/doc/develop.txt | 50 | ||||
-rw-r--r-- | runtime/doc/msgpack_rpc.txt | 21 | ||||
-rw-r--r-- | src/nvim/api/dispatch_deprecated.lua | 98 | ||||
-rw-r--r-- | src/nvim/api/tabpage.c | 6 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 20 | ||||
-rw-r--r-- | src/nvim/api/window.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | test/functional/api/buffer_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/api/tabpage_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 56 | ||||
-rw-r--r-- | test/functional/api/window_spec.lua | 60 | ||||
-rw-r--r-- | test/functional/eval/api_functions_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/helpers.lua | 4 | ||||
-rw-r--r-- | test/functional/ui/bufhl_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 2 |
16 files changed, 206 insertions, 167 deletions
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 6ecbf9fb0d..ddec137079 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -124,13 +124,26 @@ include the kitchen sink... but you can use it for plumbing." ============================================================================== 2. Design decisions *design-decisions* -Jargon *dev-jargon* +JARGON *dev-jargon* + +API client ~ +All external UIs and remote plugins (as opposed to regular Vim plugins) are +"clients" in general; but we call something an "API client" if its purpose is +to abstract or wrap the RPC API for the convenience of other applications +(just like a REST client or SDK such as boto3 for AWS: you can speak AWS REST +using an HTTP client like curl, but boto3 wraps that in a convenient python +interface). For example, the Nvim lua-client is an API client: + https://github.com/neovim/lua-client Host ~ A plugin "host" is both a client (of the Nvim API) and a server (of an external platform, e.g. python). It is a remote plugin that hosts other plugins. +Remote plugin ~ +Arbitrary code registered via |:UpdateRemotePlugins|, that runs in a separate +process and communicates with Nvim via the |api|. + Window ~ The word "window" is commonly used for several things: A window on the screen, the xterm window, a window inside Vim to view a buffer. @@ -145,7 +158,7 @@ window View on a buffer. There can be several windows in Vim, together with the command line, menubar, toolbar, etc. they fit in the shell. -Providers *dev-provider* +PROVIDERS *dev-provider* A goal of Nvim is to allow extension of the editor without special knowledge in the core. But some Vim components are too tightly coupled; in those cases @@ -189,8 +202,35 @@ Python host isn't installed then the plugin will "think" it is running in a Vim compiled without the |+python| feature. -RPC API -API client -remote plugin +API *dev-api* + +Use this pattern to name new API functions: + nvim_{thing}_{action}_{arbitrary-qualifiers} + +If the function acts on an object then {thing} is the name of that object +(e.g. "buf" or "win"). If the function operates in a "global" context then +{thing} is usually omitted (but consider "namespacing" your global operations +with a {thing} that groups functions under a common concept). + +Use existing common {action} names if possible: + add append to, or insert into, a collection + get get a thing (or subset of things by some query) + set set a thing + del delete a thing (or group of things) + list get all things + +Use consistent names for {thing} in all API function. E.g. a buffer is called +"buf" everywhere, not "buffer" in some places and "buf" in others. + +Example: `nvim_get_current_line` acts on the global editor state; the common +{action} "get" is used but {thing} is omitted. + +Example: `nvim_buf_add_highlight` acts on a `Buffer` object (the first +parameter) and uses the common {action} "add". + +Example: `nvim_list_bufs` operates in a global context (first parameter is +_not_ a Buffer). The common {action} "list" indicates that it lists all +bufs (plural) in the global context. + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt index 59e9e44f8f..b3fed9e756 100644 --- a/runtime/doc/msgpack_rpc.txt +++ b/runtime/doc/msgpack_rpc.txt @@ -124,17 +124,16 @@ You can also embed an Nvim instance via |jobstart()|, and communicate using ============================================================================== 4. Implementing API clients *rpc-api-client* *api-client* -All external UIs and remote plugins (as opposed to regular Vim plugins) are -"clients" in general; but we call something an "API client" if its purpose is -to abstract or wrap the RPC API for the convenience of other applications -(just like a REST client or SDK such as boto3 for AWS: you can speak AWS REST -using an HTTP client like curl, but boto3 wraps that in a convenient python -interface). For example, the lua-client is an API client: - https://github.com/neovim/lua-client - -The Python client (pip package "neovim") is the reference implementation of an -API client. It is always up-to-date with the Nvim API, so its source code and -test suite are an authoritative reference. +"API clients" wrap the Nvim API to provide idiomatic "SDKs" for their +respective platforms (see |dev-jargon|). You can build a new API client for +your favorite platform or programming language. + +Existing API clients are listed here: + https://github.com/neovim/neovim/wiki/Related-projects#api-clients + +The Python client is the reference implementation for API clients. It is +always up-to-date with the Nvim API, so its source code and test suite are +authoritative references. https://github.com/neovim/python-client API client implementation guidelines ~ diff --git a/src/nvim/api/dispatch_deprecated.lua b/src/nvim/api/dispatch_deprecated.lua index a4b4c8d196..5650a77ac0 100644 --- a/src/nvim/api/dispatch_deprecated.lua +++ b/src/nvim/api/dispatch_deprecated.lua @@ -1,69 +1,69 @@ local deprecated_aliases = { - nvim_buf_line_count="buffer_line_count", + nvim_buf_add_highlight="buffer_add_highlight", + nvim_buf_clear_highlight="buffer_clear_highlight", nvim_buf_get_lines="buffer_get_lines", - nvim_buf_set_lines="buffer_set_lines", - nvim_buf_get_var="buffer_get_var", - nvim_buf_get_option="buffer_get_option", - nvim_buf_set_option="buffer_set_option", - nvim_buf_get_number="buffer_get_number", + nvim_buf_get_mark="buffer_get_mark", nvim_buf_get_name="buffer_get_name", - nvim_buf_set_name="buffer_set_name", + nvim_buf_get_number="buffer_get_number", + nvim_buf_get_option="buffer_get_option", + nvim_buf_get_var="buffer_get_var", nvim_buf_is_valid="buffer_is_valid", - nvim_buf_get_mark="buffer_get_mark", - nvim_buf_add_highlight="buffer_add_highlight", - nvim_buf_clear_highlight="buffer_clear_highlight", - nvim_tabpage_get_windows="tabpage_get_windows", - nvim_tabpage_get_var="tabpage_get_var", - nvim_tabpage_get_window="tabpage_get_window", - nvim_tabpage_is_valid="tabpage_is_valid", - nvim_ui_detach="ui_detach", - nvim_ui_try_resize="ui_try_resize", + nvim_buf_line_count="buffer_line_count", + nvim_buf_set_lines="buffer_set_lines", + nvim_buf_set_name="buffer_set_name", + nvim_buf_set_option="buffer_set_option", + nvim_call_function="vim_call_function", nvim_command="vim_command", - nvim_feedkeys="vim_feedkeys", - nvim_input="vim_input", - nvim_replace_termcodes="vim_replace_termcodes", nvim_command_output="vim_command_output", + nvim_del_current_line="vim_del_current_line", + nvim_err_write="vim_err_write", + nvim_err_writeln="vim_report_error", nvim_eval="vim_eval", - nvim_call_function="vim_call_function", - nvim_strwidth="vim_strwidth", - nvim_list_runtime_paths="vim_list_runtime_paths", - nvim_change_directory="vim_change_directory", + nvim_feedkeys="vim_feedkeys", + nvim_get_api_info="vim_get_api_info", + nvim_get_color_by_name="vim_name_to_color", + nvim_get_color_map="vim_get_color_map", + nvim_get_current_buf="vim_get_current_buffer", + nvim_get_current_line="vim_get_current_line", + nvim_get_current_tabpage="vim_get_current_tabpage", + nvim_get_current_win="vim_get_current_window", + nvim_get_option="vim_get_option", nvim_get_var="vim_get_var", nvim_get_vvar="vim_get_vvar", - nvim_get_option="vim_get_option", - nvim_set_option="vim_set_option", + nvim_input="vim_input", + nvim_list_bufs="vim_get_buffers", + nvim_list_runtime_paths="vim_list_runtime_paths", + nvim_list_tabpages="vim_get_tabpages", + nvim_list_wins="vim_get_windows", nvim_out_write="vim_out_write", - nvim_err_write="vim_err_write", - nvim_report_error="vim_report_error", - nvim_get_buffers="vim_get_buffers", - nvim_get_current_buffer="vim_get_current_buffer", - nvim_set_current_buffer="vim_set_current_buffer", - nvim_get_windows="vim_get_windows", - nvim_get_current_window="vim_get_current_window", - nvim_set_current_window="vim_set_current_window", - nvim_get_tabpages="vim_get_tabpages", - nvim_get_current_tabpage="vim_get_current_tabpage", - nvim_set_current_tabpage="vim_set_current_tabpage", + nvim_replace_termcodes="vim_replace_termcodes", + nvim_set_current_buf="vim_set_current_buffer", + nvim_set_current_dir="vim_change_directory", nvim_set_current_line="vim_set_current_line", - nvim_get_current_line="vim_get_current_line", - nvim_del_current_line="vim_del_current_line", + nvim_set_current_tabpage="vim_set_current_tabpage", + nvim_set_current_win="vim_set_current_window", + nvim_set_option="vim_set_option", + nvim_strwidth="vim_strwidth", nvim_subscribe="vim_subscribe", + nvim_tabpage_get_var="tabpage_get_var", + nvim_tabpage_get_win="tabpage_get_window", + nvim_tabpage_is_valid="tabpage_is_valid", + nvim_tabpage_list_wins="tabpage_get_windows", + nvim_ui_detach="ui_detach", + nvim_ui_try_resize="ui_try_resize", nvim_unsubscribe="vim_unsubscribe", - nvim_name_to_color="vim_name_to_color", - nvim_get_color_map="vim_get_color_map", - nvim_get_api_info="vim_get_api_info", - nvim_win_get_buffer="window_get_buffer", + nvim_win_get_buf="window_get_buffer", nvim_win_get_cursor="window_get_cursor", - nvim_win_set_cursor="window_set_cursor", nvim_win_get_height="window_get_height", - nvim_win_set_height="window_set_height", - nvim_win_get_width="window_get_width", - nvim_win_set_width="window_set_width", - nvim_win_get_var="window_get_var", nvim_win_get_option="window_get_option", - nvim_win_set_option="window_set_option", nvim_win_get_position="window_get_position", nvim_win_get_tabpage="window_get_tabpage", - nvim_win_is_valid="window_is_valid" + nvim_win_get_var="window_get_var", + nvim_win_get_width="window_get_width", + nvim_win_is_valid="window_is_valid", + nvim_win_set_cursor="window_set_cursor", + nvim_win_set_height="window_set_height", + nvim_win_set_option="window_set_option", + nvim_win_set_width="window_set_width", } return deprecated_aliases diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c index 0116c9f91e..8b1fb041e2 100644 --- a/src/nvim/api/tabpage.c +++ b/src/nvim/api/tabpage.c @@ -14,7 +14,7 @@ /// @param tabpage The tabpage /// @param[out] err Details of an error that may have occurred /// @return The windows in `tabpage` -ArrayOf(Window) nvim_tabpage_get_windows(Tabpage tabpage, Error *err) +ArrayOf(Window) nvim_tabpage_list_wins(Tabpage tabpage, Error *err) { Array rv = ARRAY_DICT_INIT; tabpage_T *tab = find_tab_by_handle(tabpage, err); @@ -137,7 +137,7 @@ Object tabpage_del_var(Tabpage tabpage, String name, Error *err) /// @param tabpage The tab page handle /// @param[out] err Details of an error that may have occurred /// @return The Window handle -Window nvim_tabpage_get_window(Tabpage tabpage, Error *err) +Window nvim_tabpage_get_win(Tabpage tabpage, Error *err) { Window rv = 0; tabpage_T *tab = find_tab_by_handle(tabpage, err); @@ -147,7 +147,7 @@ Window nvim_tabpage_get_window(Tabpage tabpage, Error *err) } if (tab == curtab) { - return nvim_get_current_window(); + return nvim_get_current_win(); } else { FOR_ALL_WINDOWS_IN_TAB(wp, tab) { if (wp == tab->tp_curwin) { diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 57810134f9..d8cdad961b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -289,7 +289,7 @@ ArrayOf(String) nvim_list_runtime_paths(void) /// /// @param dir The new working directory /// @param[out] err Details of an error that may have occurred -void nvim_change_directory(String dir, Error *err) +void nvim_set_current_dir(String dir, Error *err) { if (dir.size >= MAXPATHL) { api_set_error(err, Validation, _("Directory string is too long")); @@ -446,7 +446,7 @@ void nvim_err_write(String str) /// are written by sending a trailing linefeed to `nvim_err_write` /// /// @param str The message -void nvim_report_error(String str) +void nvim_err_writeln(String str) { nvim_err_write(str); nvim_err_write((String) { .data = "\n", .size = 1 }); @@ -455,7 +455,7 @@ void nvim_report_error(String str) /// Gets the current list of buffer handles /// /// @return The number of buffers -ArrayOf(Buffer) nvim_get_buffers(void) +ArrayOf(Buffer) nvim_list_bufs(void) { Array rv = ARRAY_DICT_INIT; @@ -476,7 +476,7 @@ ArrayOf(Buffer) nvim_get_buffers(void) /// Gets the current buffer /// /// @reqturn The buffer handle -Buffer nvim_get_current_buffer(void) +Buffer nvim_get_current_buf(void) { return curbuf->handle; } @@ -485,7 +485,7 @@ Buffer nvim_get_current_buffer(void) /// /// @param id The buffer handle /// @param[out] err Details of an error that may have occurred -void nvim_set_current_buffer(Buffer buffer, Error *err) +void nvim_set_current_buf(Buffer buffer, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -506,7 +506,7 @@ void nvim_set_current_buffer(Buffer buffer, Error *err) /// Gets the current list of window handles /// /// @return The number of windows -ArrayOf(Window) nvim_get_windows(void) +ArrayOf(Window) nvim_list_wins(void) { Array rv = ARRAY_DICT_INIT; @@ -527,7 +527,7 @@ ArrayOf(Window) nvim_get_windows(void) /// Gets the current window /// /// @return The window handle -Window nvim_get_current_window(void) +Window nvim_get_current_win(void) { return curwin->handle; } @@ -535,7 +535,7 @@ Window nvim_get_current_window(void) /// Sets the current window /// /// @param handle The window handle -void nvim_set_current_window(Window window, Error *err) +void nvim_set_current_win(Window window, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -556,7 +556,7 @@ void nvim_set_current_window(Window window, Error *err) /// Gets the current list of tabpage handles /// /// @return The number of tab pages -ArrayOf(Tabpage) nvim_get_tabpages(void) +ArrayOf(Tabpage) nvim_list_tabpages(void) { Array rv = ARRAY_DICT_INIT; @@ -634,7 +634,7 @@ void nvim_unsubscribe(uint64_t channel_id, String event) channel_unsubscribe(channel_id, e); } -Integer nvim_name_to_color(String name) +Integer nvim_get_color_by_name(String name) { return name_to_color((uint8_t *)name.data); } diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 90d560cfeb..166e43f698 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -18,7 +18,7 @@ /// @param window The window handle /// @param[out] err Details of an error that may have occurred /// @return The buffer handle -Buffer nvim_win_get_buffer(Window window, Error *err) +Buffer nvim_win_get_buf(Window window, Error *err) { win_T *win = find_window_by_handle(window, err); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e707099ea3..ac6de04df6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7131,7 +7131,7 @@ static void api_wrapper(typval_T *argvars, typval_T *rettv, FunPtr fptr) Object result = fn(INVALID_CHANNEL, NO_RESPONSE, args, &err); if (err.set) { - nvim_report_error(cstr_as_string(err.msg)); + nvim_err_writeln(cstr_as_string(err.msg)); goto end; } @@ -13743,7 +13743,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr) } if (err.set) { - nvim_report_error(cstr_as_string(err.msg)); + nvim_err_writeln(cstr_as_string(err.msg)); goto end; } diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index da755802a7..71ec213b97 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -299,7 +299,7 @@ describe('buffer_* functions', function() describe('is_valid', function() it('works', function() nvim('command', 'new') - local b = nvim('get_current_buffer') + local b = nvim('get_current_buf') ok(buffer('is_valid', b)) nvim('command', 'bw!') ok(not buffer('is_valid', b)) diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 4c47f85f72..480f099b4d 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -163,10 +163,10 @@ describe('server -> client', function() end) it('can communicate buffers, tabpages, and windows', function() - eq({1}, eval("rpcrequest(vim, 'vim_get_tabpages')")) - eq({1}, eval("rpcrequest(vim, 'vim_get_windows')")) + eq({1}, eval("rpcrequest(vim, 'nvim_list_tabpages')")) + eq({1}, eval("rpcrequest(vim, 'nvim_list_wins')")) - local buf = eval("rpcrequest(vim, 'vim_get_buffers')")[1] + local buf = eval("rpcrequest(vim, 'nvim_list_bufs')")[1] eq(1, buf) eval("rpcnotify(vim, 'buffer_set_line', "..buf..", 0, 'SOME TEXT')") diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index 5bb8f27223..47dede8b44 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -11,17 +11,17 @@ local NIL = helpers.NIL describe('tabpage_* functions', function() before_each(clear) - describe('get_windows and get_window', function() + describe('list_wins and get_win', function() it('works', function() nvim('command', 'tabnew') nvim('command', 'vsplit') - local tab1, tab2 = unpack(nvim('get_tabpages')) - local win1, win2, win3 = unpack(nvim('get_windows')) - eq({win1}, tabpage('get_windows', tab1)) - eq({win2, win3}, tabpage('get_windows', tab2)) - eq(win2, tabpage('get_window', tab2)) - nvim('set_current_window', win3) - eq(win3, tabpage('get_window', tab2)) + local tab1, tab2 = unpack(nvim('list_tabpages')) + local win1, win2, win3 = unpack(nvim('list_wins')) + eq({win1}, tabpage('list_wins', tab1)) + eq({win2, win3}, tabpage('list_wins', tab2)) + eq(win2, tabpage('get_win', tab2)) + nvim('set_current_win', win3) + eq(win3, tabpage('get_win', tab2)) end) end) @@ -54,7 +54,7 @@ describe('tabpage_* functions', function() describe('is_valid', function() it('works', function() nvim('command', 'tabnew') - local tab = nvim('get_tabpages')[2] + local tab = nvim('list_tabpages')[2] nvim('set_current_tabpage', tab) ok(tabpage('is_valid', tab)) nvim('command', 'tabclose') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 0a2fd18db2..6b30c0e81c 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -117,47 +117,47 @@ describe('vim_* functions', function() end) end) - describe('{get,set}_current_buffer and get_buffers', function() + describe('{get,set}_current_buf and list_bufs', function() it('works', function() - eq(1, #nvim('get_buffers')) - eq(nvim('get_buffers')[1], nvim('get_current_buffer')) + eq(1, #nvim('list_bufs')) + eq(nvim('list_bufs')[1], nvim('get_current_buf')) nvim('command', 'new') - eq(2, #nvim('get_buffers')) - eq(nvim('get_buffers')[2], nvim('get_current_buffer')) - nvim('set_current_buffer', nvim('get_buffers')[1]) - eq(nvim('get_buffers')[1], nvim('get_current_buffer')) + eq(2, #nvim('list_bufs')) + eq(nvim('list_bufs')[2], nvim('get_current_buf')) + nvim('set_current_buf', nvim('list_bufs')[1]) + eq(nvim('list_bufs')[1], nvim('get_current_buf')) end) end) - describe('{get,set}_current_window and get_windows', function() + describe('{get,set}_current_win and list_wins', function() it('works', function() - eq(1, #nvim('get_windows')) - eq(nvim('get_windows')[1], nvim('get_current_window')) + eq(1, #nvim('list_wins')) + eq(nvim('list_wins')[1], nvim('get_current_win')) nvim('command', 'vsplit') nvim('command', 'split') - eq(3, #nvim('get_windows')) - eq(nvim('get_windows')[1], nvim('get_current_window')) - nvim('set_current_window', nvim('get_windows')[2]) - eq(nvim('get_windows')[2], nvim('get_current_window')) + eq(3, #nvim('list_wins')) + eq(nvim('list_wins')[1], nvim('get_current_win')) + nvim('set_current_win', nvim('list_wins')[2]) + eq(nvim('list_wins')[2], nvim('get_current_win')) end) end) - describe('{get,set}_current_tabpage and get_tabpages', function() + describe('{get,set}_current_tabpage and list_tabpages', function() it('works', function() - eq(1, #nvim('get_tabpages')) - eq(nvim('get_tabpages')[1], nvim('get_current_tabpage')) + eq(1, #nvim('list_tabpages')) + eq(nvim('list_tabpages')[1], nvim('get_current_tabpage')) nvim('command', 'tabnew') - eq(2, #nvim('get_tabpages')) - eq(2, #nvim('get_windows')) - eq(nvim('get_windows')[2], nvim('get_current_window')) - eq(nvim('get_tabpages')[2], nvim('get_current_tabpage')) - nvim('set_current_window', nvim('get_windows')[1]) + eq(2, #nvim('list_tabpages')) + eq(2, #nvim('list_wins')) + eq(nvim('list_wins')[2], nvim('get_current_win')) + eq(nvim('list_tabpages')[2], nvim('get_current_tabpage')) + nvim('set_current_win', nvim('list_wins')[1]) -- Switching window also switches tabpages if necessary - eq(nvim('get_tabpages')[1], nvim('get_current_tabpage')) - eq(nvim('get_windows')[1], nvim('get_current_window')) - nvim('set_current_tabpage', nvim('get_tabpages')[2]) - eq(nvim('get_tabpages')[2], nvim('get_current_tabpage')) - eq(nvim('get_windows')[2], nvim('get_current_window')) + eq(nvim('list_tabpages')[1], nvim('get_current_tabpage')) + eq(nvim('list_wins')[1], nvim('get_current_win')) + nvim('set_current_tabpage', nvim('list_tabpages')[2]) + eq(nvim('list_tabpages')[2], nvim('get_current_tabpage')) + eq(nvim('list_wins')[2], nvim('get_current_win')) end) end) @@ -305,7 +305,7 @@ describe('vim_* functions', function() end) it("doesn't leak memory on incorrect argument types", function() - local status, err = pcall(nvim, 'change_directory',{'not', 'a', 'dir'}) + local status, err = pcall(nvim, 'set_current_dir',{'not', 'a', 'dir'}) eq(false, status) ok(err:match(': Wrong type for argument 1, expecting String') ~= nil) end) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 97abcc1e9e..2c43e4db2c 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -32,14 +32,14 @@ end describe('window_* functions', function() before_each(clear) - describe('get_buffer', function() + describe('get_buf', function() it('works', function() - eq(curbuf(), window('get_buffer', nvim('get_windows')[1])) + eq(curbuf(), window('get_buf', nvim('list_wins')[1])) nvim('command', 'new') - nvim('set_current_window', nvim('get_windows')[2]) - eq(curbuf(), window('get_buffer', nvim('get_windows')[2])) - neq(window('get_buffer', nvim('get_windows')[1]), - window('get_buffer', nvim('get_windows')[2])) + nvim('set_current_win', nvim('list_wins')[2]) + eq(curbuf(), window('get_buf', nvim('list_wins')[2])) + neq(window('get_buf', nvim('list_wins')[1]), + window('get_buf', nvim('list_wins')[2])) end) end) @@ -105,28 +105,28 @@ describe('window_* functions', function() describe('{get,set}_height', function() it('works', function() nvim('command', 'vsplit') - eq(window('get_height', nvim('get_windows')[2]), - window('get_height', nvim('get_windows')[1])) - nvim('set_current_window', nvim('get_windows')[2]) + eq(window('get_height', nvim('list_wins')[2]), + window('get_height', nvim('list_wins')[1])) + nvim('set_current_win', nvim('list_wins')[2]) nvim('command', 'split') - eq(window('get_height', nvim('get_windows')[2]), - math.floor(window('get_height', nvim('get_windows')[1]) / 2)) - window('set_height', nvim('get_windows')[2], 2) - eq(2, window('get_height', nvim('get_windows')[2])) + eq(window('get_height', nvim('list_wins')[2]), + math.floor(window('get_height', nvim('list_wins')[1]) / 2)) + window('set_height', nvim('list_wins')[2], 2) + eq(2, window('get_height', nvim('list_wins')[2])) end) end) describe('{get,set}_width', function() it('works', function() nvim('command', 'split') - eq(window('get_width', nvim('get_windows')[2]), - window('get_width', nvim('get_windows')[1])) - nvim('set_current_window', nvim('get_windows')[2]) + eq(window('get_width', nvim('list_wins')[2]), + window('get_width', nvim('list_wins')[1])) + nvim('set_current_win', nvim('list_wins')[2]) nvim('command', 'vsplit') - eq(window('get_width', nvim('get_windows')[2]), - math.floor(window('get_width', nvim('get_windows')[1]) / 2)) - window('set_width', nvim('get_windows')[2], 2) - eq(2, window('get_width', nvim('get_windows')[2])) + eq(window('get_width', nvim('list_wins')[2]), + math.floor(window('get_width', nvim('list_wins')[1]) / 2)) + window('set_width', nvim('list_wins')[2], 2) + eq(2, window('get_width', nvim('list_wins')[2])) end) end) @@ -169,17 +169,17 @@ describe('window_* functions', function() describe('get_position', function() it('works', function() - local height = window('get_height', nvim('get_windows')[1]) - local width = window('get_width', nvim('get_windows')[1]) + local height = window('get_height', nvim('list_wins')[1]) + local width = window('get_width', nvim('list_wins')[1]) nvim('command', 'split') nvim('command', 'vsplit') - eq({0, 0}, window('get_position', nvim('get_windows')[1])) + eq({0, 0}, window('get_position', nvim('list_wins')[1])) local vsplit_pos = math.floor(width / 2) local split_pos = math.floor(height / 2) local win2row, win2col = - unpack(window('get_position', nvim('get_windows')[2])) + unpack(window('get_position', nvim('list_wins')[2])) local win3row, win3col = - unpack(window('get_position', nvim('get_windows')[3])) + unpack(window('get_position', nvim('list_wins')[3])) eq(0, win2row) eq(0, win3col) ok(vsplit_pos - 1 <= win2col and win2col <= vsplit_pos + 1) @@ -192,19 +192,19 @@ describe('window_* functions', function() nvim('command', 'tabnew') nvim('command', 'vsplit') eq(window('get_tabpage', - nvim('get_windows')[1]), nvim('get_tabpages')[1]) + nvim('list_wins')[1]), nvim('list_tabpages')[1]) eq(window('get_tabpage', - nvim('get_windows')[2]), nvim('get_tabpages')[2]) + nvim('list_wins')[2]), nvim('list_tabpages')[2]) eq(window('get_tabpage', - nvim('get_windows')[3]), nvim('get_tabpages')[2]) + nvim('list_wins')[3]), nvim('list_tabpages')[2]) end) end) describe('is_valid', function() it('works', function() nvim('command', 'split') - local win = nvim('get_windows')[2] - nvim('set_current_window', win) + local win = nvim('list_wins')[2] + nvim('set_current_win', win) ok(window('is_valid', win)) nvim('command', 'close') ok(not window('is_valid', win)) diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index d88f6977f1..2ef67e7808 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -13,7 +13,7 @@ describe('api functions', function() execute("call nvim_command('let g:test = 1')") eq(1, eval("nvim_get_var('test')")) - local buf = eval("nvim_get_current_buffer()") + local buf = eval("nvim_get_current_buf()") execute("call nvim_buf_set_lines("..buf..", 0, -1, v:true, ['aa', 'bb'])") expect([[ aa @@ -27,8 +27,8 @@ describe('api functions', function() end) it("throw errors for invalid arguments", function() - local err = exc_exec('call nvim_get_current_buffer("foo")') - eq('Vim(call):E118: Too many arguments for function: nvim_get_current_buffer', err) + local err = exc_exec('call nvim_get_current_buf("foo")') + eq('Vim(call):E118: Too many arguments for function: nvim_get_current_buf', err) err = exc_exec('call nvim_set_option("hlsearch")') eq('Vim(call):E119: Not enough arguments for function: nvim_set_option', err) @@ -51,17 +51,17 @@ describe('api functions', function() local screen = Screen.new(40, 8) screen:attach() local bnr = eval("bufnr('')") - local bhnd = eval("nvim_get_current_buffer()") + local bhnd = eval("nvim_get_current_buf()") local wid = eval("win_getid()") - local whnd = eval("nvim_get_current_window()") + local whnd = eval("nvim_get_current_win()") eq(bnr, bhnd) eq(wid, whnd) execute("new") -- creates new buffer and new window local bnr2 = eval("bufnr('')") - local bhnd2 = eval("nvim_get_current_buffer()") + local bhnd2 = eval("nvim_get_current_buf()") local wid2 = eval("win_getid()") - local whnd2 = eval("nvim_get_current_window()") + local whnd2 = eval("nvim_get_current_win()") eq(bnr2, bhnd2) eq(wid2, whnd2) neq(bnr, bnr2) @@ -70,11 +70,11 @@ describe('api functions', function() eq(bnr2, eval("nvim_buf_get_number(0)")) execute("bn") -- show old buffer in new window - eq(bnr, eval("nvim_get_current_buffer()")) + eq(bnr, eval("nvim_get_current_buf()")) eq(bnr, eval("bufnr('')")) eq(bnr, eval("nvim_buf_get_number(0)")) eq(wid2, eval("win_getid()")) - eq(whnd2, eval("nvim_get_current_window()")) + eq(whnd2, eval("nvim_get_current_win()")) end) it("get_lines and set_lines use NL to represent NUL", function() diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 65da278f9e..f6d09e6139 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -364,7 +364,7 @@ end local function curbuf(method, ...) if not method then - return nvim('get_current_buffer') + return nvim('get_current_buf') end return buffer(method, 0, ...) end @@ -387,7 +387,7 @@ end local function curwin(method, ...) if not method then - return nvim('get_current_window') + return nvim('get_current_win') end return window(method, 0, ...) end diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 579530bd6d..53fe303762 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -25,7 +25,7 @@ describe('Buffer highlighting', function() [8] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue}, [9] = {foreground = Screen.colors.SlateBlue, underline = true} }) - curbuf = request('vim_get_current_buffer') + curbuf = request('nvim_get_current_buf') end) after_each(function() @@ -33,11 +33,11 @@ describe('Buffer highlighting', function() end) local function add_hl(...) - return request('buffer_add_highlight', curbuf, ...) + return request('nvim_buf_add_highlight', curbuf, ...) end local function clear_hl(...) - return request('buffer_clear_highlight', curbuf, ...) + return request('nvim_buf_clear_highlight', curbuf, ...) end diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 3e0b99996e..945b16ef92 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -13,7 +13,7 @@ describe('color scheme compatibility', function() it('t_Co is set to 256 by default', function() eq('256', request('vim_eval', '&t_Co')) - request('vim_set_option', 't_Co', '88') + request('nvim_set_option', 't_Co', '88') eq('88', request('vim_eval', '&t_Co')) end) end) |