mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-14 14:37:49 +00:00
utility/ccc: add setupOpts option
Added `ccc.nvim` option `vim.utility.ccc.setupOpts` with the existing hard-coded options as default values.
This commit is contained in:
parent
af02324695
commit
90b0436f04
3 changed files with 150 additions and 86 deletions
|
|
@ -3,47 +3,25 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.strings) concatStringsSep;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
cfg = config.vim.utility.ccc;
|
||||
mkLuaIdentifier = prefix: identifier: mkLuaInline "${prefix}${identifier}";
|
||||
mapSetupOptions = setupOpts:
|
||||
setupOpts
|
||||
// {
|
||||
inputs = map (mkLuaIdentifier "ccc.input.") setupOpts.inputs;
|
||||
outputs = map (mkLuaIdentifier "ccc.output.") setupOpts.outputs;
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["ccc-nvim"];
|
||||
|
||||
vim.pluginRC.ccc = entryAnywhere ''
|
||||
local ccc = require("ccc")
|
||||
ccc.setup {
|
||||
highlighter = {
|
||||
auto_enable = true,
|
||||
max_byte = 2 * 1024 * 1024, -- 2mb
|
||||
lsp = true,
|
||||
filetypes = colorPickerFts,
|
||||
},
|
||||
pickers = {
|
||||
ccc.picker.hex,
|
||||
ccc.picker.css_rgb,
|
||||
ccc.picker.css_hsl,
|
||||
ccc.picker.ansi_escape {
|
||||
meaning1 = "bright", -- whether the 1 means bright or yellow
|
||||
},
|
||||
},
|
||||
alpha_show = "hide", -- needed when highlighter.lsp is set to true
|
||||
recognize = { output = true }, -- automatically recognize color format under cursor
|
||||
inputs = {${concatStringsSep "," (map (input: "ccc.input.${input}") cfg.inputs)}},
|
||||
outputs = {${concatStringsSep "," (map (output: "ccc.output.${output}") cfg.outputs)}},
|
||||
convert = {
|
||||
{ ccc.picker.hex, ccc.output.css_hsl },
|
||||
{ ccc.picker.css_rgb, ccc.output.css_hsl },
|
||||
{ ccc.picker.css_hsl, ccc.output.hex },
|
||||
},
|
||||
mappings = {
|
||||
["q"] = ccc.mapping.quit,
|
||||
["L"] = ccc.mapping.increase10,
|
||||
["H"] = ccc.mapping.decrease10,
|
||||
},
|
||||
}
|
||||
ccc.setup(${toLuaObject (mapSetupOptions cfg.setupOpts)})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue