fix(auto highlight): Only update highlight/position if current buffer is attached to a client
This commit is contained in:
@@ -4,6 +4,7 @@ local parser = require('symbols-outline.parser')
|
|||||||
local ui = require('symbols-outline.ui')
|
local ui = require('symbols-outline.ui')
|
||||||
local writer = require('symbols-outline.writer')
|
local writer = require('symbols-outline.writer')
|
||||||
local config = require('symbols-outline.config')
|
local config = require('symbols-outline.config')
|
||||||
|
local utils = require('symbols-outline.utils.lsp_utils')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ end
|
|||||||
|
|
||||||
function M._highlight_current_item()
|
function M._highlight_current_item()
|
||||||
if M.state.outline_buf == nil or vim.api.nvim_get_current_buf() ==
|
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(
|
local hovered_line = vim.api.nvim_win_get_cursor(
|
||||||
vim.api.nvim_get_current_win())[1] - 1
|
vim.api.nvim_get_current_win())[1] - 1
|
||||||
|
|||||||
10
lua/symbols-outline/utils/lsp_utils.lua
Normal file
10
lua/symbols-outline/utils/lsp_utils.lua
Normal 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
|
||||||
Reference in New Issue
Block a user