nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
621 stars 41 forks source link

5 seconds delay in updating lsp_status (LS : clangd ) #85

Closed sadtab closed 1 year ago

sadtab commented 1 year ago

I'm not sure if this is intentional or not. I just installed and configured lsp_status with lualine. I have the right status showing in the status bar from lsp_status but with 5 seconds delay. Is it normal? Here is my config :

local lsp_status = require('lsp-status')
lsp_status.config {
    update_interval = 100
}
lsp_status.register_progress()

local on_attach_clangd = function(client, bufnr)
    on_attach(client, bufnr)
    lsp_status.on_attach(client)
end

local handlers = {
    ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }),
    ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }),
}

local handlers_clangd = handlers
handlers_clangd["lsp_status"] = lsp_status.extensions.clangd.setup()

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)

local on_attach = function(client, bufnr)
    vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
end

require('lspconfig').clangd.setup {
    handlers = handlers_clangd,
    on_attach = on_attach_clangd,
    capabilities = vim.tbl_extend("keep", capabilities, lsp_status.capabilities),
    single_file_support = true,
    autostart = false,
    init_options = {
        clangdFileStatus = true -- required for lsp_status
    },
}

require('lualine').setup {
    options = {
        globalstatus = false,
        refresh = {
            statusline = 1000,
            tabline = 1000,
            winbar = 1000,
        }
    },
    sections = {
        lualine_x = {
            { "require('lsp-status').status()"},
        },
    },
}

I removed many irrelevant configs but included here how I constructed *_clangd handlers, cause maybe a bug is laid there

elliothatch commented 1 year ago

Not sure if this is your issue, but the "current function" text gets updated via a CursorHold autocmd.

The CursorHold delay is controlled by the updatetime option, so you can reduce the delay from the default 4000ms to, say, 300ms, by running the command :set updatetime=300, or in lua, vim.opt.updatetime = 300.

sadtab commented 1 year ago

Yep, exactly, Thanks @elliothatch