diff options
-rw-r--r-- | runtime/doc/usr_05.txt | 25 | ||||
-rw-r--r-- | runtime/doc/usr_toc.txt | 13 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 16 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 4 | ||||
-rw-r--r-- | src/nvim/lua/converter.c | 7 | ||||
-rw-r--r-- | test/functional/lua/api_spec.lua | 2 |
6 files changed, 36 insertions, 31 deletions
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index 2edef0ca23..f93a221e43 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -11,13 +11,12 @@ Vim's capabilities. Or define your own macros. |05.1| The vimrc file |05.2| The example vimrc file explained -|05.3| The defaults.vim file explained -|05.4| Simple mappings -|05.5| Adding a package -|05.6| Adding a plugin -|05.7| Adding a help file -|05.8| The option window -|05.9| Often used options +|05.3| Simple mappings +|05.4| Adding a package +|05.5| Adding a plugin +|05.6| Adding a help file +|05.7| The option window +|05.8| Often used options Next chapter: |usr_06.txt| Using syntax highlighting Previous chapter: |usr_04.txt| Making small changes @@ -200,7 +199,7 @@ mapping. If set (default), this may break plugins (but it's backward compatible). See 'langremap'. ============================================================================== -*05.4* Simple mappings +*05.3* Simple mappings A mapping enables you to bind a set of Vim commands to a single key. Suppose, for example, that you need to surround certain words with curly braces. In @@ -247,7 +246,7 @@ The ":map" command (with no arguments) lists your current mappings. At least the ones for Normal mode. More about mappings in section |40.1|. ============================================================================== -*05.5* Adding a package *add-package* *vimball-install* +*05.4* Adding a package *add-package* *vimball-install* A package is a set of files that you can add to Vim. There are two kinds of packages: optional and automatically loaded on startup. @@ -287,7 +286,7 @@ an archive or as a repository. For an archive you can follow these steps: More information about packages can be found here: |packages|. ============================================================================== -*05.6* Adding a plugin *add-plugin* *plugin* +*05.5* Adding a plugin *add-plugin* *plugin* Vim's functionality can be extended by adding plugins. A plugin is nothing more than a Vim script file that is loaded automatically when Vim starts. You @@ -423,7 +422,7 @@ Further reading: |new-filetype| How to detect a new file type. ============================================================================== -*05.7* Adding a help file *add-local-help* +*05.6* Adding a help file *add-local-help* If you are lucky, the plugin you installed also comes with a help file. We will explain how to install the help file, so that you can easily find help @@ -456,7 +455,7 @@ them through the tag. For writing a local help file, see |write-local-help|. ============================================================================== -*05.8* The option window +*05.7* The option window If you are looking for an option that does what you want, you can search in the help files here: |options|. Another way is by using this command: > @@ -495,7 +494,7 @@ border. This is what the 'scrolloff' option does, it specifies an offset from the window border where scrolling starts. ============================================================================== -*05.9* Often used options +*05.8* Often used options There are an awful lot of options. Most of them you will hardly ever use. Some of the more useful ones will be mentioned here. Don't forget you can diff --git a/runtime/doc/usr_toc.txt b/runtime/doc/usr_toc.txt index f466a8ece9..bf9c02882c 100644 --- a/runtime/doc/usr_toc.txt +++ b/runtime/doc/usr_toc.txt @@ -99,13 +99,12 @@ Read this from start to end to learn the essential commands. |usr_05.txt| Set your settings |05.1| The vimrc file |05.2| The example vimrc file explained - |05.3| The defaults.vim file explained - |05.4| Simple mappings - |05.5| Adding a package - |05.6| Adding a plugin - |05.7| Adding a help file - |05.8| The option window - |05.9| Often used options + |05.3| Simple mappings + |05.4| Adding a package + |05.5| Adding a plugin + |05.6| Adding a help file + |05.7| The option window + |05.8| Often used options |usr_06.txt| Using syntax highlighting |06.1| Switching it on diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 1d06023a4f..417b661155 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1372,16 +1372,16 @@ function M.reset(namespace, bufnr) diagnostic_cache[iter_bufnr][iter_namespace] = nil M.hide(iter_namespace, iter_bufnr) end - end - vim.api.nvim_buf_call(bufnr, function() - vim.api.nvim_command( - string.format( - "doautocmd <nomodeline> DiagnosticChanged %s", - vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr)) + vim.api.nvim_buf_call(iter_bufnr, function() + vim.api.nvim_command( + string.format( + "doautocmd <nomodeline> DiagnosticChanged %s", + vim.fn.fnameescape(vim.api.nvim_buf_get_name(iter_bufnr)) + ) ) - ) - end) + end) + end end --- Add all diagnostics to the quickfix list. diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index ae667c4106..603ed0d290 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1677,7 +1677,7 @@ function M.symbols_to_items(symbols, bufnr) end return _items end - return _symbols_to_items(symbols, {}, bufnr) + return _symbols_to_items(symbols, {}, bufnr or 0) end --- Removes empty lines from the beginning and end. @@ -1796,7 +1796,7 @@ end ---@returns { textDocument = { uri = `current_file_uri` }, range = { start = ---`current_position`, end = `current_position` } } function M.make_range_params(window, offset_encoding) - local buf = vim.api.nvim_win_get_buf(window) + local buf = vim.api.nvim_win_get_buf(window or 0) offset_encoding = offset_encoding or M._get_offset_encoding(buf) local position = make_position_param(window, offset_encoding) return { diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index b6792a5a97..8a702ddd60 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -1242,7 +1242,12 @@ LuaRef nlua_pop_LuaRef(lua_State *const lstate, Error *err) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT \ { \ type ret; \ - ret = (type)lua_tonumber(lstate, -1); \ + if (lua_type(lstate, -1) != LUA_TNUMBER) { \ + api_set_error(err, kErrorTypeValidation, "Expected Lua number"); \ + ret = (type)-1; \ + } else { \ + ret = (type)lua_tonumber(lstate, -1); \ + } \ lua_pop(lstate, 1); \ return ret; \ } diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua index f6038e23fe..cb37fb9a1c 100644 --- a/test/functional/lua/api_spec.lua +++ b/test/functional/lua/api_spec.lua @@ -183,6 +183,8 @@ describe('luaeval(vim.api.…)', function() remove_trace(exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 'test', 1, false)")]]))) eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Number is not integral', remove_trace(exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 1.5, 1, false)")]]))) + eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected Lua number', + remove_trace(exc_exec([[call luaeval("vim.api.nvim_win_is_valid(nil)")]]))) eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table', remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_float('test')")]]))) |