diff --git a/configuration.nix b/configuration.nix index af62a944..a2a337fd 100644 --- a/configuration.nix +++ b/configuration.nix @@ -192,6 +192,7 @@ isMaximal: { vim-wakatime.enable = false; diffview-nvim.enable = true; yanky-nvim.enable = false; + qmk-nvim.enable = false; # requires hardware specific options icon-picker.enable = isMaximal; surround.enable = isMaximal; leetcode-nvim.enable = isMaximal; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 8032d719..61a13533 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -482,12 +482,11 @@ [jsonfmt]: https://github.com/caarlos0/jsonfmt [superhtml]: https://github.com/kristoff-it/superhtml [htmlHTML]: https://github.com/htmlhint/HTMLHint +[qmk-nvim]: https://github.com/codethread/qmk.nvim - Add just support under `vim.languages.just` using [just-lsp]. - - Add [roslyn-ls] to the `vim.languages.csharp` module. - -- Added json support under `vim.languages.json` using [jsonls] and [jsonfmt]. - -- Added advanced HTML support with [superhtml] for lsp and formatting and - [htmlHINT] for diagnostics. +- Add JSON support under `vim.languages.json` using [jsonls] and [jsonfmt]. +- Add advanced HTML support under `vim.languages.html` using [superhtml] and + [htmlHINT]. +- Add QMK support under `vim.utility.qmk-nvim` via [qmk-nvim]. diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index 8069b6c1..b49ef0b6 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -18,6 +18,7 @@ ./oil-nvim ./outline ./preview + ./qmk-nvim ./sleuth ./smart-splits ./snacks-nvim diff --git a/modules/plugins/utility/qmk-nvim/config.nix b/modules/plugins/utility/qmk-nvim/config.nix new file mode 100644 index 00000000..c86a483a --- /dev/null +++ b/modules/plugins/utility/qmk-nvim/config.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAfter; + + cfg = config.vim.utility.qmk-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["qmk-nvim"]; + + pluginRC.qmk-nvim = entryAfter ["nvim-notify"] '' + require('qmk').setup(${toLuaObject cfg.setupOpts}) + ''; + }; + + assertions = [ + { + assertion = cfg.setupOpts.variant == "qmk" && cfg.setupOpts.comment_preview.position != "inside"; + message = "comment_preview.position can only be set to inside when using the qmk layoyt"; + } + { + assertion = cfg.setupOpts.name != null; + message = "qmk-nvim requires 'vim.utility.qmk.setupOpts.name' to be set."; + } + { + assertion = cfg.setupOpts.layout != null; + message = "qmk-nvim requires 'vim.utility.qmk.setupOpts.layout' to be set."; + } + ]; + }; +} diff --git a/modules/plugins/utility/qmk-nvim/default.nix b/modules/plugins/utility/qmk-nvim/default.nix new file mode 100644 index 00000000..4162ff2e --- /dev/null +++ b/modules/plugins/utility/qmk-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./qmk-nvim.nix + ]; +} diff --git a/modules/plugins/utility/qmk-nvim/qmk-nvim.nix b/modules/plugins/utility/qmk-nvim/qmk-nvim.nix new file mode 100644 index 00000000..2c541e64 --- /dev/null +++ b/modules/plugins/utility/qmk-nvim/qmk-nvim.nix @@ -0,0 +1,49 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) attrsOf nullOr enum lines str; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.utility.qmk-nvim = { + enable = mkEnableOption "QMK and ZMK keymaps in nvim"; + + setupOpts = mkPluginSetupOption "qmk.nvim" { + name = mkOption { + type = nullOr str; + default = null; + description = "The name of the layout"; + }; + + layout = mkOption { + type = nullOr lines; + default = null; + description = '' + The keyboard key layout + see for more details + ''; + }; + + variant = mkOption { + type = enum ["qmk" "zmk"]; + default = "qmk"; + description = "Chooses the expected hardware target"; + }; + + comment_preview = { + position = mkOption { + type = enum ["top" "bottom" "inside" "none"]; + default = "top"; + description = "Controls the position of the preview"; + }; + + keymap_overrides = mkOption { + type = attrsOf str; + default = {}; + description = '' + Key codes to text replacements + see for more details + ''; + }; + }; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index eec2fde9..0ec503ac 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -2186,6 +2186,19 @@ "url": "https://github.com/kevinhwang91/promise-async/archive/119e8961014c9bfaf1487bf3c2a393d254f337e2.tar.gz", "hash": "0q4a0rmy09hka6zvydzjj2gcm2j5mlbrhbxfcdjj33ngpblkmqzm" }, + "qmk-nvim": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "codethread", + "repo": "qmk.nvim" + }, + "branch": "main", + "submodules": false, + "revision": "3c804c1480991e4837514900b22b9358cfd64fa1", + "url": "https://github.com/codethread/qmk.nvim/archive/3c804c1480991e4837514900b22b9358cfd64fa1.tar.gz", + "hash": "03fsx6qsn8b36jp5m0fkdla6gkkzdv2j18y378y3cqpjclgq995a" + }, "rainbow-delimiters-nvim": { "type": "Git", "repository": {