fix(auto highlight): Only update highlight/position if current buffer is attached to a client

This commit is contained in:
simrat39
2021-04-24 15:05:59 -07:00
parent aaae362ae8
commit 21f085cb92
2 changed files with 12 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ local parser = require('symbols-outline.parser')
local ui = require('symbols-outline.ui')
local writer = require('symbols-outline.writer')
local config = require('symbols-outline.config')
local utils = require('symbols-outline.utils.lsp_utils')
local M = {}
@@ -73,7 +74,7 @@ end
function M._highlight_current_item()
if M.state.outline_buf == nil or vim.api.nvim_get_current_buf() ==
M.state.outline_buf then return end
M.state.outline_buf or not utils.is_buf_attached_to_lsp() then return end
local hovered_line = vim.api.nvim_win_get_cursor(
vim.api.nvim_get_current_win())[1] - 1

View File

@@ -0,0 +1,10 @@
local vim = vim
local M = {}
function M.is_buf_attached_to_lsp(bufnr)
local clients = vim.lsp.buf_get_clients(bufnr or 0)
return clients ~= nil and #clients > 0
end
return M