Skip to content

Commit

Permalink
feat(mini.files): "g." to toggle hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
lkhphuc committed Jun 23, 2023
1 parent ed89d01 commit 690671e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lua/lazyvim/plugins/extras/editor/mini-files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,26 @@ return {
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,
}

0 comments on commit 690671e

Please sign in to comment.