Compare commits

...

5 commits

Author SHA1 Message Date
Soliprem
2e1134806a
Merge b321c01047 into 57067e85ed 2024-11-08 10:16:32 +00:00
Soliprem
b321c01047 languages/r: removing toggle for wrappers 2024-11-05 17:21:37 +01:00
Soliprem
fbd15f5f3a languages/r: attempting to create a toggle for wrappers 2024-11-05 17:20:31 +01:00
Soliprem
152acfce5a changelog: added entry for r formatter 2024-11-04 08:52:26 +01:00
Soliprem
1d90aaec55 r: added formatters 2024-11-04 08:50:56 +01:00
2 changed files with 53 additions and 0 deletions

View file

@ -294,6 +294,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
[Soliprem](https://github.com/Soliprem): [Soliprem](https://github.com/Soliprem):
- Add LSP and Treesitter support for R under `vim.languages.R`. - Add LSP and Treesitter support for R under `vim.languages.R`.
- Add formatter suppoort for R
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
ccc ccc
- Fixed typo in Otter's setupOpts - Fixed typo in Otter's setupOpts

View file

@ -18,6 +18,37 @@
packages = with pkgs.rPackages; [languageserver]; packages = with pkgs.rPackages; [languageserver];
}; };
defaultFormat = "format_r";
formats = {
styler = {
package = pkgs.rWrapper.override {
packages = with pkgs.rPackages; [styler];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.styler.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
};
format_r = {
package = pkgs.rWrapper.override {
packages = with pkgs.rPackages; [formatR];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.format_r.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
};
};
defaultServer = "r_language_server"; defaultServer = "r_language_server";
servers = { servers = {
r_language_server = { r_language_server = {
@ -62,6 +93,22 @@ in {
default = servers.${cfg.lsp.server}.package; default = servers.${cfg.lsp.server}.package;
}; };
}; };
format = {
enable = mkEnableOption "R formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "R formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "R formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
@ -70,6 +117,11 @@ in {
vim.treesitter.grammars = [cfg.treesitter.package]; vim.treesitter.grammars = [cfg.treesitter.package];
}) })
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.r-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true; vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig; vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig;