Why doesn't document symbols window populate until I reopen it the second time? #1169
Answered
by
ibhagwan
niamleeson
asked this question in
Q&A
-
Here's my config. Document symbols come up empty until I close it and reopen it the second time. { -- LSP Configuration & Plugins
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
{ 'folke/neodev.nvim', opts = {} },
},
config = function()
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end,
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
local servers = {
-- tsserver = {}, -- npm i -g typescript typescript-language-server
-- eslint = {}, -- npm i -g vscode-langservers-extracted
ember = {}, -- npm install -g @lifeart/ember-language-server
html = {}, -- npm i -g vscode-langservers-extracted
cssls = {}, -- npm i -g vscode-langservers-extracted
svelte = {}, -- npm install -g svelte-language-server
lua_ls = {},
}
require('mason').setup()
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
}
end,
},
{
'ibhagwan/fzf-lua',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require('fzf-lua').setup {
-- global history
-- fzf_opts = {
-- ['--history'] = vim.fn.stdpath 'data' .. '/fzf-lua-history',
-- },
keymap = {
builtin = {
['<F12>'] = 'toggle-help',
['<F11>'] = 'toggle-preview',
['<S-down>'] = 'preview-page-down',
['<S-up>'] = 'preview-page-up',
['<S-left>'] = 'preview-page-reset',
},
fzf = {
['down'] = 'next-history',
['up'] = 'prev-history',
['ctrl-n'] = 'down',
['ctrl-p'] = 'up',
},
},
grep = {
fzf_opts = {
['--history'] = vim.fn.stdpath 'data' .. '/fzf-lua-grep-history',
},
},
files = {
formatter = 'path.filename_first', -- vscode like find where file name can be specified first
-- path_shorten = 4,
fzf_opts = {
['--history'] = vim.fn.stdpath 'data' .. '/fzf-lua-files-history',
},
},
winopts = {
fullscreen = true,
preview = {
layout = 'vertical',
vertical = 'down:50%',
horizontal = 'right:40%',
title_pos = 'left',
},
},
actions = {
files = {
['default'] = require('fzf-lua.actions').file_edit,
},
},
previewers = {
builtin = {
title_fnamemodify = function(s)
return s
end,
},
},
file_ignore_patterns = { 'i18n/', '%.lock$', '%.lua$', '%.vim$' },
}
end,
}, |
Beta Was this translation helpful? Give feedback.
Answered by
ibhagwan
May 1, 2024
Replies: 1 comment 5 replies
-
Your LSP server is probably not ready when you first run the command, symbols run asynchronous by default, if you wait long enough for your LSP server to be ready it will populate immediately. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
ibhagwan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your LSP server is probably not ready when you first run the command, symbols run asynchronous by default, if you wait long enough for your LSP server to be ready it will populate immediately.