tried about 238472893764 ways to import rubocop and solargraph

Have a look if you want, I give up
This commit is contained in:
Yoni FIRROLONI 2023-07-13 17:03:34 +02:00
commit 5364dc4ba2
6 changed files with 122 additions and 263 deletions

View file

@ -10,6 +10,5 @@ gem "rubocop-rake"
gem "rubocop-graphql" gem "rubocop-graphql"
gem "rubocop-capybara" gem "rubocop-capybara"
gem "rubocop-factory_bot" gem "rubocop-factory_bot"
gem "solargraph" gem "rubocop-performance"
gem "mini_portile2", "~> 2.8.2"
# gem "rails" # gem "rails"

View file

@ -7,24 +7,12 @@ GEM
minitest (>= 5.1) minitest (>= 5.1)
tzinfo (~> 2.0) tzinfo (~> 2.0)
ast (2.4.2) ast (2.4.2)
backport (1.2.0)
benchmark (0.2.1)
concurrent-ruby (1.2.2) concurrent-ruby (1.2.2)
diff-lcs (1.5.0)
e2mmap (0.1.0)
i18n (1.14.1) i18n (1.14.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jaro_winkler (1.5.6)
json (2.6.3) 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) language_server-protocol (3.17.0.3)
mini_portile2 (2.8.2)
minitest (5.18.1) minitest (5.18.1)
nokogiri (1.15.3-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0) parallel (1.23.0)
parser (3.2.2.3) parser (3.2.2.3)
ast (~> 2.4.1) ast (~> 2.4.1)
@ -32,12 +20,9 @@ GEM
racc (1.7.1) racc (1.7.1)
rack (3.0.8) rack (3.0.8)
rainbow (3.1.1) rainbow (3.1.1)
rbs (2.8.4)
regexp_parser (2.8.1) regexp_parser (2.8.1)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5) rexml (3.2.5)
rubocop (1.54.1) rubocop (1.54.2)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
@ -58,6 +43,9 @@ GEM
rubocop (>= 0.87, < 2) rubocop (>= 0.87, < 2)
rubocop-minitest (0.31.0) rubocop-minitest (0.31.0)
rubocop (>= 1.39, < 2.0) rubocop (>= 1.39, < 2.0)
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.20.2) rubocop-rails (2.20.2)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
@ -71,44 +59,24 @@ GEM
rubocop-sequel (0.3.4) rubocop-sequel (0.3.4)
rubocop (~> 1.0) rubocop (~> 1.0)
ruby-progressbar (1.13.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) tzinfo (2.0.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2) unicode-display_width (2.4.2)
yard (0.9.34)
PLATFORMS PLATFORMS
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
mini_portile2 (~> 2.8.2)
rubocop rubocop
rubocop-capybara rubocop-capybara
rubocop-factory_bot rubocop-factory_bot
rubocop-graphql rubocop-graphql
rubocop-minitest rubocop-minitest
rubocop-performance
rubocop-rails rubocop-rails
rubocop-rake rubocop-rake
rubocop-rspec rubocop-rspec
rubocop-sequel rubocop-sequel
solargraph
BUNDLED WITH BUNDLED WITH
2.4.14 2.4.14

View file

@ -0,0 +1,41 @@
{
pkgs,
stdenv,
}: let
#formatter-env = with pkgs;
# bundlerEnv {
# name = "Gem dependencies";
# # inherit ruby_3_2;
# 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
# pkgs.rubocop
# pkgs.solargraph
# ];
# Add the derivation to the PATH
buildInputs = [
pkgs.libxslt
pkgs.libxml2
pkgs.rubocop
pkgs.solargraph
# formatter-env
];
}

View file

@ -1,38 +0,0 @@
{
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

@ -20,26 +20,6 @@
}; };
version = "2.4.2"; 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 = { concurrent-ruby = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -50,26 +30,6 @@
}; };
version = "1.2.2"; 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 = { i18n = {
dependencies = ["concurrent-ruby"]; dependencies = ["concurrent-ruby"];
groups = ["default"]; groups = ["default"];
@ -81,16 +41,6 @@
}; };
version = "1.14.1"; version = "1.14.1";
}; };
jaro_winkler = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "10fd3i92897blalxfkgc0jjv0qqx31v7cm7j2b6a3b97an0bfz80";
type = "gem";
};
version = "1.5.6";
};
json = { json = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -101,28 +51,6 @@
}; };
version = "2.6.3"; 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 = { language_server-protocol = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -133,16 +61,6 @@
}; };
version = "3.17.0.3"; version = "3.17.0.3";
}; };
mini_portile2 = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0z7f38iq37h376n9xbl4gajdrnwzq284c9v1py4imw3gri2d5cj6";
type = "gem";
};
version = "2.8.2";
};
minitest = { minitest = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -153,17 +71,6 @@
}; };
version = "5.18.1"; 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 = { parallel = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -215,16 +122,6 @@
}; };
version = "3.1.1"; version = "3.1.1";
}; };
rbs = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0dgj5n7rj83981fvrhswfwsh88x42p7r00nvd80hkxmdcjvda2h6";
type = "gem";
};
version = "2.8.4";
};
regexp_parser = { regexp_parser = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -235,17 +132,6 @@
}; };
version = "2.8.1"; 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 = { rexml = {
groups = ["default"]; groups = ["default"];
platforms = []; platforms = [];
@ -262,10 +148,10 @@
platforms = []; platforms = [];
source = { source = {
remotes = ["https://rubygems.org"]; remotes = ["https://rubygems.org"];
sha256 = "1vklabd0510isqhikx4bfx5qn9g8pyj8h9jxryayp2wj8mx4kg74"; sha256 = "1hc469ahgpfwbvv2q3hqlhp7dlzcii8dlm8k6k324sq26lilv27r";
type = "gem"; type = "gem";
}; };
version = "1.54.1"; version = "1.54.2";
}; };
rubocop-ast = { rubocop-ast = {
dependencies = ["parser"]; dependencies = ["parser"];
@ -322,6 +208,17 @@
}; };
version = "0.31.0"; version = "0.31.0";
}; };
rubocop-performance = {
dependencies = ["rubocop" "rubocop-ast"];
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0bp02784v0qm8qcswi169s0ar6216rwk516v3idzpbxznpqp97ac";
type = "gem";
};
version = "1.18.0";
};
rubocop-rails = { rubocop-rails = {
dependencies = ["activesupport" "rack" "rubocop"]; dependencies = ["activesupport" "rack" "rubocop"];
groups = ["default"]; groups = ["default"];
@ -376,37 +273,6 @@
}; };
version = "1.13.0"; 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 = { tzinfo = {
dependencies = ["concurrent-ruby"]; dependencies = ["concurrent-ruby"];
groups = ["default"]; groups = ["default"];
@ -428,14 +294,4 @@
}; };
version = "2.4.2"; version = "2.4.2";
}; };
yard = {
groups = ["default"];
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "013yrnwx1zhzhn1fnc19zck22a1qgimsaglp2iwgf5bz9l8h93js";
type = "gem";
};
version = "0.9.34";
};
} }

View file

@ -6,19 +6,52 @@
}: }:
with lib; with lib;
with builtins; let with builtins; let
format-env = pkgs.callPackage ./format_derivation.nix {inherit pkgs;}; formatter-env = with pkgs;
bundlerEnv {
name = "Gem dependencies";
inherit ruby_3_2;
ruby = ruby_3_2;
gemdir = ./.;
#gemConfig =
# pkgs.defaultGemConfig
# // {
# nokogiri = attrs: {
# buildFlags = ["--use-system-libraries"]; # "--with-zlib-include=${pkgs.zlib}/include/libxml2"];
#};
# };
};
#format-env = pkgs.callPackage ./format-derivation.nix {inherit pkgs;};
cfg = config.vim.languages.ruby; cfg = config.vim.languages.ruby;
defaultServer = "rubyserver"; defaultServer = "rubyserver";
servers = { servers = {
rubyserver = { rubyserver = {
package = pkgs.rubyPackages_3_2.solargraph; package = pkgs.rubyPackages_3_2.solargraph.overrideAttrs (
fa: oa: {
buildInputs = oa.buildInputs ++ [formatter-env];
}
);
lspConfig = '' lspConfig = ''
lspconfig.solargraph.setup { lspconfig.solargraph.setup {
capabilities = capabilities,
on_attach = attach_keymaps, on_attach = attach_keymaps,
cmd = { "${cfg.lsp.package}/bin/solargraph", "stdio" } --cmd = { "${pkgs.ruby_3_2}/bin/bundle exec solargraph", "stdio" }
cmd = { "${cfg.lsp.package}/bin/solargraph", "stdio" },
settings = {
solargraph = {
diagnostics = true,
autoformat = true,
-- bundlerPath = "${pkgs.ruby_3_2}/bin/bundler",
completion = true,
formatting = true,
logLevel = "debug",
references = true,
useBundler = false
} }
}
}
''; '';
}; };
}; };
@ -27,11 +60,15 @@ with builtins; let
defaultFormat = "rubocop"; defaultFormat = "rubocop";
formats = { formats = {
rubocop = { rubocop = {
package = format-env; package = pkgs.rubyPackages_3_2.rubocop.overrideAttrs (
fa: oa: {
buildInputs = oa.buildInputs ++ [formatter-env];
}
);
nullConfig = '' nullConfig = ''
lspconfig.rubocop.setup { lspconfig.rubocop.setup {
on_attach = attach_keymaps, 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" } cmd = { "${cfg.format.package}/bin/rubocop", "--require", "${formatter-env}/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.20.2/lib/rubocop-rails.rb"} --, nls.builtins.formatting.rubocop._opts.args }
} }
-- local conditional = function(fn) -- local conditional = function(fn)
-- local utils = require("null-ls.utils").make_conditional_utils() -- local utils = require("null-ls.utils").make_conditional_utils()
@ -40,15 +77,11 @@ with builtins; let
-- --
-- table.insert( -- table.insert(
-- ls_sources, -- ls_sources,
-- conditional(function(utils) -- null_ls.builtins.formatting.rubocop.with({
-- return utils.root_has_file("Gemfile") -- command = "${cfg.format.package}/bin/rubocop",
-- and null_ls.builtins.formatting.rubocop.with({ -- args = { "--require", "${formatter-env}/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.20.2/lib/rubocop-rails.rb"}
-- command = ",
-- args = vim.list_extend(
-- { "exec", "rubocop" },
-- nls.builtins.formatting.rubocop._opts.args
-- ),
-- }) -- })
-- )
-- or null_ls.builtins.formatting.rubocop.with({ -- or null_ls.builtins.formatting.rubocop.with({
-- command = "${cfg.format.package}/bin/rubocop", -- command = "${cfg.format.package}/bin/rubocop",
-- }) -- })