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
|
||||
getName
|
||||
mkEnableOption
|
||||
getExe
|
||||
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
|
||||
{
|
||||
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 =
|
||||
[ "vim.g.coq_settings = { auto_start = 'shut-up' }" ]
|
||||
++ (map (
|
||||
v: "require'lspconfig'.${v.name}.setup(require('coq').lsp_ensure_capabilities(${v.config}))"
|
||||
) (filter (v: v.vimIntegration) tooling.lang_servers));
|
||||
v:
|
||||
"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; [
|
||||
nvim-lspconfig
|
||||
|
@ -34,33 +62,73 @@ in
|
|||
|
||||
options.grimmShared.tooling.lang_servers = mkOption {
|
||||
type = types.listOf (
|
||||
types.submodule (
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.nullOr types.nonEmptyStr;
|
||||
default = getName config.package;
|
||||
description = "lspconfig module name";
|
||||
};
|
||||
types.submodule {
|
||||
options = {
|
||||
lsp = mkOption {
|
||||
type = types.nullOr (
|
||||
types.submodule (
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
lspconf_mod_name = mkOption {
|
||||
type = types.nullOr types.nonEmptyStr;
|
||||
default = getName config.package;
|
||||
description = "lspconfig module name";
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
default = "{}";
|
||||
description = "options to pass to lspconfig";
|
||||
};
|
||||
lspconf_config = mkOption {
|
||||
type = types.nonEmptyStr;
|
||||
default = "{}";
|
||||
description = "options to pass to lspconfig";
|
||||
};
|
||||
|
||||
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // {
|
||||
default = true;
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = null;
|
||||
description = "LSP package";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.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 = { };
|
||||
description = "Language servers available on the system";
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
(writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"")
|
||||
|
||||
nixpkgs-review
|
||||
nixpkgs-fmt
|
||||
nixfmt-rfc-style
|
||||
nixd
|
||||
nixpkgs-hammering
|
||||
|
@ -22,7 +21,15 @@
|
|||
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 = {
|
||||
experimental-features = [
|
||||
|
|
|
@ -18,7 +18,6 @@ in
|
|||
config = mkIf (enable && tooling.enable) {
|
||||
environment.systemPackages = with pkgs; [
|
||||
dos2unix
|
||||
treefmt
|
||||
neovim-remote
|
||||
];
|
||||
|
||||
|
|
|
@ -19,22 +19,27 @@ in
|
|||
config = lib.mkIf (enable && tooling.enable) {
|
||||
environment.systemPackages = [
|
||||
(pkgs.python3.withPackages pyLibs)
|
||||
pkgs.yapf
|
||||
pkgs.pyright
|
||||
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
|
||||
|
||||
programs.xonsh = {
|
||||
enable = true;
|
||||
config = lib.concatLines (
|
||||
lib.mapAttrsToList (
|
||||
name: value: ''aliases["${name}"] = "${value}"''
|
||||
name: value: "aliases[\"${name}\"] = '''${value}'''"
|
||||
) config.environment.shellAliases
|
||||
);
|
||||
package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; };
|
||||
};
|
||||
|
||||
grimmShared.tooling.nvim.extraLuaRC = lib.singleton ''
|
||||
require'lspconfig'.pyright.setup{}
|
||||
'';
|
||||
grimmShared.tooling.lang_servers = [
|
||||
{
|
||||
lsp.package = pkgs.pyright;
|
||||
fmt = {
|
||||
package = pkgs.yapf;
|
||||
includes = [ "*.py" ];
|
||||
options = [ "-i" ];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,16 +11,18 @@ in
|
|||
config = lib.mkIf (enable && tooling.enable) {
|
||||
environment.systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
rustfmt
|
||||
pkg-config
|
||||
]
|
||||
++ lib.optionals graphical [ jetbrains.clion ];
|
||||
[ pkg-config ] ++ lib.optionals graphical [ jetbrains.clion ];
|
||||
|
||||
grimmShared.tooling.lang_servers = [
|
||||
{
|
||||
package = pkgs.rust-analyzer;
|
||||
name = "rust_analyzer";
|
||||
lsp = {
|
||||
package = pkgs.rust-analyzer;
|
||||
lspconf_mod_name = "rust_analyzer";
|
||||
};
|
||||
fmt = {
|
||||
package = pkgs.rustfmt;
|
||||
includes = [ "*.rs" ];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue