nvim-lspinstall
nvim-lspinstall copied to clipboard
Config to require servers
Instead of having to manually install servers, include a config option where you can basically provide a list of language servers you need, so that lspinstall can automatically install them if they aren't already installed.
Good idea. You can already do that, by adding this to your lua config:
-- Install missing servers
local required_servers = { "lua", "tailwindcss", "bash" }
local installed_servers = require'lspinstall'.installed_servers()
for _, server in pairs(required_servers) do
if not vim.tbl_contains(installed_servers, server) then
require'lspinstall'.install_server(server)
end
end
Will probably add this to the README :)
Strange, first time I wanted it I actually wrote a similar piece of code but it showed some errors. This seems to work though
Maybe also add a way to update them automatically?
auto update won't work, see https://github.com/kabouzeid/nvim-lspinstall/issues/8
Ah alright, I'll close the issue then
I'll leave it open until I added this to the README
also how can I have custom configurations to extend the default configurations you provide?
Imagine I want to setup prettier/eslint using efm/diagnosticls how would I go about doing that while still respecting the default configs that come from this?
I'm doing this in my personal config: https://github.com/kabouzeid/nvim-lspinstall/wiki
Relevant part:
-- lsp-install
local function setup_servers()
require'lspinstall'.setup()
-- get all installed servers
local servers = require'lspinstall'.installed_servers()
-- ... and add manually installed servers
table.insert(servers, "clangd")
table.insert(servers, "sourcekit")
for _, server in pairs(servers) do
local config = make_config()
-- language specific config
if server == "lua" then
config.settings = lua_settings
end
if server == "sourcekit" then
config.filetypes = {"swift", "objective-c", "objective-cpp"}; -- we don't want c and cpp!
end
if server == "clangd" then
config.filetypes = {"c", "cpp"}; -- we don't want objective-c and objective-cpp!
end
require'lspconfig'[server].setup(config)
end
end
Does this work for you?
Basically as usual, you can use config
in require'lspconfig'[server].setup(config)
to override any config options.
See: https://github.com/neovim/nvim-lspconfig#example-override-some-defaults
eg
local lspconfig = require'lspconfig'
lspconfig.latex.setup {
name = 'latex_fancy';
settings = {
latex = {
build = {
onSave = true;
}
}
}
}
alright. so its just a matter of creating some object where the key matches your language server name in the LspInstall
What's the proper way of modifying the settings for tailwindcss. This is what I'm trying to get working, but so far no luck!?
local tailwindcss = function(config)
local opts = {
settings = {
includeLanguages = { typescript = 'javascript', typescriptreact = 'javascript' },
tailwindCSS = {
experimental = {
classRegex = {
'tw`([^`]*)',
'tw="([^"]*)',
'tw={"([^"}]*)',
'tw\\.\\w+`([^`]*)',
'tw\\(.*?\\)`([^`]*)'
}
}
}
}
}
for k, v in pairs(config) do opts[k] = v end
return opts
end
return tailwindcss
@pedropmedina should work now, I fixed it 22 days ago.
https://github.com/kabouzeid/nvim-lspinstall/issues/45#issuecomment-826902941