mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 13:20:44 +00:00
languages/ocaml: add formatting support
This commit is contained in:
parent
db810bbf9f
commit
cc0aba4e21
1 changed files with 21 additions and 0 deletions
|
@ -30,6 +30,15 @@ in {
|
|||
default = pkgs.ocamlPackages.ocaml-lsp;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;};
|
||||
package = mkOption {
|
||||
description = "OCaml formatter package";
|
||||
type = package;
|
||||
default = pkgs.ocamlPackages.ocamlformat;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
|
@ -52,5 +61,17 @@ in {
|
|||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.ocamlformat = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.ocamlformat.with({
|
||||
command = "${cfg.format.package}/bin/ocamlformat",
|
||||
})
|
||||
)
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue