53 lines
1.2 KiB
Nix
53 lines
1.2 KiB
Nix
|
{ config, lib, ... }:
|
||
|
|
||
|
let cfg = config.plugins.style.neoformat; in
|
||
|
{
|
||
|
options.plugins.style.neoformat = with lib; {
|
||
|
enable = mkEnableOption "neoformat";
|
||
|
|
||
|
package = mkPackageOption pkgs.vimPlugins "neoformat" { };
|
||
|
|
||
|
settings = mkOption {
|
||
|
type = types.attrs;
|
||
|
default = { };
|
||
|
description = ''
|
||
|
See: https://github.com/sbdchd/neoformat?tab=readme-ov-file#config-optional
|
||
|
'';
|
||
|
example = {
|
||
|
neoformat_enabled_markdown = [ "denofmt" ];
|
||
|
neoformat_rust_rustfmt = {
|
||
|
exe = "rustfmt";
|
||
|
args = [ "--edition 2021" ];
|
||
|
stdin = 1;
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
autoformat.enable = mkEnableOption "Autoformat on save file";
|
||
|
};
|
||
|
|
||
|
config = lib.mkIf cfg.enable {
|
||
|
plugin.neoformat = {
|
||
|
# we shouldn't import this plugin
|
||
|
isDependency = true;
|
||
|
package = cfg.package;
|
||
|
};
|
||
|
|
||
|
vim.g = {
|
||
|
neoformat_try_node_exe = 1;
|
||
|
neoformat_only_msg_on_error = 1;
|
||
|
} // cfg.settings;
|
||
|
|
||
|
vim.namedCmd = lib.mkIf cfg.autoformat.enable {
|
||
|
autoformat = ''
|
||
|
aug fmt
|
||
|
au!
|
||
|
au BufWritePre * try | undojoin | Neoformat | catch /E790/ | Neoformat | endtry
|
||
|
aug END
|
||
|
'';
|
||
|
|
||
|
};
|
||
|
};
|
||
|
|
||
|
}
|