mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-10 06:03:53 +00:00
Compare commits
No commits in common. "3e48f13c3ce8372d00be2e27f313f2ed8da5bc82" and "dde524f7cc4b9e56cf45223a23e1b598f68848d7" have entirely different histories.
3e48f13c3c
...
dde524f7cc
9 changed files with 98 additions and 60 deletions
1
.github/typos.toml
vendored
1
.github/typos.toml
vendored
|
|
@ -9,6 +9,5 @@ default.extend-ignore-words-re = [
|
||||||
"edn",
|
"edn",
|
||||||
"esy",
|
"esy",
|
||||||
"BA", # somehow "BANanaD3V" is valid, but BA is not...
|
"BA", # somehow "BANanaD3V" is valid, but BA is not...
|
||||||
"Emac"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ The changes are, in no particular order:
|
||||||
|
|
||||||
- Add [ocaml-lsp] support
|
- Add [ocaml-lsp] support
|
||||||
|
|
||||||
- Fix misspelled "Emacs"
|
- Fix "Emac" typo
|
||||||
|
|
||||||
- Add [new-file-template.nvim] to automatically fill new file contents using
|
- Add [new-file-template.nvim] to automatically fill new file contents using
|
||||||
templates
|
templates
|
||||||
|
|
|
||||||
|
|
@ -569,7 +569,8 @@
|
||||||
[typst-concealer]: https://github.com/PartyWumpus/typst-concealer
|
[typst-concealer]: https://github.com/PartyWumpus/typst-concealer
|
||||||
|
|
||||||
- Add inline typst concealing support under `vim.languages.typst` using
|
- 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.
|
- Update `python` language module to use correct lsp binary.
|
||||||
- Fix `python` pyright and basedpyright language servers not using default on
|
- Fix `python` pyright and basedpyright language servers not using default on
|
||||||
|
|
|
||||||
130
lib/lua.nix
130
lib/lua.nix
|
|
@ -1,52 +1,92 @@
|
||||||
# Helpers for converting values to lua
|
# Helpers for converting values to lua
|
||||||
{lib}: let
|
{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";
|
isLuaInline = object: (object._type or null) == "lua-inline";
|
||||||
|
|
||||||
toLuaObject = args:
|
toLuaObject = args:
|
||||||
{
|
if isAttrs args
|
||||||
int = toString args;
|
then
|
||||||
float = toString args;
|
if isLuaInline 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
|
then args.expr
|
||||||
else "{${
|
else if hasAttr "__empty" args
|
||||||
lib.pipe args [
|
then
|
||||||
(lib.filterAttrs (_: v: v != null))
|
warn ''
|
||||||
(builtins.mapAttrs (
|
Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead.
|
||||||
n: v:
|
'' "{ }"
|
||||||
if lib.hasPrefix "@" n
|
else
|
||||||
|
"{"
|
||||||
|
+ (concatStringsSep ","
|
||||||
|
(mapAttrsToList
|
||||||
|
(n: v:
|
||||||
|
if head (stringToCharacters n) == "@"
|
||||||
then toLuaObject v
|
then toLuaObject v
|
||||||
else "[${toLuaObject n}] = ${toLuaObject v}"
|
else "[${toLuaObject n}] = " + (toLuaObject v))
|
||||||
))
|
(filterAttrs
|
||||||
builtins.attrValues
|
(_: v: v != null)
|
||||||
(lib.concatStringsSep ",\n")
|
args)))
|
||||||
]
|
+ "}"
|
||||||
}}";
|
else if isList args
|
||||||
}
|
then "{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||||
.${
|
else if isString args
|
||||||
builtins.typeOf args
|
then
|
||||||
}
|
# This should be enough!
|
||||||
or (builtins.throw "Could not convert object of type `${builtins.typeOf args}` to lua object");
|
toJSON args
|
||||||
in
|
else if isPath args
|
||||||
{
|
then toJSON (toString args)
|
||||||
inherit isLuaInline toLuaObject;
|
else if isBool args
|
||||||
luaTable = x: (toLuaObject (map lib.mkLuaInline x));
|
then "${boolToString args}"
|
||||||
}
|
else if isFloat args
|
||||||
// lib.genAttrs [
|
then "${toString args}"
|
||||||
"nullString"
|
else if isInt args
|
||||||
"expToLua"
|
then "${toString args}"
|
||||||
"listToLuaTable"
|
else if (args == null)
|
||||||
"attrsetToLuaTable"
|
then "nil"
|
||||||
] (name: lib.warn "${name} is deprecated use toLuaObject instead" toLuaObject)
|
else throw "could not convert object of type `${typeOf args}` to lua object";
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
inherit (lib.strings) concatLines concatStringsSep optionalString;
|
inherit (lib.strings) concatLines concatStringsSep optionalString;
|
||||||
inherit (lib.attrsets) mapAttrsToList;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
inherit (lib.types) listOf str attrsOf;
|
inherit (lib.types) listOf str attrsOf;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) listToLuaTable;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
|
||||||
cfg = config.vim.spellcheck;
|
cfg = config.vim.spellcheck;
|
||||||
|
|
@ -152,7 +152,7 @@ in {
|
||||||
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
|
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
|
||||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
group = "nvf_autocmds",
|
group = "nvf_autocmds",
|
||||||
pattern = ${toLuaObject cfg.ignoredFiletypes},
|
pattern = ${listToLuaTable cfg.ignoredFiletypes},
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.spell = false
|
vim.opt_local.spell = false
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ in {
|
||||||
accept = mkOption {
|
accept = mkOption {
|
||||||
type = nullOr str;
|
type = nullOr str;
|
||||||
default = "<M-l>";
|
default = "<M-l>";
|
||||||
description = "Accept suggestion";
|
description = "Accept suggetion";
|
||||||
};
|
};
|
||||||
|
|
||||||
acceptWord = mkOption {
|
acceptWord = mkOption {
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,11 @@
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
inherit (lib.meta) getExe';
|
inherit (lib.meta) getExe';
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (pkgs) haskellPackages;
|
inherit (pkgs) haskellPackages;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.languages.haskell;
|
cfg = config.vim.languages.haskell;
|
||||||
|
|
||||||
|
|
@ -119,7 +120,7 @@ in {
|
||||||
dap = {
|
dap = {
|
||||||
cmd = ${
|
cmd = ${
|
||||||
if isList cfg.dap.package
|
if isList cfg.dap.package
|
||||||
then toLuaObject cfg.dap.package
|
then expToLua cfg.dap.package
|
||||||
else ''{"${cfg.dap.package}/bin/haskell-debug-adapter"}''
|
else ''{"${cfg.dap.package}/bin/haskell-debug-adapter"}''
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.types) bool package str listOf either enum;
|
inherit (lib.types) bool package str listOf either enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.languages.rust;
|
cfg = config.vim.languages.rust;
|
||||||
|
|
@ -153,7 +153,7 @@ in {
|
||||||
server = {
|
server = {
|
||||||
cmd = ${
|
cmd = ${
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then toLuaObject cfg.lsp.package
|
then expToLua cfg.lsp.package
|
||||||
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
||||||
},
|
},
|
||||||
default_settings = {
|
default_settings = {
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,6 @@
|
||||||
# In systems where we only have a package and no module, this can be used
|
# In systems where we only have a package and no module, this can be used
|
||||||
# to access the built init.lua
|
# to access the built init.lua
|
||||||
initLua = dummyInit;
|
initLua = dummyInit;
|
||||||
|
|
||||||
mnwConfig = neovim-wrapped.passthru.config;
|
|
||||||
mnwConfigDir = neovim-wrapped.passthru.configDir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
meta =
|
meta =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue