mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
refactor(neovim): Telescope: filter argument in separate table
- Use same filter arguments for both `default` & `find_command`
This commit is contained in:
@@ -124,27 +124,29 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
-- NOTE: Search in hidden files trick taken from: https://stackoverflow.com/a/75500661/11057673
|
|
||||||
local telescopeConfig = require("telescope.config")
|
local telescopeConfig = require("telescope.config")
|
||||||
|
|
||||||
|
local filters = {
|
||||||
|
"--hidden",
|
||||||
|
"--glob",
|
||||||
|
"!**/.git/*",
|
||||||
|
"--glob",
|
||||||
|
"!**/node_modules/*",
|
||||||
|
"--glob",
|
||||||
|
"!**/target/*",
|
||||||
|
}
|
||||||
|
|
||||||
-- Clone the default Telescope configuration
|
-- Clone the default Telescope configuration
|
||||||
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
|
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
|
||||||
|
|
||||||
-- Add flag to search hidden files/folders
|
-- Merge default arguments with filters
|
||||||
table.insert(vimgrep_arguments, "--hidden")
|
for i = 1, #filters do
|
||||||
table.insert(vimgrep_arguments, "--glob")
|
vimgrep_arguments[#vimgrep_arguments + 1] = filters[i]
|
||||||
-- And to ignore .git directory. Needed since its not `.gitignore`d
|
end
|
||||||
table.insert(vimgrep_arguments, "!**/.git/*")
|
|
||||||
table.insert(vimgrep_arguments, "--glob")
|
|
||||||
table.insert(vimgrep_arguments, "!**/node_modules/*")
|
|
||||||
table.insert(vimgrep_arguments, "--glob")
|
|
||||||
table.insert(vimgrep_arguments, "!**/target/*")
|
|
||||||
|
|
||||||
require("telescope").setup({
|
require("telescope").setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
-- `hidden = true` is not supported in text grep commands.
|
|
||||||
hidden = true,
|
hidden = true,
|
||||||
-- Without this live_grep would show .git entries
|
|
||||||
vimgrep_arguments = vimgrep_arguments,
|
vimgrep_arguments = vimgrep_arguments,
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
@@ -157,8 +159,11 @@ return {
|
|||||||
colorscheme = { enable_preview = true },
|
colorscheme = { enable_preview = true },
|
||||||
find_files = {
|
find_files = {
|
||||||
hidden = true,
|
hidden = true,
|
||||||
-- Redoing the vimgrep_arguments changes for find_files as well
|
find_command = {
|
||||||
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*", "--glob", "!**/node_modules/*", "--glob", "!**/target/*" },
|
unpack(telescopeConfig.values.vimgrep_arguments),
|
||||||
|
"--files",
|
||||||
|
unpack(filters),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extensions = {
|
extensions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user