chore: nvim - include hidden and ignored files

This commit is contained in:
tukuaiai 2026-02-20 20:58:30 +08:00
parent 421a91dab1
commit f0d4babaa2
2 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,15 @@
-- Keymaps are automatically loaded on the VeryLazy event -- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here -- Add any additional keymaps here
-- ==================== 文件搜索:包含隐藏/被忽略文件 ====================
-- 说明:
-- - LazyVim 默认 <leader>ff 通常不包含 .gitignore 忽略的文件
-- - 这个快捷键用于“真的找不到文件时”兜底(例如 .env
vim.keymap.set("n", "<leader>fF", function()
require("telescope.builtin").find_files({
hidden = true,
no_ignore = true,
no_ignore_parent = true,
})
end, { desc = "Find All Files (hidden + ignored)" })

View File

@ -6,6 +6,9 @@ return {
filtered_items = { filtered_items = {
hide_dotfiles = false, hide_dotfiles = false,
hide_gitignored = false, hide_gitignored = false,
-- 避免被默认规则额外隐藏(例如 .git 等)
hide_by_name = {},
hide_by_pattern = {},
}, },
}, },
window = { window = {
@ -22,6 +25,26 @@ return {
-- Neotree 打开逻辑已移到 autocmds.lua这里不再重复 -- Neotree 打开逻辑已移到 autocmds.lua这里不再重复
end, end,
}, },
-- Telescope 默认不展示 dotfiles以及可能被 .gitignore 忽略的文件),这里统一打开
{
"nvim-telescope/telescope.nvim",
opts = function(_, opts)
opts.pickers = opts.pickers or {}
opts.pickers.find_files = vim.tbl_deep_extend("force", opts.pickers.find_files or {}, {
hidden = true,
no_ignore = true,
no_ignore_parent = true,
})
-- live_grep / grep_string 默认也包含 dotfiles但仍遵循 ignore 规则,避免把 node_modules 等全扫进来)
opts.defaults = opts.defaults or {}
local telescope_defaults = require("telescope.config").values
opts.defaults.vimgrep_arguments = vim.deepcopy(opts.defaults.vimgrep_arguments or telescope_defaults.vimgrep_arguments)
if not vim.tbl_contains(opts.defaults.vimgrep_arguments, "--hidden") then
table.insert(opts.defaults.vimgrep_arguments, "--hidden")
end
end,
},
{ {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
event = "VeryLazy", event = "VeryLazy",
@ -67,4 +90,4 @@ return {
require("bufferline").setup(opts) require("bufferline").setup(opts)
end, end,
}, },
} }