Closed benjaminbauer closed 2 years ago
Hey! Most servers (if not all) supports installing a specific version, this is done by appending the version number to the server name being installed, for example rust_analyzer@nightly
or tsserver@0.6.0
. This can then be provided to either :LspInstall <server_name>
or require("nvim-lsp-installer").install(server_name)
.
Is there a file where nvim-lsp-installer keeps a list of installed servers? Or is it possible/advisable to have a block in my nvim config? Something like the vim-plug config?
There's no manifest file or single orchestration layer as such. It's all done via filesystem entries, where a server is considered installed if it exists on the filesystem.
Thanks @williamboman ! I do not have the requirement to pin the version, although that might come in handy.
What I would really like is the workflow like for vim-plug:
:LspInstallAll
and all configured servers get installedAh then perhaps this snippet in the wiki might be helpful. :help nvim-lsp-installer
might provide some more information about what APIs are available!
Hi @williamboman, based on the snippet, the API and the idea, that I want it to work somewhat like vim-plug, I whipped up this: nvim-lsplug. Would love your feedback!
Cool, looks very useful!
Maybe the API could be a bit less imperative? Lua lends itself pretty nicely to DSL-like expressions. Maybe something like:
require("nvim-lsplug").setup {
"sumneko_lua",
"vimls",
{
"jsonls",
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
end,
},
},
},
}
-- or packer.nvim-style
require("nvim-lsplug").setup(function(enable)
enable { "sumneko_lua", "vimls" } -- neovim dev LSPs
-- web LSPs
enable {
"tsserver",
"graphql",
"eslint",
{
"jsonls",
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
end,
},
},
},
}
-- this would make conditionally opting in for certain servers very easy too
if work_computer then
enable { "clangd", "rust_analyzer" }
end
end)
And as for the commands, I think it's a pretty established convention to prefix them with :Lsp
(like you already do), but also make sure the following character is uppercase. I think sticking to that aids with discoverability and autocompletion.
Btw this is a feature I've been planning to add to this plugin, I've seen it's a very common thing people put in their own configs.
Thanks for the feedback! I will adapt your recommendation for the casing of the command. Your hint to make it more DSL-like: what I like about the more imperative vim-plug style: it is very modular. I can do stuff, like your if clause, in between, or even split it through several files. To that end, I think your second proposal is a good compromise.
If this project supports something like the above, I think all my requirements that lead to making my plugin would be solved. And I agree: many people manage the installed servers in their "dotfiles" to make it reproducible. It would reduce the amount of boilerplate that users put around nvim-lsp-installer.
Hi @williamboman
Btw this is a feature I've been planning to add to this plugin, I've seen it's a very common thing people put in their own configs.
So will this be added (or has already been added) natively to nvim-lsp-installer
or the idea is to use @benjaminbauer 's plugin? Thanks in advance
It's not been added so far. You can either use that plugin or add it yourself, there's really not a lot of code needed and there's an example in the Wiki.
I have all my nvim config version controlled.
Goal: I also want to version control the list of installed lsp servers
Is there a file where nvim-lsp-installer keeps a list of installed servers? Or is it possible/advisable to have a block in my nvim config? Something like the vim-plug config?
Is this something that depends on the outcome of https://github.com/williamboman/nvim-lsp-installer/issues/184? If so, then from a user perspective I would really love to see it work as simple as vim-plug, just for lsp servers :)