Hello everyone,
I am working on configuring neovim for development in python, shell script, lisp (common lisp), Lua, and c. I read over the Readme (will not let me add this link) for nvim-lspconfig as well as the wiki, but am having three issues I am seeking help with.
The first issue is more of a recommendation. See, in my neovim configuration, I maintain two files for managing LSP configuration, hook.lua, where the initializing of LSP is done (i.e. this is where my on_attach
function is) and lsp.lua where the actual configuration of LSP formatting, servers, etc is to be done. In reading over the wiki I noticed that you need to call on_attach
in the setup
for each LSP server in order for them to work properly, thus I have this question: is there any way for me to configure my LSP servers, pyright for example, in lsp.lua and then initialize them all using one on_attach
function in hook.lua?
My second question is kind of a two-parter. I have LSP configured to only show diagnostic messages using floating windows instead of The second part of this is that, for some reason, my keybindings are not set within my virtual_text
, this helps me keep everything neat and clean. The issue is that while I have read the customization of UI section (will not let me add this link) of the wiki, but I can’t seem to get borders to show for my floating windows. Inside of my colorscheme (will not let me add this link) I am setting the needed colors, but am not seeing them in the border for the floating window. I also tried directly creating my own border and calling that as recommended in the wiki entry I linked above, but that does not work either. Am I doing something wrong with how I am setting the border (will not let me add this link)? Additionally, I have noticed that the floating windows do not always use the proper color for text only my errors are showing in the color I set them too. Is this normal or it is possible to have the floating windows for LSP show the messages in the proper color for what they correspond to?on_server_attach
function. I have debugged the prior iteration of this part of my post. It turned out that, for some reason, I was calling a vim.lsp function improperly (I think I mistyped one character, but an unsure of what exactly I did wrong), and have the border issue resolved. The last main issue I can notice is that my bindings don’t seem to be being set. I am unsure why this is, but am working on debugging that right now.
I apologize for the noob post as I know there are way more people here facing much more important issues, but I can’t for the life of me solve these issues. In case it helps here are the relevant files in one block of links (it will not let me add my links, please comment below and I will link them if needed).
Thank you for your time.
Solutions
I wanted to add updates for the issues that I have solved.
Colorize Floating Window Text For LSP
To colorize the text within the floating windows (LSP) set the following settings
LspDiagnosticsFloatingError = {fg=color1,bg=none,style='bold'};
LspDiagnosticsFloatingWarning = {fg=color2,bg=none,style='bold'};
LspDiagnosticsFloatingInformation = {fg=color3,bg=none,style='italic'};
LspDiagnosticsFloatingHint = {fg=color4,bg=none,style='italic'};
Note that this will not change the color of the actual header within the border, to disable that you will need to add show_header = false
to vim.cmd([[ autocmd CursorHold,CursorHoldI <buffer> lua vim.lsp.util.show_line_diagnostics({focusable = false, show_header = false, border = "single"}) ]])
, that said this still does not work for me. I am still debugging why.