Compare commits

..
Author SHA1 Message Date
romanzy313 69d69b27c4 implemted oil compatibility 2026-09-18 14:46:46 +02:00
9 changed files with 41 additions and 174 deletions
+10 -7
View File
@@ -14,12 +14,6 @@ To remove a plugin run `:lua vim.pack.del({ "<plugin name>" })`.
See custom keymaps with short descriptions with `<leader><leader>h`. See custom keymaps with short descriptions with `<leader><leader>h`.
General shortcuts:
- `<leader>e` opens the file browser
- `gx` opens an external viewer
- `gR`, `<F5>` refresh
Windowing shortcuts: Windowing shortcuts:
- `<leader>sv` open a vertical split - `<leader>sv` open a vertical split
@@ -54,10 +48,19 @@ Git shortcuts:
- `[h`, `]h`, `[H`, `]H` jump to hunks - `[h`, `]h`, `[H`, `]H` jump to hunks
- `<leader>th` — toggle the expanded hunk view - `<leader>th` — toggle the expanded hunk view
Refresh shortcuts (oil and buffers):
- `gR` refresh the current buffer
- `<F5>` refresh the current buffer
Files usage:
- `<leader>e` opens the file browser
- `gx` opens the file in external viewer
Toggle shortcuts: Toggle shortcuts:
- `<leader>tw` toggle soft wrap - `<leader>tw` toggle soft wrap
- `<leader>ts` toggle spell checking
- `<leader>ti` toggle inline diagnostics - `<leader>ti` toggle inline diagnostics
- `<leader>tv` toggle virtual diagnostics - `<leader>tv` toggle virtual diagnostics
- `<leader>th` — toggle the expanded hunk view - `<leader>th` — toggle the expanded hunk view
@@ -2,7 +2,6 @@ local M = {}
function M.close_hidden() function M.close_hidden()
local visible_buffers = {} local visible_buffers = {}
local closed_count = 0
for _, tabpage in ipairs(vim.api.nvim_list_tabpages()) do for _, tabpage in ipairs(vim.api.nvim_list_tabpages()) do
for _, window in ipairs(vim.api.nvim_tabpage_list_wins(tabpage)) do for _, window in ipairs(vim.api.nvim_tabpage_list_wins(tabpage)) do
@@ -13,17 +12,8 @@ function M.close_hidden()
for _, buffer in ipairs(vim.api.nvim_list_bufs()) do for _, buffer in ipairs(vim.api.nvim_list_bufs()) do
if vim.bo[buffer].buflisted and not visible_buffers[buffer] then if vim.bo[buffer].buflisted and not visible_buffers[buffer] then
vim.api.nvim_buf_delete(buffer, { force = true }) vim.api.nvim_buf_delete(buffer, { force = true })
closed_count = closed_count + 1
end end
end end
if closed_count == 0 then
vim.notify("No hidden buffers to close", vim.log.levels.INFO)
return
end
local buffer_label = closed_count == 1 and "buffer" or "buffers"
vim.notify(string.format("Closed %d hidden %s", closed_count, buffer_label), vim.log.levels.INFO)
end end
return M return M
@@ -1,12 +1,7 @@
-- Custom module to config a few things for the mini.files:
-- - git highlighting
-- - refresh
-- - file open in external programs
local M = {} local M = {}
local uv = vim.uv or vim.loop local uv = vim.uv or vim.loop
local cache_ttl_ms = 1000 local cache_ttl_ms = 500
local status_cache = {} local status_cache = {}
local git_root_cache = {} local git_root_cache = {}
@@ -40,9 +35,6 @@ local function is_conflict(status)
end end
local function status_priority(status) local function status_priority(status)
-- Folder aggregation follows the Zed-inspired order create < edit <
-- delete. `subtree_status()` uses the greatest priority, so deletion
-- must outrank every create or edit status.
if #status < 2 then if #status < 2 then
return 0 return 0
end end
@@ -60,17 +52,20 @@ local function status_priority(status)
local index_status = status:sub(1, 1) local index_status = status:sub(1, 1)
local worktree_status = status:sub(2, 2) local worktree_status = status:sub(2, 2)
if index_status == "M" then
return 7
end
if index_status == "D" or worktree_status == "D" then if index_status == "D" or worktree_status == "D" then
return 4 return 5
end end
if index_status == "A" then if index_status == "A" then
return 2 return 4
end end
if index_status == "R" or index_status == "C" then if index_status == "R" or index_status == "C" then
return 3 return 3
end end
if index_status == "M" or worktree_status == "M" then if worktree_status == "M" then
return 3 return 6
end end
return 0 return 0
@@ -307,17 +302,9 @@ function M.filter(fs_entry)
return fs_entry.name ~= ".git" return fs_entry.name ~= ".git"
end end
local function get_entry_status(fs_entry)
local data = get_status_data(fs_entry)
if data == nil then
return nil
end
return lookup_status(data, fs_entry)
end
function M.highlight(fs_entry) function M.highlight(fs_entry)
local status = get_entry_status(fs_entry) local data = get_status_data(fs_entry)
local status = data == nil and nil or lookup_status(data, fs_entry)
return status_highlight(status) return status_highlight(status)
or (fs_entry.fs_type == "directory" and "MiniFilesDirectory" or "MiniFilesFile") or (fs_entry.fs_type == "directory" and "MiniFilesDirectory" or "MiniFilesFile")
end end
@@ -341,62 +328,9 @@ local function refresh()
end) end)
end end
local function refresh_filetree()
M.invalidate()
if _G.MiniFiles == nil or MiniFiles.get_explorer_state() == nil then
return
end
vim.schedule(function()
if MiniFiles.get_explorer_state() ~= nil then
MiniFiles.refresh({
content = {
filter = M.filter,
highlight = M.highlight,
},
})
end
end)
end
local function open_external()
local fs_entry = MiniFiles.get_fs_entry()
if fs_entry == nil then
vim.notify("No file system entry under the cursor", vim.log.levels.WARN)
return
end
vim.ui.open(fs_entry.path)
end
function M.setup() function M.setup()
local group = vim.api.nvim_create_augroup("romanzy_mini_files_git", { clear = true }) local group = vim.api.nvim_create_augroup("romanzy_mini_files_git", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = group,
pattern = "MiniFilesBufferCreate",
callback = function(args)
if args.data == nil then
return
end
for _, lhs in ipairs({ "gR", "<F5>" }) do
vim.keymap.set("n", lhs, refresh_filetree, {
buffer = args.data.buf_id,
desc = "refresh mini.files filetree",
})
end
vim.keymap.set("n", "gx", open_external, {
buffer = args.data.buf_id,
desc = "open mini.files entry externally",
})
vim.keymap.set("n", "<CR>", "L", {
buffer = args.data.buf_id,
remap = true,
desc = "go in entry plus (extra)",
})
end,
})
vim.api.nvim_create_autocmd({ "BufWritePost", "FocusGained", "TermClose" }, { vim.api.nvim_create_autocmd({ "BufWritePost", "FocusGained", "TermClose" }, {
group = group, group = group,
callback = refresh, callback = refresh,
@@ -1,35 +0,0 @@
local M = {}
--- Toggle spell checking for the current window.
function M.toggle()
if vim.bo.buftype == "terminal" then
return
end
vim.opt_local.spell = not vim.wo.spell
vim.cmd("redrawstatus")
end
function M.setup()
vim.opt.spelllang = { "en_us" }
vim.opt.spell = true
local group = vim.api.nvim_create_augroup("RomanzySpell", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = group,
pattern = "terminal",
callback = function()
vim.opt_local.spell = false
end,
})
vim.api.nvim_create_autocmd("TermOpen", {
group = group,
callback = function()
vim.cmd("setfiletype terminal")
end,
})
end
return M
+3 -11
View File
@@ -18,18 +18,11 @@ local function telescope_picker(picker)
end end
end end
local function open_mini_files_at_current_buffer()
local current_path = vim.api.nvim_buf_get_name(0)
if vim.bo.buftype ~= "" or current_path == "" then
current_path = nil
end
MiniFiles.open(current_path)
end
map("n", "<leader><leader>r", ":source ~/.config/nvim/init.lua<CR>", { desc = "reload init.lua" }) map("n", "<leader><leader>r", ":source ~/.config/nvim/init.lua<CR>", { desc = "reload init.lua" })
map("n", "<leader><leader>h", telescope_picker("keymaps"), { desc = "show keymaps" }) map("n", "<leader><leader>h", telescope_picker("keymaps"), { desc = "show keymaps" })
map("n", "<leader>e", open_mini_files_at_current_buffer, { desc = "open mini.files" }) map("n", "<leader>e", function()
MiniFiles.open()
end, { desc = "open mini.files" })
map("n", "<leader>ff", telescope_picker("find_files"), { desc = "find files" }) map("n", "<leader>ff", telescope_picker("find_files"), { desc = "find files" })
map("n", "<leader>fg", telescope_picker("live_grep"), { desc = "live grep" }) map("n", "<leader>fg", telescope_picker("live_grep"), { desc = "live grep" })
map("n", "<leader>fb", telescope_picker("buffers"), { desc = "find buffers" }) map("n", "<leader>fb", telescope_picker("buffers"), { desc = "find buffers" })
@@ -38,7 +31,6 @@ map("n", "<leader>lg", "<Cmd>LazyGit<CR>", { desc = "open lazygit" })
map("n", "<leader>dv", "<Cmd>DiffviewOpen<CR>", { desc = "open diffview" }) map("n", "<leader>dv", "<Cmd>DiffviewOpen<CR>", { desc = "open diffview" })
map("n", "<leader>dc", "<Cmd>DiffviewClose<CR>", { desc = "close diffview" }) map("n", "<leader>dc", "<Cmd>DiffviewClose<CR>", { desc = "close diffview" })
map("n", "<leader>tw", require("romanzy.custom.wrap").toggle, { desc = "toggle soft wrap" }) map("n", "<leader>tw", require("romanzy.custom.wrap").toggle, { desc = "toggle soft wrap" })
map("n", "<leader>ts", require("romanzy.custom.spell").toggle, { desc = "toggle spell checking" })
map("n", "<leader>th", function() map("n", "<leader>th", function()
MiniDiff.toggle_overlay() MiniDiff.toggle_overlay()
end, { desc = "toggle hunk view" }) end, { desc = "toggle hunk view" })
@@ -32,6 +32,7 @@ o.incsearch = true -- Updates search m
o.completeopt = { "menuone", "noinsert", "fuzzy", "nosort" } -- Enables fuzzy completion matching. o.completeopt = { "menuone", "noinsert", "fuzzy", "nosort" } -- Enables fuzzy completion matching.
o.pumheight = 8 -- Limits the completion popup menu size. o.pumheight = 8 -- Limits the completion popup menu size.
o.updatetime = 50 -- Reduces idle delay for swap and CursorHold events. o.updatetime = 50 -- Reduces idle delay for swap and CursorHold events.
o.spelllang = { "en_us" } -- Uses US English for spell checking.
o.shell = "bash" -- Runs shell commands through bash. o.shell = "bash" -- Runs shell commands through bash.
-- Only show the invisible characters inside the code editing buffers -- Only show the invisible characters inside the code editing buffers
+1 -2
View File
@@ -9,5 +9,4 @@ require("romanzy.plugins.nvim-treesitter")
require("romanzy.plugins.conform") require("romanzy.plugins.conform")
require("romanzy.plugins.lsp") require("romanzy.plugins.lsp")
require("romanzy.plugins.codamheader") require("romanzy.plugins.codamheader")
require("romanzy.custom.spell").setup() require("romanzy.plugins.romanzy")
require("romanzy.custom.tabline").setup()
+15 -33
View File
@@ -6,10 +6,9 @@ vim.pack.add({
}, },
}) })
local icons = require("mini.icons")
local input = require("mini.input")
local clue = require("mini.clue") local clue = require("mini.clue")
local completion = require("mini.completion") local completion = require("mini.completion")
local icons = require("mini.icons")
local files = require("mini.files") local files = require("mini.files")
local git = require("mini.git") local git = require("mini.git")
local diff = require("mini.diff") local diff = require("mini.diff")
@@ -21,20 +20,6 @@ local ai = require("mini.ai")
local notify = require("mini.notify") local notify = require("mini.notify")
local surround = require("mini.surround") local surround = require("mini.surround")
icons.setup({})
local input_view = input.gen_view.floatwin({
-- other interesting symbols for the caret `▏` `⎕` `░` `▒` `▓`
to_chunks = function(state, max_width)
return input.state_to_chunks(state, max_width, {
include_prompt = false,
include_hint = false,
symbol_caret = "█",
})
end,
})
input.setup({ handlers = { view = input_view } })
clue.setup({ clue.setup({
triggers = { triggers = {
{ mode = "n", keys = "<leader>" }, { mode = "n", keys = "<leader>" },
@@ -56,6 +41,8 @@ clue.setup({
}, },
}) })
icons.setup({})
files.setup(require("romanzy.custom.mini_files").setup()) files.setup(require("romanzy.custom.mini_files").setup())
git.setup({}) git.setup({})
@@ -77,29 +64,24 @@ vim.api.nvim_create_autocmd("ColorScheme", {
callback = set_mini_diff_highlights, callback = set_mini_diff_highlights,
}) })
local function statusline_filetype()
local filetype = vim.bo.filetype
if filetype == "" then
return ""
end
local icon = MiniIcons.get("filetype", filetype)
return icon .. " " .. filetype
end
-- Custom de-cluttered status line output. The default was waaay to noisy -- Custom de-cluttered status line output. The default was waaay to noisy
local function statusline_active() local function statusline_active()
local function statusline_filetype()
local filetype = vim.bo.filetype
if filetype == "" then
return ""
end
local icon = MiniIcons.get("filetype", filetype)
return icon .. " " .. filetype
end
local function statusline_spell()
return vim.wo.spell and "spell" or ""
end
local mode, mode_hl = statusline.section_mode({ trunc_width = 120 }) local mode, mode_hl = statusline.section_mode({ trunc_width = 120 })
local git_info = statusline.section_git({ trunc_width = 40 }) local git_info = statusline.section_git({ trunc_width = 40 })
-- local diff_info = statusline.section_diff({ trunc_width = 75 }) -- local diff_info = statusline.section_diff({ trunc_width = 75 })
-- local diagnostics = statusline.section_diagnostics({ trunc_width = 75 }) -- local diagnostics = statusline.section_diagnostics({ trunc_width = 75 })
local lsp = statusline.section_lsp({ trunc_width = 75 }) local lsp = statusline.section_lsp({ trunc_width = 75 })
local filename = statusline.section_filename({ trunc_width = 140 }) local filename = statusline.section_filename({ trunc_width = 140 })
local spell = statusline_spell()
local fileinfo = statusline_filetype() local fileinfo = statusline_filetype()
local search = statusline.section_searchcount({ trunc_width = 75 }) local search = statusline.section_searchcount({ trunc_width = 75 })
@@ -109,7 +91,7 @@ local function statusline_active()
"%<", "%<",
{ hl = "MiniStatuslineFilename", strings = { filename } }, { hl = "MiniStatuslineFilename", strings = { filename } },
"%=", "%=",
{ hl = "MiniStatuslineFileinfo", strings = { spell, fileinfo } }, { hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
{ hl = mode_hl, strings = { search } }, { hl = mode_hl, strings = { search } },
}) })
end end
@@ -150,7 +132,7 @@ notify.setup({
lsp_progress = { lsp_progress = {
-- the message "lua_ls: processing completion..." and -- the message "lua_ls: processing completion..." and
-- "lua_ls: Diagnosing" is very annoying -- "lua_ls: Diagnosing" is very annoying
-- enable = true, enable = true,
}, },
}) })
vim.notify = notify.make_notify() vim.notify = notify.make_notify()
@@ -0,0 +1 @@
require("romanzy.custom.tabline").setup()