Lsp trying to use old/deleted server

In trying to debug why clangd lsp isnt working in a repo, i noticed some errors in the log file(~/.cache/nvim/lsp.log)

some of the errors are mentioning file not found at location.
.local/share/nvim/lspinstall/cpp/clangd/lib/clang/12.0.0/include
but this is from the old lsp i was using from a different lsp install manager plugin.
ive since switched to williamboman/nvim-lsp-installer

which puts it here .local/share/nvim/lsp_servers/clangd/clangd_13.0.0/lib/clang/13.0.0/include/

is there some cached data somewhere that i need to delete to get it to start reading in the new lsp location?

I would recommend clearing your runtime files (~/.local/share/nvim/site) and checking in your config for any references to old cmd or deprecated plugins.

did an rm -rf ~/.local/share/nvim/site but log has same errors after deleting it and trying to open a cpp file.

references to old cmd

not sure what this is referring to but i did not see anything relating to “cmd” or something like it being used around my lsp stuff. the rest of the init.vim had autocmd stuff that didn’t look lsp or cpp specific.

deprecated plugins

my lsp related plugins are

Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'hrsh7th/nvim-compe'
Plug 'ray-x/lsp_signature.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}

Kinda surprising, i went through trying trying to clean out any hidden files:
rm -rf ~/.cache/nvim ~/.local/share/nvim ~/.config/nvim ~/.clangd

reinstalled vim-plug and my plugins.

and the log still shows it trying to read files out of local/share/nvim/lspinstall instead of local/share/nvim/lsp_servers

So there’s still some sneaky cached data somewhere but i dont know where it is.

You can check set rtp?

runtimepath=~/.config/nvim,
~/.fzf,
~/.config/nvim/plugged/fzf.vim,
~/.config/nvim/plugged/gundo.vim,
~/.config/nvim/plugged/tagbar,
~/.config/nvim/plugged/vim-fugitive,
~/.config/nvim/plugged/vim-surround,
~/.config/nvim/plugged/auto-pairs,
~/.config/nvim/plugged/vim-qfedit,
~/.config/nvim/plugged/vim-startuptime,
~/.config/nvim/plugged/star-search,
~/.config/nvim/plugged/hop.nvim,
~/.config/nvim/plugged/nvim-lspconfig,
~/.config/nvim/plugged/nvim-lsp-installer,
~/.config/nvim/plugged/nvim-compe,
~/.config/nvim/plugged/lsp_signature.nvim,
~/.config/nvim/plugged/nvim-treesitter,
~/.config/nvim/plugged/nvim-colorizer.lua,
~/.config/nvim/plugged/nvim-bufferline.lua,
~/.config/nvim/plugged/vim-floaterm,
~/.config/nvim/plugged/tcomment_vim,
~/.config/nvim/plugged/targets.vim,
~/.config/nvim/plugged/Alduin,
~/.config/nvim/plugged/vim-glsl,
~/.config/nvim/plugged/hlsl.vim,
/etc/xdg/nvim,
~/.local/share/nvim/site,
/usr/local/share/nvim/site,
/usr/share/nvim/site,
/var/lib/snapd/desktop/nvim/site,
/usr/local/share/nvim/runtime,
/usr/local/share/nvim/runtime/pack/dist/opt/matchit,
/usr/local/lib/nvim,
/var/lib/snapd/desktop/nvim/site/after,
/usr/share/nvim/site/after,
/usr/local/share/nvim/site/after,
~/.local/share/nvim/site/after,
/etc/xdg/nvim/after,
~/.config/nvim/plugged/nvim-compe/after,
~/.config/nvim/plugged/nvim-treesitter/after,
~/.config/nvim/plugged/vim-glsl/after,
~/.config/nvim/after

fwiw these don’t actually exist:
/etc/xdg/nvim
/usr/local/share/nvim/site
/usr/share/nvim/site
/var/lib/snapd/desktop/nvim/site,
/var/lib/snapd/desktop/nvim/site/after,
/usr/share/nvim/site/after,
/usr/local/share/nvim/site/after
~/.local/share/nvim/site/after
/etc/xdg/nvim/after

anyway looks like i have a list of things to try and hose, willing to wipe everything and reinstall at this point, though my hopes are not high.

well removed everything and reinstalled neovim from master.

good news is i no longer get that error where it tries to look in an old server location, however it can no longer find clangd. i installed clangd via williamboman/nvim-lsp-installer (:LspInstallInfo then press i on clangd in the list of servers) so ~/.local/share/nvim/lsp_servers/clangd exists.

set rtp? looks the same.

which clangd returns nothing. it’s unclear from the nvim-lsp-installer readme if you are supposed to setup a clangd alias or something in bash pointing to its install location. LspInfo does mention another client “cpp” so not sure what that is.

after doing sudo update-alternatives --install /usr/bin/clangd clangd ~/.local/share/nvim/lsp_servers/clangd/clangd 100

:LspInfo said clangd attached to buffer but looking at the log file, it’s still searching in old locations.

I know i did a similar ‘update-alternatives’ thing for my old sudo apt install clang-12 installs which were version 12. wondering if that’s playing a role.

Why did you do this? Lspconfig works fine with a system clangd installation

I removed all my system clang stuff and was trying to get the lsp to find the one installed via the lsp installer plugin. still not sure why its looking in lspinstall folder.

Can you reproduce with our minimal init.lua?

I am still able to find “lspinstall” string in the log file with this init.vim

call plug#begin()
Plug 'neovim/nvim-lspconfig'
call plug#end()

:lua << EOF
    local nvim_lsp = require('lspconfig')
    nvim_lsp.clangd.setup{}
    vim.lsp.set_log_level("debug")
EOF

What does it say when you type ‘which clangd’ on the command line

  1. You should probably undo that update-alternatives and just use your system’s clangd instead of lspinstaller

  2. Can you try wiping your compile_commands.json for that project?

I got my nvim stuff set up on Windows and I managed to get good lsp functionality.

One thing i did not mention about all this is that the repo resides on mnt/c side (so i can run/debug with msvc) while my nvim is on the linux side. i have used wsl2 to edit projects that reside on the Windows side without issue in the past (you have to use the linux side cmake to generate the compile_commands.json) but maybe there’s something about this project where it starts to choke on something.

My understanding of lsps is very poor so to me it seems like it should be no big deal, follow some paths in compile_commands and get some symbols. maybe someone with a better understanding is looking at this and thinking wtaf. My windows workflow ended up being this way since nvim on windows (both gui and terminal) in the past had been totally unusable for me, but it looks like that is no longer the case.

having gone through this exercise i get the feeling that magnitude of “off label use” with a linux-nvim-to-edit-windows-project might be much more than i thought, and not even worth mentioning on the forum? sry for wasting your time if that’s the case.

anyway for clangd on linux, lsp_server vs system gets the same results. they both will have the old lspinstaller path in the log file (its still unclear to me if that’s the root cause of some basic lsp stuff not working, like goto def of pod).

Did you clear the lspinstaller/resolve the path/wipe the compile commands.json linux side?

Can you look in compile_commands.json for references to the lspinstaller managed clangd’s headers?

, and not even worth mentioning on the forum? sry for wasting your time if that’s the case.

It’s fine, it’s just important to make these things known.

anyway for clangd on linux, lsp_server vs system gets the same results. they both will have the old lspinstaller path in the log file (its still unclear to me if that’s the root cause of some basic lsp stuff not working, like goto def of pod).

This is a message from clangd that indiciates its looking for headers, which IMO implies these are added to the compile_commands.json somehow

This is why I strongly recommend against using an lsp-installer plugin and just managing your servers manually via your system package manager hah.

fwiw there were no “lspinstaller” strings in the compile_commands when it was getting those strings in the log. there was a .cache folder in the root of the repo that may or may not have been playing a role. clangd puts it there.

not sure what i did but im using clang12 system stuff again and i no longer get those lspinstaller strings in the log.

the indexing percentage goes up to 100 but there a bunch of “Failed to compile” messages on all the project files.

I thought it might be not having visibility to some windows includes so i tried adding those to $PATH but still get “Failed to compile” messages.