feat: mkDeprecate, tex math conceal, more zen, spellcheck, show pids
parent
eef0fdcd14
commit
e4ae633a1d
|
@ -0,0 +1,29 @@
|
||||||
|
\documentclass{article}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\section{Sample LaTeX Document with Math Symbols}
|
||||||
|
|
||||||
|
Here are some math symbols and commands:
|
||||||
|
|
||||||
|
1. Infinity: $\infty$
|
||||||
|
2. Element of: $a \in A$
|
||||||
|
3. Angle: $\angle ABC$
|
||||||
|
4. Approximation: $a \approx b$
|
||||||
|
5. Union: $A \cup B$
|
||||||
|
6. Intersection: $A \cap B$
|
||||||
|
7. Big union: $\bigcup_{i=1}^{n} A_i$
|
||||||
|
8. Big intersection: $\bigcap_{i=1}^{n} A_i$
|
||||||
|
9. Down arrow: $\downarrow$
|
||||||
|
10. Double down arrow: $\Downarrow$
|
||||||
|
11. Copyright symbol: $\copyright$
|
||||||
|
12. Quadruple space: $a \qquad b$
|
||||||
|
13. Empty set: $\emptyset$
|
||||||
|
14. Aleph symbol: $\aleph$
|
||||||
|
15. Product: $\prod_{i=1}^{n} a_i$
|
||||||
|
16. Integration: $\int f(x) \, dx$
|
||||||
|
17. Clubsuit: $\clubsuit$
|
||||||
|
18. dot: $\dot{B}$
|
||||||
|
|
||||||
|
\end{document}
|
||||||
|
|
|
@ -53,10 +53,9 @@ vim.call('plug#begin')
|
||||||
|
|
||||||
-- libs and dependencies
|
-- libs and dependencies
|
||||||
WPlug('nvim-lua/plenary.nvim') -- The base of all plugins
|
WPlug('nvim-lua/plenary.nvim') -- The base of all plugins
|
||||||
WPlug('MunifTanjim/nui.nvim') -- For some .so or .dylib neovim UI action
|
--
|
||||||
|
--
|
||||||
|
-- -- plugins
|
||||||
-- plugins
|
|
||||||
WPlug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting
|
WPlug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting
|
||||||
WPlug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
WPlug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
||||||
WPlug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser
|
WPlug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser
|
||||||
|
@ -101,10 +100,10 @@ WPlug('ThePrimeagen/harpoon') -- 1-click through marked files per p
|
||||||
WPlug('TimUntersberger/neogit') -- Easy-to-see git status
|
WPlug('TimUntersberger/neogit') -- Easy-to-see git status
|
||||||
WPlug('folke/trouble.nvim') -- File-grouped workspace diagnostics
|
WPlug('folke/trouble.nvim') -- File-grouped workspace diagnostics
|
||||||
WPlug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands
|
WPlug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands
|
||||||
WPlug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein"
|
-- WPlug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein"
|
||||||
WPlug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator
|
WPlug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator
|
||||||
-- WPlug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs)
|
-- WPlug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs)
|
||||||
WPlug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*)
|
WPlug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*).# TODO: supply chain?
|
||||||
WPlug('kylechui/nvim-surround') -- surrounds with tags/parenthesis
|
WPlug('kylechui/nvim-surround') -- surrounds with tags/parenthesis
|
||||||
WPlug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration
|
WPlug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration
|
||||||
-- WPlug('tjdevries/sg.nvim') -- Cody and other cool sourcegraph stuffs
|
-- WPlug('tjdevries/sg.nvim') -- Cody and other cool sourcegraph stuffs
|
||||||
|
@ -171,6 +170,14 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
||||||
|
|
||||||
vim.g.gruvbox_contrast_dark = "soft";
|
vim.g.gruvbox_contrast_dark = "soft";
|
||||||
vim.g.gruvbox_contrast_light = "soft";
|
vim.g.gruvbox_contrast_light = "soft";
|
||||||
|
|
||||||
|
-- no more partial keystrokes, it's distracting
|
||||||
|
vim.opt.showcmd = false;
|
||||||
|
-- rely on lualine
|
||||||
|
vim.opt.showmode = false;
|
||||||
|
-- Suppress buffer/file written message
|
||||||
|
vim.opt.shortmess = "atToOCF"
|
||||||
|
|
||||||
vim.opt.ignorecase = true;
|
vim.opt.ignorecase = true;
|
||||||
vim.opt.smartcase = true;
|
vim.opt.smartcase = true;
|
||||||
vim.opt.incsearch = true;
|
vim.opt.incsearch = true;
|
||||||
|
@ -190,6 +197,72 @@ vim.opt.colorcolumn = "80";
|
||||||
|
|
||||||
vim.opt.background = "dark";
|
vim.opt.background = "dark";
|
||||||
|
|
||||||
|
vim.opt.spelllang = "en_us";
|
||||||
|
do -- selective spell-checking
|
||||||
|
local spellcheck = vim.api.nvim_create_augroup("SpellChecking", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
|
group = spellcheck,
|
||||||
|
pattern = { "tex", "markdown", "md", },
|
||||||
|
callback = function() vim.opt_local.spell = true end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
do -- selective concealing/ligature {{{
|
||||||
|
g_docs = "docs"
|
||||||
|
group_map = {
|
||||||
|
plaintex = g_docs,
|
||||||
|
tex = g_docs,
|
||||||
|
markdown = g_docs,
|
||||||
|
}
|
||||||
|
conceal_by_mode = {
|
||||||
|
n = 2,
|
||||||
|
i = 0,
|
||||||
|
c = 2,
|
||||||
|
v = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
local group_handler = {
|
||||||
|
[g_docs] = function(_ft, _group)
|
||||||
|
vim.notify("group_handler: " .. vim.inspect({ _ft, _group }))
|
||||||
|
vim.opt_local.concealcursor = "n"
|
||||||
|
-- HACK: seems to be some lifetime racing issues here
|
||||||
|
-- Putting this inside `vim.schedule` puts this at the end of the
|
||||||
|
-- queue, so under the assumption that aucommands are done in an
|
||||||
|
-- event loop, we're sure that the current augroup invocation
|
||||||
|
-- would be done before syn is set
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.opt_local.syn = "tex"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
local conceal = vim.api.nvim_create_augroup("Conceal", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
|
group = conceal,
|
||||||
|
pattern = { "*" },
|
||||||
|
callback = function(args)
|
||||||
|
-- `:h FileType` and `:h nvim_create_augroup`.
|
||||||
|
-- `amatch`: value of filetype; args.match <- amatch
|
||||||
|
local ft = args.match
|
||||||
|
local group = group_map[ft]
|
||||||
|
if group == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
group_handler[group](ft, group)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd({ "ModeChanged" }, {
|
||||||
|
group = conceal,
|
||||||
|
pattern = "?:?",
|
||||||
|
callback = function()
|
||||||
|
local new_mode = vim.fn.mode("1")
|
||||||
|
local level = conceal_by_mode[new_mode]
|
||||||
|
if level then
|
||||||
|
vim.opt_local.conceallevel = level
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end -- }}}
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('Dark', function(opts)
|
vim.api.nvim_create_user_command('Dark', function(opts)
|
||||||
-- opts: {name, args: str, fargs: Splited<str>, range, ...}
|
-- opts: {name, args: str, fargs: Splited<str>, range, ...}
|
||||||
---@type string
|
---@type string
|
||||||
|
@ -307,8 +380,9 @@ require('trouble').setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- TODO: Any way to collect all the TODOs and its variants?
|
-- TODO + Trouble: `:TodoTrouble`
|
||||||
require('todo-comments').setup()
|
require('todo-comments').setup {}
|
||||||
|
|
||||||
|
|
||||||
-- plugin keymaps
|
-- plugin keymaps
|
||||||
|
|
||||||
|
@ -320,11 +394,12 @@ end
|
||||||
-- Comment.nvim
|
-- Comment.nvim
|
||||||
require('Comment').setup()
|
require('Comment').setup()
|
||||||
-- -- lukas-reineke/indent-blankline.nvim
|
-- -- lukas-reineke/indent-blankline.nvim
|
||||||
-- vim.opt.list = true
|
vim.opt.list = true
|
||||||
-- vim.opt.listchars:append "space:⋅"
|
vim.opt.listchars:append "space:⋅"
|
||||||
-- vim.opt.listchars:append "eol:↴"
|
vim.opt.listchars:append "eol:↴"
|
||||||
|
|
||||||
require("ibl").setup {
|
require("ibl").setup {
|
||||||
|
-- indent = {char = {space='', eol=''}, },
|
||||||
-- show_end_of_line = true,
|
-- show_end_of_line = true,
|
||||||
-- space_char_blankline = " ",
|
-- space_char_blankline = " ",
|
||||||
|
|
||||||
|
@ -439,7 +514,6 @@ stdout> (builtin.__file)
|
||||||
|
|
||||||
log.debug(vim.inspect(filenames))
|
log.debug(vim.inspect(filenames))
|
||||||
|
|
||||||
|
|
||||||
for _, filename in pairs(filenames) do
|
for _, filename in pairs(filenames) do
|
||||||
require('harpoon.mark').add_file(filename)
|
require('harpoon.mark').add_file(filename)
|
||||||
end
|
end
|
||||||
|
@ -1437,15 +1511,17 @@ require('lualine').setup {
|
||||||
newfile_status = false,
|
newfile_status = false,
|
||||||
path = 1,
|
path = 1,
|
||||||
symbols = {
|
symbols = {
|
||||||
modified = '[+]',
|
modified = '[~]',
|
||||||
readonly = '[-]',
|
readonly = '[-]',
|
||||||
unnamed = '[Unnamed]',
|
unnamed = '<?>',
|
||||||
newfile = '[New]',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_x = { 'encoding', 'fileformat', 'filetype', },
|
lualine_x = { 'encoding', 'fileformat', {
|
||||||
lualine_y = { 'progress' },
|
'filetype',
|
||||||
|
colored = true,
|
||||||
|
}, },
|
||||||
|
lualine_y = { function() return "pid#" .. vim.loop.os_getpid() end },
|
||||||
lualine_z = { 'location' },
|
lualine_z = { 'location' },
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
in {
|
in {
|
||||||
default = std.lib.dev.mkShell {
|
default = std.lib.dev.mkShell {
|
||||||
name = "default";
|
name = "default";
|
||||||
imports = [inputs.std.std.devshellProfiles.default];
|
imports = [
|
||||||
|
inputs.std.std.devshellProfiles.default
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
{config.programs.home-manager.enable = true;}
|
{config.programs.home-manager.enable = true;}
|
||||||
# home-profiles.nix-index
|
# home-profiles.nix-index
|
||||||
home-profiles.neovim
|
home-profiles.neovim
|
||||||
|
{
|
||||||
|
config.repo.shells.shellAliases = {
|
||||||
|
nixr = "if [ -f $(pwd)/.nix-replrc ]; then nix repl $(pwd)/.nix-replrc; elif [ -f ~/.config/.nix-replrc ]; then nix repl ~/.config/.nix-replrc; else nix repl; fi";
|
||||||
|
};
|
||||||
|
}
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
homeConfigurations.htran = home-config {
|
homeConfigurations.htran = home-config {
|
||||||
|
|
|
@ -8,12 +8,7 @@ _imports @ {
|
||||||
namespace = "repo";
|
namespace = "repo";
|
||||||
imports = _imports // {inherit namespace;};
|
imports = _imports // {inherit namespace;};
|
||||||
in {
|
in {
|
||||||
git = {
|
git = { config, lib, options, ... }: let
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
options,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
cfg = config."${namespace}".git;
|
cfg = config."${namespace}".git;
|
||||||
baseAliases = {
|
baseAliases = {
|
||||||
a = "add";
|
a = "add";
|
||||||
|
|
|
@ -96,6 +96,7 @@ in {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
plugins = let
|
plugins = let
|
||||||
|
inherit (cell.lib.deprecate) mkDeprecate deprecate-seq-handler;
|
||||||
inherit
|
inherit
|
||||||
(inputs.nixpkgs-vimplugins.legacyPackages.${system}.vimPlugins)
|
(inputs.nixpkgs-vimplugins.legacyPackages.${system}.vimPlugins)
|
||||||
plenary-nvim
|
plenary-nvim
|
||||||
|
@ -144,63 +145,75 @@ in {
|
||||||
nvim-colorizer-lua
|
nvim-colorizer-lua
|
||||||
git-worktree-nvim
|
git-worktree-nvim
|
||||||
;
|
;
|
||||||
# inherit (inputs.cells.dotfiles.packages) sg-nvim;
|
sg-nvim = let
|
||||||
in [
|
_sg = inputs.cells.dotfiles.packages.sg-nvim;
|
||||||
plenary-nvim
|
in {
|
||||||
nvim-treesitter.withAllGrammars
|
plugin = _sg;
|
||||||
nvim-treesitter-textobjects
|
# NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API
|
||||||
telescope-fzf-native-nvim
|
config = ''
|
||||||
telescope-file-browser-nvim
|
package.cpath = package.cpath .. ";${_sg}/lib/*.so;${_sg}/lib/*.dylib"
|
||||||
telescope-nvim
|
'';
|
||||||
nvim-lspconfig
|
type = "lua";
|
||||||
gruvbox-community
|
};
|
||||||
neodev-nvim
|
in
|
||||||
cmp-nvim-lsp
|
deprecate-seq-handler 1 [
|
||||||
cmp-path
|
(mkDeprecate {inherit sg-nvim;} {
|
||||||
cmp-buffer
|
stage = 2;
|
||||||
cmp-cmdline
|
meta.since = "2023-10-20";
|
||||||
nvim-cmp
|
})
|
||||||
lspkind-nvim
|
(mkDeprecate {inherit vim-jack-in;} {
|
||||||
nvim-autopairs
|
stage = 2;
|
||||||
nvim-ts-autotag
|
meta.since = "2023-10-20";
|
||||||
guess-indent-nvim
|
})
|
||||||
harpoon
|
plenary-nvim
|
||||||
luasnip
|
nvim-treesitter.withAllGrammars
|
||||||
nvim-treesitter-context
|
nvim-treesitter-textobjects
|
||||||
fidget-nvim
|
telescope-fzf-native-nvim
|
||||||
rust-tools-nvim
|
telescope-file-browser-nvim
|
||||||
telescope-live-grep-args-nvim
|
telescope-nvim
|
||||||
comment-nvim
|
nvim-lspconfig
|
||||||
|
gruvbox-community
|
||||||
|
neodev-nvim
|
||||||
|
cmp-nvim-lsp
|
||||||
|
cmp-path
|
||||||
|
cmp-buffer
|
||||||
|
cmp-cmdline
|
||||||
|
nvim-cmp
|
||||||
|
lspkind-nvim
|
||||||
|
nvim-autopairs
|
||||||
|
nvim-ts-autotag
|
||||||
|
guess-indent-nvim
|
||||||
|
harpoon
|
||||||
|
luasnip
|
||||||
|
nvim-treesitter-context
|
||||||
|
fidget-nvim
|
||||||
|
rust-tools-nvim
|
||||||
|
telescope-live-grep-args-nvim
|
||||||
|
comment-nvim
|
||||||
|
|
||||||
cmp_luasnip
|
cmp_luasnip
|
||||||
gitsigns-nvim
|
gitsigns-nvim
|
||||||
indent-blankline-nvim
|
indent-blankline-nvim
|
||||||
lualine-nvim
|
lualine-nvim
|
||||||
mason-lspconfig-nvim
|
mason-lspconfig-nvim
|
||||||
mason-nvim
|
mason-nvim
|
||||||
neogit
|
neogit
|
||||||
nvim-jqx
|
nvim-jqx
|
||||||
nvim-surround
|
nvim-surround
|
||||||
nvim-web-devicons
|
nvim-web-devicons
|
||||||
playground
|
playground
|
||||||
todo-comments-nvim
|
todo-comments-nvim
|
||||||
trouble-nvim
|
trouble-nvim
|
||||||
vim-dispatch
|
vim-dispatch
|
||||||
vim-dispatch-neovim
|
vim-dispatch-neovim
|
||||||
vim-fugitive
|
vim-fugitive
|
||||||
nvim-colorizer-lua
|
nvim-colorizer-lua
|
||||||
vim-jack-in
|
git-worktree-nvim
|
||||||
# {
|
(mkDeprecate {inherit nui-nvim;} {
|
||||||
# plugin = sg-nvim;
|
stage = 2;
|
||||||
# # NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API
|
meta.since = "2023-10-20";
|
||||||
# config = ''
|
})
|
||||||
# package.cpath = package.cpath .. ";${sg-nvim}/lib/*.so;${sg-nvim}/lib/*.dylib"
|
];
|
||||||
# '';
|
|
||||||
# type = "lua";
|
|
||||||
# }
|
|
||||||
git-worktree-nvim
|
|
||||||
nui-nvim
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
# home.packages = nvim_pkgs;
|
# home.packages = nvim_pkgs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
{
|
std-passthru @ {
|
||||||
inputs,
|
inputs,
|
||||||
cell,
|
cell,
|
||||||
}: let
|
}: let
|
||||||
namespace = "repo"; # ignore: unused
|
|
||||||
|
|
||||||
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
|
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
|
||||||
outputPath
|
outputPath
|
||||||
{
|
{
|
||||||
|
@ -15,6 +13,18 @@
|
||||||
''
|
''
|
||||||
echo "$yamlContent" | yq >$out
|
echo "$yamlContent" | yq >$out
|
||||||
'');
|
'');
|
||||||
|
|
||||||
|
exec_tests = testUnit: let
|
||||||
|
testNames = builtins.attrNames testUnit;
|
||||||
|
evaluateTest = testName: assert testUnit."${testName}" == true; testName;
|
||||||
|
in
|
||||||
|
builtins.concatStringsSep ", " (builtins.foldl' (acc: testName: acc ++ [(evaluateTest testName)]) [] testNames);
|
||||||
|
tests = import ./tests.nix std-passthru;
|
||||||
in {
|
in {
|
||||||
fromYAML = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
|
fromYAML = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
|
||||||
|
ty = import ./ty.nix std-passthru;
|
||||||
|
deprecate = import ./mk-deprecate.nix std-passthru;
|
||||||
|
|
||||||
|
inherit tests;
|
||||||
|
exec-tests = exec_tests tests;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
{inputs, cell}: {
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
cell,
|
||||||
|
}: let
|
||||||
|
inherit (cell.lib.ty) brand-ctor brand-coalesce-seq unbranded_name;
|
||||||
|
|
||||||
|
deprecate_t = a @ {
|
||||||
|
id ? null,
|
||||||
|
msg ? null,
|
||||||
|
ctx_str ? null,
|
||||||
|
meta ? null,
|
||||||
|
/*
|
||||||
|
the higher the more likely to be removed
|
||||||
|
*/
|
||||||
|
stage ? 0,
|
||||||
|
}: let
|
||||||
|
ctx =
|
||||||
|
if ctx_str == null
|
||||||
|
then ""
|
||||||
|
else ": ${ctx_str}";
|
||||||
|
_msg =
|
||||||
|
if msg == null
|
||||||
|
then
|
||||||
|
if id == null
|
||||||
|
then "deprecated${ctx}"
|
||||||
|
else "${id} is deprecated${ctx}"
|
||||||
|
else msg;
|
||||||
|
in
|
||||||
|
builtins.trace _msg (v: (brand-ctor "deprecate" v) // {inherit stage;} // a);
|
||||||
|
in {
|
||||||
|
inherit deprecate_t;
|
||||||
|
mkDeprecate = inherit_v: a: deprecate_t ({id = builtins.head (builtins.attrNames inherit_v);} // a) (builtins.head (builtins.attrValues inherit_v));
|
||||||
|
deprecate-seq-handler = trim_stage: s: let
|
||||||
|
v = builtins.foldl' (lst: {
|
||||||
|
__value,
|
||||||
|
__brand,
|
||||||
|
...
|
||||||
|
} @ a:
|
||||||
|
if __brand == "deprecate" && trim_stage < a.stage
|
||||||
|
then lst
|
||||||
|
else
|
||||||
|
lst
|
||||||
|
++ [
|
||||||
|
(
|
||||||
|
if __brand == "deprecate" || __brand == unbranded_name
|
||||||
|
then __value
|
||||||
|
else a
|
||||||
|
)
|
||||||
|
]) [] (brand-coalesce-seq s);
|
||||||
|
in
|
||||||
|
v;
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
cell,
|
||||||
|
}: {
|
||||||
|
ty-deprecate = let
|
||||||
|
exampleBrand = cell.lib.ty.brand-ctor "example";
|
||||||
|
brandedItem = exampleBrand "someValue";
|
||||||
|
in
|
||||||
|
assert (brandedItem.__brand == "example");
|
||||||
|
assert (brandedItem.__value == "someValue"); let
|
||||||
|
coalescedItem = cell.lib.ty.brand-coalesce brandedItem;
|
||||||
|
coalescedSeq = cell.lib.ty.brand-coalesce-seq [brandedItem "hello"];
|
||||||
|
promoted = cell.lib.ty.brand-coalesce "hello";
|
||||||
|
in
|
||||||
|
assert (coalescedItem.__brand != "__unbranded__");
|
||||||
|
assert (promoted.__brand == "__unbranded__");
|
||||||
|
assert ((builtins.elemAt coalescedSeq 0) == brandedItem);
|
||||||
|
assert ((let v = builtins.elemAt coalescedSeq 1; in builtins.trace "${builtins.toJSON v}" v) == promoted); let
|
||||||
|
items = [(exampleBrand "A") (exampleBrand "B") (cell.lib.ty.brand-ctor "second" "C")];
|
||||||
|
grouped = cell.lib.ty.brand-group items;
|
||||||
|
in
|
||||||
|
assert (builtins.length (grouped.example) == 2);
|
||||||
|
assert (builtins.length (grouped.second) == 1); let
|
||||||
|
retainItem = cell.lib.deprecate.mkDeprecate {myItem = "value";} {ctx_str = "example context";};
|
||||||
|
deprecate = cell.lib.deprecate.mkDeprecate {deprecate = 15;} {stage = 256;};
|
||||||
|
processedSeq = cell.lib.deprecate.deprecate-seq-handler 0 [retainItem];
|
||||||
|
partiallyRemoved = cell.lib.deprecate.deprecate-seq-handler 2 [retainItem brandedItem];
|
||||||
|
removeDeprecated = cell.lib.deprecate.deprecate-seq-handler 2 [deprecate brandedItem];
|
||||||
|
passthru = cell.lib.deprecate.deprecate-seq-handler 4 [retainItem brandedItem deprecate];
|
||||||
|
in
|
||||||
|
assert (retainItem.__brand == "deprecate");
|
||||||
|
# Since the stage is 0, it filters the deprecated item out
|
||||||
|
assert (builtins.length processedSeq == 1);
|
||||||
|
assert (builtins.head partiallyRemoved == "value");
|
||||||
|
assert (builtins.head removeDeprecated == brandedItem);
|
||||||
|
assert (builtins.length passthru == 2); true;
|
||||||
|
deprecate = let
|
||||||
|
inherit (cell.lib.deprecate) mkDeprecate deprecate-seq-handler;
|
||||||
|
inherit (inputs.nixpkgs) system;
|
||||||
|
inherit
|
||||||
|
(inputs.nixpkgs-vimplugins.legacyPackages.${system}.vimPlugins)
|
||||||
|
plenary-nvim
|
||||||
|
nvim-treesitter
|
||||||
|
nvim-treesitter-textobjects
|
||||||
|
nvim-treesitter-context
|
||||||
|
telescope-fzf-native-nvim
|
||||||
|
telescope-file-browser-nvim
|
||||||
|
vim-jack-in
|
||||||
|
nui-nvim
|
||||||
|
telescope-live-grep-args-nvim
|
||||||
|
nvim-colorizer-lua
|
||||||
|
git-worktree-nvim
|
||||||
|
;
|
||||||
|
sg-nvim = let
|
||||||
|
_sg = inputs.cells.dotfiles.packages.sg-nvim;
|
||||||
|
in {
|
||||||
|
plugin = _sg;
|
||||||
|
# NOTE: Wait, this mean the plugin is exclusively lua only since package.cpath is Lua API
|
||||||
|
config = ''
|
||||||
|
package.cpath = package.cpath .. ";${_sg}/lib/*.so;${_sg}/lib/*.dylib"
|
||||||
|
'';
|
||||||
|
type = "lua";
|
||||||
|
};
|
||||||
|
plugins = [
|
||||||
|
(mkDeprecate {inherit sg-nvim;} {
|
||||||
|
stage = 2;
|
||||||
|
meta.since = "2023-10-20";
|
||||||
|
})
|
||||||
|
(mkDeprecate {inherit vim-jack-in;} {
|
||||||
|
stage = 2;
|
||||||
|
meta.since = "2023-10-20";
|
||||||
|
})
|
||||||
|
plenary-nvim
|
||||||
|
nvim-treesitter.withAllGrammars
|
||||||
|
nvim-treesitter-textobjects
|
||||||
|
telescope-fzf-native-nvim
|
||||||
|
telescope-file-browser-nvim
|
||||||
|
nvim-treesitter-context
|
||||||
|
telescope-live-grep-args-nvim
|
||||||
|
nvim-colorizer-lua
|
||||||
|
git-worktree-nvim
|
||||||
|
nui-nvim
|
||||||
|
];
|
||||||
|
pluglen = builtins.length plugins;
|
||||||
|
rm = let v = deprecate-seq-handler 1 plugins; in assert (builtins.length v) < pluglen; v;
|
||||||
|
retain = let v = deprecate-seq-handler 10 plugins; in assert (builtins.length v) == pluglen; v;
|
||||||
|
in
|
||||||
|
builtins.trace (builtins.toJSON {inherit rm retain;}) true;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
inputs,
|
||||||
|
cell,
|
||||||
|
}: let
|
||||||
|
brand-ctor = name:
|
||||||
|
assert builtins.isString name;
|
||||||
|
v: {
|
||||||
|
__brand = name;
|
||||||
|
__value = v;
|
||||||
|
};
|
||||||
|
unbranded_name = "__unbranded__";
|
||||||
|
unbranded_t = brand-ctor unbranded_name;
|
||||||
|
brand-of = {
|
||||||
|
__brand ? unbranded_name,
|
||||||
|
__value ? null,
|
||||||
|
}:
|
||||||
|
__brand;
|
||||||
|
brand-coalesce = v: if v ? __brand then v else unbranded_t v;
|
||||||
|
in {
|
||||||
|
inherit brand-ctor brand-of brand-coalesce unbranded_name;
|
||||||
|
brand-group = seq: builtins.mapAttrs (_: builtins.map (v: v.__value)) (builtins.groupBy (brnd: brnd.__brand) seq);
|
||||||
|
brand-coalesce-seq = builtins.map brand-coalesce;
|
||||||
|
}
|
Loading…
Reference in New Issue