diff --git a/.github/typos.toml b/.github/typos.toml index 13748137..25d5c0e1 100644 --- a/.github/typos.toml +++ b/.github/typos.toml @@ -9,5 +9,6 @@ default.extend-ignore-words-re = [ "edn", "esy", "BA", # somehow "BANanaD3V" is valid, but BA is not... + "Emac" ] diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index ed9d2d81..dca9319a 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -170,7 +170,7 @@ The changes are, in no particular order: - Add [ocaml-lsp] support -- Fix "Emac" typo +- Fix misspelled "Emacs" - Add [new-file-template.nvim] to automatically fill new file contents using templates diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 8cdf081a..6b072507 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -569,8 +569,7 @@ [typst-concealer]: https://github.com/PartyWumpus/typst-concealer - Add inline typst concealing support under `vim.languages.typst` using - [typst-concealer]. -[simon-wg](https://github.com/simon-wg): + [typst-concealer]. [simon-wg](https://github.com/simon-wg): - Update `python` language module to use correct lsp binary. - Fix `python` pyright and basedpyright language servers not using default on diff --git a/lib/lua.nix b/lib/lua.nix index 4106a4c2..bf879031 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -1,92 +1,52 @@ # Helpers for converting values to lua {lib}: let - inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON; - inherit (lib.attrsets) mapAttrsToList filterAttrs; - inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters; - inherit (lib.trivial) boolToString warn; -in rec { - # Convert a null value to lua's nil - nullString = value: - if value == null - then "nil" - else "'${value}'"; - - # convert an expression to lua - expToLua = exp: - if isList exp - then listToLuaTable exp # if list, convert to lua table - else if isAttrs exp - then attrsetToLuaTable exp # if attrs, convert to table - else if isBool exp - then boolToString exp # if bool, convert to string - else if isInt exp - then toString exp # if int, convert to string - else if exp == null - then "nil" - else (toJSON exp); # otherwise jsonify the value and print as is - - # convert list to a lua table - listToLuaTable = list: - "{ " + (concatStringsSep ", " (map expToLua list)) + " }"; - - # convert attrset to a lua table - attrsetToLuaTable = attrset: - "{ " - + ( - concatStringsSep ", " - ( - mapAttrsToList ( - name: value: - name - + " = " - + (expToLua value) - ) - attrset - ) - ) - + " }"; - # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first - luaTable = items: ''{${concatStringsSep "," items}}''; - isLuaInline = object: (object._type or null) == "lua-inline"; toLuaObject = args: - if isAttrs args - then - if isLuaInline args - then args.expr - else if hasAttr "__empty" args - then - warn '' - Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead. - '' "{ }" - else - "{" - + (concatStringsSep "," - (mapAttrsToList - (n: v: - if head (stringToCharacters n) == "@" - then toLuaObject v - else "[${toLuaObject n}] = " + (toLuaObject v)) - (filterAttrs - (_: v: v != null) - args))) - + "}" - else if isList args - then "{" + concatMapStringsSep "," toLuaObject args + "}" - else if isString args - then - # This should be enough! - toJSON args - else if isPath args - then toJSON (toString args) - else if isBool args - then "${boolToString args}" - else if isFloat args - then "${toString args}" - else if isInt args - then "${toString args}" - else if (args == null) - then "nil" - else throw "could not convert object of type `${typeOf args}` to lua object"; -} + { + int = toString args; + float = toString args; + + # escapes \ and quotes + string = builtins.toJSON args; + path = builtins.toJSON args; + + bool = lib.boolToString args; + null = "nil"; + + list = "{${lib.concatMapStringsSep ",\n" toLuaObject args}}"; + + set = + if lib.isDerivation args + then ''"${args}"'' + else if isLuaInline args + then args.expr + else "{${ + lib.pipe args [ + (lib.filterAttrs (_: v: v != null)) + (builtins.mapAttrs ( + n: v: + if lib.hasPrefix "@" n + then toLuaObject v + else "[${toLuaObject n}] = ${toLuaObject v}" + )) + builtins.attrValues + (lib.concatStringsSep ",\n") + ] + }}"; + } + .${ + builtins.typeOf args + } + or (builtins.throw "Could not convert object of type `${builtins.typeOf args}` to lua object"); +in + { + inherit isLuaInline toLuaObject; + luaTable = x: (toLuaObject (map lib.mkLuaInline x)); + } + // lib.genAttrs [ + "nullString" + "expToLua" + "listToLuaTable" + "attrsetToLuaTable" + ] (name: lib.warn "${name} is deprecated use toLuaObject instead" toLuaObject) diff --git a/modules/neovim/init/spellcheck.nix b/modules/neovim/init/spellcheck.nix index 5c593a65..9f635bf5 100644 --- a/modules/neovim/init/spellcheck.nix +++ b/modules/neovim/init/spellcheck.nix @@ -9,7 +9,7 @@ inherit (lib.strings) concatLines concatStringsSep optionalString; inherit (lib.attrsets) mapAttrsToList; inherit (lib.types) listOf str attrsOf; - inherit (lib.nvim.lua) listToLuaTable; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryAfter; cfg = config.vim.spellcheck; @@ -152,7 +152,7 @@ in { vim.api.nvim_create_augroup("nvf_autocmds", {clear = false}) vim.api.nvim_create_autocmd({ "FileType" }, { group = "nvf_autocmds", - pattern = ${listToLuaTable cfg.ignoredFiletypes}, + pattern = ${toLuaObject cfg.ignoredFiletypes}, callback = function() vim.opt_local.spell = false end, diff --git a/modules/plugins/assistant/copilot/copilot.nix b/modules/plugins/assistant/copilot/copilot.nix index b19a7d6b..24c4286b 100644 --- a/modules/plugins/assistant/copilot/copilot.nix +++ b/modules/plugins/assistant/copilot/copilot.nix @@ -93,7 +93,7 @@ in { accept = mkOption { type = nullOr str; default = ""; - description = "Accept suggetion"; + description = "Accept suggestion"; }; acceptWord = mkOption { diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index 2b26640a..ac18fe55 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -11,11 +11,10 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.dag) entryAfter; - inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.meta) getExe'; inherit (lib.generators) mkLuaInline; inherit (pkgs) haskellPackages; - inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.languages.haskell; @@ -120,7 +119,7 @@ in { dap = { cmd = ${ if isList cfg.dap.package - then expToLua cfg.dap.package + then toLuaObject cfg.dap.package else ''{"${cfg.dap.package}/bin/haskell-debug-adapter"}'' }, }, diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index 3a0a2a9e..17a82a40 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -13,7 +13,7 @@ inherit (lib.lists) isList; inherit (lib.types) bool package str listOf either enum; inherit (lib.nvim.types) mkGrammarOption; - inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryAfter entryAnywhere; cfg = config.vim.languages.rust; @@ -153,7 +153,7 @@ in { server = { cmd = ${ if isList cfg.lsp.package - then expToLua cfg.lsp.package + then toLuaObject cfg.lsp.package else ''{"${cfg.lsp.package}/bin/rust-analyzer"}'' }, default_settings = { diff --git a/modules/wrapper/build/config.nix b/modules/wrapper/build/config.nix index 03c42787..68b2c00d 100644 --- a/modules/wrapper/build/config.nix +++ b/modules/wrapper/build/config.nix @@ -130,6 +130,9 @@ # In systems where we only have a package and no module, this can be used # to access the built init.lua initLua = dummyInit; + + mnwConfig = neovim-wrapped.passthru.config; + mnwConfigDir = neovim-wrapped.passthru.configDir; }; meta =