mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-24 12:28:32 +00:00
55 lines
1.4 KiB
Nix
55 lines
1.4 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit (lib.options) mkEnableOption mkOption;
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
inherit (lib.types) package;
|
|
inherit (lib.nvim.types) mkGrammarOption;
|
|
inherit (lib.lists) isList;
|
|
inherit (lib.nvim.lua) expToLua;
|
|
|
|
cfg = config.vim.languages.kotlin;
|
|
in {
|
|
options.vim.languages.kotlin = {
|
|
enable = mkEnableOption "kotlin/HCL support";
|
|
|
|
treesitter = {
|
|
enable = mkEnableOption "kotlin treesitter" // {default = config.vim.languages.enableTreesitter;};
|
|
package = mkGrammarOption pkgs "kotlin";
|
|
};
|
|
|
|
lsp = {
|
|
enable = mkEnableOption "kotlin LSP support (kotlin-ls)" // {default = config.vim.languages.enableLSP;};
|
|
|
|
package = mkOption {
|
|
description = "kotlin-ls package";
|
|
type = package;
|
|
default = pkgs.kotlin-language-server;
|
|
};
|
|
};
|
|
};
|
|
config = mkIf cfg.enable (mkMerge [
|
|
(mkIf cfg.treesitter.enable {
|
|
vim.treesitter.enable = true;
|
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
|
})
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
vim.lsp.lspconfig.enable = true;
|
|
vim.lsp.lspconfig.sources.kotlin-ls = ''
|
|
lspconfig.kotlinls.setup {
|
|
capabilities = capabilities,
|
|
on_attach=default_on_attach,
|
|
cmd = ${
|
|
if isList cfg.lsp.package
|
|
then expToLua cfg.lsp.package
|
|
else ''{"${cfg.lsp.package}/bin/kotlin-language-server"}''
|
|
},
|
|
}
|
|
'';
|
|
})
|
|
]);
|
|
}
|