fmt support
This commit is contained in:
parent
7b2265b906
commit
a791b41455
5 changed files with 123 additions and 42 deletions
|
@ -12,18 +12,46 @@ let
|
||||||
mkIf
|
mkIf
|
||||||
getName
|
getName
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
|
getExe
|
||||||
filter
|
filter
|
||||||
|
optionalString
|
||||||
|
concatLines
|
||||||
;
|
;
|
||||||
|
|
||||||
|
conf_def =
|
||||||
|
fmt:
|
||||||
|
(
|
||||||
|
''
|
||||||
|
[formatter.${getName fmt.package}]
|
||||||
|
command = "${getExe fmt.package}"
|
||||||
|
includes = ${builtins.toJSON fmt.includes}
|
||||||
|
''
|
||||||
|
+ (optionalString (fmt.options != [ ]) "options = ${builtins.toJSON fmt.options}\n")
|
||||||
|
);
|
||||||
|
|
||||||
|
treefmt_conf = pkgs.writeText "treefmt.toml" (
|
||||||
|
concatLines (map (v: (conf_def v.fmt)) (filter (v: !isNull v.fmt) tooling.lang_servers))
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkIf (enable && tooling.enable) {
|
config = mkIf (enable && tooling.enable) {
|
||||||
environment.systemPackages = map (v: v.package) tooling.lang_servers;
|
environment.systemPackages =
|
||||||
|
[
|
||||||
|
pkgs.treefmt
|
||||||
|
pkgs.findup
|
||||||
|
pkgs.gnused
|
||||||
|
]
|
||||||
|
++ (map (v: v.lsp.package) (filter (v: !isNull v.lsp) tooling.lang_servers))
|
||||||
|
++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers));
|
||||||
|
|
||||||
|
environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file ${treefmt_conf}";
|
||||||
|
|
||||||
grimmShared.tooling.nvim.extraLuaRC =
|
grimmShared.tooling.nvim.extraLuaRC =
|
||||||
[ "vim.g.coq_settings = { auto_start = 'shut-up' }" ]
|
[ "vim.g.coq_settings = { auto_start = 'shut-up' }" ]
|
||||||
++ (map (
|
++ (map (
|
||||||
v: "require'lspconfig'.${v.name}.setup(require('coq').lsp_ensure_capabilities(${v.config}))"
|
v:
|
||||||
) (filter (v: v.vimIntegration) tooling.lang_servers));
|
"require'lspconfig'.${v.lsp.lspconf_mod_name}.setup(require('coq').lsp_ensure_capabilities(${v.lsp.lspconf_config}))"
|
||||||
|
) (filter (v: !isNull v.lsp && v.lsp.vimIntegration) tooling.lang_servers));
|
||||||
|
|
||||||
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
|
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
|
||||||
nvim-lspconfig
|
nvim-lspconfig
|
||||||
|
@ -34,34 +62,74 @@ in
|
||||||
|
|
||||||
options.grimmShared.tooling.lang_servers = mkOption {
|
options.grimmShared.tooling.lang_servers = mkOption {
|
||||||
type = types.listOf (
|
type = types.listOf (
|
||||||
|
types.submodule {
|
||||||
|
options = {
|
||||||
|
lsp = mkOption {
|
||||||
|
type = types.nullOr (
|
||||||
types.submodule (
|
types.submodule (
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
lspconf_mod_name = mkOption {
|
||||||
type = types.nullOr types.nonEmptyStr;
|
type = types.nullOr types.nonEmptyStr;
|
||||||
default = getName config.package;
|
default = getName config.package;
|
||||||
description = "lspconfig module name";
|
description = "lspconfig module name";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkOption {
|
lspconf_config = mkOption {
|
||||||
type = types.nonEmptyStr;
|
type = types.nonEmptyStr;
|
||||||
default = "{}";
|
default = "{}";
|
||||||
description = "options to pass to lspconfig";
|
description = "options to pass to lspconfig";
|
||||||
};
|
};
|
||||||
|
|
||||||
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // {
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
default = null;
|
||||||
description = "LSP package";
|
description = "LSP package";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
fmt = mkOption {
|
||||||
|
type = types.nullOr (
|
||||||
|
types.submodule (
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
description = "FMT package";
|
||||||
|
};
|
||||||
|
|
||||||
|
options = mkOption {
|
||||||
|
type = types.listOf types.nonEmptyStr;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
includes = mkOption {
|
||||||
|
type = types.listOf types.nonEmptyStr;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
command = mkOption {
|
||||||
|
type = types.nonEmptyStr;
|
||||||
|
default = getExe config.package;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
default = { };
|
default = { };
|
||||||
description = "Language servers available on the system";
|
description = "Language servers available on the system";
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
(writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"")
|
(writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"")
|
||||||
|
|
||||||
nixpkgs-review
|
nixpkgs-review
|
||||||
nixpkgs-fmt
|
|
||||||
nixfmt-rfc-style
|
nixfmt-rfc-style
|
||||||
nixd
|
nixd
|
||||||
nixpkgs-hammering
|
nixpkgs-hammering
|
||||||
|
@ -22,7 +21,15 @@
|
||||||
plugins = with pkgs.vimPlugins; [ vim-nix ];
|
plugins = with pkgs.vimPlugins; [ vim-nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
grimmShared.tooling.lang_servers = [ { package = pkgs.nixd; } ];
|
grimmShared.tooling.lang_servers = [
|
||||||
|
{
|
||||||
|
lsp.package = pkgs.nixd;
|
||||||
|
fmt = {
|
||||||
|
package = pkgs.nixpkgs-fmt;
|
||||||
|
includes = [ "*.nix" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
nix.settings = {
|
nix.settings = {
|
||||||
experimental-features = [
|
experimental-features = [
|
||||||
|
|
|
@ -18,7 +18,6 @@ in
|
||||||
config = mkIf (enable && tooling.enable) {
|
config = mkIf (enable && tooling.enable) {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
dos2unix
|
dos2unix
|
||||||
treefmt
|
|
||||||
neovim-remote
|
neovim-remote
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -19,22 +19,27 @@ in
|
||||||
config = lib.mkIf (enable && tooling.enable) {
|
config = lib.mkIf (enable && tooling.enable) {
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
(pkgs.python3.withPackages pyLibs)
|
(pkgs.python3.withPackages pyLibs)
|
||||||
pkgs.yapf
|
|
||||||
pkgs.pyright
|
|
||||||
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
|
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
|
||||||
|
|
||||||
programs.xonsh = {
|
programs.xonsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config = lib.concatLines (
|
config = lib.concatLines (
|
||||||
lib.mapAttrsToList (
|
lib.mapAttrsToList (
|
||||||
name: value: ''aliases["${name}"] = "${value}"''
|
name: value: "aliases[\"${name}\"] = '''${value}'''"
|
||||||
) config.environment.shellAliases
|
) config.environment.shellAliases
|
||||||
);
|
);
|
||||||
package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; };
|
package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; };
|
||||||
};
|
};
|
||||||
|
|
||||||
grimmShared.tooling.nvim.extraLuaRC = lib.singleton ''
|
grimmShared.tooling.lang_servers = [
|
||||||
require'lspconfig'.pyright.setup{}
|
{
|
||||||
'';
|
lsp.package = pkgs.pyright;
|
||||||
|
fmt = {
|
||||||
|
package = pkgs.yapf;
|
||||||
|
includes = [ "*.py" ];
|
||||||
|
options = [ "-i" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,18 @@ in
|
||||||
config = lib.mkIf (enable && tooling.enable) {
|
config = lib.mkIf (enable && tooling.enable) {
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
with pkgs;
|
with pkgs;
|
||||||
[
|
[ pkg-config ] ++ lib.optionals graphical [ jetbrains.clion ];
|
||||||
rustfmt
|
|
||||||
pkg-config
|
|
||||||
]
|
|
||||||
++ lib.optionals graphical [ jetbrains.clion ];
|
|
||||||
|
|
||||||
grimmShared.tooling.lang_servers = [
|
grimmShared.tooling.lang_servers = [
|
||||||
{
|
{
|
||||||
|
lsp = {
|
||||||
package = pkgs.rust-analyzer;
|
package = pkgs.rust-analyzer;
|
||||||
name = "rust_analyzer";
|
lspconf_mod_name = "rust_analyzer";
|
||||||
|
};
|
||||||
|
fmt = {
|
||||||
|
package = pkgs.rustfmt;
|
||||||
|
includes = [ "*.rs" ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue