mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
refactor(lua): type annotations
This commit is contained in:

committed by
Lewis Russell

parent
924a7ef8bb
commit
14e4b6bbd8
@@ -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
|
||||
|
Reference in New Issue
Block a user