Public Access
90 lines
2.9 KiB
Lua
90 lines
2.9 KiB
Lua
vim.pack.add({
|
|
{
|
|
src = "https://github.com/stevearc/oil.nvim",
|
|
name = "oil.nvim",
|
|
},
|
|
{
|
|
src = "https://github.com/malewicz1337/oil-git.nvim",
|
|
name = "oil-git.nvim",
|
|
},
|
|
})
|
|
|
|
local function set_oil_git_highlights()
|
|
vim.api.nvim_set_hl(0, "OilGitAdded", { link = "MiniDiffSignAdd" })
|
|
vim.api.nvim_set_hl(0, "OilGitUntracked", { link = "MiniDiffSignAdd" })
|
|
vim.api.nvim_set_hl(0, "OilGitModifiedStaged", { link = "MiniDiffSignChange" })
|
|
vim.api.nvim_set_hl(0, "OilGitModifiedUnstaged", { link = "MiniDiffSignChange" })
|
|
vim.api.nvim_set_hl(0, "OilGitRenamed", { link = "MiniDiffSignChange" })
|
|
vim.api.nvim_set_hl(0, "OilGitCopied", { link = "MiniDiffSignChange" })
|
|
vim.api.nvim_set_hl(0, "OilGitDeleted", { link = "MiniDiffSignDelete" })
|
|
vim.api.nvim_set_hl(0, "OilGitConflict", { link = "MiniDiffSignDelete" })
|
|
vim.api.nvim_set_hl(0, "OilGitIgnored", { link = "Comment" })
|
|
end
|
|
|
|
require("oil").setup({
|
|
keymaps = {
|
|
["<C-h>"] = false,
|
|
["<C-j>"] = false,
|
|
["<C-k>"] = false,
|
|
["<C-l>"] = false,
|
|
["gR"] = "actions.refresh", -- replaces default <C-l> behavior
|
|
["<F5>"] = "actions.refresh",
|
|
["<C-s>"] = false,
|
|
["<C-p>"] = { "actions.preview", opts = { vertical = true, split = "belowright" } },
|
|
["<BS>"] = { "actions.parent", mode = "n" },
|
|
},
|
|
view_options = {
|
|
show_hidden = true,
|
|
is_hidden_file = function(_, _)
|
|
return false
|
|
end,
|
|
is_always_hidden = function(name, _)
|
|
return name == ".git"
|
|
end,
|
|
},
|
|
})
|
|
|
|
local oil_git_trie = require("oil-git.trie")
|
|
local oil_git_lookup = oil_git_trie.lookup
|
|
|
|
-- ugly internal monkey patch to not show partially git-ignored foldres as grey
|
|
rawset(oil_git_trie, "lookup", function(root, entry_path, git_root, exclude_ignored)
|
|
local status = oil_git_lookup(root, entry_path, git_root, exclude_ignored)
|
|
if status ~= "!!" or exclude_ignored then
|
|
return status
|
|
end
|
|
|
|
local relative_path = entry_path:sub(#git_root + 2)
|
|
local node = root
|
|
for segment in relative_path:gmatch("[^/\\]+") do
|
|
node = node.children[segment]
|
|
if not node then
|
|
return nil
|
|
end
|
|
end
|
|
|
|
-- oil-git normally propagates an ignored child's status to every parent.
|
|
-- Only grey a directory when Git reported that directory itself as ignored.
|
|
if not node.is_dir_ignored then
|
|
return nil
|
|
end
|
|
|
|
return status
|
|
end)
|
|
|
|
require("oil-git").setup({
|
|
show_file_highlights = true,
|
|
show_directory_highlights = true,
|
|
show_ignored_files = true,
|
|
show_ignored_directories = true,
|
|
show_file_symbols = true,
|
|
show_directory_symbols = true,
|
|
symbol_position = "none",
|
|
})
|
|
|
|
set_oil_git_highlights()
|
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
|
group = vim.api.nvim_create_augroup("romanzy_oil_git_highlights", { clear = true }),
|
|
callback = set_oil_git_highlights,
|
|
})
|