mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 08:39:50 +01:00
feat: make clang lsp install optional
This commit is contained in:
parent
ed09cb7ed6
commit
232d93024c
1 changed files with 7 additions and 3 deletions
|
@ -9,6 +9,10 @@ with builtins; let
|
|||
cfg = config.vim.languages.clang;
|
||||
|
||||
defaultServer = "ccls";
|
||||
packageToCmd = package: defaultCmd:
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
|
||||
servers = {
|
||||
ccls = {
|
||||
package = pkgs.ccls;
|
||||
|
@ -16,7 +20,7 @@ with builtins; let
|
|||
lspconfig.ccls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
cmd = {"${cfg.lsp.package}/bin/ccls"};
|
||||
cmd = ${packageToCmd cfg.lsp.package "ccls"};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
||||
}
|
||||
'';
|
||||
|
@ -30,7 +34,7 @@ with builtins; let
|
|||
lspconfig.clangd.setup{
|
||||
capabilities = clangd_cap;
|
||||
on_attach=default_on_attach;
|
||||
cmd = {"${cfg.lsp.package}/bin/clangd"};
|
||||
cmd = ${packageToCmd cfg.lsp.package "clangd"};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
||||
}
|
||||
'';
|
||||
|
@ -95,7 +99,7 @@ in {
|
|||
|
||||
package = mkOption {
|
||||
description = "clang LSP server package";
|
||||
type = types.package;
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue