From 98a79590474c3a6bdf41b6cfb9af161cf48823c3 Mon Sep 17 00:00:00 2001 From: LilleAila Date: Sat, 11 Jan 2025 14:02:21 +0100 Subject: [PATCH 1/9] snippets/luasnip: add setupOpts Also fixed a bug where the plugin previously would not get loaded, as lazy was set to true without a trigger event. --- modules/plugins/snippets/luasnip/config.nix | 12 ++++++------ modules/plugins/snippets/luasnip/luasnip.nix | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/plugins/snippets/luasnip/config.nix b/modules/plugins/snippets/luasnip/config.nix index 927b21fd..60a5ca6d 100644 --- a/modules/plugins/snippets/luasnip/config.nix +++ b/modules/plugins/snippets/luasnip/config.nix @@ -9,12 +9,12 @@ in { config = mkIf cfg.enable { vim = { - lazy.plugins = { - luasnip = { - package = "luasnip"; - lazy = true; - after = cfg.loaders; - }; + lazy.plugins.luasnip = { + package = "luasnip"; + event = "BufEnter"; + after = cfg.loaders; + setupModule = "luasnip"; + inherit (cfg) setupOpts; }; startPlugins = cfg.providers; autocomplete.nvim-cmp = { diff --git a/modules/plugins/snippets/luasnip/luasnip.nix b/modules/plugins/snippets/luasnip/luasnip.nix index d9563a5b..edfd72b9 100644 --- a/modules/plugins/snippets/luasnip/luasnip.nix +++ b/modules/plugins/snippets/luasnip/luasnip.nix @@ -1,7 +1,7 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; inherit (lib.types) listOf lines; - inherit (lib.nvim.types) pluginType; + inherit (lib.nvim.types) pluginType mkPluginSetupOption; in { options.vim.snippets.luasnip = { enable = mkEnableOption "luasnip"; @@ -32,5 +32,7 @@ in { ``` ''; }; + + setupOpts = mkPluginSetupOption "LuaSnip" {}; }; } From 69cb99dc2bf6f57af48fdea98a6c653f214d4d67 Mon Sep 17 00:00:00 2001 From: LilleAila Date: Sat, 11 Jan 2025 14:04:40 +0100 Subject: [PATCH 2/9] snippets/luasnip: add example option to setupOpts --- modules/plugins/snippets/luasnip/luasnip.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/plugins/snippets/luasnip/luasnip.nix b/modules/plugins/snippets/luasnip/luasnip.nix index edfd72b9..6b189b61 100644 --- a/modules/plugins/snippets/luasnip/luasnip.nix +++ b/modules/plugins/snippets/luasnip/luasnip.nix @@ -33,6 +33,8 @@ in { ''; }; - setupOpts = mkPluginSetupOption "LuaSnip" {}; + setupOpts = mkPluginSetupOption "LuaSnip" { + enable_autosnippets = mkEnableOption "autosnippets"; + }; }; } From 7012938e21ec105813ba857cf4ae8e0a632ae472 Mon Sep 17 00:00:00 2001 From: LilleAila Date: Sat, 11 Jan 2025 14:06:14 +0100 Subject: [PATCH 3/9] snippets/luasnip: add changelog entry --- docs/release-notes/rl-0.8.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index c65defeb..f79eb940 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -51,3 +51,5 @@ - Remove `vim.notes.obsidian.setupOpts.dir`, which was set by default. Fixes issue with setting the workspace directory. +- Add `vim.snippets.luasnip.setupOpts`, which was previously missing. +- Add a trigger event for luasnip lazy-loading From 9818d199378ff70c7bf77d0988e9da05fc27f1a4 Mon Sep 17 00:00:00 2001 From: LilleAila Date: Sun, 12 Jan 2025 09:58:55 +0100 Subject: [PATCH 4/9] snippets/luasnip: revert adding lazy event --- docs/release-notes/rl-0.8.md | 1 - modules/plugins/snippets/luasnip/config.nix | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index f79eb940..3c07aa09 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -52,4 +52,3 @@ - Remove `vim.notes.obsidian.setupOpts.dir`, which was set by default. Fixes issue with setting the workspace directory. - Add `vim.snippets.luasnip.setupOpts`, which was previously missing. -- Add a trigger event for luasnip lazy-loading diff --git a/modules/plugins/snippets/luasnip/config.nix b/modules/plugins/snippets/luasnip/config.nix index 60a5ca6d..0f887e5f 100644 --- a/modules/plugins/snippets/luasnip/config.nix +++ b/modules/plugins/snippets/luasnip/config.nix @@ -11,7 +11,7 @@ in { vim = { lazy.plugins.luasnip = { package = "luasnip"; - event = "BufEnter"; + lazy = true; after = cfg.loaders; setupModule = "luasnip"; inherit (cfg) setupOpts; From c59f8922b298d471b561a49573f739dd9529b1f6 Mon Sep 17 00:00:00 2001 From: LilleAila <67327023+LilleAila@users.noreply.github.com> Date: Sun, 12 Jan 2025 11:39:41 +0100 Subject: [PATCH 5/9] snippets/luasnip: add whitespace, organize options Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> --- modules/plugins/snippets/luasnip/config.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/plugins/snippets/luasnip/config.nix b/modules/plugins/snippets/luasnip/config.nix index 0f887e5f..a3767aa7 100644 --- a/modules/plugins/snippets/luasnip/config.nix +++ b/modules/plugins/snippets/luasnip/config.nix @@ -11,10 +11,13 @@ in { vim = { lazy.plugins.luasnip = { package = "luasnip"; + lazy = true; - after = cfg.loaders; + setupModule = "luasnip"; inherit (cfg) setupOpts; + + after = cfg.loaders; }; startPlugins = cfg.providers; autocomplete.nvim-cmp = { From fedbee3a30e9b0043b77bb1c705dd83c0860dbc6 Mon Sep 17 00:00:00 2001 From: LilleAila Date: Sun, 12 Jan 2025 12:48:44 +0100 Subject: [PATCH 6/9] snippets/luasnip: fix formatting --- modules/plugins/snippets/luasnip/config.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/plugins/snippets/luasnip/config.nix b/modules/plugins/snippets/luasnip/config.nix index a3767aa7..b05f9f27 100644 --- a/modules/plugins/snippets/luasnip/config.nix +++ b/modules/plugins/snippets/luasnip/config.nix @@ -11,12 +11,12 @@ in { vim = { lazy.plugins.luasnip = { package = "luasnip"; - + lazy = true; - + setupModule = "luasnip"; inherit (cfg) setupOpts; - + after = cfg.loaders; }; startPlugins = cfg.providers; From bbca939cedd09b423820e20d387fc42e85589a5d Mon Sep 17 00:00:00 2001 From: kaktu5 <108426150+kaktu5@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:57:18 +0100 Subject: [PATCH 7/9] languages/wgsl: init module Adds Treesitter and LSP support for WebGPU Shading Language --- docs/release-notes/rl-0.8.md | 4 ++ modules/plugins/languages/default.nix | 1 + modules/plugins/languages/wgsl.nix | 79 +++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 modules/plugins/languages/wgsl.nix diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 62e83a0e..93f6c1da 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -52,3 +52,7 @@ - Remove `vim.notes.obsidian.setupOpts.dir`, which was set by default. Fixes issue with setting the workspace directory. - Add `"prettierd"` as a formatter option in `vim.languages.markdown.format.type`. + +[kaktu5](https://github.com/kaktu5): + +- Add WGSL support under `vim.languages.wgsl`. diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index ee9f55e1..bf9194f2 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -38,6 +38,7 @@ in { ./julia.nix ./nu.nix ./odin.nix + ./wgsl.nix ]; options.vim.languages = { diff --git a/modules/plugins/languages/wgsl.nix b/modules/plugins/languages/wgsl.nix new file mode 100644 index 00000000..7c8a1016 --- /dev/null +++ b/modules/plugins/languages/wgsl.nix @@ -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; + }; + }; + }) + ]); +} From 149d68b3e815e101d113a497bee5c96452391cdb Mon Sep 17 00:00:00 2001 From: tomasguinzburg Date: Sun, 12 Jan 2025 23:33:26 +0100 Subject: [PATCH 8/9] languages/ruby: add ruby support --- configuration.nix | 1 + docs/release-notes/rl-0.8.md | 6 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/ruby.nix | 152 ++++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 modules/plugins/languages/ruby.nix diff --git a/configuration.nix b/configuration.nix index 15f85480..2159edc8 100644 --- a/configuration.nix +++ b/configuration.nix @@ -80,6 +80,7 @@ isMaximal: { ocaml.enable = false; elixir.enable = false; haskell.enable = false; + ruby.enable = false; tailwind.enable = false; svelte.enable = false; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index cfa70cd5..d15c6842 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -57,3 +57,9 @@ [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]. diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index bf9194f2..219e04fb 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -39,6 +39,7 @@ in { ./nu.nix ./odin.nix ./wgsl.nix + ./ruby.nix ]; options.vim.languages = { diff --git a/modules/plugins/languages/ruby.nix b/modules/plugins/languages/ruby.nix new file mode 100644 index 00000000..33f11d5d --- /dev/null +++ b/modules/plugins/languages/ruby.nix @@ -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; + }; + }) + ]); +} From 9142a5b9dd7dacf54825d2fcd730604457535ebc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 14 Jan 2025 16:01:56 +0300 Subject: [PATCH 9/9] docs: update contribution guidelines Update URL for nixpkgs flavoured markdown, add mkOption argument ordering --- docs/manual/hacking/guidelines.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/manual/hacking/guidelines.md b/docs/manual/hacking/guidelines.md index 882deea8..a1db27e8 100644 --- a/docs/manual/hacking/guidelines.md +++ b/docs/manual/hacking/guidelines.md @@ -14,14 +14,11 @@ necessarily) before you start developing. ## Adding Documentation {#sec-guidelines-documentation} -Most, if not all, changes warrant changes to the documentation. Module options -should be documented with -[Nixpkgs-flavoured Markdown](https://nixos.org/manual/nixpkgs/unstable/#sec-contributing-markup), -albeit with exceptions. +[Nixpkgs Flavoured Markdown]: https://github.com/NixOS/nixpkgs/blob/master/doc/README.md#syntax -::: {.note} As of **v0.5**, **nvf** is itself documented using full markdown in -both module options and the manual. With **v0.6**, this manual has also been -converted to markdown in full. ::: +Almost all changes warrant updates to the documentation: at the very least, you +must update the changelog. Both the manual and module options use +[Nixpkgs Flavoured Markdown]. The HTML version of this manual containing both the module option descriptions and the documentation of **nvf** (such as this page) can be generated and opened @@ -117,10 +114,11 @@ applies to string literals and module descriptions and documentation. ### Nix {#sec-code-style-nix} -**nvf** is formatted by the -[alejandra](https://github.com/kamadorueda/alejandra) tool and the formatting is -checked in the pull request and push workflows. Run the `nix fmt` command inside -the project repository before submitting your pull request. +[alejandra]: https://github.com/kamadorueda/alejandra + +**nvf** is formatted by the [alejandra] tool and the formatting is checked in +the pull request and push workflows. Run the `nix fmt` command inside the +project repository before submitting your pull request. While Alejandra is mostly opinionated on how code looks after formatting, certain changes are done at the user's discretion based on how the original code @@ -138,10 +136,14 @@ module = { # same as parent modules, unfold submodules subModule = { # this is an option that contains more than one nested value + # Note: try to be careful about the ordering of `mkOption` arguments. + # General rule of thumb is to order from least to most likely to change. + # This is, for most cases, type < default < description. + # Example, if present, would be between default and description someOtherValue = mkOption { type = lib.types.bool; - description = "Some other description"; default = true; + description = "Some other description"; }; }; }