language/r: migrate to conform/nvim-lint

This commit is contained in:
Ching Pei Yang 2025-03-28 11:09:20 +01:00
parent a5deffb890
commit 7cf9e5c0a6
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -24,28 +24,29 @@
package = pkgs.rWrapper.override {
packages = [pkgs.rPackages.styler];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.styler.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
config = {
command = "${cfg.format.package}/bin/R";
};
};
format_r = {
package = pkgs.rWrapper.override {
packages = [pkgs.rPackages.formatR];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.format_r.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
config = {
command = "${cfg.format.package}/bin/R";
stdin = true;
args = [
"--slave"
"--no-restore"
"--no-save"
"-s"
"-e"
''formatR::tidy_source(source="stdin")''
];
# TODO: range_args seem to be possible
# https://github.com/nvimtools/none-ls.nvim/blob/main/lua/null-ls/builtins/formatting/format_r.lua
};
};
};
@ -118,8 +119,11 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.r-format = formats.${cfg.format.type}.nullConfig;
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.r = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
};
})
(mkIf cfg.lsp.enable {