feat(config): make kind filter configurable for telescope/aerial/...

This commit is contained in:
Folke Lemaitre
2023-10-12 00:09:04 +02:00
parent 20d36ccd84
commit c555e17e48
2 changed files with 41 additions and 32 deletions

View File

@ -84,6 +84,26 @@ local defaults = {
Variable = "󰀫 ",
},
},
---@type table<string, string[]>?
kind_filter = {
default = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Property",
"Struct",
"Trait",
},
-- you can specify a different filter for each filetype
-- lua = {
-- "Function",
-- },
},
}
M.json = {
@ -167,6 +187,17 @@ function M.setup(opts)
Util.track()
end
---@param buf? number
---@return string[]?
function M.get_kind_filter(buf)
buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf
local ft = vim.bo[buf].filetype
if M.kind_filter == false then
return
end
return M.kind_filter[ft] or M.kind_filter.default
end
---@param name "autocmds" | "options" | "keymaps"
function M.load(name)
local function _load(mod)

View File

@ -150,42 +150,20 @@ return {
{ "<leader>uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" },
{
"<leader>ss",
Util.telescope("lsp_document_symbols", {
symbols = {
"Class",
"Function",
"Method",
"Constructor",
"Interface",
"Module",
"Struct",
"Trait",
"Field",
"Property",
"Enum",
"Constant",
},
}),
function()
require("telescope.builtin").lsp_document_symbols({
symbols = require("lazyvim.config").get_kind_filter(),
})
end,
desc = "Goto Symbol",
},
{
"<leader>sS",
Util.telescope("lsp_dynamic_workspace_symbols", {
symbols = {
"Class",
"Function",
"Method",
"Constructor",
"Interface",
"Module",
"Struct",
"Trait",
"Field",
"Property",
"Enum",
"Constant",
},
}),
function()
require("telescope.builtin").lsp_dynamic_workspace_symbols({
symbols = require("lazyvim.config").get_kind_filter(),
})
end,
desc = "Goto Symbol (Workspace)",
},
},