mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 05:19:48 +01:00
Merge pull request #134 from horriblename/optional-lsp-installation
This commit is contained in:
commit
0a1a12e778
14 changed files with 117 additions and 37 deletions
|
@ -18,3 +18,18 @@ Language specific support means there is a combination of language specific plug
|
|||
|
||||
Adding support for more languages, and improving support for existing ones are great places where you can contribute with a PR.
|
||||
|
||||
=== LSP Custom Packages/Command
|
||||
|
||||
In any of the `opt.languages.<language>.lsp.package` options you can provide your own LSP package, or provide the command to launch the language server, as a list of strings.
|
||||
|
||||
You can use this to skip automatic installation of a language server, and instead use the one found in your `$PATH` during runtime, for example:
|
||||
|
||||
[source,nix]
|
||||
----
|
||||
vim.languages.java = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
package = ["jdt-language-server" "-data" "~/.cache/jdtls/workspace"];
|
||||
};
|
||||
}
|
||||
----
|
||||
|
|
|
@ -14,6 +14,8 @@ https://github.com/horriblename[horriblename]:
|
|||
|
||||
* Streamlined and simplified extra plugin API with the addition of <<opt-vim.extraPlugins>>
|
||||
|
||||
* Allow using command names in place of LSP packages to avoid automatic installation.
|
||||
|
||||
https://github.com/amanse[amanse]:
|
||||
|
||||
* Added daily notes options for obsidian plugin.
|
||||
|
|
|
@ -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}"}
|
||||
}
|
||||
'';
|
||||
|
@ -94,8 +98,9 @@ in {
|
|||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "clang LSP server package";
|
||||
type = types.package;
|
||||
description = "clang LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,11 @@ with builtins; let
|
|||
lspconfig.dartls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
cmd = {"${pkgs.dart}/bin/dart", "language-server", "--protocol=lsp"};
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
||||
};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
||||
}
|
||||
'';
|
||||
|
|
|
@ -15,7 +15,11 @@ with builtins; let
|
|||
lspconfig.dartls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
cmd = {"${pkgs.dart}/bin/dart", "language-server", "--protocol=lsp"};
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
||||
};
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
||||
}
|
||||
'';
|
||||
|
@ -38,8 +42,9 @@ in {
|
|||
default = defaultServer;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Dart LSP server package";
|
||||
type = types.package;
|
||||
description = "Dart LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
opts = mkOption {
|
||||
|
|
|
@ -16,7 +16,11 @@ with builtins; let
|
|||
lspconfig.gopls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = {"${cfg.lsp.package}/bin/gopls", "serve"},
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/gopls", "serve"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -81,8 +85,9 @@ in {
|
|||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Go LSP server package";
|
||||
type = types.package;
|
||||
description = "Go LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -20,8 +20,9 @@ in {
|
|||
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "java language server";
|
||||
type = types.package;
|
||||
description = "java language server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.jdt-language-server;
|
||||
};
|
||||
};
|
||||
|
@ -32,7 +33,11 @@ in {
|
|||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.jdtls = ''
|
||||
lspconfig.jdtls.setup {
|
||||
cmd = {"${cfg.lsp.package}/bin/jdt-language-server", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"},
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/jdt-language-server", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -12,6 +12,10 @@ with builtins; let
|
|||
noFormat = "on_attach = attach_keymaps";
|
||||
|
||||
defaultServer = "nil";
|
||||
packageToCmd = package: defaultCmd:
|
||||
if isList package
|
||||
then lib.nvim.lua.expToLua package
|
||||
else ''{"${package}/bin/${defaultCmd}"}'';
|
||||
servers = {
|
||||
rnix = {
|
||||
package = pkgs.rnix-lsp;
|
||||
|
@ -24,7 +28,7 @@ with builtins; let
|
|||
then useFormat
|
||||
else noFormat
|
||||
},
|
||||
cmd = {"${cfg.lsp.package}/bin/rnix-lsp"},
|
||||
cmd = ${packageToCmd cfg.lsp.package "rnix-lsp"},
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -40,7 +44,7 @@ with builtins; let
|
|||
then useFormat
|
||||
else noFormat
|
||||
},
|
||||
cmd = {"${cfg.lsp.package}/bin/nil"},
|
||||
cmd = ${packageToCmd cfg.lsp.package "nil"},
|
||||
${optionalString cfg.format.enable ''
|
||||
settings = {
|
||||
["nil"] = {
|
||||
|
@ -130,8 +134,9 @@ in {
|
|||
default = defaultServer;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Nix LSP server package";
|
||||
type = types.package;
|
||||
description = "Nix LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,7 +16,11 @@ with builtins; let
|
|||
lspconfig.pyright.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = {"${cfg.lsp.package}/bin/pyright-langserver", "--stdio"}
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/pyright-langserver", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -122,8 +126,9 @@ in {
|
|||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "python LSP server package";
|
||||
type = types.package;
|
||||
description = "python LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf string);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -29,8 +29,9 @@ in {
|
|||
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "rust-analyzer package";
|
||||
type = types.package;
|
||||
description = "rust-analyzer package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.rust-analyzer;
|
||||
};
|
||||
|
||||
|
@ -118,7 +119,11 @@ in {
|
|||
server = {
|
||||
capabilities = capabilities,
|
||||
on_attach = rust_on_attach,
|
||||
cmd = {"${cfg.lsp.package}/bin/rust-analyzer"},
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
||||
},
|
||||
settings = {
|
||||
${cfg.lsp.opts}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@ with builtins; let
|
|||
on_attach_keymaps(client, bufnr)
|
||||
require'sqls'.setup{}
|
||||
end,
|
||||
cmd = { "${cfg.lsp.package}/bin/sqls", "-config", string.format("%s/config.yml", vim.fn.getcwd()) }
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{ "${cfg.lsp.package}/bin/sqls", "-config", string.format("%s/config.yml", vim.fn.getcwd()) }''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -87,8 +91,9 @@ in {
|
|||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "SQL LSP server package";
|
||||
type = types.package;
|
||||
description = "SQL LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,7 +16,11 @@ with builtins; let
|
|||
lspconfig.svelte.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
cmd = { "${cfg.lsp.package}/bin/svelteserver", "--stdio" }
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/svelteserver", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -73,8 +77,9 @@ in {
|
|||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Svelte LSP server package";
|
||||
type = types.package;
|
||||
description = "Svelte LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,7 +16,11 @@ with builtins; let
|
|||
lspconfig.tsserver.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
cmd = { "${cfg.lsp.package}/bin/typescript-language-server", "--stdio" }
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -27,7 +31,11 @@ with builtins; let
|
|||
lspconfig.denols.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
cmd = { "${cfg.lsp.package}/bin/deno", "lsp" }
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/deno", "lsp"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -95,8 +103,9 @@ in {
|
|||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Typescript/Javascript LSP server package";
|
||||
type = types.package;
|
||||
description = "Typescript/Javascript LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -20,8 +20,9 @@ in {
|
|||
enable = mkEnableOption "Zig LSP support (zls)" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
description = "ZLS package";
|
||||
type = types.package;
|
||||
description = "ZLS package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
||||
type = with types; either package (listOf str);
|
||||
default = pkgs.zls;
|
||||
};
|
||||
|
||||
|
@ -44,7 +45,11 @@ in {
|
|||
lspconfig.zls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach=default_on_attach,
|
||||
cmd = {"${cfg.lsp.package}/bin/zls"},
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then nvim.lua.expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/zls"}''
|
||||
},
|
||||
settings = {
|
||||
["zls"] = {
|
||||
zig_exe_path = "${cfg.lsp.zigPackage}/bin/zig",
|
||||
|
|
Loading…
Reference in a new issue