From 358b6b4273b1fd8949452b0795c4ff1602d8edd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Sterle?= Date: Thu, 11 Nov 2021 20:58:55 +0100 Subject: [PATCH] run docgen.sh --- doc/nvim-lua-guide.txt | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/nvim-lua-guide.txt b/doc/nvim-lua-guide.txt index 331d70e..a6f7891 100644 --- a/doc/nvim-lua-guide.txt +++ b/doc/nvim-lua-guide.txt @@ -575,7 +575,7 @@ store the output in a variable, for example). let s:mytext = 'hello world' function! s:MyFunction(text) - echo a:text + echo a:text endfunction call s:MyFunction(s:mytext) @@ -611,10 +611,10 @@ Alias for `vim.api.nvim_exec()`. Only the command argument is needed, vim.cmd('buffers') vim.cmd([[ let g:multiline_list = [ - \ 1, - \ 2, - \ 3, - \ ] + \ 1, + \ 2, + \ 3, + \ ] echo g:multiline_list ]]) @@ -651,7 +651,7 @@ tempted to do it like this: > function _G.smart_tab() - return vim.fn.pumvisible() == 1 and [[\]] or [[\]] + return vim.fn.pumvisible() == 1 and [[\]] or [[\]] end vim.api.nvim_set_keymap('i', '', 'v:lua.smart_tab()', {expr = @@ -681,8 +681,8 @@ This is a little verbose. Making a reusable wrapper can help: -- The function is called `t` for `termcodes`. -- You don't have to call it that, but I find the terseness convenient local function t(str) - -- Adjust boolean arguments as needed - return vim.api.nvim_replace_termcodes(str, true, true, true) + -- Adjust boolean arguments as needed + return vim.api.nvim_replace_termcodes(str, true, true, true) end print(t'') @@ -692,11 +692,11 @@ Coming back to our earlier example, this should now work as expected: > local function t(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) + return vim.api.nvim_replace_termcodes(str, true, true, true) end function _G.smart_tab() - return vim.fn.pumvisible() == 1 and t'' or t'' + return vim.fn.pumvisible() == 1 and t'' or t'' end vim.api.nvim_set_keymap('i', '', 'v:lua.smart_tab()', {expr = @@ -911,8 +911,8 @@ meta-accessors: > vim.g.some_global_variable = { - key1 = 'value', - key2 = 300 + key1 = 'value', + key2 = 300 } print(vim.inspect(vim.g.some_global_variable)) -- { key1 = "value", @@ -981,7 +981,7 @@ converted back and forth from Lua to Vimscript. print(vim.inspect(reversed_list)) -- { "c", "b", "a" } local function print_stdout(chan_id, data, name) - print(data[1]) + print(data[1]) end vim.fn.jobstart('ls', { on_stdout = print_stdout }) @@ -1022,7 +1022,7 @@ falsy, enabling constructs like these: > if has('nvim') - " do something... + " do something... endif < @@ -1032,7 +1032,7 @@ check for `1` or `0`: > if vim.fn.has('nvim') == 1 then - -- do something... + -- do something... end < @@ -1189,7 +1189,7 @@ modify the `package.loaded` global table: < The nvim-lua/plenary.nvim: -https://github.com/nvim-lua/plenary.nvim plugin has a custom function: +https://github.com/nvim-lua/plenary.nvim plugin has a custom function: https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/reload.lua that does this for you. @@ -1265,9 +1265,9 @@ variables is not: > -- This works: vim.fn.jobstart({'ls'}, { - on_stdout = function(chan_id, data, name) - print(vim.inspect(data)) - end + on_stdout = function(chan_id, data, name) + print(vim.inspect(data)) + end }) -- This doesn't: @@ -1314,7 +1314,7 @@ the `vim` global by putting this configuration in `~/.luacheckrc` or > globals = { - "vim", + "vim", } < @@ -1326,9 +1326,9 @@ its documentation: https://luacheck.readthedocs.io/en/stable/config.html sumneko/lua-language-server~ -The nvim-lspconfig: https://github.com/neovim/nvim-lspconfig/ repository +The nvim-lspconfig: https://github.com/neovim/nvim-lspconfig/ repository contains instructions to configure sumneko/lua-language-server: -https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#sumneko_lua +https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua the example uses the built-in LSP client but the configuration should be identical for other LSP client implementations .