Compare commits

...

7 commits

Author SHA1 Message Date
Soliprem
90adf65125
Merge 4eeadf3c96 into 4b9047025f 2025-01-13 22:06:48 +01:00
raf
4b9047025f
Merge pull request #556 from tomasguinzburg/feat-languages-ruby
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-html) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-json) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-manpages) (push) Waiting to run
Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Check for typos in the source tree / check-typos (push) Waiting to run
languages/ruby: add ruby support
2025-01-13 22:17:30 +03:00
tomasguinzburg
149d68b3e8 languages/ruby: add ruby support 2025-01-13 16:55:38 +01:00
raf
dc5fc8c6a4
Merge pull request #553 from kaktu5/main
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-html) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-json) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-manpages) (push) Waiting to run
Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Check for typos in the source tree / check-typos (push) Waiting to run
languages/wgsl: init module
2025-01-13 12:57:36 +03:00
raf
2e3c479e84
Merge branch 'main' into main 2025-01-12 23:32:11 +03:00
kaktu5
bbca939ced languages/wgsl: init module
Adds Treesitter and LSP support for WebGPU Shading Language
2025-01-12 21:12:33 +01:00
Soliprem
4eeadf3c96 R: added R-nvim 2024-12-21 04:14:08 +01:00
7 changed files with 298 additions and 9 deletions

View file

@ -80,6 +80,7 @@ isMaximal: {
ocaml.enable = false;
elixir.enable = false;
haskell.enable = false;
ruby.enable = false;
tailwind.enable = false;
svelte.enable = false;

View file

@ -53,3 +53,13 @@
issue with setting the workspace directory.
- Add `vim.snippets.luasnip.setupOpts`, which was previously missing.
- Add `"prettierd"` as a formatter option in `vim.languages.markdown.format.type`.
[kaktu5](https://github.com/kaktu5):
- Add WGSL support under `vim.languages.wgsl`.
[tomasguinzburg](https://github.com/tomasguinzburg):
[solargraph]: https://github.com/castwide/solargraph
- Add Ruby support under `vim.languages.ruby` using [solargraph].

View file

@ -735,6 +735,11 @@
flake = false;
};
plugin-R-nvim = {
url = "github:R-nvim/R.nvim";
flake = false;
};
plugin-haskell-tools-nvim = {
url = "github:mrcjkb/haskell-tools.nvim";
flake = false;

View file

@ -38,6 +38,8 @@ in {
./julia.nix
./nu.nix
./odin.nix
./wgsl.nix
./ruby.nix
];
options.vim.languages = {

View file

@ -6,11 +6,13 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.types) enum either listOf package str nullOr attrsOf;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.r;
@ -74,7 +76,12 @@ in {
treesitter = {
enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "r";
rPackage = mkGrammarOption pkgs "r";
rnowebPackage = mkGrammarOption pkgs "rnoweb";
mdPackage = mkGrammarOption pkgs "markdown";
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
yamlPackage = mkGrammarOption pkgs "yaml";
csvPackage = mkGrammarOption pkgs "csv";
};
lsp = {
@ -109,14 +116,28 @@ in {
description = "R formatter package";
};
};
extensions = {
R-nvim = {
enable =
mkEnableOption ''
[R.nvim]: https://github.com/R-Nvim/R.nvim
R.nvim adds R support to Neovim, including:
- Communication with R via Neovim's built-in terminal or tmux
- A built-in object explorer and autocompletions built from your R environment
- Keyboard shortcuts for common inserts like <- and |>
- Quarto/R Markdown support
''
// {default = true;};
setupOpts = mkPluginSetupOption "R-nvim" {};
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
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;
@ -126,5 +147,24 @@ in {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [
cfg.treesitter.rPackage
cfg.treesitter.rnowebPackage
cfg.treesitter.mdPackage
cfg.treesitter.mdInlinePackage
cfg.treesitter.yamlPackage
cfg.treesitter.csvPackage
];
})
(mkIf cfg.extensions.R-nvim.enable {
vim.startPlugins = ["R-nvim"];
vim.pluginRC.R-nvim= entryAnywhere ''
require("r").setup(${toLuaObject cfg.extensions.R-nvim.setupOpts})
'';
})
]);
}

View file

@ -0,0 +1,152 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.ruby;
defaultServer = "rubyserver";
servers = {
rubyserver = {
package = pkgs.rubyPackages.solargraph;
lspConfig = ''
lspconfig.solargraph.setup {
capabilities = capabilities,
on_attach = attach_keymaps,
flags = {
debounce_text_changes = 150,
},
cmd = { "${pkgs.solargraph}/bin/solargraph", "stdio" }
}
'';
};
};
# testing
defaultFormat = "rubocop";
formats = {
rubocop = {
package = pkgs.rubyPackages.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
),
})
)
'';
};
};
defaultDiagnosticsProvider = ["rubocop"];
diagnosticsProviders = {
rubocop = {
package = pkgs.rubyPackages.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 language support";
treesitter = {
enable = mkEnableOption "Ruby treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "ruby";
};
lsp = {
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
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 = {
enable = mkEnableOption "Ruby formatter support" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Ruby formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "Ruby formatter package";
};
};
extraDiagnostics = {
enable =
mkEnableOption "Ruby extra diagnostics support"
// {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Ruby";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(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 = diagnosticsToLua {
lang = "ruby";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
};
})
]);
}

View file

@ -0,0 +1,79 @@
{
config,
lib,
pkgs,
...
}: let
inherit (builtins) attrNames;
inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.options) literalExpression mkEnableOption mkOption;
inherit (lib.types) either enum listOf package str;
cfg = config.vim.languages.wgsl;
defaultServer = "wgsl-analyzer";
servers = {
wgsl-analyzer = {
package = pkgs.wgsl-analyzer;
internalFormatter = true;
lspConfig = ''
lspconfig.wgsl_analyzer.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/wgsl_analyzer'}"
}
}
'';
};
};
in {
options.vim.languages.wgsl = {
enable = mkEnableOption "WGSL language support";
treesitter = {
enable = mkEnableOption "WGSL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "wgsl";
};
lsp = {
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "WGSL LSP server to use";
};
package = mkOption {
description = "wgsl-analyzer package, or the command to run as a list of strings";
example = literalExpression "[(lib.getExe pkgs.wgsl-analyzer)]";
type = either package (listOf str);
default = pkgs.wgsl-analyzer;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter = {
enable = true;
grammars = [cfg.treesitter.package];
};
})
(mkIf cfg.lsp.enable {
vim = {
lsp.lspconfig = {
enable = true;
sources.wgsl_analyzer = servers.${cfg.lsp.server}.lspConfig;
};
};
})
]);
}