mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
convert ruby module
This commit is contained in:
parent
11bb5982c5
commit
d0e8de0951
1 changed files with 39 additions and 44 deletions
|
@ -9,44 +9,41 @@
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.types) listOf package enum;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
inherit (lib.types) either listOf package str enum;
|
|
||||||
|
|
||||||
cfg = config.vim.languages.ruby;
|
cfg = config.vim.languages.ruby;
|
||||||
|
|
||||||
defaultServer = "rubyserver";
|
defaultServers = ["solargraph"];
|
||||||
servers = {
|
servers = {
|
||||||
rubyserver = {
|
ruby_lsp = {
|
||||||
package = pkgs.rubyPackages.solargraph;
|
enable = true;
|
||||||
lspConfig = ''
|
cmd = [(getExe pkgs.ruby-lsp)];
|
||||||
lspconfig.solargraph.setup {
|
filetypes = ["ruby" "eruby"];
|
||||||
capabilities = capabilities,
|
root_markers = ["Gemfile" ".git"];
|
||||||
on_attach = attach_keymaps,
|
init_options = {
|
||||||
flags = {
|
formatter = "auto";
|
||||||
debounce_text_changes = 150,
|
};
|
||||||
},
|
|
||||||
cmd = ${
|
|
||||||
if isList cfg.lsp.package
|
|
||||||
then expToLua cfg.lsp.package
|
|
||||||
else ''{ "${cfg.lsp.package}/bin/solargraph", "stdio" }''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
rubylsp = {
|
|
||||||
package = pkgs.ruby-lsp;
|
solargraph = {
|
||||||
lspConfig = ''
|
enable = true;
|
||||||
lspconfig.ruby_lsp.setup {
|
cmd = [(getExe pkgs.rubyPackages.solargraph) "stdio"];
|
||||||
capabilities = capabilities,
|
filetypes = ["ruby"];
|
||||||
on_attach = default_on_attach,
|
root_markers = ["Gemfile" ".git"];
|
||||||
cmd = ${
|
settings = {
|
||||||
if isList cfg.lsp.package
|
solargraph = {
|
||||||
then expToLua cfg.lsp.package
|
diagnostics = true;
|
||||||
else ''{ "${cfg.lsp.package}/bin/ruby-lsp" }''
|
};
|
||||||
}
|
};
|
||||||
}
|
|
||||||
'';
|
flags = {
|
||||||
|
debounce_text_changes = 150;
|
||||||
|
};
|
||||||
|
|
||||||
|
init_options = {
|
||||||
|
formatting = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,17 +76,11 @@ in {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.lsp.enable;};
|
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.lsp.enable;};
|
||||||
|
|
||||||
server = mkOption {
|
servers = mkOption {
|
||||||
type = enum (attrNames servers);
|
type = listOf (enum (attrNames servers)); default = defaultServers;
|
||||||
default = defaultServer;
|
default = defaultServers;
|
||||||
description = "Ruby LSP server to use";
|
description = "Ruby LSP server to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = either package (listOf str);
|
|
||||||
default = servers.${cfg.lsp.server}.package;
|
|
||||||
description = "Ruby LSP server package, or the command to run as a list of strings";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
|
@ -128,8 +119,12 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.servers =
|
||||||
vim.lsp.lspconfig.sources.ruby-lsp = servers.${cfg.lsp.server}.lspConfig;
|
mapListToAttrs (n: {
|
||||||
|
name = n;
|
||||||
|
value = servers.${n};
|
||||||
|
})
|
||||||
|
cfg.lsp.servers;
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue