Added derivation for the environment of ruboocop and solargraph (PAIN)

This commit is contained in:
Yoni FIRROLONI 2023-07-13 05:03:55 +02:00
commit c129696679
8 changed files with 766 additions and 158 deletions

View file

@ -12,12 +12,12 @@ in {
./tidal
./dart
./elixir
./ruby
./clang.nix
./go.nix
./nix.nix
./python.nix
./ruby.nix
./rust.nix
./sql.nix
./ts.nix

View file

@ -1,157 +0,0 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.languages.ruby;
defaultServer = "rubyserver";
servers = {
rubyserver = {
package = pkgs.rubyPackages_3_2.solargraph;
lspConfig = ''
lspconfig.rubyserver.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = { "${pkgs.bundler}/bin/bundle exec solargraph", "stdio" }
}
'';
};
};
# TODO: specify packages
defaultFormat = "rubocop";
formats = {
rubocop = {
package = pkgs.rubocop;
nullConfig = ''
local conditional = function(fn)
local utils = require("null-ls.utils").make_conditional_utils()
return fn(utils)
end
table.insert(
ls_sources,
null_ls.builtins.formatting.rubocop.with({
command = "${pkgs.bundler}/bin/bundle",
args = vim.list_extend(
{ "exec", "rubocop", "-a" },
null_ls.builtins.formatting.rubocop._opts.args
),
})
-- conditional(function(utils)
-- return utils.root_has_file("Gemfile")
-- and null_ls.builtins.formatting.rubocop.with({
-- command = "${pkgs.bundler}",
-- args = vim.list_extend(
-- { "exec", "rubocop" },
-- nls.builtins.formatting.rubocop._opts.args
-- ),
-- })
-- or null_ls.builtins.formatting.rubocop.with({
-- command = "${cfg.format.package}/bin/rubocop",
-- })
-- end)
)
'';
};
};
# TODO: specify packages
defaultDiagnostics = ["rubocop"];
diagnostics = {
rubocop = {
package = pkgs.rubyPackages_3_2.rubocop;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.rubocop.with({
command = "${lib.getExe pkg}",
})
)
'';
};
};
in {
options.vim.languages.ruby = {
enable = mkEnableOption "Ruby/Ruby on Rails language support";
treesitter = {
enable = mkEnableOption "Enable Ruby treesitter" // {default = config.vim.languages.enableTreesitter;};
rubyPackage = nvim.types.mkGrammarOption pkgs "ruby";
};
lsp = {
enable = mkEnableOption "Enable Ruby/Ruby on Rails LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Ruby/RoR LSP server to use";
type = with types; enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Ruby/RoR LSP server package";
type = types.package;
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "Enable Ruby/RoR formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Ruby/RoR formatter to use";
type = with types; enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Ruby/RoR formatter package";
type = types.package;
default = formats.${cfg.format.type}.package;
};
};
extraDiagnostics = {
enable = mkEnableOption "Enable extra Ruby/RoR diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics {
langDesc = "Ruby/RoR";
inherit diagnostics;
inherit defaultDiagnostics;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.rubyPackage];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.ruby-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ruby-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua {
lang = "ruby";
config = cfg.extraDiagnostics.types;
inherit diagnostics;
};
})
]);
}

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
source "https://rubygems.org"
gem "rubocop"
gem "rubocop-rails"
gem "rubocop-rspec"
gem "rubocop-minitest"
gem "rubocop-sequel"
gem "rubocop-rake"
gem "rubocop-graphql"
gem "rubocop-capybara"
gem "rubocop-factory_bot"
gem "solargraph"
gem "mini_portile2", "~> 2.8.2"
# gem "rails"

View file

@ -0,0 +1,114 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
backport (1.2.0)
benchmark (0.2.1)
concurrent-ruby (1.2.2)
diff-lcs (1.5.0)
e2mmap (0.1.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.6)
json (2.6.3)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
mini_portile2 (2.8.2)
minitest (5.18.1)
nokogiri (1.15.3-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
racc (1.7.1)
rack (3.0.8)
rainbow (3.1.1)
rbs (2.8.4)
regexp_parser (2.8.1)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
rubocop (1.54.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.23.1)
rubocop (~> 1.33)
rubocop-graphql (1.3.0)
rubocop (>= 0.87, < 2)
rubocop-minitest (0.31.0)
rubocop (>= 1.39, < 2.0)
rubocop-rails (2.20.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.22.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-sequel (0.3.4)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
solargraph (0.49.0)
backport (~> 1.2)
benchmark
bundler (~> 2.0)
diff-lcs (~> 1.4)
e2mmap
jaro_winkler (~> 1.5)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.1)
parser (~> 3.0)
rbs (~> 2.0)
reverse_markdown (~> 2.0)
rubocop (~> 1.38)
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
thor (1.2.2)
tilt (2.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
yard (0.9.34)
PLATFORMS
x86_64-linux
DEPENDENCIES
mini_portile2 (~> 2.8.2)
rubocop
rubocop-capybara
rubocop-factory_bot
rubocop-graphql
rubocop-minitest
rubocop-rails
rubocop-rake
rubocop-rspec
rubocop-sequel
solargraph
BUNDLED WITH
2.4.14

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./ruby.nix
];
}

View file

@ -0,0 +1,38 @@
{
pkgs,
stdenv,
}: let
formatter-env = with pkgs;
bundlerEnv {
name = "Gem dependencies";
inherit self;
ruby = ruby_3_2;
gemdir = ./.;
gemConfig =
pkgs.defaultGemConfig
// {
nokogiri = attrs: {
buildFlags = ["--use-system-libraries"]; # "--with-zlib-include=${pkgs.zlib}/include/libxml2"];
};
};
};
in
stdenv.mkDerivation {
name = "Format environment";
nativeBuildInputs = [
pkgs.libxslt
pkgs.zlib
pkgs.libxml2
pkgs.pkg-config
];
# Add the derivation to the PATH
buildInputs = [
pkgs.libxslt
pkgs.zlib
pkgs.libxml2
pkgs.pkg-config
formatter-env
];
}

View file

@ -0,0 +1,441 @@
{
activesupport = {
dependencies = ["concurrent-ruby" "i18n" "minitest" "tzinfo"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1cjsf26656996hv48wgv2mkwxf0fy1qc68ikgzq7mzfq2mmvmayk";
type = "gem";
};
version = "7.0.6";
};
ast = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "04nc8x27hlzlrr5c2gn7mar4vdr0apw5xg22wp6m8dx3wqr04a0y";
type = "gem";
};
version = "2.4.2";
};
backport = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0xbzzjrgah0f8ifgd449kak2vyf30micpz6x2g82aipfv7ypsb4i";
type = "gem";
};
version = "1.2.0";
};
benchmark = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "017jh2lx3z5hqjvnqclc5bfr5q0d3zk0nqjfz73909ybr4h20kmi";
type = "gem";
};
version = "0.2.1";
};
concurrent-ruby = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0krcwb6mn0iklajwngwsg850nk8k9b35dhmc2qkbdqvmifdi2y9q";
type = "gem";
};
version = "1.2.2";
};
diff-lcs = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0rwvjahnp7cpmracd8x732rjgnilqv2sx7d1gfrysslc3h039fa9";
type = "gem";
};
version = "1.5.0";
};
e2mmap = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0n8gxjb63dck3vrmsdcqqll7xs7f3wk78mw8w0gdk9wp5nx6pvj5";
type = "gem";
};
version = "0.1.0";
};
i18n = {
dependencies = ["concurrent-ruby"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0qaamqsh5f3szhcakkak8ikxlzxqnv49n2p7504hcz2l0f4nj0wx";
type = "gem";
};
version = "1.14.1";
};
jaro_winkler = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "10fd3i92897blalxfkgc0jjv0qqx31v7cm7j2b6a3b97an0bfz80";
type = "gem";
};
version = "1.5.6";
};
json = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0nalhin1gda4v8ybk6lq8f407cgfrj6qzn234yra4ipkmlbfmal6";
type = "gem";
};
version = "2.6.3";
};
kramdown = {
dependencies = ["rexml"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1ic14hdcqxn821dvzki99zhmcy130yhv5fqfffkcf87asv5mnbmn";
type = "gem";
};
version = "2.4.0";
};
kramdown-parser-gfm = {
dependencies = ["kramdown"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0a8pb3v951f4x7h968rqfsa19c8arz21zw1vaj42jza22rap8fgv";
type = "gem";
};
version = "1.1.0";
};
language_server-protocol = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0gvb1j8xsqxms9mww01rmdl78zkd72zgxaap56bhv8j45z05hp1x";
type = "gem";
};
version = "3.17.0.3";
};
mini_portile2 = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0z7f38iq37h376n9xbl4gajdrnwzq284c9v1py4imw3gri2d5cj6";
type = "gem";
};
version = "2.8.2";
};
minitest = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1kg9wh7jlc9zsr3hkhpzkbn0ynf4np5ap9m2d8xdrb8shy0y6pmb";
type = "gem";
};
version = "5.18.1";
};
nokogiri = {
dependencies = ["racc"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "sha256-h2YxKVqFMV2sN+enE4bWLZ60UqiRCDz+dQXMpIBQiMs=";
type = "gem";
};
version = "1.15.3";
};
parallel = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0jcc512l38c0c163ni3jgskvq1vc3mr8ly5pvjijzwvfml9lf597";
type = "gem";
};
version = "1.23.0";
};
parser = {
dependencies = ["ast" "racc"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1swigds85jddb5gshll1g8lkmbcgbcp9bi1d4nigwvxki8smys0h";
type = "gem";
};
version = "3.2.2.3";
};
racc = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "11v3l46mwnlzlc371wr3x6yylpgafgwdf0q7hc7c1lzx6r414r5g";
type = "gem";
};
version = "1.7.1";
};
rack = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0j3j8lxb3pda25lq9l3661rjd99a3z2ky6cqxbg7sdmvnwpr2b4w";
type = "gem";
};
version = "3.0.8";
};
rainbow = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0smwg4mii0fm38pyb5fddbmrdpifwv22zv3d3px2xx497am93503";
type = "gem";
};
version = "3.1.1";
};
rbs = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0dgj5n7rj83981fvrhswfwsh88x42p7r00nvd80hkxmdcjvda2h6";
type = "gem";
};
version = "2.8.4";
};
regexp_parser = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "136br91alxdwh1s85z912dwz23qlhm212vy6i3wkinz3z8mkxxl3";
type = "gem";
};
version = "2.8.1";
};
reverse_markdown = {
dependencies = ["nokogiri"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0087vhw5ik50lxvddicns01clkx800fk5v5qnrvi3b42nrk6885j";
type = "gem";
};
version = "2.1.1";
};
rexml = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "08ximcyfjy94pm1rhcx04ny1vx2sk0x4y185gzn86yfsbzwkng53";
type = "gem";
};
version = "3.2.5";
};
rubocop = {
dependencies = ["json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rexml" "rubocop-ast" "ruby-progressbar" "unicode-display_width"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1vklabd0510isqhikx4bfx5qn9g8pyj8h9jxryayp2wj8mx4kg74";
type = "gem";
};
version = "1.54.1";
};
rubocop-ast = {
dependencies = ["parser"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "188bs225kkhrb17dsf3likdahs2p1i1sqn0pr3pvlx50g6r2mnni";
type = "gem";
};
version = "1.29.0";
};
rubocop-capybara = {
dependencies = ["rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "01fn05a87g009ch1sh00abdmgjab87i995msap26vxq1a5smdck6";
type = "gem";
};
version = "2.18.0";
};
rubocop-factory_bot = {
dependencies = ["rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0kqchl8f67k2g56sq2h1sm2wb6br5gi47s877hlz94g5086f77n1";
type = "gem";
};
version = "2.23.1";
};
rubocop-graphql = {
dependencies = ["rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1afxc4ff1ykws8l7wkxqacx2hbm0wvz635vbcqkycwibfx6968vc";
type = "gem";
};
version = "1.3.0";
};
rubocop-minitest = {
dependencies = ["rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1gm31ny25cpw9mwbwfxbg3wxzqkcykxk4pwxwdwbvxsc2yjh3fw7";
type = "gem";
};
version = "0.31.0";
};
rubocop-rails = {
dependencies = ["activesupport" "rack" "rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "05r46ds0dm44fb4p67hbz721zck8mdwblzssz2y25yh075hvs36j";
type = "gem";
};
version = "2.20.2";
};
rubocop-rake = {
dependencies = ["rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1nyq07sfb3vf3ykc6j2d5yq824lzq1asb474yka36jxgi4hz5djn";
type = "gem";
};
version = "0.6.0";
};
rubocop-rspec = {
dependencies = ["rubocop" "rubocop-capybara" "rubocop-factory_bot"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "00rsflhijcr0q838fgbdmk7knm5kcjpimn6x0k9qmiw15hi96x1d";
type = "gem";
};
version = "2.22.0";
};
rubocop-sequel = {
dependencies = ["rubocop"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1jfdw5vfw77r19njzjn5j055jv7401rr7497flcx5p85sa90dydy";
type = "gem";
};
version = "0.3.4";
};
ruby-progressbar = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0cwvyb7j47m7wihpfaq7rc47zwwx9k4v7iqd9s1xch5nm53rrz40";
type = "gem";
};
version = "1.13.0";
};
solargraph = {
dependencies = ["backport" "benchmark" "diff-lcs" "e2mmap" "jaro_winkler" "kramdown" "kramdown-parser-gfm" "parser" "rbs" "reverse_markdown" "rubocop" "thor" "tilt" "yard"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "18wpma2mgw82qzf1jwjalmz7nwdvn87b22wd5yy16jb67fqgrq78";
type = "gem";
};
version = "0.49.0";
};
thor = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0k7j2wn14h1pl4smibasw0bp66kg626drxb59z7rzflch99cd4rg";
type = "gem";
};
version = "1.2.2";
};
tilt = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0bmjgbv8158klwp2r3klxjwaj93nh1sbl4xvj9wsha0ic478avz7";
type = "gem";
};
version = "2.2.0";
};
tzinfo = {
dependencies = ["concurrent-ruby"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "16w2g84dzaf3z13gxyzlzbf748kylk5bdgg3n1ipvkvvqy685bwd";
type = "gem";
};
version = "2.0.6";
};
unicode-display_width = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1gi82k102q7bkmfi7ggn9ciypn897ylln1jk9q67kjhr39fj043a";
type = "gem";
};
version = "2.4.2";
};
yard = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "013yrnwx1zhzhn1fnc19zck22a1qgimsaglp2iwgf5bz9l8h93js";
type = "gem";
};
version = "0.9.34";
};
}

View file

@ -0,0 +1,152 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
format-env = pkgs.callPackage ./format_derivation.nix {inherit pkgs;};
cfg = config.vim.languages.ruby;
defaultServer = "rubyserver";
servers = {
rubyserver = {
package = pkgs.rubyPackages_3_2.solargraph;
lspConfig = ''
lspconfig.solargraph.setup {
on_attach = attach_keymaps,
cmd = { "${cfg.lsp.package}/bin/solargraph", "stdio" }
}
'';
};
};
# TODO: specify packages
defaultFormat = "rubocop";
formats = {
rubocop = {
package = format-env;
nullConfig = ''
lspconfig.rubocop.setup {
on_attach = attach_keymaps,
cmd = { "${cfg.format.package}/bin/rubocop", "--lsp", "--require", "${cfg.format.package}/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.20.2/lib/rubocop-rails.rb" }
}
-- local conditional = function(fn)
-- local utils = require("null-ls.utils").make_conditional_utils()
-- return fn(utils)
-- end
--
-- table.insert(
-- ls_sources,
-- conditional(function(utils)
-- return utils.root_has_file("Gemfile")
-- and null_ls.builtins.formatting.rubocop.with({
-- command = ",
-- args = vim.list_extend(
-- { "exec", "rubocop" },
-- nls.builtins.formatting.rubocop._opts.args
-- ),
-- })
-- or null_ls.builtins.formatting.rubocop.with({
-- command = "${cfg.format.package}/bin/rubocop",
-- })
-- end)
-- )
'';
};
};
# TODO: specify packages
# defaultDiagnostics = ["rubocop"];
# diagnostics = {
# rubocop = {
# package = pkgs.rubyPackages_3_2.rubocop;
# nullConfig = pkg: ''
# table.insert(
# ls_sources,
# null_ls.builtins.diagnostics.rubocop.with({
# command = "${lib.getExe pkg}",
# })
# )
# '';
# };
# };
in {
options.vim.languages.ruby = {
enable = mkEnableOption "Ruby/Ruby on Rails language support";
treesitter = {
enable = mkEnableOption "Enable Ruby treesitter" // {default = config.vim.languages.enableTreesitter;};
rubyPackage = nvim.types.mkGrammarOption pkgs "ruby";
};
lsp = {
enable = mkEnableOption "Enable Ruby/Ruby on Rails LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Ruby/RoR LSP server to use";
type = with types; enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Ruby/RoR LSP server package";
type = types.package;
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "Enable Ruby/RoR formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Ruby/RoR formatter to use";
type = with types; enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Ruby/RoR formatter package";
type = types.package;
default = formats.${cfg.format.type}.package;
};
};
# extraDiagnostics = {
# enable = mkEnableOption "Enable extra Ruby/RoR diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
# types = lib.nvim.types.diagnostics {
# langDesc = "Ruby/RoR";
# inherit diagnostics;
# inherit defaultDiagnostics;
# };
# };
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.rubyPackage];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.ruby-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ruby-format = formats.${cfg.format.type}.nullConfig;
})
# (mkIf cfg.extraDiagnostics.enable {
# vim.lsp.null-ls.enable = true;
# vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua {
# lang = "ruby";
# config = cfg.extraDiagnostics.types;
# inherit diagnostics;
# };
# })
]);
}