From f8ba62a6bb55c5ef968e6557fe907b31f436668c Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 29 Sep 2026 21:32:45 +0200 Subject: [PATCH] Revert "disable oil, enable mini.files" This reverts commit 75eae3f174c5d44bfef1b289156c8f001607ee09. --- nvim/.config/nvim/README.md | 14 ++ nvim/.config/nvim/lua/romanzy/keymaps.lua | 2 +- .../.config/nvim/lua/romanzy/plugins/mini.lua | 4 +- nvim/.config/nvim/lua/romanzy/plugins/oil.lua | 178 +++++++++--------- 4 files changed, 106 insertions(+), 92 deletions(-) diff --git a/nvim/.config/nvim/README.md b/nvim/.config/nvim/README.md index e180abb..0e17a18 100644 --- a/nvim/.config/nvim/README.md +++ b/nvim/.config/nvim/README.md @@ -54,6 +54,20 @@ Git shortcuts: - `[h`, `]h`, `[H`, `]H` jump to hunks - `th` — toggle the expanded hunk view +Refresh shortcuts (oil and buffers): + +- `gR` refresh the current buffer +- `` refresh the current buffer + +Oil usage: + +- `dl` opens the file browser +- `-`, `` goes to the parent directory +- `` also goes to the parent directory +- `` opens the selected file or enters the selected directory +- `` previews the selected entry +- `gx` opens the file in external viewer + Toggle shortcuts: - `tw` toggle soft wrap diff --git a/nvim/.config/nvim/lua/romanzy/keymaps.lua b/nvim/.config/nvim/lua/romanzy/keymaps.lua index d5057a2..3acf0c5 100644 --- a/nvim/.config/nvim/lua/romanzy/keymaps.lua +++ b/nvim/.config/nvim/lua/romanzy/keymaps.lua @@ -29,7 +29,7 @@ end map("n", "r", ":source ~/.config/nvim/init.lua", { desc = "reload init.lua" }) map("n", "h", telescope_picker("keymaps"), { desc = "show keymaps" }) -map("n", "e", open_mini_files_at_current_buffer, { desc = "open mini.files" }) +map("n", "dl", "Oil", { desc = "open oil" }) map("n", "ff", telescope_picker("find_files"), { desc = "find files" }) map("n", "fg", telescope_picker("live_grep"), { desc = "live grep" }) map("n", "fb", telescope_picker("buffers"), { desc = "find buffers" }) diff --git a/nvim/.config/nvim/lua/romanzy/plugins/mini.lua b/nvim/.config/nvim/lua/romanzy/plugins/mini.lua index 842bcb9..e34f0e0 100644 --- a/nvim/.config/nvim/lua/romanzy/plugins/mini.lua +++ b/nvim/.config/nvim/lua/romanzy/plugins/mini.lua @@ -10,7 +10,7 @@ local icons = require("mini.icons") local input = require("mini.input") local clue = require("mini.clue") local completion = require("mini.completion") -local files = require("mini.files") +local icons = require("mini.icons") local git = require("mini.git") local diff = require("mini.diff") local statusline = require("mini.statusline") @@ -56,7 +56,7 @@ clue.setup({ }, }) -files.setup(require("romanzy.custom.mini_files").setup()) +icons.setup({}) git.setup({}) diff --git a/nvim/.config/nvim/lua/romanzy/plugins/oil.lua b/nvim/.config/nvim/lua/romanzy/plugins/oil.lua index 36fe27a..f883529 100644 --- a/nvim/.config/nvim/lua/romanzy/plugins/oil.lua +++ b/nvim/.config/nvim/lua/romanzy/plugins/oil.lua @@ -1,89 +1,89 @@ --- 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 = { --- [""] = false, --- [""] = false, --- [""] = false, --- [""] = false, --- ["gR"] = "actions.refresh", -- replaces default behavior --- [""] = "actions.refresh", --- [""] = false, --- [""] = { "actions.preview", opts = { vertical = true, split = "belowright" } }, --- [""] = { "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, --- }) +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 = { + [""] = false, + [""] = false, + [""] = false, + [""] = false, + ["gR"] = "actions.refresh", -- replaces default behavior + [""] = "actions.refresh", + [""] = false, + [""] = { "actions.preview", opts = { vertical = true, split = "belowright" } }, + [""] = { "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, +})