LunarVim icon indicating copy to clipboard operation
LunarVim copied to clipboard

LSP server started multiple times

Open LostInTheLogs opened this issue 3 years ago • 6 comments

Problem description

Function client_is_configured in lsp manager looks for a name of the client in result.command, but command is not set since this commit. I think it can be fixed by changing command to desc, which does contain the name. Doing this fixed it for me.

LunarVim version

master-e4a5fe97

Neovim version (>= 0.7)

NVIM v0.7.2

Operating system/version

Fedora Linux 36

Affected language servers

all

Steps to reproduce

  1. Open a cpp file (cpp because then both c and cpp ftplugins will run, so require("lvim.lsp.manager").setup("clangd") will be called twice)

Actual behavior

Clangd starts two times

Expected behavior

Clangd starts once

support info

# :LspInfo
 Language client log: /home/adam/.cache/lvim/lsp.log
 Detected filetype:   cpp
 
 1 client(s) attached to this buffer: 
 
 Client: clangd (id: 2, pid: 12469, bufnr: [1])
 	filetypes:       c, cpp, objc, objcpp, cuda, proto
 	autostart:       true
 	root directory:  /home/adam/Repos/test_cpp2
 	cmd:             clangd
 
 1 active client(s) not attached to this buffer: 
 
 Client: clangd (id: 1, pid: 12462, bufnr: [])
 	filetypes:       c, cpp, objc, objcpp, cuda, proto
 	autostart:       true
 	root directory:  /home/adam/Repos/test_cpp2
 	cmd:             clangd
 
 Configured servers list: clangd
# :LvimInfo
Buffer info
* filetype:                cpp
* bufnr:                   1
* treesitter status:       active

Active client(s)
* name:                      clangd
* id:                        1
* supported filetype(s):     [c, cpp, objc, objcpp, cuda, proto]
* attached buffers:          []
* root_dir pattern:          []
* capabilities:              hoverProvider                 | selectionRangeProvider  | documentSymbolProvider
                             astProvider                   | referencesProvider      | implementationProvider
                             clangdInlayHintsProvider      | definitionProvider      | documentRangeFormattingProvider
                             standardTypeHierarchyProvider | workspaceSymbolProvider | documentFormattingProvider
                             inlayHintProvider             | declarationProvider     | documentHighlightProvider
                             memoryUsageProvider           | callHierarchyProvider
                             typeHierarchyProvider         | typeDefinitionProvider
* name:                      clangd
* id:                        2
* supported filetype(s):     [c, cpp, objc, objcpp, cuda, proto]
* attached buffers:          1
* root_dir pattern:          1
* capabilities:              hoverProvider                 | selectionRangeProvider  | documentSymbolProvider
                             astProvider                   | referencesProvider      | implementationProvider
                             clangdInlayHintsProvider      | definitionProvider      | documentRangeFormattingProvider
                             standardTypeHierarchyProvider | workspaceSymbolProvider | documentFormattingProvider
                             inlayHintProvider             | declarationProvider     | documentHighlightProvider
                             memoryUsageProvider           | callHierarchyProvider
                             typeHierarchyProvider         | typeDefinitionProvider

Automatic LSP info
* Skipped servers: [angularls, ansiblels, csharp_ls, cssmodules_ls, denols, ember, emmet_ls, eslint, golangci_lint_ls, graphql, jedi_language_server, ltex, phpactor, psalm, pylsp, quick_lint_js, rome, reason_ls, solang, sorbet, sourcery, sqlls, sqls, stylelint_lsp, tflint, svlangserver, verible, vuels, jdtls]

Formatters info
* Active: 
* Supported: [astyle, clang_format, uncrustify]

Linters info
* Active: 
* Supported: [clang_check, cppcheck, cpplint, gccdiag]

Code actions info
* Active: 

logs

No response

Screenshots

No response

LostInTheLogs avatar Oct 04 '22 15:10 LostInTheLogs

That solved the issue for me.

vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })
local capabilities = require("lvim.lsp").common_capabilities()
capabilities.offsetEncoding = { "utf-16" }
local opts = {capabilities = capabilities}
require("lvim.lsp.manager").setup("clangd", opts)

Put code in config.lua and exec :LvimCacheReset.

afaikiac avatar Oct 16 '22 08:10 afaikiac

That solved the issue for me.

vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })
local capabilities = require("lvim.lsp").common_capabilities()
capabilities.offsetEncoding = { "utf-16" }
local opts = {capabilities = capabilities}
require("lvim.lsp.manager").setup("clangd", opts)

Put code in config.lua and exec :LvimCacheReset.

This will only work for clangd and because require("lvim.lsp.manager").setup("clangd", opts) is called once. If you duplicate the line clangd will be started twice.

LostInTheLogs avatar Oct 16 '22 08:10 LostInTheLogs

That solved the issue for me.

vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" })
local capabilities = require("lvim.lsp").common_capabilities()
capabilities.offsetEncoding = { "utf-16" }
local opts = {capabilities = capabilities}
require("lvim.lsp.manager").setup("clangd", opts)

Put code in config.lua and exec :LvimCacheReset.

This will only work for clangd and because require("lvim.lsp.manager").setup("clangd", opts) is called once. If you duplicate the line clangd will be started twice.

Ok, I get it. You're right.

afaikiac avatar Oct 16 '22 08:10 afaikiac

So this isn't a bug and the issue is resolved correct?

ChristianChiarulli avatar Oct 17 '22 17:10 ChristianChiarulli

So this isn't a bug and the issue is resolved correct?

It is a bug

LostInTheLogs avatar Oct 17 '22 17:10 LostInTheLogs

This fix doesn't work anymore since this commit in lspconfig

LostInTheLogs avatar Oct 17 '22 17:10 LostInTheLogs