mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 08:39:50 +01:00
plugins: switch to mkLuaInline
This commit is contained in:
parent
77d3cd5e0c
commit
5d8eb192d7
8 changed files with 80 additions and 79 deletions
|
@ -12,6 +12,7 @@
|
|||
inherit (lib.types) bool str listOf oneOf attrsOf nullOr attrs submodule unspecified lines;
|
||||
inherit (lib.nvim.types) dagOf pluginsOpt extraPluginType;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.vim) valToVim;
|
||||
|
||||
|
@ -86,7 +87,7 @@
|
|||
else config;
|
||||
action =
|
||||
if action.lua
|
||||
then {"__raw" = action.action;}
|
||||
then mkLuaInline action.action
|
||||
else action.action;
|
||||
};
|
||||
in
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
|
||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||
inherit (lib.types) bool int str enum nullOr listOf;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
imports =
|
||||
[
|
||||
|
@ -22,7 +23,7 @@ in {
|
|||
options.vim.presence.neocord = {
|
||||
enable = mkEnableOption "neocord plugin for discord rich presence";
|
||||
|
||||
setupOpts = lib.nvim.mkPluginSetupOption "neocord" {
|
||||
setupOpts = mkPluginSetupOption "neocord" {
|
||||
logo = mkOption {
|
||||
type = str; # TODO: can the default be documented better, maybe with an enum?
|
||||
default = "auto";
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
|
||||
cfg = config.vim.statusline.lualine;
|
||||
breadcrumbsCfg = config.vim.ui.breadcrumbs;
|
||||
rawLua = code: {"__raw" = code;};
|
||||
in {
|
||||
config = mkMerge [
|
||||
# TODO: move into nvim-tree file
|
||||
|
@ -23,7 +24,7 @@ in {
|
|||
# TODO: rewrite in new syntax
|
||||
winbar.lualine_c = [
|
||||
"navic"
|
||||
(rawLua "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}")
|
||||
(mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}")
|
||||
];
|
||||
};
|
||||
})
|
||||
|
@ -49,20 +50,20 @@ in {
|
|||
};
|
||||
|
||||
sections = {
|
||||
lualine_a = builtins.map rawLua (cfg.activeSection.a ++ cfg.extraActiveSection.a);
|
||||
lualine_b = builtins.map rawLua (cfg.activeSection.b ++ cfg.extraActiveSection.b);
|
||||
lualine_c = builtins.map rawLua (cfg.activeSection.c ++ cfg.extraActiveSection.c);
|
||||
lualine_x = builtins.map rawLua (cfg.activeSection.x ++ cfg.extraActiveSection.x);
|
||||
lualine_y = builtins.map rawLua (cfg.activeSection.y ++ cfg.extraActiveSection.y);
|
||||
lualine_z = builtins.map rawLua (cfg.activeSection.z ++ cfg.extraActiveSection.z);
|
||||
lualine_a = builtins.map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a);
|
||||
lualine_b = builtins.map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b);
|
||||
lualine_c = builtins.map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c);
|
||||
lualine_x = builtins.map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x);
|
||||
lualine_y = builtins.map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y);
|
||||
lualine_z = builtins.map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z);
|
||||
};
|
||||
inactive_sections = {
|
||||
lualine_a = builtins.map rawLua (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a);
|
||||
lualine_b = builtins.map rawLua (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b);
|
||||
lualine_c = builtins.map rawLua (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c);
|
||||
lualine_x = builtins.map rawLua (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x);
|
||||
lualine_y = builtins.map rawLua (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y);
|
||||
lualine_z = builtins.map rawLua (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z);
|
||||
lualine_a = builtins.map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a);
|
||||
lualine_b = builtins.map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b);
|
||||
lualine_c = builtins.map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c);
|
||||
lualine_x = builtins.map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x);
|
||||
lualine_y = builtins.map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y);
|
||||
lualine_z = builtins.map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z);
|
||||
};
|
||||
# probably don't need this?
|
||||
tabline = [];
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.types) nullOr str enum bool package either int;
|
||||
inherit (lib) mkRenamedOptionModule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption rawLua;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"])
|
||||
|
@ -38,10 +39,9 @@ in {
|
|||
};
|
||||
|
||||
size = mkOption {
|
||||
type = either rawLua int;
|
||||
type = either luaInline int;
|
||||
description = "Number or lua function which is passed to the current terminal";
|
||||
default = {
|
||||
__raw = ''
|
||||
default = mkLuaInline ''
|
||||
function(term)
|
||||
if term.direction == "horizontal" then
|
||||
return 15
|
||||
|
@ -51,14 +51,12 @@ in {
|
|||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
winbar = {
|
||||
enabled = mkEnableOption "winbar in terminal" // {default = true;};
|
||||
name_formatter = mkOption {
|
||||
type = rawLua;
|
||||
type = luaInline;
|
||||
description = "Winbar formatter function.";
|
||||
default = {
|
||||
__raw = ''
|
||||
default = mkLuaInline ''
|
||||
function(term)
|
||||
return term.name
|
||||
end
|
||||
|
@ -66,7 +64,6 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lazygit = {
|
||||
enable = mkEnableOption "LazyGit integration";
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
inherit (lib.lists) optionals;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
|
||||
cfg = config.vim.ui.breadcrumbs;
|
||||
mkRawLua = code: {__raw = code;};
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins =
|
||||
|
@ -31,40 +31,40 @@ in {
|
|||
|
||||
vim.ui.breadcrumbs.navbuddy.setupOpts = {
|
||||
mappings = {
|
||||
${cfg.navbuddy.mappings.close} = mkRawLua "actions.close()";
|
||||
${cfg.navbuddy.mappings.nextSibling} = mkRawLua "actions.next_sibling()";
|
||||
${cfg.navbuddy.mappings.previousSibling} = mkRawLua "actions.previous_sibling()";
|
||||
${cfg.navbuddy.mappings.parent} = mkRawLua "actions.parent()";
|
||||
${cfg.navbuddy.mappings.children} = mkRawLua "actions.children()";
|
||||
${cfg.navbuddy.mappings.root} = mkRawLua "actions.root()";
|
||||
${cfg.navbuddy.mappings.close} = mkLuaInline "actions.close()";
|
||||
${cfg.navbuddy.mappings.nextSibling} = mkLuaInline "actions.next_sibling()";
|
||||
${cfg.navbuddy.mappings.previousSibling} = mkLuaInline "actions.previous_sibling()";
|
||||
${cfg.navbuddy.mappings.parent} = mkLuaInline "actions.parent()";
|
||||
${cfg.navbuddy.mappings.children} = mkLuaInline "actions.children()";
|
||||
${cfg.navbuddy.mappings.root} = mkLuaInline "actions.root()";
|
||||
|
||||
${cfg.navbuddy.mappings.visualName} = mkRawLua "actions.visual_name()";
|
||||
${cfg.navbuddy.mappings.visualScope} = mkRawLua "actions.visual_scope()";
|
||||
${cfg.navbuddy.mappings.visualName} = mkLuaInline "actions.visual_name()";
|
||||
${cfg.navbuddy.mappings.visualScope} = mkLuaInline "actions.visual_scope()";
|
||||
|
||||
${cfg.navbuddy.mappings.yankName} = mkRawLua "actions.yank_name()";
|
||||
${cfg.navbuddy.mappings.yankScope} = mkRawLua "actions.yank_scope()";
|
||||
${cfg.navbuddy.mappings.yankName} = mkLuaInline "actions.yank_name()";
|
||||
${cfg.navbuddy.mappings.yankScope} = mkLuaInline "actions.yank_scope()";
|
||||
|
||||
${cfg.navbuddy.mappings.insertName} = mkRawLua "actions.insert_name()";
|
||||
${cfg.navbuddy.mappings.insertScope} = mkRawLua "actions.insert_scope()";
|
||||
${cfg.navbuddy.mappings.insertName} = mkLuaInline "actions.insert_name()";
|
||||
${cfg.navbuddy.mappings.insertScope} = mkLuaInline "actions.insert_scope()";
|
||||
|
||||
${cfg.navbuddy.mappings.appendName} = mkRawLua "actions.append_name()";
|
||||
${cfg.navbuddy.mappings.appendScope} = mkRawLua "actions.append_scope()";
|
||||
${cfg.navbuddy.mappings.appendName} = mkLuaInline "actions.append_name()";
|
||||
${cfg.navbuddy.mappings.appendScope} = mkLuaInline "actions.append_scope()";
|
||||
|
||||
${cfg.navbuddy.mappings.rename} = mkRawLua "actions.rename()";
|
||||
${cfg.navbuddy.mappings.rename} = mkLuaInline "actions.rename()";
|
||||
|
||||
${cfg.navbuddy.mappings.delete} = mkRawLua "actions.delete()";
|
||||
${cfg.navbuddy.mappings.delete} = mkLuaInline "actions.delete()";
|
||||
|
||||
${cfg.navbuddy.mappings.foldCreate} = mkRawLua "actions.fold_create()";
|
||||
${cfg.navbuddy.mappings.foldDelete} = mkRawLua "actions.fold_delete()";
|
||||
${cfg.navbuddy.mappings.foldCreate} = mkLuaInline "actions.fold_create()";
|
||||
${cfg.navbuddy.mappings.foldDelete} = mkLuaInline "actions.fold_delete()";
|
||||
|
||||
${cfg.navbuddy.mappings.comment} = mkRawLua "actions.comment()";
|
||||
${cfg.navbuddy.mappings.comment} = mkLuaInline "actions.comment()";
|
||||
|
||||
${cfg.navbuddy.mappings.select} = mkRawLua "actions.select()";
|
||||
${cfg.navbuddy.mappings.select} = mkLuaInline "actions.select()";
|
||||
|
||||
${cfg.navbuddy.mappings.moveDown} = mkRawLua "actions.move_down()";
|
||||
${cfg.navbuddy.mappings.moveUp} = mkRawLua "actions.move_up()";
|
||||
${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()";
|
||||
${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()";
|
||||
|
||||
${cfg.navbuddy.mappings.telescope} = mkRawLua ''
|
||||
${cfg.navbuddy.mappings.telescope} = mkLuaInline ''
|
||||
actions.telescope({
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = {
|
||||
|
@ -74,7 +74,7 @@ in {
|
|||
preview_width = 0.50
|
||||
},
|
||||
})'';
|
||||
${cfg.navbuddy.mappings.help} = mkRawLua "actions.help()";
|
||||
${cfg.navbuddy.mappings.help} = mkLuaInline "actions.help()";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@ in {
|
|||
vim = {
|
||||
startPlugins = ["smartcolumn"];
|
||||
|
||||
vim.luaConfigRC.smartcolumn = entryAnywhere ''
|
||||
luaConfigRC.smartcolumn = entryAnywhere ''
|
||||
require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
# TODO: move this to its own module
|
||||
inherit (lib) pushDownDefault;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.telescope;
|
||||
self = import ./telescope.nix {inherit pkgs lib;};
|
||||
|
@ -66,7 +67,7 @@ in {
|
|||
|
||||
vim.luaConfigRC.telescope = entryAnywhere ''
|
||||
local telescope = require('telescope')
|
||||
telescope.setup(${nvim.lua.toLuaObject cfg.setupOpts})
|
||||
telescope.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${
|
||||
if config.vim.ui.noice.enable
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
inherit (lib.strings) toUpper;
|
||||
inherit (lib.types) int float bool str enum listOf attrsOf;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
rawLua = lua: {__raw = lua;};
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] ["vim" "visuals" "fidget-nvim" "setupOpts" "notification" "window" "align"])
|
||||
|
@ -50,7 +49,7 @@ in {
|
|||
apply = clear:
|
||||
if clear
|
||||
then
|
||||
rawLua ''
|
||||
mkLuaInline ''
|
||||
function(client_id)
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
return client and client.name or nil
|
||||
|
@ -66,7 +65,7 @@ in {
|
|||
return msg.lsp_client.name
|
||||
end
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
ignore = mkOption {
|
||||
description = "Ignore LSP servers by name";
|
||||
|
@ -177,7 +176,7 @@ in {
|
|||
default = ''
|
||||
require("fidget.progress.display").default_format_message
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
format_annote = mkOption {
|
||||
description = "How to format a progress annotation";
|
||||
|
@ -185,7 +184,7 @@ in {
|
|||
default = ''
|
||||
function(msg) return msg.title end
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
format_group_name = mkOption {
|
||||
description = "How to format a progress notification group's name";
|
||||
|
@ -193,13 +192,13 @@ in {
|
|||
default = ''
|
||||
function(group) return tostring(group) end
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
overrides = mkOption {
|
||||
description = "Override options from the default notification config";
|
||||
type = attrsOf str;
|
||||
default = {rust_analyzer = "{ name = 'rust-analyzer' }";};
|
||||
apply = mapAttrs (key: lua: rawLua lua);
|
||||
apply = mapAttrs (key: lua: mkLuaInline lua);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -227,7 +226,7 @@ in {
|
|||
description = "Minimum notifications level";
|
||||
type = enum ["debug" "info" "warn" "error"];
|
||||
default = "info";
|
||||
apply = filter: rawLua "vim.log.levels.${toUpper filter}";
|
||||
apply = filter: mkLuaInline "vim.log.levels.${toUpper filter}";
|
||||
};
|
||||
history_size = mkOption {
|
||||
description = "Number of removed messages to retain in history";
|
||||
|
@ -243,7 +242,7 @@ in {
|
|||
description = "How to configure notification groups when instantiated";
|
||||
type = attrsOf str;
|
||||
default = {default = "require('fidget.notification').default_config";};
|
||||
apply = mapAttrs (key: lua: rawLua lua);
|
||||
apply = mapAttrs (key: lua: mkLuaInline lua);
|
||||
};
|
||||
redirect = mkOption {
|
||||
description = "Conditionally redirect notifications to another backend";
|
||||
|
@ -255,7 +254,7 @@ in {
|
|||
end
|
||||
end
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
|
||||
view = {
|
||||
|
@ -287,7 +286,7 @@ in {
|
|||
return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg)
|
||||
end
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -373,7 +372,7 @@ in {
|
|||
description = "Minimum logging level";
|
||||
type = enum ["debug" "error" "info" "trace" "warn" "off"];
|
||||
default = "warn";
|
||||
apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}";
|
||||
apply = logLevel: mkLuaInline "vim.log.levels.${toUpper logLevel}";
|
||||
};
|
||||
max_size = mkOption {
|
||||
description = "Maximum log file size, in KB";
|
||||
|
@ -391,7 +390,7 @@ in {
|
|||
default = ''
|
||||
string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache"))
|
||||
'';
|
||||
apply = rawLua;
|
||||
apply = mkLuaInline;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue