diff --git a/lua/nvim-navic/init.lua b/lua/nvim-navic/init.lua index f6fc666..87f079e 100644 --- a/lua/nvim-navic/init.lua +++ b/lua/nvim-navic/init.lua @@ -99,6 +99,10 @@ function M.setup(opts) return end + if opts.symbols ~= nil then + config.symbols_filter = opts.symbols + end + if opts.lsp ~= nil and opts.lsp.auto_attach then setup_auto_attach(opts) end @@ -294,7 +298,7 @@ end local awaiting_lsp_response = {} local function lsp_callback(for_buf, symbols) awaiting_lsp_response[for_buf] = false - lib.update_data(for_buf, symbols) + lib.update_data(for_buf, lib.filter_symbols(symbols, config.symbols_filter)) end function M.attach(client, bufnr) diff --git a/lua/nvim-navic/lib.lua b/lua/nvim-navic/lib.lua index e9733c6..921996c 100644 --- a/lua/nvim-navic/lib.lua +++ b/lua/nvim-navic/lib.lua @@ -448,4 +448,14 @@ function M.adapt_lsp_num_to_str(n) return lsp_num_to_str[n] end +function M.filter_symbols(symbols, symbols_filter) + if not symbols_filter then + return symbols + end + + return vim.tbl_filter(function(symbol) + return vim.tbl_contains(symbols_filter, M.adapt_lsp_num_to_str(symbol.kind)) + end, symbols) +end + return M