mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-24 12:28:32 +00:00
kotlin: implemented formatter
This commit is contained in:
parent
fdf88d500e
commit
6f56fa813e
1 changed files with 44 additions and 1 deletions
|
@ -6,7 +6,8 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) package;
|
inherit (lib.types) package enum;
|
||||||
|
inherit (lib.attrsets) attrNames;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
|
@ -27,6 +28,33 @@
|
||||||
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.kotlin]}
|
--prefix PATH : ${pkgs.lib.makeBinPath [pkgs.kotlin]}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultFormat = "ktlint";
|
||||||
|
formats = {
|
||||||
|
ktlint = {
|
||||||
|
package = pkgs.kitlint;
|
||||||
|
nullConfig = ''
|
||||||
|
table.insert(
|
||||||
|
ls_sources,
|
||||||
|
null_ls.builtins.formatting.typstfmt.with({
|
||||||
|
command = "${cfg.format.package}/bin/ktlint",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
# https://github.com/Enter-tainer/typstyle
|
||||||
|
ktfmt = {
|
||||||
|
package = pkgs.ktfmt;
|
||||||
|
nullConfig = ''
|
||||||
|
table.insert(
|
||||||
|
ls_sources,
|
||||||
|
null_ls.builtins.formatting.typstfmt.with({
|
||||||
|
command = "${cfg.format.package}/bin/ktfmt",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.kotlin = {
|
options.vim.languages.kotlin = {
|
||||||
enable = mkEnableOption "Kotlin/HCL support";
|
enable = mkEnableOption "Kotlin/HCL support";
|
||||||
|
@ -45,6 +73,21 @@ in {
|
||||||
default = kotlinLspWithRuntime;
|
default = kotlinLspWithRuntime;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
format = {
|
||||||
|
enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
|
type = mkOption {
|
||||||
|
description = "Kotlin formatter to use";
|
||||||
|
type = enum (attrNames formats);
|
||||||
|
default = defaultFormat;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
description = "Kotlin formatter package";
|
||||||
|
type = package;
|
||||||
|
default = formats.${cfg.format.type}.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
|
|
Loading…
Add table
Reference in a new issue