mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
languages/r: attempting to create a toggle for wrappers
This commit is contained in:
parent
152acfce5a
commit
fbd15f5f3a
1 changed files with 25 additions and 28 deletions
|
@ -20,24 +20,14 @@
|
||||||
|
|
||||||
defaultFormat = "format_r";
|
defaultFormat = "format_r";
|
||||||
formats = {
|
formats = {
|
||||||
prettier = {
|
|
||||||
package = pkgs.nodePackages.prettier;
|
|
||||||
nullConfig = ''
|
|
||||||
local prettier = null_ls.builtins.formatting.prettier.with({
|
|
||||||
filetypes = { "r" },
|
|
||||||
extra_args = {
|
|
||||||
"--plugin", "prettier-plugin-r",
|
|
||||||
"--parser", "r"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
table.insert(ls_sources, prettier)
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
styler = {
|
styler = {
|
||||||
package = pkgs.rWrapper.override {
|
package =
|
||||||
packages = with pkgs.rPackages; [styler];
|
if cfg.useWrappedPackages
|
||||||
};
|
then
|
||||||
|
(pkgs.rWrapper.override {
|
||||||
|
packages = with pkgs.rPackages; [styler];
|
||||||
|
})
|
||||||
|
else pkgs.rPackages.styler;
|
||||||
nullConfig = ''
|
nullConfig = ''
|
||||||
table.insert(
|
table.insert(
|
||||||
ls_sources,
|
ls_sources,
|
||||||
|
@ -49,9 +39,13 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
format_r = {
|
format_r = {
|
||||||
package = pkgs.rWrapper.override {
|
package =
|
||||||
packages = with pkgs.rPackages; [formatR];
|
if cfg.useWrappedPackages
|
||||||
};
|
then
|
||||||
|
(pkgs.rWrapper.override {
|
||||||
|
packages = with pkgs.rPackages; [formatR];
|
||||||
|
})
|
||||||
|
else pkgs.rPackages.formatR;
|
||||||
nullConfig = ''
|
nullConfig = ''
|
||||||
table.insert(
|
table.insert(
|
||||||
ls_sources,
|
ls_sources,
|
||||||
|
@ -66,9 +60,16 @@
|
||||||
defaultServer = "r_language_server";
|
defaultServer = "r_language_server";
|
||||||
servers = {
|
servers = {
|
||||||
r_language_server = {
|
r_language_server = {
|
||||||
package = pkgs.writeShellScriptBin "r_lsp" ''
|
package =
|
||||||
${r-with-languageserver}/bin/R --slave -e "languageserver::run()"
|
if cfg.useWrappedPackages
|
||||||
'';
|
then
|
||||||
|
(pkgs.writeShellScriptBin "r_lsp" ''
|
||||||
|
${r-with-languageserver}/bin/R --slave -e "languageserver::run()"
|
||||||
|
'')
|
||||||
|
else
|
||||||
|
pkgs.writeShellScriptBin "r_lsp" ''
|
||||||
|
R --slave -e "languageserver::run()"
|
||||||
|
'';
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
lspconfig.r_language_server.setup{
|
lspconfig.r_language_server.setup{
|
||||||
capabilities = capabilities;
|
capabilities = capabilities;
|
||||||
|
@ -85,6 +86,7 @@
|
||||||
in {
|
in {
|
||||||
options.vim.languages.r = {
|
options.vim.languages.r = {
|
||||||
enable = mkEnableOption "R language support";
|
enable = mkEnableOption "R language support";
|
||||||
|
useWrappedPackages = mkEnableOption "use rWrapper for packages to work without R in user's PATH" // {default = true;};
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;};
|
enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
@ -93,16 +95,13 @@ in {
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
|
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "R LSP server to use";
|
description = "R LSP server to use";
|
||||||
type = enum (attrNames servers);
|
type = enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "R LSP server package, or the command to run as a list of strings";
|
description = "R LSP server package, or the command to run as a list of strings";
|
||||||
example = literalExpression "[ (lib.getExe pkgs.jdt-language-server) \"-data\" \"~/.cache/jdtls/workspace\" ]";
|
|
||||||
type = either package (listOf str);
|
type = either package (listOf str);
|
||||||
default = servers.${cfg.lsp.server}.package;
|
default = servers.${cfg.lsp.server}.package;
|
||||||
};
|
};
|
||||||
|
@ -110,13 +109,11 @@ in {
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkEnableOption "R formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "R formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "R formatter to use";
|
description = "R formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = enum (attrNames formats);
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "R formatter package";
|
description = "R formatter package";
|
||||||
type = package;
|
type = package;
|
||||||
|
|
Loading…
Reference in a new issue