diff --git a/README.md b/README.md index 1d80054..b306c09 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ vim.g.symbols_outline = { rename_symbol = "r", code_actions = "a", }, + lsp_blacklist = {}, } ``` @@ -52,15 +53,17 @@ let g:symbols_outline = { \ "rename_symbol": "r", \ "code_actions": "a", \ }, + \ "lsp_blacklist": [], \ } ``` -| Property | Description | Type | Default | -| ---------------------- | ------------------------------------------------------------------ | ----------------- | ------------------------ | -| highlight_hovered_item | Whether to highlight the currently hovered symbol (high cpu usage) | boolean | true | -| show_guides | Wether to show outline guides | boolean | true | -| position | Where to open the split window | 'right' or 'left' | 'right' | -| keymaps | Which keys do what | table | [here](#default-keymaps) | +| Property | Description | Type | Default | +| ---------------------- | ------------------------------------------------------------------ | ------------------ | ------------------------ | +| highlight_hovered_item | Whether to highlight the currently hovered symbol (high cpu usage) | boolean | true | +| show_guides | Wether to show outline guides | boolean | true | +| position | Where to open the split window | 'right' or 'left' | 'right' | +| keymaps | Which keys do what | table (dictionary) | [here](#default-keymaps) | +| lsp_blacklist | Which lsp clients to ignore | table (array) | {} | ### Commands diff --git a/lua/symbols-outline.lua b/lua/symbols-outline.lua index a085e62..bfb31d3 100644 --- a/lua/symbols-outline.lua +++ b/lua/symbols-outline.lua @@ -49,8 +49,9 @@ end function M._refresh() if M.state.outline_buf ~= nil then vim.lsp.buf_request(0, "textDocument/documentSymbol", getParams(), - function(_, _, result) + function(_, _, result, client_id) if result == nil or type(result) ~= 'table' then return end + if config.is_client_blacklisted(client_id) then return end M.state.code_win = vim.api.nvim_get_current_win() M.state.outline_items = parser.parse(result) @@ -182,8 +183,9 @@ local function setup_buffer() vim.api.nvim_buf_set_option(M.state.outline_buf, "modifiable", false) end -local function handler(_, _, result) +local function handler(_, _, result, client_id) if result == nil or type(result) ~= 'table' then return end + if config.is_client_blacklisted(client_id) then return end M.state.code_win = vim.api.nvim_get_current_win() diff --git a/lua/symbols-outline/config.lua b/lua/symbols-outline/config.lua index 8f6bf17..75ff426 100644 --- a/lua/symbols-outline/config.lua +++ b/lua/symbols-outline/config.lua @@ -12,8 +12,9 @@ local defaults = { focus_location = "o", hover_symbol = "", rename_symbol = "r", - code_actions = "a", - } + code_actions = "a" + }, + lsp_blacklist = {} } M.options = {} @@ -34,6 +35,17 @@ function M.get_split_command() end end +local function has_value(tab, val) + for _, value in ipairs(tab) do if value == val then return true end end + + return false +end + +function M.is_client_blacklisted(client_id) + local client = vim.lsp.get_client_by_id(client_id) + return has_value(M.options.lsp_blacklist, client.name) +end + function M.setup(options) M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) end