I have gotten the clangd backend working.
However, I have not idea how to make it work like in the example video you posted on reddit: https://v.redd.it/lfi72durjay31
Perhaps this is not the place for it, but I would think that it handy to have a example config that shows how to turn on all the bells and whistles of the LSP client.
For example the automatic popups on hover and so on.
EDIT: I do have the commands from :h lsp.txt. But I just want to make sure that there is nothing else that I'm missing.
FYI, I wasn't auto popping up hover or anything. I was just pressing a key combination. If you wanted to do hover on idle, you could do autocmd CursorHold <buffer> call lsp#text_document_hover() or something similar, but that's not how I like to do things.
The reason why things may seem different in that video is that, as the writer of the LSP PR and a general Lua pro, I personalized my own configuration. I'm testing things that I may want to include in the core, but I would have to test them for longer still. I use the builtin client as a daily driver now, so slowly those things will be included, but just in case you're wondering how I do my configuration, here is a cleaned up summary. It uses my own library https://github.com/norcalli/nvim_utils
if vim.lsp then
-- In case I'm reloading.
vim.lsp.stop_all_clients()
-- Mappings and settings
local function lsp_setup(_)
local function focusable_popup()
local popup_win
return function(winnr)
if popup_win and nvim.win_is_valid(popup_win) then
if nvim.get_current_win() == popup_win then
nvim.ex.wincmd "p"
else
nvim.set_current_win(popup_win)
end
return
end
popup_win = winnr
end
end
local diagnostic_popup = focusable_popup()
local mappings = {
["nK"] = map_cmd [[call lsp#text_document_hover()]];
["ngd"] = map_cmd [[call lsp#text_document_definition()]];
["ngD"] = { function()
local _, winnr = vim.lsp.util.show_line_diagnostics()
diagnostic_popup(winnr)
end };
["ngp"] = { function()
local params = vim.lsp.protocol.make_text_document_position_params()
local callback = vim.lsp.builtin_callbacks["textDocument/peekDefinition"]
vim.lsp.buf_request(0, 'textDocument/definition', params, callback)
end };
}
nvim.bo.omnifunc = "lsp#omnifunc"
nvim_apply_mappings(mappings, { buffer = true; silent = true; })
end
local nvim_lsp = require'nvim_lsp'
local servers = {'texlab', 'gopls', 'clangd', 'elmls', 'tsserver', 'bashls'}
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = lsp_setup;
}
end
end
If that seems complicated to you, then you may understand why I don't post my init.lua either :P
However, we do want to make a general configuration and better examples, btw. The caveat is that, in my opinion/expectation, if you're using the LSP client right now, it's because you're an intermediate to advanced vim user who wants to try things sooner.
Those are the users who will help us test and improve things and potentially contribute fixes. Otherwise, everything is going to improve at the pace at which I implement things. Therefore, helping programming or (neo)vim beginners try it out would take away time from doing that, so it isn't one of my highest priorities right now.
README.md has tons of documentation now. If something is missing, make a specific suggestion or PR.
Most helpful comment
However, we do want to make a general configuration and better examples, btw. The caveat is that, in my opinion/expectation, if you're using the LSP client right now, it's because you're an intermediate to advanced vim user who wants to try things sooner.
Those are the users who will help us test and improve things and potentially contribute fixes. Otherwise, everything is going to improve at the pace at which I implement things. Therefore, helping programming or (neo)vim beginners try it out would take away time from doing that, so it isn't one of my highest priorities right now.