diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-03-16 17:11:42 +0000 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-03-16 19:26:10 +0000 |
commit | 14e4b6bbd8640675d7393bdeb3e93d74ab875ff1 (patch) | |
tree | 3e48d63a51e5ff90b9d47deccc86b22c43fc5fcf /runtime/lua/vim/snippet.lua | |
parent | 924a7ef8bb3b74eccbffd48bc1a283d3867b8119 (diff) | |
download | rneovim-14e4b6bbd8640675d7393bdeb3e93d74ab875ff1.tar.gz rneovim-14e4b6bbd8640675d7393bdeb3e93d74ab875ff1.tar.bz2 rneovim-14e4b6bbd8640675d7393bdeb3e93d74ab875ff1.zip |
refactor(lua): type annotations
Diffstat (limited to 'runtime/lua/vim/snippet.lua')
-rw-r--r-- | runtime/lua/vim/snippet.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/runtime/lua/vim/snippet.lua b/runtime/lua/vim/snippet.lua index 2ffd89367f..a1e3360b2d 100644 --- a/runtime/lua/vim/snippet.lua +++ b/runtime/lua/vim/snippet.lua @@ -254,9 +254,10 @@ local function display_choices(tabstop) assert(tabstop.choices, 'Tabstop has no choices') local start_col = tabstop:get_range()[2] + 1 - local matches = vim.iter.map(function(choice) - return { word = choice } - end, tabstop.choices) + local matches = {} --- @type table[] + for _, choice in ipairs(tabstop.choices) do + matches[#matches + 1] = { word = choice } + end vim.defer_fn(function() vim.fn.complete(start_col, matches) @@ -449,7 +450,9 @@ function M.expand(input) local shiftwidth = vim.fn.shiftwidth() local curbuf = vim.api.nvim_get_current_buf() local expandtab = vim.bo[curbuf].expandtab - local lines = vim.iter.map(function(i, line) + + local lines = {} --- @type string[] + for i, line in ipairs(text_to_lines(text)) do -- Replace tabs by spaces. if expandtab then line = line:gsub('\t', (' '):rep(shiftwidth)) --- @type string @@ -459,8 +462,8 @@ function M.expand(input) line = #line ~= 0 and base_indent .. line or (expandtab and (' '):rep(shiftwidth) or '\t'):rep(vim.fn.indent('.') / shiftwidth + 1) end - return line - end, ipairs(text_to_lines(text))) + lines[#lines + 1] = line + end table.insert(snippet_text, table.concat(lines, '\n')) end |