mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 13:20:44 +00:00
Compare commits
2 commits
76783408b2
...
8889f71247
Author | SHA1 | Date | |
---|---|---|---|
8889f71247 | |||
|
516174e296 |
2 changed files with 54 additions and 1 deletions
|
@ -297,6 +297,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, with styler and formatR as options
|
||||||
- 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
|
||||||
|
|
|
@ -15,7 +15,38 @@
|
||||||
cfg = config.vim.languages.r;
|
cfg = config.vim.languages.r;
|
||||||
|
|
||||||
r-with-languageserver = pkgs.rWrapper.override {
|
r-with-languageserver = pkgs.rWrapper.override {
|
||||||
packages = with pkgs.rPackages; [languageserver];
|
packages = [pkgs.rPackages.languageserver];
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultFormat = "format_r";
|
||||||
|
formats = {
|
||||||
|
styler = {
|
||||||
|
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",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
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",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultServer = "r_language_server";
|
defaultServer = "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 {
|
||||||
|
type = enum (attrNames formats);
|
||||||
|
default = defaultFormat;
|
||||||
|
description = "R formatter to use";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = package;
|
||||||
|
default = formats.${cfg.format.type}.package;
|
||||||
|
description = "R formatter 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;
|
||||||
|
|
Loading…
Reference in a new issue