renaming: lua-tree -> nvim-tree
This commit is contained in:
@@ -56,12 +56,12 @@ local function get_links()
|
||||
CursorLine = 'CursorLine',
|
||||
VertSplit = 'VertSplit',
|
||||
CursorColumn = 'CursorColumn',
|
||||
FileDirty = 'LuaTreeGitDirty',
|
||||
FileNew = 'LuaTreeGitNew',
|
||||
FileRenamed = 'LuaTreeGitRenamed',
|
||||
FileMerge = 'LuaTreeGitMerge',
|
||||
FileStaged = 'LuaTreeGitStaged',
|
||||
FileDeleted = 'LuaTreeGitDeleted',
|
||||
FileDirty = 'NvimTreeGitDirty',
|
||||
FileNew = 'NvimTreeGitNew',
|
||||
FileRenamed = 'NvimTreeGitRenamed',
|
||||
FileMerge = 'NvimTreeGitMerge',
|
||||
FileStaged = 'NvimTreeGitStaged',
|
||||
FileDeleted = 'NvimTreeGitDeleted',
|
||||
}
|
||||
end
|
||||
|
||||
@@ -72,12 +72,12 @@ function M.setup()
|
||||
local higlight_groups = get_hl_groups()
|
||||
for k, d in pairs(higlight_groups) do
|
||||
local gui = d.gui or 'NONE'
|
||||
api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg)
|
||||
api.nvim_command('hi def NvimTree'..k..' gui='..gui..' guifg='..d.fg)
|
||||
end
|
||||
|
||||
local links = get_links()
|
||||
for k, d in pairs(links) do
|
||||
api.nvim_command('hi def link LuaTree'..k..' '..d)
|
||||
api.nvim_command('hi def link NvimTree'..k..' '..d)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
function M.get_icon_state()
|
||||
local show_icons = vim.g.lua_tree_show_icons or { git = 1, folders = 1, files = 1 }
|
||||
local show_icons = vim.g.nvim_tree_show_icons or { git = 1, folders = 1, files = 1 }
|
||||
local icons = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
@@ -20,7 +20,7 @@ function M.get_icon_state()
|
||||
}
|
||||
}
|
||||
|
||||
local user_icons = vim.g.lua_tree_icons
|
||||
local user_icons = vim.g.nvim_tree_icons
|
||||
if user_icons then
|
||||
if user_icons.default then
|
||||
icons.default = user_icons.default
|
||||
@@ -50,7 +50,7 @@ function M.get_icon_state()
|
||||
end
|
||||
|
||||
function M.get_bindings()
|
||||
local keybindings = vim.g.lua_tree_bindings or {}
|
||||
local keybindings = vim.g.nvim_tree_bindings or {}
|
||||
return {
|
||||
edit = keybindings.edit or {'<CR>', 'o'},
|
||||
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||
@@ -75,8 +75,8 @@ end
|
||||
|
||||
function M.window_options()
|
||||
local opts = {}
|
||||
opts.winhl = 'EndOfBuffer:LuaTreeEndOfBuffer,Normal:LuaTreeNormal,CursorLine:LuaTreeCursorLine,VertSplit:LuaTreeVertSplit'
|
||||
if vim.g.lua_tree_side == 'right' then
|
||||
opts.winhl = 'EndOfBuffer:NvimTreeEndOfBuffer,Normal:NvimTreeNormal,CursorLine:NvimTreeCursorLine,VertSplit:NvimTreeVertSplit'
|
||||
if vim.g.nvim_tree_side == 'right' then
|
||||
opts.side = 'L'
|
||||
opts.open_command = 'h'
|
||||
opts.preview_command = 'l'
|
||||
|
||||
@@ -13,7 +13,7 @@ local function clear_prompt()
|
||||
end
|
||||
|
||||
local function refresh_tree()
|
||||
vim.api.nvim_command(":LuaTreeRefresh")
|
||||
vim.api.nvim_command(":NvimTreeRefresh")
|
||||
end
|
||||
|
||||
local function create_file(file)
|
||||
|
||||
@@ -14,10 +14,10 @@ local M = {}
|
||||
|
||||
M.Tree = {
|
||||
entries = {},
|
||||
buf_name = 'LuaTree',
|
||||
buf_name = 'NvimTree',
|
||||
cwd = nil,
|
||||
win_width = vim.g.lua_tree_width or 30,
|
||||
win_width_allow_resize = vim.g.lua_tree_width_allow_resize,
|
||||
win_width = vim.g.nvim_tree_width or 30,
|
||||
win_width_allow_resize = vim.g.nvim_tree_width_allow_resize,
|
||||
loaded = false,
|
||||
bufnr = nil,
|
||||
winnr = function()
|
||||
@@ -125,7 +125,7 @@ function M.refresh_tree()
|
||||
-- if stat.mtime.sec ~= M.Tree.last_modified then
|
||||
refresh_nodes(M.Tree)
|
||||
-- end
|
||||
if config.get_icon_state().show_git_icon or vim.g.lua_tree_git_hl then
|
||||
if config.get_icon_state().show_git_icon or vim.g.nvim_tree_git_hl then
|
||||
git.reload_roots()
|
||||
refresh_git(M.Tree)
|
||||
end
|
||||
@@ -206,7 +206,7 @@ function M.open_file(mode, filename)
|
||||
api.nvim_command('vertical resize '..M.Tree.win_width)
|
||||
M.win_focus(cur_win)
|
||||
end
|
||||
if vim.g.lua_tree_quit_on_open == 1 and mode ~= 'preview' then
|
||||
if vim.g.nvim_tree_quit_on_open == 1 and mode ~= 'preview' then
|
||||
M.close()
|
||||
end
|
||||
end
|
||||
@@ -218,13 +218,13 @@ function M.change_dir(foldername)
|
||||
end
|
||||
|
||||
local function set_mapping(buf, key, fn)
|
||||
api.nvim_buf_set_keymap(buf, 'n', key, ':lua require"tree".'..fn..'<cr>', {
|
||||
api.nvim_buf_set_keymap(buf, 'n', key, ':lua require"nvim-tree".'..fn..'<cr>', {
|
||||
nowait = true, noremap = true, silent = true
|
||||
})
|
||||
end
|
||||
|
||||
local function set_mappings()
|
||||
if vim.g.lua_tree_disable_keybindings == 1 then
|
||||
if vim.g.nvim_tree_disable_keybindings == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ local luv = vim.loop
|
||||
|
||||
local M = {
|
||||
show_ignored = false,
|
||||
show_dotfiles = vim.g.lua_tree_hide_dotfiles ~= 1,
|
||||
show_dotfiles = vim.g.nvim_tree_hide_dotfiles ~= 1,
|
||||
}
|
||||
|
||||
local path_to_matching_str = require'lib.utils'.path_to_matching_str
|
||||
@@ -66,8 +66,8 @@ end
|
||||
|
||||
local function gen_ignore_check()
|
||||
local ignore_list = {}
|
||||
if vim.g.lua_tree_ignore and #vim.g.lua_tree_ignore > 0 then
|
||||
for _, entry in pairs(vim.g.lua_tree_ignore) do
|
||||
if vim.g.nvim_tree_ignore and #vim.g.nvim_tree_ignore > 0 then
|
||||
for _, entry in pairs(vim.g.nvim_tree_ignore) do
|
||||
ignore_list[entry] = true
|
||||
end
|
||||
end
|
||||
@@ -211,7 +211,7 @@ function M.populate(entries, cwd)
|
||||
table.insert(entries, file)
|
||||
end
|
||||
|
||||
if (not icon_config.show_git_icon) and vim.g.lua_tree_git_hl ~= 1 then
|
||||
if (not icon_config.show_git_icon) and vim.g.nvim_tree_git_hl ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ local api = vim.api
|
||||
local lines = {}
|
||||
local hl = {}
|
||||
local index = 0
|
||||
local namespace_id = api.nvim_create_namespace('LuaTreeHighlights')
|
||||
local namespace_id = api.nvim_create_namespace('NvimTreeHighlights')
|
||||
|
||||
local icon_state = config.get_icon_state()
|
||||
|
||||
@@ -29,7 +29,7 @@ if icon_state.show_folder_icon then
|
||||
end
|
||||
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
|
||||
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len})
|
||||
table.insert(hl, {'LuaTreeFolderIcon', line, depth, depth+icon_len})
|
||||
table.insert(hl, {'NvimTreeFolderIcon', line, depth, depth+icon_len})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,38 +69,38 @@ end
|
||||
local get_git_icons = function() return "" end
|
||||
local get_git_hl = function() return end
|
||||
|
||||
if vim.g.lua_tree_git_hl == 1 then
|
||||
if vim.g.nvim_tree_git_hl == 1 then
|
||||
local git_hl = {
|
||||
["M "] = { { hl = "LuaTreeFileStaged" } },
|
||||
[" M"] = { { hl = "LuaTreeFileDirty" } },
|
||||
["M "] = { { hl = "NvimTreeFileStaged" } },
|
||||
[" M"] = { { hl = "NvimTreeFileDirty" } },
|
||||
["MM"] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileDirty" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileDirty" }
|
||||
},
|
||||
["A "] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileNew" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileNew" }
|
||||
},
|
||||
["AD"] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileDeleted" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileDeleted" }
|
||||
},
|
||||
["AM"] = {
|
||||
{ hl = "LuaTreeFileStaged" },
|
||||
{ hl = "LuaTreeFileNew" },
|
||||
{ hl = "LuaTreeFileDirty" }
|
||||
{ hl = "NvimTreeFileStaged" },
|
||||
{ hl = "NvimTreeFileNew" },
|
||||
{ hl = "NvimTreeFileDirty" }
|
||||
},
|
||||
["??"] = { { hl = "LuaTreeFileNew" } },
|
||||
["R "] = { { hl = "LuaTreeFileRenamed" } },
|
||||
["UU"] = { { hl = "LuaTreeFileMerge" } },
|
||||
[" D"] = { { hl = "LuaTreeFileDeleted" } },
|
||||
["??"] = { { hl = "NvimTreeFileNew" } },
|
||||
["R "] = { { hl = "NvimTreeFileRenamed" } },
|
||||
["UU"] = { { hl = "NvimTreeFileMerge" } },
|
||||
[" D"] = { { hl = "NvimTreeFileDeleted" } },
|
||||
["D "] = {
|
||||
{ hl = "LuaTreeFileDeleted" },
|
||||
{ hl = "LuaTreeFileStaged" }
|
||||
{ hl = "NvimTreeFileDeleted" },
|
||||
{ hl = "NvimTreeFileStaged" }
|
||||
},
|
||||
[" A"] = { { hl = "none" } },
|
||||
["RM"] = { { hl = "LuaTreeFileRenamed" } },
|
||||
dirty = { { hl = "LuaTreeFileDirty" } },
|
||||
["RM"] = { { hl = "NvimTreeFileRenamed" } },
|
||||
dirty = { { hl = "NvimTreeFileDirty" } },
|
||||
}
|
||||
get_git_hl = function(node)
|
||||
local git_status = node.git_status
|
||||
@@ -121,33 +121,33 @@ end
|
||||
|
||||
if icon_state.show_git_icon then
|
||||
local git_icon_state = {
|
||||
["M "] = { { icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" } },
|
||||
[" M"] = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } },
|
||||
["M "] = { { icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" } },
|
||||
[" M"] = { { icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" } },
|
||||
["MM"] = {
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" }
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" }
|
||||
},
|
||||
["A "] = {
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" }
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitNew" }
|
||||
},
|
||||
[" A"] = {
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitNew" },
|
||||
},
|
||||
["AM"] = {
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "LuaTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" }
|
||||
{ icon = icon_state.icons.git_icons.staged, hl = "NvimTreeGitStaged" },
|
||||
{ icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitNew" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" }
|
||||
},
|
||||
["??"] = { { icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitDirty" } },
|
||||
["R "] = { { icon = icon_state.icons.git_icons.renamed, hl = "LuaTreeGitRenamed" } },
|
||||
["??"] = { { icon = icon_state.icons.git_icons.untracked, hl = "NvimTreeGitDirty" } },
|
||||
["R "] = { { icon = icon_state.icons.git_icons.renamed, hl = "NvimTreeGitRenamed" } },
|
||||
["RM"] = {
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" },
|
||||
{ icon = icon_state.icons.git_icons.renamed, hl = "LuaTreeGitRenamed" },
|
||||
{ icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" },
|
||||
{ icon = icon_state.icons.git_icons.renamed, hl = "NvimTreeGitRenamed" },
|
||||
},
|
||||
["UU"] = { { icon = icon_state.icons.git_icons.unmerged, hl = "LuaTreeGitMerge" } },
|
||||
[" D"] = { { icon = icon_state.icons.git_icons.deleted, hl = "LuaTreeGitDeleted" } },
|
||||
dirty = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } },
|
||||
["UU"] = { { icon = icon_state.icons.git_icons.unmerged, hl = "NvimTreeGitMerge" } },
|
||||
[" D"] = { { icon = icon_state.icons.git_icons.deleted, hl = "NvimTreeGitDeleted" } },
|
||||
dirty = { { icon = icon_state.icons.git_icons.unstaged, hl = "NvimTreeGitDirty" } },
|
||||
}
|
||||
|
||||
get_git_icons = function(node, line, depth, icon_len)
|
||||
@@ -157,7 +157,7 @@ if icon_state.show_git_icon then
|
||||
local icon = ""
|
||||
local icons = git_icon_state[git_status]
|
||||
if not icons then
|
||||
if vim.g.lua_tree_git_hl ~= 1 then
|
||||
if vim.g.nvim_tree_git_hl ~= 1 then
|
||||
utils.echo_warning('Unrecognized git state "'..git_status..'". Please open up an issue on https://github.com/kyazdani42/nvim-tree.lua/issues with this message.')
|
||||
end
|
||||
icons = git_icon_state.dirty
|
||||
@@ -175,7 +175,7 @@ local get_padding = function(depth)
|
||||
return string.rep(' ', depth)
|
||||
end
|
||||
|
||||
if vim.g.lua_tree_indent_markers == 1 then
|
||||
if vim.g.nvim_tree_indent_markers == 1 then
|
||||
get_padding = function(depth, idx, tree, _, markers)
|
||||
local padding = ""
|
||||
if depth ~= 0 then
|
||||
@@ -209,13 +209,13 @@ local special = {
|
||||
["readme.md"] = true,
|
||||
}
|
||||
|
||||
local root_folder_modifier = vim.g.lua_tree_root_folder_modifier or ':~'
|
||||
local root_folder_modifier = vim.g.nvim_tree_root_folder_modifier or ':~'
|
||||
|
||||
local function update_draw_data(tree, depth, markers)
|
||||
if tree.cwd and tree.cwd ~= '/' then
|
||||
local root_name = vim.fn.fnamemodify(tree.cwd, root_folder_modifier):gsub('/$', '').."/.."
|
||||
table.insert(lines, root_name)
|
||||
table.insert(hl, {'LuaTreeRootFolder', index, 0, string.len(root_name)})
|
||||
table.insert(hl, {'NvimTreeRootFolder', index, 0, string.len(root_name)})
|
||||
index = 1
|
||||
end
|
||||
|
||||
@@ -223,7 +223,7 @@ local function update_draw_data(tree, depth, markers)
|
||||
local padding = get_padding(depth, idx, tree, node, markers)
|
||||
local offset = string.len(padding)
|
||||
if depth > 0 then
|
||||
table.insert(hl, { 'LuaTreeIndentMarker', index, 0, offset })
|
||||
table.insert(hl, { 'NvimTreeIndentMarker', index, 0, offset })
|
||||
end
|
||||
|
||||
local git_hl = get_git_hl(node)
|
||||
@@ -232,7 +232,7 @@ local function update_draw_data(tree, depth, markers)
|
||||
local icon = get_folder_icon(node.open, node.link_to ~= nil)
|
||||
local git_icon = get_git_icons(node, index, offset, #icon+1) or ""
|
||||
-- INFO: this is mandatory in order to keep gui attributes (bold/italics)
|
||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'LuaTreeFolderName')
|
||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, 'NvimTreeFolderName')
|
||||
if git_hl then
|
||||
set_folder_hl(index, offset, #icon, #node.name+#git_icon, git_hl)
|
||||
end
|
||||
@@ -245,7 +245,7 @@ local function update_draw_data(tree, depth, markers)
|
||||
end
|
||||
elseif node.link_to then
|
||||
local icon = get_symlink_icon()
|
||||
local link_hl = git_hl or 'LuaTreeSymlink'
|
||||
local link_hl = git_hl or 'NvimTreeSymlink'
|
||||
table.insert(hl, { link_hl, index, offset, -1 })
|
||||
table.insert(lines, padding..icon..node.name.." ➛ "..node.link_to)
|
||||
index = index + 1
|
||||
@@ -256,7 +256,7 @@ local function update_draw_data(tree, depth, markers)
|
||||
if special[node.name] then
|
||||
icon = get_special_icon()
|
||||
git_icons = get_git_icons(node, index, offset, 0)
|
||||
table.insert(hl, {'LuaTreeSpecialFile', index, offset+#git_icons, -1})
|
||||
table.insert(hl, {'NvimTreeSpecialFile', index, offset+#git_icons, -1})
|
||||
else
|
||||
icon = get_file_icon(node.name, node.extension, index, offset)
|
||||
git_icons = get_git_icons(node, index, offset, #icon)
|
||||
@@ -264,9 +264,9 @@ local function update_draw_data(tree, depth, markers)
|
||||
table.insert(lines, padding..icon..git_icons..node.name)
|
||||
|
||||
if node.executable then
|
||||
table.insert(hl, {'LuaTreeExecFile', index, offset+#icon+#git_icons, -1 })
|
||||
table.insert(hl, {'NvimTreeExecFile', index, offset+#icon+#git_icons, -1 })
|
||||
elseif picture[node.extension] then
|
||||
table.insert(hl, {'LuaTreeImageFile', index, offset+#icon+#git_icons, -1 })
|
||||
table.insert(hl, {'NvimTreeImageFile', index, offset+#icon+#git_icons, -1 })
|
||||
end
|
||||
|
||||
if git_hl then
|
||||
|
||||
@@ -7,7 +7,7 @@ end
|
||||
|
||||
function M.echo_warning(msg)
|
||||
api.nvim_command('echohl WarningMsg')
|
||||
api.nvim_command("echom '[LuaTree] "..msg:gsub("'", "''").."'")
|
||||
api.nvim_command("echom '[NvimTree] "..msg:gsub("'", "''").."'")
|
||||
api.nvim_command('echohl None')
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function M.toggle()
|
||||
if lib.win_open() then
|
||||
lib.close()
|
||||
else
|
||||
if vim.g.lua_tree_follow == 1 then
|
||||
if vim.g.nvim_tree_follow == 1 then
|
||||
vim.schedule(function() M.find_file(true) end)
|
||||
else
|
||||
vim.schedule(lib.open)
|
||||
@@ -122,7 +122,7 @@ function M.on_enter()
|
||||
if is_dir then
|
||||
api.nvim_command('cd '..bufname)
|
||||
end
|
||||
local should_open = vim.g.lua_tree_auto_open == 1 and (bufname == '' or is_dir)
|
||||
local should_open = vim.g.nvim_tree_auto_open == 1 and (bufname == '' or is_dir)
|
||||
colors.setup()
|
||||
lib.init(should_open, should_open)
|
||||
end
|
||||
@@ -177,7 +177,7 @@ end
|
||||
|
||||
function M.buf_enter()
|
||||
update_root_dir()
|
||||
if vim.g.lua_tree_follow == 1 then
|
||||
if vim.g.nvim_tree_follow == 1 then
|
||||
M.find_file(false)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user