Skip to content

Commit

Permalink
Add telescope filters
Browse files Browse the repository at this point in the history
  • Loading branch information
b-ggs committed Aug 1, 2024
1 parent 2752199 commit 56011d9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions nvim/.config/nvim/lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,35 @@ return {
{ "<Leader>s", ":Telescope lsp_dynamic_workspace_symbols<CR>" },
},
lazy = true,
config = function()
local previewers = require("telescope.previewers")

-- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#disable-highlighting-for-certain-files
local _bad = { ".*%.csv", ".*%.lua", "Dockerfile.*" } -- Put all filetypes that slow you down in this array
local bad_files = function(filepath)
for _, v in ipairs(_bad) do
if filepath:match(v) then
return false
end
end

return true
end

local new_maker = function(filepath, bufnr, opts)
opts = opts or {}
if opts.use_ft_detect == nil then opts.use_ft_detect = true end
opts.use_ft_detect = opts.use_ft_detect == false and false or bad_files(filepath)
previewers.buffer_previewer_maker(filepath, bufnr, opts)
end

require("telescope").setup {
defaults = {
buffer_previewer_maker = new_maker,
preview = {
filesize_limit = 0.05, -- in MB
},
}
}
end,
}

0 comments on commit 56011d9

Please sign in to comment.