2022-09-19 17:44:04 +02:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.config = function()
|
2023-02-04 16:22:41 +01:00
|
|
|
local utils = require "lvim.utils.modules"
|
|
|
|
local actions = utils.require_on_exported_call "lir.actions"
|
|
|
|
local clipboard_actions = utils.require_on_exported_call "lir.clipboard.actions"
|
|
|
|
|
2022-09-19 17:44:04 +02:00
|
|
|
lvim.builtin.lir = {
|
|
|
|
active = true,
|
|
|
|
on_config_done = nil,
|
2022-10-03 02:56:23 +02:00
|
|
|
icon = "",
|
2022-09-19 17:44:04 +02:00
|
|
|
show_hidden_files = false,
|
2023-01-07 16:03:03 +01:00
|
|
|
ignore = {}, -- { ".DS_Store" "node_modules" } etc.
|
2023-01-12 08:59:00 +01:00
|
|
|
devicons = {
|
|
|
|
enable = true,
|
|
|
|
highlight_dirname = true,
|
|
|
|
},
|
2022-09-19 17:44:04 +02:00
|
|
|
mappings = {
|
|
|
|
["l"] = actions.edit,
|
|
|
|
["<CR>"] = actions.edit,
|
|
|
|
["<C-s>"] = actions.split,
|
|
|
|
["v"] = actions.vsplit,
|
|
|
|
["<C-t>"] = actions.tabedit,
|
|
|
|
|
|
|
|
["h"] = actions.up,
|
|
|
|
["q"] = actions.quit,
|
|
|
|
|
|
|
|
["A"] = actions.mkdir,
|
|
|
|
["a"] = actions.newfile,
|
|
|
|
["r"] = actions.rename,
|
|
|
|
["@"] = actions.cd,
|
|
|
|
["Y"] = actions.yank_path,
|
|
|
|
["i"] = actions.toggle_show_hidden,
|
|
|
|
["d"] = actions.delete,
|
|
|
|
|
|
|
|
["J"] = function()
|
2023-02-04 16:22:41 +01:00
|
|
|
require("lir.mark.actions").toggle_mark()
|
2022-09-19 17:44:04 +02:00
|
|
|
vim.cmd "normal! j"
|
|
|
|
end,
|
|
|
|
["c"] = clipboard_actions.copy,
|
|
|
|
["x"] = clipboard_actions.cut,
|
|
|
|
["p"] = clipboard_actions.paste,
|
|
|
|
},
|
|
|
|
float = {
|
|
|
|
winblend = 0,
|
|
|
|
curdir_window = {
|
|
|
|
enable = false,
|
|
|
|
highlight_dirname = true,
|
|
|
|
},
|
|
|
|
|
2023-01-07 16:03:03 +01:00
|
|
|
-- You can define a function that returns a table to be passed as the third
|
|
|
|
-- argument of nvim_open_win().
|
2022-09-19 17:44:04 +02:00
|
|
|
win_opts = function()
|
|
|
|
local width = math.floor(vim.o.columns * 0.7)
|
|
|
|
local height = math.floor(vim.o.lines * 0.7)
|
|
|
|
return {
|
|
|
|
border = "rounded",
|
|
|
|
width = width,
|
|
|
|
height = height,
|
|
|
|
}
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
hide_cursor = false,
|
|
|
|
on_init = function()
|
|
|
|
-- use visual mode
|
|
|
|
vim.api.nvim_buf_set_keymap(
|
|
|
|
0,
|
|
|
|
"x",
|
|
|
|
"J",
|
|
|
|
':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>',
|
|
|
|
{ noremap = true, silent = true }
|
|
|
|
)
|
|
|
|
end,
|
2023-02-04 16:22:41 +01:00
|
|
|
}
|
2022-09-19 17:44:04 +02:00
|
|
|
end
|
|
|
|
|
2022-10-03 02:56:23 +02:00
|
|
|
function M.icon_setup()
|
2023-01-13 16:48:37 +01:00
|
|
|
local devicons_ok, devicons = pcall(require, "nvim-web-devicons")
|
|
|
|
if not devicons_ok then
|
2023-01-13 15:24:05 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-10-03 02:56:23 +02:00
|
|
|
local function get_hl_by_name(name)
|
|
|
|
local ret = vim.api.nvim_get_hl_by_name(name.group, true)
|
|
|
|
return string.format("#%06x", ret[name.property])
|
|
|
|
end
|
|
|
|
|
|
|
|
local found, icon_hl = pcall(get_hl_by_name, { group = "NvimTreeFolderIcon", property = "foreground" })
|
|
|
|
if not found then
|
|
|
|
icon_hl = "#42A5F5"
|
|
|
|
end
|
|
|
|
|
2023-01-13 16:48:37 +01:00
|
|
|
devicons.set_icon {
|
|
|
|
lir_folder_icon = {
|
|
|
|
icon = lvim.builtin.lir.icon,
|
|
|
|
color = icon_hl,
|
|
|
|
name = "LirFolderNode",
|
|
|
|
},
|
|
|
|
}
|
2022-10-03 02:56:23 +02:00
|
|
|
end
|
|
|
|
|
2022-09-19 17:44:04 +02:00
|
|
|
function M.setup()
|
2022-10-03 02:56:23 +02:00
|
|
|
local status_ok, lir = pcall(reload, "lir")
|
2022-09-19 17:44:04 +02:00
|
|
|
if not status_ok then
|
|
|
|
return
|
|
|
|
end
|
2023-01-13 15:24:05 +01:00
|
|
|
|
|
|
|
if not lvim.use_icons then
|
|
|
|
lvim.builtin.lir.devicons.enable = false
|
|
|
|
end
|
|
|
|
|
2022-10-04 19:23:52 +02:00
|
|
|
lir.setup(lvim.builtin.lir)
|
2023-02-04 16:22:41 +01:00
|
|
|
M.icon_setup()
|
2022-09-19 17:44:04 +02:00
|
|
|
|
|
|
|
if lvim.builtin.lir.on_config_done then
|
|
|
|
lvim.builtin.lir.on_config_done(lir)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|