add .luacheckrc and fix linter issues
This commit is contained in:
parent
1e67a7c6f4
commit
18dac0ed84
13
.luacheckrc
Normal file
13
.luacheckrc
Normal file
@ -0,0 +1,13 @@
|
||||
-- vim: ft=lua tw=80
|
||||
|
||||
-- Don't report unused self arguments of methods.
|
||||
self = false
|
||||
|
||||
ignore = {
|
||||
"631", -- max_line_length
|
||||
}
|
||||
|
||||
-- Global objects defined by the C code
|
||||
read_globals = {
|
||||
"vim",
|
||||
}
|
||||
@ -28,7 +28,7 @@ local function create_file(file)
|
||||
end
|
||||
|
||||
local function get_num_entries(iter)
|
||||
i = 0
|
||||
local i = 0
|
||||
for _ in iter do
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
@ -51,8 +51,8 @@ local function create_root(cwd)
|
||||
return true
|
||||
end
|
||||
|
||||
function M.update_status(entries, cwd)
|
||||
local cwd = cwd:gsub(' ', '\\ ')
|
||||
function M.update_status(entries, _cwd)
|
||||
local cwd = _cwd:gsub(' ', '\\ ')
|
||||
local git_root, git_status = get_git_root(cwd)
|
||||
if not git_root then
|
||||
if not create_root(cwd) then
|
||||
|
||||
@ -125,7 +125,7 @@ function M.refresh_entries(entries, cwd)
|
||||
if not named_entries[name] then
|
||||
local n = e.fn(cwd, name)
|
||||
|
||||
local idx = 1
|
||||
idx = 1
|
||||
if prev then
|
||||
idx = entries_idx[prev] + 1
|
||||
end
|
||||
|
||||
@ -11,8 +11,8 @@ local namespace_id = api.nvim_create_namespace('LuaTreeHighlights')
|
||||
local icon_state = config.get_icon_state()
|
||||
|
||||
local get_folder_icon = function() return "" end
|
||||
local set_folder_hl = function(index, depth, git_icon_len)
|
||||
table.insert(hl, {'LuaTreeFolderName', index, depth+git_icon_len, -1})
|
||||
local set_folder_hl = function(line, depth, git_icon_len)
|
||||
table.insert(hl, {'LuaTreeFolderName', line, depth+git_icon_len, -1})
|
||||
end
|
||||
|
||||
if icon_state.show_folder_icon then
|
||||
@ -23,9 +23,9 @@ if icon_state.show_folder_icon then
|
||||
return icon_state.icons.folder_icons.default .. " "
|
||||
end
|
||||
end
|
||||
set_folder_hl = function(index, depth, icon_len, name_len)
|
||||
table.insert(hl, {'LuaTreeFolderName', index, depth+icon_len, depth+icon_len+name_len})
|
||||
table.insert(hl, {'LuaTreeFolderIcon', index, depth, depth+icon_len})
|
||||
set_folder_hl = function(line, depth, icon_len, name_len)
|
||||
table.insert(hl, {'LuaTreeFolderName', line, depth+icon_len, depth+icon_len+name_len})
|
||||
table.insert(hl, {'LuaTreeFolderIcon', line, depth, depth+icon_len})
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,8 +33,9 @@ local get_file_icon = function() return "" end
|
||||
if icon_state.show_file_icon then
|
||||
local web_devicons = require'nvim-web-devicons'
|
||||
|
||||
get_file_icon = function(fname, extension, index, depth)
|
||||
local icon, hl_group = web_devicons.get_icon(fname, extension)
|
||||
get_file_icon = function(fname, extension, line, depth)
|
||||
local hl_group
|
||||
local icon, _ = web_devicons.get_icon(fname, extension)
|
||||
-- TODO: remove this hl_group and make this in nvim-web-devicons
|
||||
if #extension == 0 then
|
||||
hl_group = colors.hl_groups[fname]
|
||||
@ -42,7 +43,7 @@ if icon_state.show_file_icon then
|
||||
hl_group = colors.hl_groups[extension]
|
||||
end
|
||||
if hl_group and icon then
|
||||
table.insert(hl, { 'LuaTree'..hl_group, index, depth, depth + #icon })
|
||||
table.insert(hl, { 'LuaTree'..hl_group, line, depth, depth + #icon })
|
||||
return icon.." "
|
||||
else
|
||||
return icon_state.icons.default and icon_state.icons.default.." " or ""
|
||||
@ -52,10 +53,8 @@ if icon_state.show_file_icon then
|
||||
end
|
||||
|
||||
local get_git_icons = function() return "" end
|
||||
local git_icon_state = {}
|
||||
if icon_state.show_git_icon then
|
||||
|
||||
git_icon_state = {
|
||||
local git_icon_state = {
|
||||
["M "] = { { icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" } },
|
||||
[" M"] = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } },
|
||||
["MM"] = {
|
||||
@ -77,14 +76,14 @@ if icon_state.show_git_icon then
|
||||
dirty = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } },
|
||||
}
|
||||
|
||||
get_git_icons = function(node, index, depth, icon_len)
|
||||
get_git_icons = function(node, line, depth, icon_len)
|
||||
local git_status = node.git_status
|
||||
if not git_status then return "" end
|
||||
|
||||
local icon = ""
|
||||
local icons = git_icon_state[git_status]
|
||||
for _, v in ipairs(icons) do
|
||||
table.insert(hl, { v.hl, index, depth+icon_len+#icon, depth+icon_len+#icon+#v.icon })
|
||||
table.insert(hl, { v.hl, line, depth+icon_len+#icon, depth+icon_len+#icon+#v.icon })
|
||||
icon = icon..v.icon.." "
|
||||
end
|
||||
|
||||
|
||||
@ -21,8 +21,12 @@ M.Tree = {
|
||||
bufnr = nil,
|
||||
winnr = nil,
|
||||
buf_options = {
|
||||
'sidescroll=5', 'noswapfile', 'splitbelow',
|
||||
'noruler', 'noshowmode', 'noshowcmd'
|
||||
'sidescroll=5',
|
||||
'noswapfile',
|
||||
'splitbelow',
|
||||
'noruler',
|
||||
'noshowmode',
|
||||
'noshowcmd'
|
||||
},
|
||||
win_options = {
|
||||
relativenumber = false,
|
||||
@ -114,7 +118,7 @@ local function refresh_nodes(node)
|
||||
end
|
||||
|
||||
function M.refresh_tree()
|
||||
local stat = luv.fs_stat(M.Tree.cwd)
|
||||
-- local stat = luv.fs_stat(M.Tree.cwd)
|
||||
-- if stat.mtime.sec ~= M.Tree.last_modified then
|
||||
refresh_nodes(M.Tree)
|
||||
-- end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user