Public Access
Compare commits
4
Commits
d41c23b9aa
...
c67352a14d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c67352a14d | ||
|
|
0e8f4bc7a5 | ||
|
|
292961ae93 | ||
|
|
9a01804f2f |
@@ -14,6 +14,12 @@ To remove a plugin run `:lua vim.pack.del({ "<plugin name>" })`.
|
||||
|
||||
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:
|
||||
|
||||
- `<leader>sv` open a vertical split
|
||||
@@ -48,16 +54,6 @@ Git shortcuts:
|
||||
- `[h`, `]h`, `[H`, `]H` jump to hunks
|
||||
- `<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:
|
||||
|
||||
- `<leader>tw` toggle soft wrap
|
||||
|
||||
+69
-11
@@ -1,5 +1,7 @@
|
||||
-- git highlighting for the mini.files
|
||||
-- unfortunately this is a mountain of code...
|
||||
-- Custom module to config a few things for the mini.files:
|
||||
-- - git highlighting
|
||||
-- - refresh
|
||||
-- - file open in external programs
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -38,6 +40,9 @@ local function is_conflict(status)
|
||||
end
|
||||
|
||||
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
|
||||
return 0
|
||||
end
|
||||
@@ -55,20 +60,17 @@ local function status_priority(status)
|
||||
local index_status = status:sub(1, 1)
|
||||
local worktree_status = status:sub(2, 2)
|
||||
|
||||
if index_status == "M" then
|
||||
return 7
|
||||
end
|
||||
if index_status == "D" or worktree_status == "D" then
|
||||
return 5
|
||||
return 4
|
||||
end
|
||||
if index_status == "A" then
|
||||
return 4
|
||||
return 2
|
||||
end
|
||||
if index_status == "R" or index_status == "C" then
|
||||
return 3
|
||||
end
|
||||
if worktree_status == "M" then
|
||||
return 6
|
||||
if index_status == "M" or worktree_status == "M" then
|
||||
return 3
|
||||
end
|
||||
|
||||
return 0
|
||||
@@ -305,9 +307,17 @@ function M.filter(fs_entry)
|
||||
return fs_entry.name ~= ".git"
|
||||
end
|
||||
|
||||
function M.highlight(fs_entry)
|
||||
local function get_entry_status(fs_entry)
|
||||
local data = get_status_data(fs_entry)
|
||||
local status = data == nil and nil or lookup_status(data, fs_entry)
|
||||
if data == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
return lookup_status(data, fs_entry)
|
||||
end
|
||||
|
||||
function M.highlight(fs_entry)
|
||||
local status = get_entry_status(fs_entry)
|
||||
return status_highlight(status)
|
||||
or (fs_entry.fs_type == "directory" and "MiniFilesDirectory" or "MiniFilesFile")
|
||||
end
|
||||
@@ -331,9 +341,57 @@ local function refresh()
|
||||
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()
|
||||
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",
|
||||
})
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost", "FocusGained", "TermClose" }, {
|
||||
group = group,
|
||||
callback = refresh,
|
||||
@@ -43,7 +43,7 @@ clue.setup({
|
||||
|
||||
icons.setup({})
|
||||
|
||||
files.setup(require("romanzy.custom.mini_files_git").setup())
|
||||
files.setup(require("romanzy.custom.mini_files").setup())
|
||||
|
||||
git.setup({})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user