1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 23:40:06 +08:00

fix(lua): fix lua warnings

This commit is contained in:
Eric Wong 2024-06-12 19:45:53 +08:00
parent 6b653dbf86
commit 7edc45e572
2 changed files with 9 additions and 18 deletions

View File

@ -25,6 +25,7 @@ end
if fn.exists('*json_decode') then if fn.exists('*json_decode') then
---@return table | string
function M.json_decode(json) function M.json_decode(json)
if json == '' then if json == '' then
return '' return ''

View File

@ -366,18 +366,6 @@ local registed_sections = {
['search count'] = search_count, ['search count'] = search_count,
} }
local function check_mode()
if vim.fn.mode() == 'n' then
return 'n'
elseif vim.fn.mode() == 'i' then
return 'i'
elseif string.match(vim.fn.mode(), 'v') then
return 'v'
elseif string.match(vim.fn.mode(), 'R') then
return 'R'
end
end
local function current_tag() local function current_tag()
return '%{ v:lua.require("spacevim.plugin.statusline")._current_tag() }' return '%{ v:lua.require("spacevim.plugin.statusline")._current_tag() }'
end end
@ -957,7 +945,7 @@ function M.config()
'toggle the statusline itself', 'toggle the statusline itself',
1 1
) )
local function TagbarStatusline(in_tagbar, sortstr, fname, flags) local function TagbarStatusline(_, _, fname, _)
local name = '' local name = ''
if vim.fn.strwidth(fname) > vim.g.spacevim_sidebar_width - 15 then if vim.fn.strwidth(fname) > vim.g.spacevim_sidebar_width - 15 then
name = string.sub(fname, vim.g.spacevim_sidebar_width - 20) .. '..' name = string.sub(fname, vim.g.spacevim_sidebar_width - 20) .. '..'
@ -995,15 +983,17 @@ function M.config()
'' ''
) )
) )
for k, v in pairs(conf) do if type(conf) == 'table' then
if v == 1 or v == true then for k, v in pairs(conf) do
log.debug('cached major mode: ' .. k) if v == 1 or v == true then
M.toggle_mode(k) log.debug('cached major mode: ' .. k)
M.toggle_mode(k)
end
end end
end end
end end
end end
function M.ctrlp(focus, byfname, regex, prev, item, next, marked) function M.ctrlp(focus, byfname, _, prev, item, next, _)
return statusline.build( return statusline.build(
{ ' Ctrlp ', ' ' .. prev .. ' ', ' ' .. item .. ' ', ' ' .. next .. ' ' }, { ' Ctrlp ', ' ' .. prev .. ' ', ' ' .. item .. ' ', ' ' .. next .. ' ' },
{ ' ' .. focus .. ' ', ' ' .. byfname .. ' ', ' ' .. vim.fn.getcwd() .. ' ' }, { ' ' .. focus .. ' ', ' ' .. byfname .. ' ', ' ' .. vim.fn.getcwd() .. ' ' },