This commit is contained in:
sharings 2025-07-26 12:43:01 +00:00
commit 1e2ca5a6fc
71 changed files with 3330 additions and 0 deletions

View file

@ -0,0 +1,7 @@
{
plugins = {
bufferline = {
enable = true;
};
};
}

66
config/plugins/cmp.nix Normal file
View file

@ -0,0 +1,66 @@
{
config,
lib,
helpers,
...
}:
let
inherit (helpers) mkRaw;
in
{
# TJ
# https://www.youtube.com/watch?v=_DnmphIwnjo
plugins = {
cmp = {
enable = true;
autoEnableSources = true;
settings = {
sources =
lib.optionals config.plugins.lsp.enable [
{ name = "nvim_lsp"; }
]
++ lib.optionals config.plugins.luasnip.enable [
{
name = "luasnip";
option = {
show_autosnippets = true;
};
}
]
++ [
{ name = "path"; }
{ name = "spell"; }
{ name = "latex_symbols"; }
{
name = "buffer";
keyword_length = 5;
}
];
mapping = mkRaw ''
cmp.mapping.preset.insert({
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<C-y>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
})
'';
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
experimental = {
# ghost_text = true;
};
view.entries = {
name = "custom";
# selection_order = "top_down";
};
};
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
comment = {
enable = true;
};
};
}

View file

@ -0,0 +1,17 @@
{
pkgs,
...
}:
{
# in 20241208, csvview-nvim not available in nixos-24.11 yet
extraPlugins = with pkgs.vimPlugins; [ csvview-nvim ];
extraConfigLua = ''
require('csvview').setup({
-- Add your configuration here
vim.keymap.set( 'n', '<leader>ct', function() require('csvview').toggle() end, { desc = 'CsvViewToggle' }),
view = {
display_mode = "border",
},
})
'';
}

View file

@ -0,0 +1,21 @@
# {pkgs, ...}: {
# extraPlugins = with pkgs.vimPlugins; [nvim-scrollview];
#
# # gitsigns support
# # https://github.com/dstein64/nvim-scrollview/blob/main/lua/scrollview/contrib/gitsigns.lua
# extraConfigLua = ''
# require('scrollview.contrib.gitsigns').setup({ })
# '';
# }
{
plugins = {
scrollview = {
enable = true;
settings = {
winblend_gui = 35;
hide_on_intersect = true;
signs_hidden_for_insert = [ "all" ];
};
};
};
}

View file

@ -0,0 +1,4 @@
{ pkgs, ... }:
{
extraPlugins = with pkgs.vimPlugins; [ vim-rhubarb ];
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
{
# https://github.com/h-hg/fcitx.nvim
extraPlugins = with pkgs.vimPlugins; [ fcitx-vim ];
extraConfigLua = ''
-- let g:fcitx5_rime = 1
vim.g.fcitx5_rime = 1;
vim.g.fcitx5_remote = "${pkgs.fcitx5}/bin/fcitx5-remote";
'';
}

23
config/plugins/flash.nix Normal file
View file

@ -0,0 +1,23 @@
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in
{
plugins.flash = {
enable = true;
};
keymaps = [
{
mode = [
"n"
"x"
"o"
];
key = "<leader>ss";
action = mkRaw ''
function() require("flash").jump() end
'';
options.desc = "Flash jump";
}
];
}

View file

@ -0,0 +1,21 @@
{
plugins = {
fugitive = {
enable = true;
};
};
keymaps = [
{
mode = [ "n" ];
key = "<leader>git";
action.__raw = ''function() vim.cmd('Git') end '';
options.desc = "[fujitive] Git";
}
{
mode = [ "n" ];
key = "<leader>G";
action.__raw = ''function() vim.api.nvim_feedkeys(':Git ', 'n', true) end '';
options.desc = "[fujitive] :Git";
}
];
}

View file

@ -0,0 +1,24 @@
{
plugins = {
git-conflict = {
enable = true;
settings = {
default_commands = true;
default_mappings = {
both = "<leader>Gb";
next = "<leader>Gn";
none = "<leader>G0";
ours = "<leader>Go";
prev = "<leader>Gp";
theirs = "<leader>Gt";
};
disable_diagnostics = false;
highlights = {
current = "DiffText";
incoming = "DiffAdd";
};
list_opener = "copen";
};
};
};
}

View file

@ -0,0 +1,58 @@
{
plugins = {
gitsigns = {
enable = true;
settings = {
# https://github.com/lewis6991/gitsigns.nvim
# https://nix-community.github.io/nixvim/plugins/gitsigns/settings/index.html
on_attach = ''
function(bufnr)
local gitsigns = require('gitsigns')
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then
vim.cmd.normal({']c', bang = true})
else
gitsigns.nav_hunk('next')
end
end)
map('n', '[c', function()
if vim.wo.diff then
vim.cmd.normal({'[c', bang = true})
else
gitsigns.nav_hunk('prev')
end
end)
-- Setup keymaps
local gitsigns = require('gitsigns')
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = "Stage hunk" } )
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = "Reset hunk" } )
map('v', '<leader>hs', function() gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = "Stage hunk" } )
map('v', '<leader>hr', function() gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = "Reset hunk" } )
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = "Stage buffer" } )
map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = "Undo stage hunk" } )
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = "Reset buffer" } )
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = "Preview hunk" } )
map('n', '<leader>hP', gitsigns.preview_hunk_inline, { desc = "Preview hunk inline" } )
-- map('n', '<leader>hb', function() gitsigns.blame_line{full=true} end, { desc = "Blame line full" } )
map('n', '<leader>hb', function() gitsigns.blame_line{full=false} end, { desc = "Blame line" } )
map('n', '<leader>hB', function() gitsigns.blame() end, { desc = "Blame" } )
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = "Toggle current line blame" } )
map('n', '<leader>hd', gitsigns.diffthis, { desc = "Diffthis" } )
map('n', '<leader>hD', function() gitsigns.diffthis('~') end, { desc = "Diffthis ~" } )
map('n', '<leader>td', gitsigns.toggle_deleted, { desc = "Toggle deleted" } )
end
'';
};
};
};
}

108
config/plugins/harpoon.nix Normal file
View file

@ -0,0 +1,108 @@
{
plugins = {
harpoon = {
enable = true;
settings = {
# save_on_toggle = true;
# sync_on_ui_close = false;
};
# DEPRECATED, keep the comments because not all moved to keymaps
#
# enableTelescope = true;
# keymaps = {
# /*
# DUPRECATED, moved to keymaps session
# navFile = {
# "1" = "<C-h>";
# "2" = "<C-t>";
# "3" = "<C-n>";
# # "4" = "<C-m>"; # <C-m> breaks neorg links (<C-m> also treat as Enter key in terminal)
# "4" = "<C-l>";
# # "5" = "<C-l>"; # spare for luasnip
# };
# */
#
# /*
# # https://github.com/ThePrimeagen/harpoon/issues/487
# # DUPRECATED, but seems not yet implemented very well in harpoon2
# gotoTerminal = {
# "1" = "<C-a>1";
# "2" = "<C-a>2";
# "3" = "<C-a>3";
# "4" = "<C-a>4";
# "5" = "<C-a>5";
# };
# */
#
# # Moved to keymaps session to add descriptions
# # addFile = "<leader>hm";
# # toggleQuickMenu = "<leader>ht";
# # navNext = "<C-j>";
# # navPrev = "<C-k>";
# };
};
};
keymaps = [
{
mode = "n";
key = "<C-h>";
action.__raw = "function() require'harpoon':list():select(1) end";
}
{
mode = "n";
key = "<C-t>";
action.__raw = "function() require'harpoon':list():select(2) end";
}
{
mode = "n";
key = "<C-n>";
action.__raw = "function() require'harpoon':list():select(3) end";
}
{
mode = "n";
key = "<C-l>";
action.__raw = "function() require'harpoon':list():select(4) end";
}
{
mode = "n";
key = "<leader>hm";
options = {
silent = false;
desc = "Harpoon marks current file";
};
# action = mkRaw "require('harpoon.mark').add_file";
action.__raw = "function() require'harpoon':list():add() end";
}
{
mode = "n";
key = "<leader>ht";
options = {
silent = false;
desc = "Harpoon quick menu toggle";
};
# action = mkRaw "require('harpoon.ui').toggle_quick_menu";
action.__raw = "function() require'harpoon.ui':toggle_quick_menu(harpoon:list()) end";
}
{
mode = "n";
key = "<C-S-j>";
options = {
silent = false;
desc = "Harpoon next file";
};
# action = mkRaw "require('harpoon.ui').nav_next";
action.__raw = "function() require'harpoon':list():next() end";
}
{
mode = "n";
key = "<C-S-k>";
options = {
silent = false;
desc = "Harpoon previous file";
};
# action = mkRaw "require('harpoon.ui').nav_prev";
action.__raw = "function() require'harpoon':list():prev() end";
}
];
}

30
config/plugins/image.nix Normal file
View file

@ -0,0 +1,30 @@
{
pkgs,
config,
lib,
...
}:
{
plugins = {
# For "core.latex.renderer" to work
image = {
enable = lib.mkIf (builtins.hasAttr "core.latex.renderer" config.plugins.neorg.settings.load) true;
settings.integrations = {
backend = "ueberzug";
neorg = {
enabled = true;
clearInInsertMode = true;
filetypes = [ "norg" ];
};
markdown = {
enabled = true;
clearInInsertMode = true;
filetypes = [
"markdown"
"vimwiki"
];
};
};
};
};
}

View file

@ -0,0 +1,36 @@
{
plugins = {
indent-blankline = {
enable = true;
settings = {
indent = {
char = ""; # "│" or "▎"
tab_char = "";
};
scope = {
enabled = true;
show_start = true;
};
exclude = {
buftypes = [
"terminal"
"nofile"
];
filetypes = [
"help"
"alpha"
"dashboard"
"neo-tree"
"Trouble"
"trouble"
"lazy"
"mason"
"notify"
"toggleterm"
"lazyterm"
];
};
};
};
};
}

77
config/plugins/leap.nix Normal file
View file

@ -0,0 +1,77 @@
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in
{
plugins.leap = {
enable = true;
addDefaultMappings = false;
};
keymaps = [
{
mode = [ "n" ];
key = "<leader>ss";
action = mkRaw "function () require('leap').leap {} end";
options.desc = "leap";
}
{
mode = [
"x"
"o"
];
key = "<leader>ss";
action = mkRaw "function () require('leap').leap { inclusive_op = true } end";
options.desc = "leap";
}
{
mode = [
"n"
"x"
"o"
];
key = "<leader>sS";
action = "<Plug>(leap-backward-to)";
options.desc = "leap-backward-to";
}
{
mode = [
"n"
"x"
"o"
];
key = "<leader>sx";
action = "<Plug>(leap-forward-till)";
options.desc = "leap-forward-till";
}
{
mode = [
"n"
"x"
"o"
];
key = "<leader>sX";
action = "<Plug>(leap-backward-till)";
options.desc = "leap-backward-till";
}
{
mode = [
"n"
"x"
"o"
];
key = "<leader>sgs";
action = "<Plug>(leap-from-window)";
options.desc = "leap-from-window";
}
{
mode = [
"n"
"x"
"o"
];
key = "<leader>sgs";
action = "<Plug>(leap-cross-window)";
options.desc = "leap-cross-window";
}
];
}

View file

@ -0,0 +1,19 @@
{
plugins.linediff.enable = true;
}
# { lib, ... }:
# lib.nixvim.plugins.mkVimPlugin {
# name = "linediff";
# packPathName = "linediff.vim";
# package = "linediff-vim";
#
# globalPrefix = "linediff_";
#
# maintainers = [ lib.maintainers.GaetanLepage ];
#
# settingsExample = {
# modify_statusline = 0;
# first_buffer_command = "topleft new";
# second_buffer_command = "vertical new";
# };

View file

@ -0,0 +1,152 @@
{
lib,
config,
helpers,
pkgs,
...
}:
let
inherit (helpers) mkRaw;
in
{
plugins = {
# https://github.com/stevearc/conform.nvim/
# Preserves extmarks and folds
# Fixes bad-behaving LSP formatters
# Enables range formatting for all formatters
# And more
conform-nvim = {
enable = lib.mkIf config.plugins.lsp.enable true;
settings = {
formatters_by_ft = {
perl = [ "perltidy" ];
# nix = ["nixfmt" "alejandra"];
nix = [ "nixfmt" ];
sh = [
"shellcheck"
"shellharden"
"shfmt"
];
bash = [
"shellcheck"
"shellharden"
"shfmt"
];
cpp = [ "clang_format" ];
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
timeout_ms = 2000;
stop_after_first = true;
};
lua = [ "stylua" ];
# -- Conform will run multiple formatters sequentially
python = [
"isort"
"black"
];
# -- You can customize some of the format options for the filetype (:help conform.format)
rust = {
_unkeyed-1 = "rustfmt";
lsp_format = "fallback";
};
tex = [ "latexindent" ];
# Use the "_" filetype to run formatters on filetypes that don't
# have other formatters configured.
"_" = [
"squeeze_blanks"
"trim_whitespace"
"trim_newlines"
];
};
# format_on_save =
# # Lua
# ''
# function(bufnr)
# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
# return
# end
#
# if slow_format_filetypes[vim.bo[bufnr].filetype] then
# return
# end
#
# local function on_format(err)
# if err and err:match("timeout$") then
# slow_format_filetypes[vim.bo[bufnr].filetype] = true
# end
# end
#
# return { timeout_ms = 200, lsp_fallback = true }, on_format
# end
# '';
# format_after_save =
# # Lua
# ''
# function(bufnr)
# if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
# return
# end
#
# if not slow_format_filetypes[vim.bo[bufnr].filetype] then
# return
# end
#
# return { lsp_fallback = true }
# end
# '';
log_level = "warn";
notify_on_error = true;
notify_no_formatters = true;
formatters = {
perltidy = {
command = lib.getExe pkgs.perlPackages.PerlTidy;
prepend_args = [ "-i=2" ]; # default 4 spaces
};
shfmt = {
command = lib.getExe pkgs.shfmt;
};
shellcheck = {
command = lib.getExe pkgs.shellcheck;
};
shellharden = {
command = lib.getExe pkgs.shellharden;
};
squeeze_blanks = {
command = lib.getExe' pkgs.coreutils "cat";
};
latexindent = {
command = lib.getExe' pkgs.texlivePackages.latexindent "latexindent";
# latexindent always produce indent.log in the current directory. It cannot be disabled in indentconfig.yaml
# This flag redirect it to /dev/null
prepend_args = [
"-g"
"/dev/null"
];
};
# alejandra = {
# command = lib.getExe pkgs.alejandra;
# prepend_args = ["--quiet"];
# };
nixfmt = {
command = lib.getExe pkgs.nixfmt-rfc-style;
};
stylua = {
command = lib.getExe pkgs.stylua;
};
};
};
};
};
keymaps = [
{
mode = [ "n" ];
key = "<leader>lf";
action = mkRaw ''
function()
require("conform").format()
end'';
options.desc = "Format with conform-nvim";
}
];
}

133
config/plugins/lsp/lsp.nix Normal file
View file

@ -0,0 +1,133 @@
{
lib,
...
}:
{
imports = [
./lspkind.nix
./conform-nvim.nix # fix lsp formatter issues
./servers/clangd.nix
./servers/eslint.nix
./servers/pyright.nix
./servers/ruff.nix
./servers/lua_ls.nix
./servers/bashls.nix
# ./servers/nil_ls.nix # replaced by nixd
./servers/nixd.nix
./servers/rust_analyzer.nix
./servers/ts_ls.nix
./servers/texlab/texlab.nix
];
plugins = {
# # https://github.com/lukas-reineke/lsp-format.nvim/
# # auto format on save
# lsp-format = {
# enable = false; # Enable it if you want lsp-format integration for none-ls
# };
# # formatter and diagnose
# none-ls = {
# enable = true;
# # don't enable use lsp-format plugin
# enableLspFormat = false;
# sources = {
# formatting = {
# alejandra.enable = true;
# stylua.enable = true;
# };
# };
# };
lsp = {
enable = true;
capabilities = "offsetEncoding = 'utf-16'";
keymaps = {
silent = true;
lspBuf = {
# use require("conform").format() instead
# "<space>lf" = {
# action = "format";
# desc = "Lsp format";
# };
gd = {
action = "definition";
desc = "Goto Definition";
};
gr = {
action = "references";
desc = "Goto References";
};
gD = {
action = "declaration";
desc = "Goto Declaration";
};
gI = {
action = "implementation";
desc = "Goto Implementation";
};
gT = {
action = "type_definition";
desc = "Type Definition";
};
K = {
action = "hover";
desc = "Hover";
};
"<leader>cw" = {
action = "workspace_symbol";
desc = "Workspace Symbol";
};
"<leader>cr" = {
action = "rename";
desc = "Rename";
};
"<leader>ca" = {
action = "code_action";
desc = "Code Action";
};
# "<C-k>" = {
"<C-S-k>" = {
action = "signature_help";
desc = "Signature Help";
};
};
diagnostic = {
"<leader>cd" = {
action = "open_float";
desc = "Line Diagnostics";
};
"[d" = {
action = "goto_next";
desc = "Next Diagnostic";
};
"]d" = {
action = "goto_prev";
desc = "Previous Diagnostic";
};
};
};
};
};
extraConfigLua = ''
local _border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, {
border = _border
}
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help, {
border = _border
}
)
vim.diagnostic.config{
float={border=_border}
};
require('lspconfig.ui.windows').default_options = {
border = _border
}
'';
}

View file

@ -0,0 +1,19 @@
{
lib,
config,
helpers,
...
}:
let
inherit (helpers) mkRaw;
in
{
# TJ
# https://www.youtube.com/watch?v=_DnmphIwnjo
plugins = {
# Make cmp have icons and colors
lspkind = {
enable = lib.mkIf config.plugins.cmp.enable true;
};
};
}

View file

@ -0,0 +1,24 @@
{
plugins.lsp.servers = {
bashls = {
enable = true;
filetypes = [
"sh"
"bash"
];
# extraOptions = {
# settings = {
# Lua = {
# completion = {
# callSnippet = "Replace";
# };
# telemetry = {
# enabled = false;
# };
# hint = {enable = true;};
# };
# };
# };
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
lsp.servers = {
clangd.enable = true;
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
lsp.servers = {
eslint.enable = true;
};
};
}

View file

@ -0,0 +1,22 @@
{
plugins.lsp.servers = {
lua_ls = {
enable = true;
extraOptions = {
settings = {
Lua = {
completion = {
callSnippet = "Replace";
};
telemetry = {
enabled = false;
};
hint = {
enable = true;
};
};
};
};
};
};
}

View file

@ -0,0 +1,12 @@
{
plugins.lsp.servers = {
nil_ls = {
enable = true;
# Fix error message:
# lsp.message LSP Message (nil_ls) Some flake inputs are not available, please run `nix flake archive` to fetch them.
# Your LSP client doesn't support confirmation. You can enable autoArchive in lsp configuration.
# https://github.com/oxalica/nil/issues/131#issuecomment-2241281279
settings.nix.flake.autoArchive = false;
};
};
}

View file

@ -0,0 +1,21 @@
{
variant,
lib,
self,
system,
...
}:
{
plugins.lsp.servers = {
nixd = {
enable = true;
settings = lib.mkMerge [
{
diagnostic.suppress = [ ];
# This will not be used, formatters use conform-nvim.nix instead in keymaps
# formatting.command = ["alejandra"];
}
];
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
lsp.servers = {
pyright.enable = true;
};
};
}

View file

@ -0,0 +1,7 @@
{
plugins = {
lsp.servers = {
ruff.enable = true;
};
};
}

View file

@ -0,0 +1,24 @@
{
plugins.lsp.servers = {
rust_analyzer = {
enable = true;
installCargo = true;
installRustc = true;
settings = {
checkOnSave = true;
check = {
command = "clippy";
};
# inlayHints = {
# enable = true;
# showParameterNames = true;
# parameterHintsPrefix = "<- ";
# otherHintsPrefix = "=> ";
# };
procMacro = {
enable = true;
};
};
};
};
}

View file

@ -0,0 +1 @@
# defaultIndent: " "

View file

@ -0,0 +1,117 @@
{
lib,
helpers,
...
}:
let
inherit (helpers) mkRaw;
use_tectonic = false;
in
{
plugins.lsp.servers = {
texlab = {
enable = true;
filetypes = [
"tex"
"plaintex"
"bib"
];
settings = {
texlab = {
# --------------------------------
# -- START texlab main config
# -- if used with texmagic, disable this
# --------------------------------
# https://github.com/latex-lsp/texlab/wiki/Configuration#deprecated-texlabauxdirectory
# auxDirectory = "tex_aux_output"; # deprecated
rootDirectory = false;
build = lib.mkMerge [
(lib.mkIf (!use_tectonic) {
executable = "latexmk";
args = [
"-xelatex"
"-verbose"
# -- "-outdir=%f_output"
# -- "-auxdir=%f_aux"
"-auxdir=tex_aux_output"
"-file-line-error"
# https://github.com/latex-lsp/texlab/wiki/Previewing
# use for forward serach and inverse search
"-synctex=1"
"-interaction=nonstopmode"
# "-pvc" # preview continuously update instead if -pv (open a new instance)
"%f"
];
})
(lib.mkIf use_tectonic {
executable = "tectonic";
# https://github.com/latex-lsp/texlab/wiki/Tectonic
# V2
args = [
"-X"
"compile"
"%f"
"--synctex"
"--keep-logs"
"--keep-intermediates"
];
})
{
auxDirectory = "tex_aux_output";
logDirectory = "tex_aux_output";
pdfDirectory = ".";
# -- forwardSearchAfter = true,
isContinuous = true;
# -- "onSave = true" failed to work properly with large files like moderncv
# -- it would not build properly until you delete all the intermediate files
onSave = true;
# --------------------------------
# -- END texlab main config
# -- if used with texmagic, disable this
# --------------------------------
# https://github.com/latex-lsp/texlab/wiki/Previewing#zathura
}
];
forwardSearch = {
executable = "zathura";
args = [
"--synctex-forward"
"%l:1:%f"
"%p"
];
};
# Inverse Search for zathura set in ~/.config/zathura/zathurarc
# set synctex true
# set synctex-editor-command "texlab inverse-search -i %{input} -l %{line}"
chktex = {
onOpenAndSave = true;
onEdit = true;
};
# https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/texlab.lua#L179-L183
# https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/texlab.lua#L179-L183
latexindent = {
local = ./indentconfig.yaml;
};
};
};
};
};
autoCmd = [
{
pattern = [ "tex" ];
event = [ "FileType" ];
callback = mkRaw ''
function()
-- vim.keymap.set( 'n', '<leader>TH', "<CMD>TexlabBuild<CR>", { desc = 'TexlabBuild' })
-- vim.keymap.set( 'n', '<leader>TD', "<CMD>TexlabCleanAuxiliary<CR>", { desc = 'TexlabCleanAuxiliary' })
-- vim.keymap.set( 'n', '<leader>TN', "<CMD>TexlabForward<CR>", { desc = 'TexlabForward' })
vim.keymap.set( 'n', '<leader>TH', function() vim.cmd.TexlabBuild() end, { desc = 'TexlabBuild' })
vim.keymap.set( 'n', '<leader>TD', function() vim.cmd.TexlabCancelBuild(); vim.cmd.TexlabCleanAuxiliary() end, { desc = 'TexlabCancelBuild+CleanAuxiliary' })
vim.keymap.set( 'n', '<leader>Td', function() vim.cmd.TexlabCleanArtifacts() end, { desc = 'TexlabCleanArtifacts' })
vim.keymap.set( 'n', '<leader>TN', function() vim.cmd.TexlabForward() end, { desc = 'TexlabForward' })
end
'';
}
];
}

View file

@ -0,0 +1,39 @@
{
plugins.lsp.servers = {
ts_ls = {
enable = false;
filetypes = [
"javascript"
"javascriptreact"
"typescript"
"typescriptreact"
];
extraOptions = {
settings = {
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
};
typescript = {
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
};
};
};
};
};
}

View file

@ -0,0 +1,27 @@
{
config,
lib,
...
}:
{
plugins = {
lualine = {
enable = true;
# Show @recording messages
# https://github.com/folke/noice.nvim/wiki/Configuration-Recipes#show-recording-messages
luaConfig.pre = lib.mkIf config.plugins.noice.enable ''
require("lualine").setup({
sections = {
lualine_x = {
{
require("noice").api.statusline.mode.get,
cond = require("noice").api.statusline.mode.has,
color = { fg = "#ff9e64" }
}
},
},
})
'';
};
};
}

View file

@ -0,0 +1,68 @@
local M = {}
-- stop lsp error messages
-- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#loaders
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
-- Example: expanding a snippet on a new line only.
-- In a snippet file, first require the line_begin condition...
local line_begin = conds.line_begin
-- This is the `get_visual` function I've been talking about.
-- ----------------------------------------------------------------------------
-- Summary: When `LS_SELECT_RAW` is populated with a visual selection, the function
-- returns an insert node whose initial text is set to the visual selection.
-- When `LS_SELECT_RAW` is empty, the function simply returns an empty insert node.
M.get_visual = function(_, parent, _, user_args)
if #parent.snippet.env.LS_SELECT_RAW > 0 then
return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW))
else -- If LS_SELECT_RAW is empty, return a blank insert node
return sn(nil, i(1, user_args))
end
end
-- https://github.com/L3MON4D3/LuaSnip/discussions/1195
M.make_single_curly_bracket_snippets = function(type, trig, command, user_args)
-- return s({trig=keyword,desc=desc}, {t"local function " .. keyword .. "(", i(1), t")"})
return s({
trig = trig,
desc = "Expand " .. trig .. " into \\" .. command .. "{}",
snippetType = type,
}, fmt("\\" .. command .. "{<>}", { d(1, M.get_visual, { user_args = { user_args } }) }, { delimiters = "<>" }))
end
M.make_scope_snippets = function(type, trig, command, user_args)
-- return s({trig=keyword,desc=desc}, {t"local function " .. keyword .. "(", i(1), t")"})
return s({
trig = trig,
desc = "Expand " .. trig .. " into {\\" .. command .. " ... }",
snippetType = type,
}, fmt("{\\" .. command .. " <>}", { d(1, M.get_visual, { user_args = { user_args } }) }, { delimiters = "<>" }))
end
return M

View file

@ -0,0 +1,102 @@
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in
{
plugins.luasnip = {
enable = true;
filetypeExtend = {
lua = [
"c"
"cpp"
];
};
settings = {
# https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#config-options
enable_autosnippets = true;
# https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#variables
cut_selection_keys = "<Tab>";
update_events = "TextChanged,TextChangedI";
};
# https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#lua
fromLua = [
{ paths = ./snippets; } # snippts attached to nixvim repo
{ paths = "~/snippets"; } # snippts in home dir
];
};
extraFiles = {
"lua/luasnip-helper-funcs.lua".source = ./helpers/luasnip-helper-funcs.lua;
};
# https://github.com/L3MON4D3/LuaSnip/wiki/Nice-Configs#hint-node-type-with-virtual-text
extraConfigLua = ''
local types = require("luasnip.util.types")
require'luasnip'.config.setup({
ext_opts = {
[types.choiceNode] = {
active = {
-- virt_text = {{"", "GruvboxOrange"}}
-- see ":h group-name" (syntax highlighting)
virt_text = {{ '««« Choice Node', 'Constant', }}
}
},
[types.insertNode] = {
active = {
-- virt_text = {{"", "GruvboxBlue"}}
-- see ":h group-name" (syntax highlighting)
virt_text = {{ '««« Insert Node', 'Comment', }}
}
}
},
})
'';
keymaps = [
{
mode = [
"i"
"s"
];
key = "<C-j>";
action = mkRaw ''
function()
local ls = require('luasnip')
if ls.expand_or_jumpable() then
ls.expand_or_jump()
end
end
'';
options.silent = true;
}
{
mode = [
"i"
"s"
];
key = "<C-k>";
action = mkRaw ''
function()
local ls = require('luasnip')
if ls.jumpable(-1) then
ls.jump(-1)
end
end
'';
options.silent = true;
}
{
mode = [
"i"
"s"
];
key = "<C-e>";
action = mkRaw ''
function()
local ls = require('luasnip')
if ls.choice_active() then
ls.change_choice(1)
end
end
'';
options.silent = true;
}
];
}

View file

@ -0,0 +1,62 @@
-- stop lsp error messages
-- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#loaders
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
-- tutorials:
-- https://ejmastnak.com/tutorials/vim-latex/luasnip/#anatomy
-- https://evesdropper.dev/files/luasnip/
return
-- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#lua
-- the files may return two lists of snippets, the snippets in the first are
-- all added as regular snippets, while the snippets in the second will be
-- added as autosnippets (both are the defaults, if a snippet defines a
-- different snippetType, that will have preference)
-- First list of snippets (snippetType = "snippet") start
{
s(
{trig = "attrs", dscr = "nix new attrs"},
fmta(
[[
<> = {
<> = <>
};
]]
, { i(1),i(2),i(3) })
),
},
-- First list of snippets (snippetType = "snippet") end
-- Second list of snippets (snippetType = "autosnippet") start
{
}
-- Second list of snippets (snippetType = "autosnippet") end

View file

@ -0,0 +1,20 @@
-- https://github.com/L3MON4D3/LuaSnip/wiki/Cool-Snippets#endless-list
local rec_ls
rec_ls = function()
return sn(nil, {
c(1, {
-- important!! Having the sn(...) as the first choice will cause infinite recursion.
t({""}),
-- The same dynamicNode as in the snippet (also note: self reference).
sn(nil, {t({"", "\t\\item "}), i(1), d(2, rec_ls, {})}),
}),
});
end
return {
s(";endlessitem", {
t({"\\begin{itemize}",
"\t\\item "}), i(1), d(2, rec_ls, {}),
t({"", "\\end{itemize}"}), i(0)
})
}

View file

@ -0,0 +1,40 @@
-- https://github.com/L3MON4D3/LuaSnip/wiki/Cool-Snippets#tabular
table_node= function(args)
local tabs = {}
local count
table = args[1][1]:gsub("%s",""):gsub("|","")
count = table:len()
for j=1, count do
local iNode
iNode = i(j)
tabs[2*j-1] = iNode
if j~=count then
tabs[2*j] = t" & "
end
end
return sn(nil, tabs)
end
rec_table = function ()
return sn(nil, {
c(1, {
t({""}),
sn(nil, {t{"\\\\",""} ,d(1,table_node, {ai[1]}), d(2, rec_table, {ai[1]})})
}),
});
end
return {
s(";table", {
t"\\begin{tabular}{",
i(1,"0"),
t{"}",""},
d(2, table_node, {1}, {}),
d(3, rec_table, {1}),
t{"","\\end{tabular}"}
}),
}

View file

@ -0,0 +1,102 @@
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return {
s(
{ trig = ";dcenvelope", dscr = "A LaTeX equation environment" },
fmta(
[[
% https://en.wikibooks.org/wiki/LaTeX/Letters#Envelopes
% https://tex.stackexchange.com/questions/268693/how-do-you-print-c4-envelopes
\documentclass{letter}
\usepackage{geometry}
\geometry{paperheight=9.25in,paperwidth=4.13in}
\usepackage{graphics}
\usepackage{envlab}
\usepackage[AutoFallBack=true]{xeCJK}
\setCJKmainfont<>
% from envlab
\SetEnvelope{9.25in}{4.13in}
% from envlab
\setlength{\ToAddressTopMargin}{0in} %Arbitrarily decided by me
% from envlab
\setlength{\ToAddressLeftMargin}{1in} %Arbitrarily decided by me
% from envlab
\makelabels
\begin{document}
\startlabels
% from envlab
\mlabel
{% This "%" is required to make alignment right
%
% Sender Address
%
% append \\ at the end of the line before inserting newline
%
% e.g. Title\\
% Address line1\\
% Address line2\\
% Address line3
<>
}
{% This "%" is required to make alignment right
%
% Reciever Address
%
% append \\ at the end of the line before inserting newline
%
% e.g. Title\\
% Address line1\\
% Address line2\\
% Address line3
<>
% if print with lpr use command "lpr -o media=EnvYou4"
}
\end{document}
]],
{
c(1, {
t({
"{Source Han Serif TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"{Source Han Sans TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]{SourceHanSerif.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
" ,UprightFeatures = {FontIndex=28}",
" ,BoldFeatures = {FontIndex=38}",
"]\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=28}",
",BoldFeatures = {FontIndex=38}",
"]{SourceHanSans.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
}),
i(3, "% Sender Address"),
i(2, "% Reciever Address"),
}
),
{ condition = line_begin } -- set condition in the `opts` table
),
}

View file

@ -0,0 +1,74 @@
local helpers = require("luasnip-helper-funcs")
local get_visual = helpers.get_visual
return {
s(
{ trig = ";dcinit", snippetType = "snippet" },
fmta(
[[
\documentclass[<>]{<>}
\usepackage[<>]{geometry}
\usepackage[AutoFallBack=true]{xeCJK}
\setCJKmainfont<>
\begin{document}
<><>
\end{document}
]],
{
c(1, {
t(""),
t("a4paper"),
t("letter"),
t("20pt"),
}),
c(2, {
t("article"),
t("extarticle"),
t("report"),
t("moderncv"),
}),
c(3, {
t(""),
t("margin=3cm"),
t("top=3cm,bottom=3cm,left=3cm,right=3cm"),
}),
c(4, {
t({
"{Source Han Serif TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"{Source Han Sans TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]{SourceHanSerif.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
" ,UprightFeatures = {FontIndex=28}",
" ,BoldFeatures = {FontIndex=38}",
"]\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=28}",
",BoldFeatures = {FontIndex=38}",
"]{SourceHanSans.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
}),
d(5, get_visual, {}, { user_args = { "Content here" } }),
i(0),
}
)
),
}

View file

@ -0,0 +1,30 @@
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return {
s(
{ trig = ";dcwatermark", dscr = "Top-right corner watermark" },
fmta(
[[
\documentclass[a4paper]{article}
\usepackage[top=.2in,right=.2in]{geometry}
\usepackage{xcolor}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
% switch off page number
% https://tex.stackexchange.com/questions/7355/how-to-suppress-page-number
\pagenumbering{gobble}
% https://superuser.com/questions/280659/how-can-i-apply-a-watermark-on-every-page-of-a-pdf-file
% pdftk original.pdf stamp watermark.pdf output final.pdf
\hfill {\Large \textcolor{red}{``<>''}}
\end{document}
]],
{
i(1, "Insert watermark"),
}
),
{ condition = line_begin } -- set condition in the `opts` table
),
}

View file

@ -0,0 +1,72 @@
local line_begin = require("luasnip.extras.expand_conditions").line_begin
local helpers = require("luasnip-helper-funcs")
local get_visual = helpers.get_visual
local mkscbs = helpers.make_single_curly_bracket_snippets
local mkss = helpers.make_scope_snippets
-- mkscbs ("snippetType", "trig", "command", "desc")
return
-- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#lua
-- First list of snippets (snippetType = "snippet") start
{
mkscbs("snippet", ";tt", "texttt", "teletypefont"),
mkscbs("snippet", ";ti", "textit", "italic shape"),
mkscbs("snippet", ";bf", "textbf", "bold"),
mkscbs("snippet", ";em", "emph", "emphasis"),
mkscbs("snippet", ";em", "emph", "emphasis"),
mkscbs("snippet", ";sf", "sfont", "secondary font"),
s(
{ trig = ";url", dscr = "The hyperref package's href{}{} command (for url links)" },
fmta("\\href{<>}{<>}", {
d(1, get_visual, { 1 }, { user_args = { "url" } }),
i(2, "display name"),
})
),
s(
-- https://en.wikibooks.org/wiki/LaTeX/Paragraph_Formatting#Verbatim_text
{ trig = ";vb", dscr = "Expands 'vb' into '\\verb++' (verbatim phrase, + as delimiters (can be changed))" },
fmta("\\verb<><><>", { i(1, "+"), d(2, get_visual, {}, { user_args = { "verbatim phrase" } }), rep(1) })
),
s(
{ trig = ";begin", dscr = "A LaTeX equation environment" },
fmta(
[[
\begin{<>}
<><>
\end{<>}
]],
-- The insert node is placed in the <> angle brackets
{ i(1), d(2, get_visual, {}, { user_args = { "Content here" } }), i(0), rep(1) }
),
{ condition = line_begin } -- set condition in the `opts` table
),
s(
{ trig = ";ff", dscr = "Expands 'ff' into '\\frac{}{}'" },
fmt("\\fanc{<>}{<>}", { i(1), i(2) }, { delimiters = "<>" })
),
-- Example use of insert node placeholder text
s({ trig = ";s", desc = "square bracket" }, fmta("\\<>[<>]", { i(1, "command"), d(2, get_visual) })),
s({ trig = ";c", desc = "curly bracket" }, fmta("\\<>{<>}", { i(1, "command"), d(2, get_visual) })),
s({ trig = ";cc", desc = "curly bracket + curly bracket" }, fmta("\\<>{<>}{<>}", { i(1, "command"), i(3), i(2) })),
s({ trig = ";sc", desc = "square bracket + curly bracket" }, fmta("\\<>[<>]{<>}", { i(1, "command"), i(3), i(2) })),
-- s(
-- { trig = ";tt", dscr = "Expands 'tt' into '\\texttt{}' (teletypefont family)" },
-- fmta("\\texttt{<>}", { d(1, get_visual, {}, { user_args = { "teletypefont" } }) })
-- ),
-- s(
-- { trig = ";ti", dscr = "Expands 'ti' into '\\textit{}' (italic shape)" },
-- fmta("\\textit{<>}", { d(1, get_visual, {}, { user_args = { "italic shape" } }) })
-- ),
-- s(
-- { trig = ";bf", dscr = "Expands 'bf' into '\\textbf{}' (bold)" },
-- fmta("\\textbf{<>}", { d(1, get_visual, {}, { user_args = { "bold" } }) })
-- ),
-- s(
-- { trig = ";em", dscr = "Expands 'em' into '\\emph{}' (emphasis)" },
-- fmta("\\emph{<>}", { d(1, get_visual, {}, { user_args = { "emphasis" } }) })
-- ),
},
-- First list of snippets (snippetType = "snippet") end
-- Second list of snippets (snippetType = "autosnippet") start
{}
-- Second list of snippets (snippetType = "autosnippet") end

View file

@ -0,0 +1,75 @@
return {
s(
";updarkmode",
t({
"\\usepackage{xcolor}",
"\\pagecolor[rgb]{0.1,0.1,0.1}",
"\\color[rgb]{1,1,1}",
})
),
s(";upurlpackage", t("\\usepackage{hyperref}")),
-- % https://old.reddit.com/r/LaTeX/comments/m8frij/aligning_text_across_lines/
-- % allign dates in working experience
-- for \brlap or \stackunder or \bllap
s(";upstack", t("\\usepackage{stackengine}")),
-- % for \CurrentLineWidth
s(";uptabto", t("\\usepackage{tabto}")),
-- % https://tex.stackexchange.com/questions/5036/how-to-prevent-latex-from-hyphenating-the-entire-document
-- % disable hyphenation at the edge
s(";upnohyphen", t("\\usepackage[none]{hyphenat}")),
s(";upinpututf8", t("\\usepackage[utf8]{inputenc}")),
s(";up", fmta("\\usepackage[<>]{<>}", { i(2), i(1) })),
-- Help using xeCJK
-- https://tex.stackexchange.com/questions/510853/using-one-xecjk-font-family-on-english-and-chinese-at-the-same-time
-- https://tex.stackexchange.com/questions/264265/defining-subfamilies-for-a-font/264275#264275
s(
";upxecjk",
fmta(
[[
\usepackage[AutoFallBack=true]{xeCJK}
\setCJKmainfont<>
]],
{
c(1, {
t({
"{Source Han Serif TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"{Source Han Sans TC}",
"\\newCJKfontfamily\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]{SourceHanSerif.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
" ,UprightFeatures = {FontIndex=28}",
" ,BoldFeatures = {FontIndex=38}",
"]\\secondaryfont{Source Han Sans TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
t({
"[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=28}",
",BoldFeatures = {FontIndex=38}",
"]{SourceHanSans.ttc}",
"\\newCJKfontfamily[Path=\\string~/.local/share/fonts/",
",UprightFeatures = {FontIndex=13}",
",BoldFeatures = {FontIndex=28}",
"]\\secondaryfont{Source Han Serif TC}",
"\\newcommand*{\\sfont}[1]{{\\secondaryfont #1}}",
}),
}),
}
)
),
}

75
config/plugins/mini.nix Normal file
View file

@ -0,0 +1,75 @@
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in
{
# evaluation warning: Nixvim: `plugins.web-devicons` was enabled automatically because the following plugins are enabled.
# This behaviour is deprecated. Please explicitly define `plugins.web-devicons.enable` or alternatively
# enable `plugins.mini.enable` with `plugins.mini.modules.icons` and `plugins.mini.mockDevIcons`.
# plugins.telescope
# plugins.nvim-tree
# plugins.bufferline
plugins = {
mini = {
enable = true;
# https://nix-community.github.io/nixvim/plugins/mini/index.html
modules.icons = {
ai = {
n_lines = 50;
search_method = "cover_or_next";
};
comment = {
mappings = {
comment = "<leader>/";
comment_line = "<leader>/";
comment_visual = "<leader>/";
textobject = "<leader>/";
};
};
diff = {
view = {
style = "sign";
};
};
starter = {
content_hooks = {
"__unkeyed-1.adding_bullet" = mkRaw "require('mini.starter').gen_hook.adding_bullet()";
"__unkeyed-2.indexing" =
mkRaw "require('mini.starter').gen_hook.indexing('all', { 'Builtin actions' })";
"__unkeyed-3.padding" = mkRaw "require('mini.starter').gen_hook.aligning('center', 'center')";
};
evaluate_single = true;
header = ''
'';
items = {
"__unkeyed-1.buildtin_actions" = mkRaw "require('mini.starter').sections.builtin_actions()";
"__unkeyed-2.recent_files_current_directory" =
mkRaw "require('mini.starter').sections.recent_files(10, false)";
"__unkeyed-3.recent_files" = mkRaw "require('mini.starter').sections.recent_files(10, true)";
"__unkeyed-4.sessions" = mkRaw "require('mini.starter').sections.sessions(5, true)";
};
};
surround = {
mappings = {
add = "gsa";
delete = "gsd";
find = "gsf";
find_left = "gsF";
highlight = "gsh";
replace = "gsr";
update_n_lines = "gsn";
};
};
};
# https://nix-community.github.io/nixvim/plugins/mini/index.html
# Whether to tell mini.icons to emulate nvim-web-devicons for plugins that dont natively support it.
# When enabled, you dont need to set plugins.web-devicons.enable. This will replace the need for it.
mockDevIcons = true;
};
};
}

151
config/plugins/neorg.nix Normal file
View file

@ -0,0 +1,151 @@
{
pkgs,
pkgs-stable,
helpers,
...
}:
let
inherit (helpers) mkRaw;
in
{
# https://github.com/nvim-neorg/neorg
# NOW neorg require lua-utils.nvim, nvim-nio, pathlib.vim
# https://github.com/nix-community/nixvim/issues/1395#issuecomment-2267262919
# Workaround
# extraPlugins = [
# (pkgs.vimUtils.buildVimPlugin {inherit (pkgs.luaPackages.lua-utils-nvim) pname version src;})
#
# (pkgs.vimUtils.buildVimPlugin {inherit (pkgs.luaPackages.pathlib-nvim) pname version src;})
#
# (pkgs.vimUtils.buildVimPlugin {inherit (pkgs.luaPackages.nvim-nio) pname version src;})
# ];
plugins = {
# https://haseebmajid.dev/posts/2024-04-21-til-how-to-fix-neorg-metadata-treesitter-issues-with-nixvim/
# no need to use neorg-overlay inputs when also add these treesitter
treesitter = {
grammarPackages = with pkgs.tree-sitter-grammars; [
tree-sitter-norg
tree-sitter-norg-meta
];
};
neorg = {
enable = true;
# package = pkgs-stable.vimPlugins.neorg;
# package = pkgs.vimPlugins.neorg;
# lazyLoading = true;
settings.load = {
"core.defaults" = helpers.emptyTable; # -- Loads default behaviour
"core.summary" = helpers.emptyTable;
"core.export" = helpers.emptyTable;
"core.export.markdown" = helpers.emptyTable;
"core.concealer" = {
config = {
folds = true;
};
}; # -- Adds pretty icons to your documents
"core.dirman" = {
config = {
workspaces = {
n = "~/neorg/notes";
e = "~/neorg/english";
l = "~/neorg/letter";
g = "~/neorg/grammar";
p = "~/neorg/perl";
m = "~/neorg/misc";
c = "~/neorg/nc";
# nvim = "~/.config/nvim/NeorgNvimNotes";
};
default_workspace = "c";
};
};
"core.keybinds" = {
config = {
default_keybinds = true;
# # Raw lua
# # https://github.com/nix-community/nixvim#raw-lua
# hook = mkRaw ''
# function(keybinds)
# keybinds.unmap("norg", "i", "<M-CR>")
# keybinds.remap_event("norg", "i", "<S-CR>", "core.itero.next-iteration", "<CR>")
# end
# '';
};
};
# "core.latex.renderer" = helpers.emptyTable;
"core.qol.toc" = {
config = {
close_after_use = true;
};
};
};
};
};
autoCmd = [
{
pattern = [ "norg" ];
event = [ "FileType" ];
callback = mkRaw ''
function()
vim.opt.formatoptions:remove('r')
vim.opt.formatoptions:remove('o')
-- use this insteand: ['core.concealer'] = { config = { folds = false }, },
vim.opt.foldlevelstart = 99
-- https://github.com/nvim-neorg/neorg/discussions/1066
vim.opt.conceallevel = 2
vim.keymap.set( 'n', '<leader>nT', function()
if vim.opt.conceallevel:get() == 2 then
vim.opt.conceallevel = 0
elseif vim.opt.conceallevel:get() == 0 then
vim.opt.conceallevel = 2
end
vim.cmd('Neorg toggle-concealer')
end, { desc = '[neorg] toggle-concealer and conceallevel' })
vim.keymap.set( 'n', '<leader>ng', function() vim.cmd.Neorg('generate-workspace-summary') end, { desc = '[neorg] generate-workspace-summary' })
vim.keymap.set( 'n', '<leader>nt', function() vim.cmd.Neorg('toc') end, { desc = '[neorg] Table of Content' })
vim.keymap.set( 'n', '<leader>nm', function() vim.cmd.Neorg('inject-metadata') end, { desc = '[neorg] Inject metadata' })
vim.keymap.set( 'n', '<leader>nj', function() vim.api.nvim_feedkeys(':Neorg journal ', 'n', true) end, { desc = '[neorg] Neorg journal <fill>' })
vim.keymap.set( 'n', '<leader>tn', "<Plug>(neorg.qol.todo-items.todo.task-cycle)", { desc = "[neorg] Cycle Task" })
vim.keymap.set('i', "<S-CR>", "<Plug>(neorg.itero.next-iteration)", {} )
end
'';
}
];
keymaps = [
{
mode = [ "n" ];
key = "<leader>nw";
action = mkRaw ''function() vim.api.nvim_feedkeys(':Neorg workspace ', 'n', true) end '';
options.desc = "[neorg] Neorg workspace <fill>";
}
{
mode = [ "n" ];
key = "<leader>nc";
action = mkRaw ''function() vim.cmd('Neorg workspace c') end '';
options.desc = "[neorg] Neorg workspace c";
}
{
mode = [ "n" ];
key = "<leader>ni";
action = mkRaw ''function() vim.cmd('Neorg index') end '';
options.desc = "[neorg] Neorg index";
}
{
mode = [ "n" ];
key = "<leader>nr";
action = mkRaw ''function() vim.cmd('Neorg return') end '';
options.desc = "[neorg] Neorg return";
}
{
mode = [ "n" ];
key = "<leader>ne";
action = mkRaw ''function() vim.cmd('Neorg workspace e') end '';
options.desc = "[neorg] Neorg workspace e (neorg-english)";
}
];
}

View file

@ -0,0 +1,30 @@
{ helpers, ... }:
{
plugins = {
neoscroll = {
enable = true;
settings = {
easing_function = "sine";
};
};
};
# https://github.com/karb94/neoscroll.nvim
extraConfigLua = ''
neoscroll = require('neoscroll')
local keymap = {
["<C-u>"] = function() neoscroll.ctrl_u({ duration = 80 }) end;
["<C-d>"] = function() neoscroll.ctrl_d({ duration = 80 }) end;
["<C-b>"] = function() neoscroll.ctrl_b({ duration = 80 }) end;
["<C-f>"] = function() neoscroll.ctrl_f({ duration = 80 }) end;
["<C-y>"] = function() neoscroll.scroll(-0.1, { move_cursor=false; duration = 40 }) end;
["<C-e>"] = function() neoscroll.scroll(0.1, { move_cursor=false; duration = 40 }) end;
["zt"] = function() neoscroll.zt({ half_win_duration = 80 }) end;
["zz"] = function() neoscroll.zz({ half_win_duration = 80 }) end;
["zb"] = function() neoscroll.zb({ half_win_duration = 80 }) end;
}
local modes = { 'n', 'v', 'x' }
for key, func in pairs(keymap) do
vim.keymap.set(modes, key, func)
end
'';
}

61
config/plugins/noice.nix Normal file
View file

@ -0,0 +1,61 @@
{
plugins = {
noice = {
enable = true;
# This does not work when "luaConfig.pre" is used
#
# settings = {
# # https://github.com/folke/noice.nvim/wiki/Configuration-Recipes#classic-cmdline
# # Classic Cmdline
# cmdline.view = "cmdline";
# presets = {
# bottom_search = true;
# command_palette = true;
# };
# # auto fallback to mini when nvim-notify not use
# # this force use min in :messages
# # messages.view = "mini";
# };
# https://github.com/folke/noice.nvim/blob/main/lua/noice/config/views.lua
# set mini (:messages) timeout to 5000
# https://github.com/folke/noice.nvim/issues/226#issuecomment-1324011122
# set mini win_options.winblend = 0 (for transparency)
luaConfig.pre = ''
require("noice").setup({
-- https://github.com/folke/noice.nvim/wiki/Configuration-Recipes#classic-cmdline
-- Classic Cmdline
cmdline = {
view = "cmdline",
},
messages = {
view = "mini", -- default fallback
},
presets = {
bottom_search = true,
command_palette = true,
},
views = {
mini = {
timeout = 10000,
win_options = {
winblend = 0
},
},
},
})
'';
};
};
keymaps = [
{
mode = "n";
key = "cm";
action = "<CMD>NoiceDismiss<CR>";
options = {
desc = "Dismiss noice messages";
};
}
];
}

24
config/plugins/notify.nix Normal file
View file

@ -0,0 +1,24 @@
{
config,
lib,
...
}:
{
plugins = {
# notify.nvim
notify = {
enable = lib.mkIf config.plugins.noice.enable true;
settings = {
# https://github.com/rcarriga/nvim-notify/issues/183#issuecomment-1464892813
on_open = ''
function(win)
vim.api.nvim_win_set_config(win, { focusable = false })
end
'';
background_colour = "#000000";
top_down = false;
render = "minimal";
};
};
};
}

View file

@ -0,0 +1,4 @@
{ pkgs, ... }:
{
extraPlugins = with pkgs.vimPlugins; [ nvim-jqx ];
}

View file

@ -0,0 +1,9 @@
{
plugins = {
# https://github.com/nvim-tree/nvim-tree.lua
# A File Explorer For Neovim Written In Lua
nvim-tree = {
enable = true;
};
};
}

22
config/plugins/oil.nix Normal file
View file

@ -0,0 +1,22 @@
{
plugins = {
oil = {
enable = true;
settings = {
view_options = {
show_hidden = true;
};
};
};
};
keymaps = [
{
mode = "n";
key = "--";
action = "<CMD>Oil<CR>";
options = {
desc = "Open parent directory";
};
}
];
}

View file

@ -0,0 +1,7 @@
{
plugins = {
sleuth = {
enable = true;
};
};
}

View file

@ -0,0 +1,226 @@
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in
{
plugins.telescope = {
enable = true;
extensions = {
fzf-native = {
enable = true;
};
ui-select = {
settings = {
specific_opts = {
codeactions = true;
};
};
};
undo = {
enable = true;
};
};
# If you'd prefer Telescope not to enter a normal-like mode when hitting escape (and instead exiting), you can map <Esc> to do so via:
settings = {
defaults = {
sorting_strategy = "ascending";
mappings = {
i = {
"<esc>" = mkRaw ''
function(...)
return require("telescope.actions").close(...)
end'';
};
};
};
};
keymaps = {
"<leader><space>" = {
action = "find_files";
options.desc = "[F]ind [F]iles";
};
"<leader>fg" = {
action = "live_grep";
options.desc = "[F]ind files by [G]rep";
};
"<leader>cm" = {
action = "command_history";
options.desc = "[C]ommand [H]istory";
};
"<leader>s." = {
action = "oldfiles";
options.desc = "[S]earch Recent Files (\".\" for repeat)";
};
"<leader>fb" = {
action = "buffers";
options.desc = "[F]ind [B]uffers";
};
"<leader>gf" = {
action = "git_files";
options.desc = "Search [G]it [F]iles";
};
"<leader>gc" = {
action = "git_commits";
options.desc = "[G]it [C]ommits";
};
"<leader>gs" = {
action = "git_status";
options.desc = "[G]it [S]tatus";
};
"<leader>sa" = {
action = "autocommands";
options.desc = "[S]earch [A]uto Commands";
};
"<leader>sb" = {
action = "current_buffer_fuzzy_find";
options.desc = "[S]earch current [B]uffer (fuzzy find)";
};
"<leader>sB" = {
action = "bulitin";
options.desc = "[S]earch [B]uiltins";
};
"<leader>sc" = {
action = "command_history";
options.desc = "[C]ommand [H]istory";
};
"<leader>sC" = {
action = "commands";
options.desc = "[S]earch [C]ommands";
};
"<leader>sD" = {
action = "diagnostics";
options.desc = "[S]earch [D]iagnostics";
};
"<leader>sh" = {
action = "help_tags";
options.desc = "[S]earch [H]elp pages";
};
"<leader>sH" = {
action = "highlights";
options.desc = "[S]earch [H]ighlight Groups";
};
"<leader>sk" = {
action = "keymaps";
options.desc = "[S]earch [K]eymaps";
};
"<leader>sM" = {
action = "man_pages";
options.desc = "[S]eanch [M]an pages";
};
"<leader>sm" = {
action = "marks";
options.desc = "[S]eanch (jump) to [M]ark";
};
"<leader>so" = {
action = "vim_options";
options.desc = "[S]earch vim [O]ptions";
};
"<leader>sR" = {
action = "resume";
options.desc = "[S]earch [R]esume";
};
"<leader>C" = {
action = "colorscheme";
options.desc = "[C]olorscheme preview";
};
};
};
keymaps = [
{
mode = [ "n" ];
key = "<leader>ffn";
action = mkRaw ''
function () require("telescope.builtin").find_files
{ cwd = "~/forgejo/nixos-configs/" }
end
'';
options.desc = "Find files in nixos-configs";
}
{
mode = [ "n" ];
key = "<leader>ffm";
action = mkRaw ''
function () require("telescope.builtin").find_files
{ cwd = "~/forgejo/my_nixvim/" }
end
'';
options.desc = "Find files in my_nixvim";
}
];
# use -j1 for ripgrep
# https://github.com/nvim-telescope/telescope.nvim/issues/647#issuecomment-1536456802
# keymaps = [
# {
# mode = [ "n" ];
# key = "<leader><space>";
# action = mkRaw ''function () require("telescope.builtin").find_files({ additional_args = { "-j1" }}) end'';
# options.desc = "Find project files";
# }
# {
# mode = [ "n" ];
# key = "<leader>fg";
# action = mkRaw ''function () require("telescope.builtin").live_grep({ additional_args = { "-j1" }}) end'';
# options.desc = "Grep (root dir)";
# }
# {
# mode = [ "n" ];
# key = "<leader>ff";
# action = mkRaw ''function () require("telescope.builtin").find_files({ additional_args = { "-j1" }}) end'';
# options.desc = "Find project files";
# }
# ];
extraConfigLua = ''
local telescope = require('telescope')
telescope.setup{
pickers = {
colorscheme = {
enable_preview = true
},
-- To prevent crash on slow machines
-- Replace (ripgrep --files) with gnu find for "find_files"
find_files = {
-- enable hidden file/folder search, but exclude hidden folder in find_command
hidden = true,
find_command = {
"find",
".",
"(",
"-path",
"*/.*",
"-type",
"d",
")",
"-prune",
"-o",
"-type",
"f",
"-printf",
"%P\n"
},
},
},
-- To prevent crash on slow machines
-- Replace ripgrep with gnu grep for "live_grep" and "grep_string"
-- https://github.com/nvim-telescope/telescope.nvim/issues/2083#issuecomment-1215476157
defaults = {
vimgrep_arguments = {
"grep",
"--extended-regexp",
"--color=never",
"--with-filename",
"--line-number",
"-b", -- grep doesn't support a `--column` option :(
"--ignore-case",
"--recursive",
"--no-messages",
"--exclude-dir=*cache*",
"--exclude-dir=*.git",
"--exclude=.*",
"--binary-files=without-match", -- skip binary files
}
}
}
'';
}

View file

@ -0,0 +1,16 @@
{
config,
lib,
...
}:
{
plugins = {
treesitter = {
enable = true;
nixvimInjections = true;
# For neorg formatting (italic/bold/etc) to work properly
# https://github.com/nvim-neorg/neorg/wiki/Dependencies#nvim-treesitter-plugin
settings.highlight.enable = lib.mkIf config.plugins.neorg.enable true;
};
};
}

View file

@ -0,0 +1,40 @@
{ helpers, ... }:
let
inherit (helpers) mkRaw;
in
{
plugins = {
undotree = {
enable = true;
settings = {
CursorLine = true;
DiffAutoOpen = true;
DiffCommand = "diff";
DiffpanelHeight = 10;
HelpLine = true;
HighlightChangedText = true;
HighlightChangedWithSign = true;
HighlightSyntaxAdd = "DiffAdd";
HighlightSyntaxChange = "DiffChange";
HighlightSyntaxDel = "DiffDelete";
RelativeTimestamp = true;
SetFocusWhenToggle = true;
ShortIndicators = false;
SplitWidth = 40;
TreeNodeShape = "*";
TreeReturnShape = "\\";
TreeSplitShape = "/";
TreeVertShape = "|";
WindowLayout = 4;
};
};
};
keymaps = [
{
mode = "n";
key = "<leader>u";
action = mkRaw "vim.cmd.UndotreeToggle";
options.desc = "UndoTreeToggle";
}
];
}

View file

@ -0,0 +1,7 @@
{
plugins = {
which-key = {
enable = true;
};
};
}