I actually got it working now, and, because I really wanted this when I was trying to get it working, here is a minimal working init.lua
configuration file to get it up and running, for anyone else that might need it.
Due to the current way I configured it for now, it'll quit once by itself, then you should re-run it three times. Why?
- Once, so that
plug.vim
installs the plugins needed
- A second time, so that
nvim-lsp-installer
installs the LSP servers (check installation progress by using :LspInstallInfo
)
- And then, if you run it a third time, the LSP servers will load
I am extremely open to suggestions for this, I know the plugin automation and plug.vim
bootstrapping is basically held together by electrical tape, if there's anyone who knows how to do any of this better, please inform me.
For a potentially more up-to-date version of this config, click here.
-- vim:fileencoding=utf-8:foldmethod=marker
--
-- Minimal working configuration to get working inline errors/LSP virtual text in Neovim
-- by Andy3153
--
-- Add here all the LSPs you want, see :LspInstallInfo or github.com/williamboman/nvim-lsp-installer#available-lsps
lspservers_to_install =
{
-- Examples:
'clangd', -- C/C++
'pylsp', -- Python
'sumneko_lua' -- Lua
}
-- {{{ Setting the environment up
vim.fn.setenv("NVIM_DATA_FOLDER", vim.fn.stdpath('data'))
vim.fn.setenv("AUTOLOAD_FOLDER", vim.fn.getenv('NVIM_DATA_FOLDER') .. "/site/autoload/")
vim.fn.setenv("PLUG_FOLDER", vim.fn.getenv('AUTOLOAD_FOLDER') .. "/plugged/")
-- {{{ Installing plugins
-- Feel free to do this however you please, with whatever package manager you like
vim.cmd [[
" Bootstraps plug.vim
if empty(glob('$AUTOLOAD_FOLDER/plug.vim'))
silent !curl -fLo $AUTOLOAD_FOLDER/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
silent !touch $AUTOLOAD_FOLDER/.setup-needed
autocmd VimEnter * q
endif
" Plugin list
call plug#begin('$PLUG_FOLDER')
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
call plug#end()
" Installs plugins after plug.vim was downloaded
if empty(glob('$AUTOLOAD_FOLDER/.setup-needed'))
else
autocmd VimEnter * PlugInstall
silent !rm $AUTOLOAD_FOLDER/.setup-needed
endif
]]
-- }}}
-- }}}
-- {{{ Setting up plugins
require("nvim-lsp-installer").setup({ ensure_installed = lspservers_to_install })
-- Forloop that enables all LSPs mentioned in the lspservers_to_install array
for _, lsp in ipairs(lspservers_to_install) do
require('lspconfig')[lsp].setup{sdf="sdf"} -- don't even ask me why anything is required in there, it won't work without it
end
-- }}}
EDIT: How does it look? Not good, it's a barebones config. Here's some code with mistakes in it to showcase it:
