feat(mini.files): "g." to toggle hidden files (#964)

This commit is contained in:
Phúc H. Lê Khắc authored and GitHub committed 2023-06-23 13:25:50 +02:00
1 parent eb7b4fc369
commit a080bc7667
1 file changed
+22
@@ -26,4 +26,26 @@ return {
desc = "Open mini.files (cwd)", desc = "Open mini.files (cwd)",
}, },
}, },
config = function(_, opts)
require("mini.files").setup(opts)
local show_dotfiles = true
local filter_show = function(fs_entry) return true end
local filter_hide = function(fs_entry) return not vim.startswith(fs_entry.name, ".") end
local toggle_dotfiles = function()
show_dotfiles = not show_dotfiles
local new_filter = show_dotfiles and filter_show or filter_hide
require("mini.files").refresh({ content = { filter = new_filter } })
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
-- Tweak left-hand side of mapping to your liking
vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id })
end,
})
end,
} }