diff --git a/flake.lock b/flake.lock index 91fc506..a67a79a 100644 --- a/flake.lock +++ b/flake.lock @@ -396,6 +396,22 @@ "type": "github" } }, + "plugin-conform-nvim": { + "flake": false, + "locked": { + "lastModified": 1726168403, + "narHash": "sha256-AWgG+16Bh/xu50pU78mKIcQy9MKzWF1YKdbEt5jX0WQ=", + "owner": "stevearc", + "repo": "conform.nvim", + "rev": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c", + "type": "github" + }, + "original": { + "owner": "stevearc", + "repo": "conform.nvim", + "type": "github" + } + }, "plugin-copilot-cmp": { "flake": false, "locked": { @@ -1133,6 +1149,22 @@ "type": "github" } }, + "plugin-nvim-lint": { + "flake": false, + "locked": { + "lastModified": 1727002360, + "narHash": "sha256-mg3IqNfIeWimasYEHilqv4Yx67hTHBubq19nLTNrjLk=", + "owner": "mfussenegger", + "repo": "nvim-lint", + "rev": "968a35d54b3a4c1ce66609cf80b14d4ae44fe77f", + "type": "github" + }, + "original": { + "owner": "mfussenegger", + "repo": "nvim-lint", + "type": "github" + } + }, "plugin-nvim-lspconfig": { "flake": false, "locked": { @@ -1800,6 +1832,7 @@ "plugin-cmp-vsnip": "plugin-cmp-vsnip", "plugin-codewindow-nvim": "plugin-codewindow-nvim", "plugin-comment-nvim": "plugin-comment-nvim", + "plugin-conform-nvim": "plugin-conform-nvim", "plugin-copilot-cmp": "plugin-copilot-cmp", "plugin-copilot-lua": "plugin-copilot-lua", "plugin-crates-nvim": "plugin-crates-nvim", @@ -1846,6 +1879,7 @@ "plugin-nvim-dap-ui": "plugin-nvim-dap-ui", "plugin-nvim-docs-view": "plugin-nvim-docs-view", "plugin-nvim-lightbulb": "plugin-nvim-lightbulb", + "plugin-nvim-lint": "plugin-nvim-lint", "plugin-nvim-lspconfig": "plugin-nvim-lspconfig", "plugin-nvim-navbuddy": "plugin-nvim-navbuddy", "plugin-nvim-navic": "plugin-nvim-navic", diff --git a/flake.nix b/flake.nix index c4996fc..a506cec 100644 --- a/flake.nix +++ b/flake.nix @@ -187,6 +187,18 @@ flake = false; }; + # Formatters + plugin-conform-nvim = { + url = "github:stevearc/conform.nvim"; + flake = false; + }; + + # Diagnostics + plugin-nvim-lint = { + url = "github:mfussenegger/nvim-lint"; + flake = false; + }; + # Copying/Registers plugin-registers = { url = "github:tversteeg/registers.nvim"; diff --git a/modules/modules.nix b/modules/modules.nix index 1204e43..e736aa6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -24,6 +24,7 @@ "dashboard" "debugger" "filetree" + "formatter" "git" "languages" "lsp" diff --git a/modules/plugins/diagnostics/default.nix b/modules/plugins/diagnostics/default.nix new file mode 100644 index 0000000..3789640 --- /dev/null +++ b/modules/plugins/diagnostics/default.nix @@ -0,0 +1,3 @@ +{ + imports = [./nvim-lint]; +} diff --git a/modules/plugins/diagnostics/nvim-lint/config.nix b/modules/plugins/diagnostics/nvim-lint/config.nix new file mode 100644 index 0000000..dac2c2f --- /dev/null +++ b/modules/plugins/diagnostics/nvim-lint/config.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.diagnostics.nvim-lint; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["nvim-lint"]; + pluginRC.nvim-lint = entryAnywhere '' + require("lint").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/diagnostics/nvim-lint/default.nix b/modules/plugins/diagnostics/nvim-lint/default.nix new file mode 100644 index 0000000..00c526f --- /dev/null +++ b/modules/plugins/diagnostics/nvim-lint/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./nvim-lint.nix + ./config.nix + ]; +} diff --git a/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix b/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix new file mode 100644 index 0000000..45674a5 --- /dev/null +++ b/modules/plugins/diagnostics/nvim-lint/nvim-lint.nix @@ -0,0 +1,36 @@ +{ + pkgs, + lib, + ... +}: let + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) attrs attrsOf listOf str; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.diagnostics.nvim-lint = { + enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]"; + setupOpts = mkPluginSetupOption "conform.nvim" { + linters_by_ft = mkOption { + type = attrsOf (listOf str); + default = {}; + example = { + text = ["vale"]; + markdown = ["vale"]; + }; + description = '' + Map of filetype to formatters. This option takes a set of + `key = value` format where the `value will` be converted + to its Lua equivalent. You are responsible for passing the + correct Nix data types to generate a correct Lua value that + conform is able to accept. + ''; + }; + + default_format_opts = mkOption { + type = attrs; + default = {lsp_format = "fallback";}; + description = "Default values when calling `conform.format()`"; + }; + }; + }; +} diff --git a/modules/plugins/formatter/conform-nvim/config.nix b/modules/plugins/formatter/conform-nvim/config.nix new file mode 100644 index 0000000..0b83d81 --- /dev/null +++ b/modules/plugins/formatter/conform-nvim/config.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.formatter.conform-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["conform-nvim"]; + pluginRC.conform-nvim = entryAnywhere '' + require("conform").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/formatter/conform-nvim/conform-nvim.nix b/modules/plugins/formatter/conform-nvim/conform-nvim.nix new file mode 100644 index 0000000..a4e0d31 --- /dev/null +++ b/modules/plugins/formatter/conform-nvim/conform-nvim.nix @@ -0,0 +1,33 @@ +{ + pkgs, + lib, + ... +}: let + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) attrs; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.formatter.conform-nvim = { + enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]"; + setupOpts = mkPluginSetupOption "conform.nvim" { + formatters_by_ft = mkOption { + type = attrs; + default = {}; + example = literalExpression "lua = [\"${pkgs.stylua}/bin/stylua\"]"; + description = '' + Map of filetype to formatters. This option takes a set of + `key = value` format where the `value will` be converted + to its Lua equivalent. You are responsible for passing the + correct Nix data types to generate a correct Lua value that + conform is able to accept. + ''; + }; + + default_format_opts = mkOption { + type = attrs; + default = {lsp_format = "fallback";}; + description = "Default values when calling `conform.format()`"; + }; + }; + }; +} diff --git a/modules/plugins/formatter/conform-nvim/default.nix b/modules/plugins/formatter/conform-nvim/default.nix new file mode 100644 index 0000000..56c90f3 --- /dev/null +++ b/modules/plugins/formatter/conform-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./conform-nvim.nix + ./config.nix + ]; +} diff --git a/modules/plugins/formatter/default.nix b/modules/plugins/formatter/default.nix new file mode 100644 index 0000000..f57ad66 --- /dev/null +++ b/modules/plugins/formatter/default.nix @@ -0,0 +1,3 @@ +{ + imports = [./conform-nvim]; +}