mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 13:03:45 +00:00
nvim fix
This commit is contained in:
parent
15d0faef95
commit
71e87d48fb
3 changed files with 116 additions and 34 deletions
|
|
@ -1,31 +1,9 @@
|
|||
vim.g.canola = {
|
||||
columns = { "icon" },
|
||||
delete = { wipe = false, recursive = true },
|
||||
hidden = { enabled = false },
|
||||
keymaps = {
|
||||
["g?"] = { callback = "actions.show_help", mode = "n" },
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-v>"] = { callback = "actions.select", opts = { vertical = true } },
|
||||
["<C-x>"] = { callback = "actions.select", opts = { horizontal = true } },
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = { callback = "actions.close", mode = "n" },
|
||||
["-"] = { callback = "actions.parent", mode = "n" },
|
||||
["g."] = { callback = "actions.toggle_hidden", mode = "n" },
|
||||
["<C-t>"] = false,
|
||||
},
|
||||
}
|
||||
|
||||
vim.pack.add {
|
||||
vim.pack.add({
|
||||
"https://github.com/barrettruth/canola.nvim",
|
||||
"https://github.com/barrettruth/canola-collection",
|
||||
}
|
||||
}, { load = function() end })
|
||||
|
||||
vim.cmd.packadd "canola-collection"
|
||||
|
||||
map("n", "-", "<cmd>Canola<cr>")
|
||||
map("n", "<leader>e", "<cmd>Canola<cr>")
|
||||
|
||||
local ns = vim.api.nvim_create_namespace "canola_git_trailing"
|
||||
local ns = vim.api.nvim_create_namespace("canola_git_trailing")
|
||||
local symbols = {
|
||||
M = { "M", "DiagnosticWarn" },
|
||||
A = { "A", "DiagnosticOk" },
|
||||
|
|
@ -72,13 +50,95 @@ local function apply_git_status(buf)
|
|||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "CanolaReadPost",
|
||||
callback = function(args)
|
||||
local buf = args.buf
|
||||
apply_git_status(buf)
|
||||
vim.defer_fn(function() apply_git_status(buf) end, 500)
|
||||
end,
|
||||
})
|
||||
return {
|
||||
{
|
||||
"barrettruth/canola.nvim",
|
||||
cmd = "Canola",
|
||||
before = function()
|
||||
pcall(vim.cmd.packadd, "nvim-web-devicons")
|
||||
pcall(vim.cmd.packadd, "nonicons.nvim")
|
||||
|
||||
return { "barrettruth/canola.nvim" }
|
||||
vim.g.canola = {
|
||||
columns = { "icon" },
|
||||
hidden = { enabled = false },
|
||||
highlights = { filename = {}, columns = true },
|
||||
save = "auto",
|
||||
extglob = true,
|
||||
delete = { wipe = false, recursive = true },
|
||||
float = { border = "single" },
|
||||
keymaps = {
|
||||
["g?"] = { callback = "actions.show_help", mode = "n" },
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-v>"] = { callback = "actions.select", opts = { vertical = true } },
|
||||
["<C-x>"] = { callback = "actions.select", opts = { horizontal = true } },
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = { callback = "actions.close", mode = "n" },
|
||||
["-"] = { callback = "actions.parent", mode = "n" },
|
||||
["g."] = { callback = "actions.toggle_hidden", mode = "n" },
|
||||
["<C-t>"] = false,
|
||||
},
|
||||
}
|
||||
end,
|
||||
after = function()
|
||||
vim.cmd.packadd("canola-collection")
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("UserCanolaConfig", { clear = true })
|
||||
local detail_columns = { "git_status", "permissions", "owner", "size", "mtime" }
|
||||
local base_columns = vim.deepcopy(vim.g.canola.columns or {})
|
||||
local show_all = false
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup,
|
||||
pattern = "canola",
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
|
||||
vim.keymap.set("n", "gC", function()
|
||||
show_all = not show_all
|
||||
require("canola").set_columns(show_all and detail_columns or base_columns)
|
||||
end, {
|
||||
buffer = bufnr,
|
||||
desc = "toggle canola columns",
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "gX", function()
|
||||
local canola = require("canola")
|
||||
local entry = canola.get_cursor_entry()
|
||||
local dir = canola.get_current_dir()
|
||||
if not entry or not dir then return end
|
||||
|
||||
vim.ui.input({ prompt = "chmod: ", default = "755" }, function(mode)
|
||||
if not mode then return end
|
||||
|
||||
vim.uv.fs_chmod(dir .. entry.name, tonumber(mode, 8), function(err)
|
||||
if err then
|
||||
vim.schedule(function() vim.notify(err, vim.log.levels.ERROR) end)
|
||||
return
|
||||
end
|
||||
|
||||
vim.schedule(function() require("canola.actions").refresh.callback() end)
|
||||
end)
|
||||
end)
|
||||
end, {
|
||||
buffer = bufnr,
|
||||
desc = "chmod entry",
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
group = augroup,
|
||||
pattern = "CanolaReadPost",
|
||||
callback = function(args)
|
||||
local buf = args.buf
|
||||
apply_git_status(buf)
|
||||
vim.defer_fn(function() apply_git_status(buf) end, 500)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "-", "<cmd>Canola<cr>" },
|
||||
{ "<leader>e", "<cmd>Canola<cr>" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue