This commit is contained in:
2025-02-06 17:45:39 +02:00
commit a3f3abb460
84 changed files with 5567 additions and 0 deletions

View File

@ -0,0 +1,42 @@
{
lib,
config,
...
}: {
options = {
better-escape.enable = lib.mkEnableOption "Enable better-escape module";
};
config = lib.mkIf config.better-escape.enable {
plugins.better-escape = {
enable = true;
settings = {
timeout = 200;
default_mappings = false;
mappings = {
i = {
j = {
k = "<Esc>";
j = "<Esc>";
};
};
c = {
j = {
k = "<Esc>";
j = "<Esc>";
};
};
v = {
j = {
k = "<Esc>";
};
};
s = {
j = {
k = "<Esc>";
};
};
};
};
};
};
}

28
config/utils/cloak.nix Normal file
View File

@ -0,0 +1,28 @@
{
lib,
config,
...
}: {
options = {
cloak.enable = lib.mkEnableOption "Enable cloak module";
};
config = lib.mkIf config.cloak.enable {
plugins.cloak = {
enable = true;
settings = {
cloak_character = "*";
highlight_group = "Comment";
patterns = [
{
file_pattern = [
".env*"
"wrangler.toml"
".dev.vars"
];
cloak_pattern = "=.+";
}
];
};
};
};
}

View File

@ -0,0 +1,14 @@
{
lib,
config,
...
}: {
options = {
colorizer.enable = lib.mkEnableOption "Enable nvim-colorizer module";
};
config = lib.mkIf config.colorizer.enable {
plugins.colorizer = {
enable = true;
};
};
}

60
config/utils/default.nix Normal file
View File

@ -0,0 +1,60 @@
{
lib,
config,
...
}: {
imports = [
./better-escape.nix
./cloak.nix
./colorizer.nix
./harpoon.nix
./markdown-preview.nix
./mini.nix
./neocord.nix
./neotest.nix
./nvim-autopairs.nix
./nvim-surround.nix
./nvterm.nix
./oil.nix
./persistence.nix
./plenary.nix
./project-nvim.nix
./sidebar.nix
./tmux-navigator.nix
./todo-comments.nix
./ultimate-autopair.nix
./undotree.nix
./wakatime.nix
./which-key.nix
./wilder.nix
];
options = {
utils.enable = lib.mkEnableOption "Enable utils module";
};
config = lib.mkIf config.utils.enable {
better-escape.enable = lib.mkDefault true;
cloak.enable = lib.mkDefault true;
harpoon.enable = lib.mkDefault false;
markdown-preview.enable = lib.mkDefault false;
mini.enable = lib.mkDefault true;
neocord.enable = lib.mkDefault false;
neotest.enable = lib.mkDefault true;
nvim-autopairs.enable = lib.mkDefault true;
colorizer.enable = lib.mkDefault true;
nvim-surround.enable = lib.mkDefault true;
nvterm.enable = lib.mkDefault true;
oil.enable = lib.mkDefault true;
persistence.enable = lib.mkDefault true;
plenary.enable = lib.mkDefault true;
project-nvim.enable = lib.mkDefault true;
sidebar.enable = lib.mkDefault false;
tmux-navigator.enable = lib.mkDefault true;
todo-comments.enable = lib.mkDefault true;
ultimate-autopair.enable = lib.mkDefault true;
undotree.enable = lib.mkDefault true;
wakatime.enable = lib.mkDefault false;
which-key.enable = lib.mkDefault true;
wilder.enable = lib.mkDefault false;
};
}

26
config/utils/harpoon.nix Normal file
View File

@ -0,0 +1,26 @@
{
lib,
config,
...
}: {
options = {
harpoon.enable = lib.mkEnableOption "Enable harpoon module";
};
config = lib.mkIf config.harpoon.enable {
plugins.harpoon = {
enable = true;
enableTelescope = true;
keymapsSilent = true;
keymaps = {
addFile = "<leader>ha";
toggleQuickMenu = "<C-e>";
navFile = {
"1" = "<leader>hj";
"2" = "<leader>hk";
"3" = "<leader>hl";
"4" = "<leader>hm";
};
};
};
};
}

View File

@ -0,0 +1,29 @@
{
lib,
config,
...
}: {
# TODO: Switch to peek.nvim
options = {
markdown-preview.enable = lib.mkEnableOption "Enable markdown-preview module";
};
config = lib.mkIf config.markdown-preview.enable {
plugins.markdown-preview = {
enable = true;
settings = {
browser = "firefox";
theme = "dark";
};
};
keymaps = [
{
mode = "n";
key = "<leader>cp";
action = "<cmd>MarkdownPreview<cr>";
options = {
desc = "Markdown Preview";
};
}
];
};
}

28
config/utils/mini.nix Normal file
View File

@ -0,0 +1,28 @@
{
lib,
config,
...
}: {
options = {
mini.enable = lib.mkEnableOption "Enable mini module";
};
config = lib.mkIf config.mini.enable {
plugins.mini = {
enable = true;
modules = {
comment = {
options = {
customCommentString = ''
<cmd>lua require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring<cr>
'';
};
};
cursorword = {
opts = {
delay = 100;
};
};
};
};
};
}

36
config/utils/neocord.nix Normal file
View File

@ -0,0 +1,36 @@
{
lib,
config,
...
}: {
options = {
neocord.enable = lib.mkEnableOption "Enable neocord module";
};
config = lib.mkIf config.neocord.enable {
plugins.neocord = {
enable = true;
settings = {
auto_update = true;
blacklist = [];
client_id = "1157438221865717891";
debounce_timeout = 10;
editing_text = "Editing...";
enable_line_number = true;
logo = "https://repository-images.githubusercontent.com/325421844/ecb73f47-cb89-4ee0-a0fd-9743c2f3569a";
logo_tooltip = "NixVim";
file_assets = null;
file_explorer_text = "Browsing...";
git_commit_text = "Committing changes...";
global_timer = true;
line_number_text = "Line %s out of %s";
log_level = null;
main_image = "logo";
plugin_manager_text = "Managing plugins...";
reading_text = "Reading...";
show_time = true;
terminal_text = "Using Terminal...";
workspace_text = "Working on %s";
};
};
};
}

144
config/utils/neotest.nix Normal file
View File

@ -0,0 +1,144 @@
{
lib,
config,
pkgs,
...
}: {
# TODO: Refactor this as neotest is supported on nixvim now
options = {
neotest.enable = lib.mkEnableOption "Enable neotest module";
};
config = lib.mkIf config.neotest.enable {
extraPlugins = with pkgs.vimPlugins; [
# (pkgs.vimUtils.buildVimPlugin {
# pname = "neotest-java";
# version = "v0.17.6";
# src = pkgs.fetchFromGitHub {
# owner = "rcasia";
# repo = "neotest-java";
# rev = "43b4cf9ee0d3d05f56a9a43c89c4268157cfbc79";
# sha256 = "0653fx7bcr8mn38dfza4qywia1i862zc42frwf18s51zp5jjrfqy";
# };
# })
(pkgs.vimUtils.buildVimPlugin {
pname = "neotest-vim-test";
version = "2023-04-17";
src = pkgs.fetchFromGitHub {
owner = "nvim-neotest";
repo = "neotest-vim-test";
rev = "75c4228882ae4883b11bfce9b8383e637eb44192";
sha256 = "12ix1lzmqlk3iyngaafby9c02fcl9d5iva965miwxfljvmibjnbw";
};
})
neotest
FixCursorHold-nvim
neotest-plenary
vim-test
neotest-python
neotest-vitest
];
extraConfigLua = ''
require("neotest").setup({
adapters = {
-- require("neotest-java")({
-- ignore_wrapper = false,
-- -- function to determine which runner to use based on project path
-- determine_runner = function(project_root_path)
-- -- return should be "maven" or "gradle"
-- return "maven"
-- end,
-- -- override the builtin runner discovery behaviour to always use given
-- -- tool. Default is "nil", so no override
-- force_runner = nil,
-- -- if the automatic runner discovery can't uniquely determine whether
-- -- to use Gradle or Maven, fallback to using this runner. Default is
-- -- "maven"
-- fallback_runner = "gradle"
-- }),
require("neotest-python")({
dap = { justMyCode = false },
}),
require "neotest-vim-test" {
ignore_file_types = { "python", "java", "vim", "lua", "javascript", "typescript" },
},
},
output = { enabled = true, open_on_run = true },
summary = { enabled = true, },
})
'';
keymaps = [
{
mode = "n";
key = "<leader>tt";
action = "<cmd>lua require('neotest').run.run(vim.fn.expand '%')<CR>";
options = {
desc = "Run File";
silent = true;
};
}
{
mode = "n";
key = "<leader>tT";
action = "<cmd>lua require('neotest').run.run(vim.loop.cwd())<CR>";
options = {
desc = "Run All Test Files";
silent = true;
};
}
{
mode = "n";
key = "<leader>tr";
action = "<cmd>lua require('neotest').run.run()<CR>";
options = {
desc = "Run Nearest";
silent = true;
};
}
{
mode = "n";
key = "<leader>td";
action = "<cmd>lua require('neotest').run.run({strategy = 'dap'})<CR>";
options = {
desc = "Run Nearest with debugger";
silent = true;
};
}
{
mode = "n";
key = "<leader>ts";
action = "<cmd>lua require('neotest').summary.toggle()<CR>";
options = {
desc = "Toggle Summary";
silent = true;
};
}
{
mode = "n";
key = "<leader>to";
action = "<cmd>lua require('neotest').output.open{ enter = true, auto_close = true }<CR>";
options = {
desc = "Show Output";
silent = true;
};
}
{
mode = "n";
key = "<leader>tO";
action = "<cmd>lua require('neotest').output_panel.toggle()<CR>";
options = {
desc = "Toggle Output Panel";
silent = true;
};
}
{
mode = "n";
key = "<leader>tS";
action = "<cmd>lua require('neotest').run.stop()<CR>";
options = {
desc = "Stop";
silent = true;
};
}
];
};
}

View File

@ -0,0 +1,14 @@
{
lib,
config,
...
}: {
options = {
nvim-autopairs.enable = lib.mkEnableOption "Enable nvim-autopairs module";
};
config = lib.mkIf config.nvim-autopairs.enable {
plugins.nvim-autopairs = {
enable = true;
};
};
}

View File

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}: {
options = {
nvim-surround.enable = lib.mkEnableOption "Enable nvim-surround module";
};
config = lib.mkIf config.nvim-surround.enable {
plugins.nvim-surround = {
enable = true;
};
};
}

73
config/utils/nvterm.nix Normal file
View File

@ -0,0 +1,73 @@
{
lib,
config,
pkgs,
...
}: {
options = {
nvterm.enable = lib.mkEnableOption "Enable nvterm module";
};
config = lib.mkIf config.nvterm.enable {
extraPlugins = [
pkgs.vimPlugins.nvterm
];
extraConfigLua = ''
require("nvterm").setup({
terminals = {
shell = vim.o.shell,
list = {},
type_opts = {
float = {
relative = "editor",
row = 0.3,
col = 0.25,
width = 0.5,
height = 0.4,
border = "single",
},
horizontal = { location = "rightbelow", split_ratio = 0.5 },
vertical = { location = "rightbelow", split_ratio = 0.5 },
},
},
behavior = {
autoclose_on_quit = {
enabled = false,
confirm = true,
},
close_on_exit = true,
auto_insert = true,
},
})
local terminal = require("nvterm.terminal")
local toggle_modes = { "n", "t" }
local mappings = {
{
toggle_modes,
"<A-h>",
function()
terminal.toggle("horizontal")
end,
},
{
toggle_modes,
"<A-v>",
function()
terminal.toggle("vertical")
end,
},
{
toggle_modes,
"<A-i>",
function()
terminal.toggle("float")
end,
},
}
local opts = { noremap = true, silent = true }
for _, mapping in ipairs(mappings) do
vim.keymap.set(mapping[1], mapping[2], mapping[3], opts)
end
'';
};
}

66
config/utils/oil.nix Normal file
View File

@ -0,0 +1,66 @@
{
lib,
config,
...
}: {
options = {
oil.enable = lib.mkEnableOption "Enable oil module";
};
config = lib.mkIf config.oil.enable {
plugins.oil = {
enable = true;
settings = {
deleteToTrash = true;
useDefaultKeymaps = true;
viewOptions = {
showHidden = true;
};
preview = {
border = "rounded";
win_options = {
winblend = 0;
};
};
float = {
padding = 2;
maxWidth = 0; # ''math.ceil(vim.o.lines * 0.8 - 4)'';
maxHeight = 0; # ''math.ceil(vim.o.columns * 0.8)'';
border = "rounded"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
winOptions = {
winblend = 0;
};
};
keymaps = {
"g?" = "actions.show_help";
"<CR>" = "actions.select";
"<C-\\>" = "actions.select_vsplit";
"<C-enter>" = "actions.select_split"; # this is used to navigate left
"<C-t>" = "actions.select_tab";
"<C-p>" = "actions.preview";
"<C-c>" = "actions.close";
"<C-r>" = "actions.refresh";
"-" = "actions.parent";
"_" = "actions.open_cwd";
"`" = "actions.cd";
"~" = "actions.tcd";
"gs" = "actions.change_sort";
"gx" = "actions.open_external";
"g." = "actions.toggle_hidden";
"q" = "actions.close";
};
};
};
keymaps = [
{
mode = "n";
key = "<leader>o";
action = ":Oil --float<CR>";
options = {
desc = "Open parent directory";
silent = true;
};
}
];
};
}

View File

@ -0,0 +1,14 @@
{
lib,
config,
...
}: {
options = {
persistence.enable = lib.mkEnableOption "Enable persistence module";
};
config = lib.mkIf config.persistence.enable {
plugins.persistence = {
enable = true;
};
};
}

15
config/utils/plenary.nix Normal file
View File

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}: {
options = {
plenary.enable = lib.mkEnableOption "Enable plenary module";
};
config = lib.mkIf config.plenary.enable {
extraPlugins = with pkgs.vimPlugins; [
plenary-nvim
];
};
}

View File

@ -0,0 +1,15 @@
{
lib,
config,
...
}: {
options = {
project-nvim.enable = lib.mkEnableOption "Enable project-nvim module";
};
config = lib.mkIf config.project-nvim.enable {
plugins.project-nvim = {
enable = true;
enableTelescope = true;
};
};
}

65
config/utils/sidebar.nix Normal file
View File

@ -0,0 +1,65 @@
{
lib,
config,
pkgs,
...
}: {
options = {
sidebar.enable = lib.mkEnableOption "Enable sidebar module";
};
config = lib.mkIf config.sidebar.enable {
extraPlugins = with pkgs.vimUtils; [
(buildVimPlugin {
pname = "sidebar.nvim";
version = "2024-02-07";
src = pkgs.fetchFromGitHub {
owner = "sidebar-nvim";
repo = "sidebar.nvim";
rev = "5695712eef6288fff667343c4ae77c54911bdb1b";
sha256 = "1p12189367x0x26cys9wxipzwr3i0bmz4lb0s79ki0a49d6zja2c";
};
})
];
extraConfigLua = ''
local sidebar = require("sidebar-nvim")
sidebar.setup({
disable_default_keybindings = 0,
bindings = nil,
open = false,
side = "left",
initial_width = 32,
hide_statusline = false,
update_interval = 1000,
sections = { "git", "containers" },
section_separator = {"", "-----", ""},
section_title_separator = {""},
containers = {
attach_shell = "/bin/sh", show_all = true, interval = 5000,
},
datetime = { format = "%a %b %d, %H:%M", clocks = { { name = "local" } } },
todos = { ignored_paths = {} },
["git"] = {
icon = "", --
},
})
cmd = {
"SidebarNvimToggle",
"SidebarNvimOpen",
"SidebarNvimFocus",
"SidebarNvimUpdate",
},
'';
keymaps = [
{
mode = "n";
key = "<leader>e";
action = ":SidebarNvimToggle<CR>";
options = {
desc = "Toggle Explorer";
silent = true;
};
}
];
};
}

View File

@ -0,0 +1,14 @@
{
lib,
config,
...
}: {
options = {
tmux-navigator.enable = lib.mkEnableOption "Enable tmux-navigator module";
};
config = lib.mkIf config.tmux-navigator.enable {
plugins.tmux-navigator = {
enable = true;
};
};
}

View File

@ -0,0 +1,14 @@
{
lib,
config,
...
}: {
options = {
todo-comments.enable = lib.mkEnableOption "Enable todo-comments module";
};
config = lib.mkIf config.todo-comments.enable {
plugins.todo-comments = {
enable = true;
};
};
}

View File

@ -0,0 +1,27 @@
{
lib,
config,
pkgs,
...
}: {
options = {
ultimate-autopair.enable = lib.mkEnableOption "Enable ultimate-autopair module";
};
config = lib.mkIf config.ultimate-autopair.enable {
extraPlugins = with pkgs.vimUtils; [
(buildVimPlugin {
pname = "ultimate-autopair.nvim";
version = "2024-02-05";
src = pkgs.fetchFromGitHub {
owner = "altermo";
repo = "ultimate-autopair.nvim";
rev = "25c13e0ce167db0255456cac10158b27d2be30c0";
sha256 = "0bsxfj6g8fii9nn92vl15hdhafx3fikgiz4srr7y10pxz01c5s4c";
};
})
];
extraConfigLua = ''
require('ultimate-autopair').setup()
'';
};
}

29
config/utils/undotree.nix Normal file
View File

@ -0,0 +1,29 @@
{
lib,
config,
...
}: {
options = {
undotree.enable = lib.mkEnableOption "Enable undotree module";
};
config = lib.mkIf config.undotree.enable {
plugins.undotree = {
enable = true;
settings = {
autoOpenDiff = true;
focusOnToggle = true;
};
};
keymaps = [
{
mode = "n";
key = "<leader>ut";
action = "<cmd>UndotreeToggle<CR>";
options = {
silent = true;
desc = "Undotree";
};
}
];
};
}

14
config/utils/wakatime.nix Normal file
View File

@ -0,0 +1,14 @@
{
lib,
config,
...
}: {
options = {
wakatime.enable = lib.mkEnableOption "Enable wakatime module";
};
config = lib.mkIf config.wakatime.enable {
plugins.wakatime = {
enable = true;
};
};
}

126
config/utils/which-key.nix Normal file
View File

@ -0,0 +1,126 @@
{
lib,
config,
...
}: {
options = {
which-key.enable = lib.mkEnableOption "Enable which-key module";
};
config = lib.mkIf config.which-key.enable {
plugins.which-key = {
enable = true;
settings = {
icons = {
breadcrumb = "»";
group = "+";
separator = ""; # ➜
};
spec = [
# Harpoon Configs
{
__unkeyed-1 = "<leader>h";
mode = "n";
group = "+harpoon";
icon = "󱡁";
}
{
__unkeyed-1 = "<leader>ha";
mode = "n";
group = "Add file to Harpoon";
}
{
__unkeyed-1 = "<leader>hj";
mode = "n";
group = "Harpoon File 1";
}
{
__unkeyed-1 = "<leader>hk";
mode = "n";
group = "Harpoon File 2";
}
{
__unkeyed-1 = "<leader>hl";
mode = "n";
group = "Harpoon File 3";
}
{
__unkeyed-1 = "<leader>hm";
mode = "n";
group = "Harpoon File 4";
}
# General Mappings
{
__unkeyed-1 = "<leader>c";
mode = [
"n"
"v"
];
group = "+code";
}
{
__unkeyed-1 = "<leader>d";
mode = [
"n"
"v"
];
group = "+debug";
}
{
__unkeyed-1 = "<leader>f";
mode = "n";
group = "+find/file";
}
{
__unkeyed-1 = "<leader>g";
mode = [
"n"
"v"
];
group = "+git";
}
{
__unkeyed-1 = "<leader>q";
mode = "n";
group = "+quit/session";
}
{
__unkeyed-1 = "<leader>s";
mode = "n";
group = "+search";
}
{
__unkeyed-1 = "<leader><Tab>";
mode = "n";
group = "+tab";
}
{
__unkeyed-1 = "<leader>t";
mode = "n";
group = "+test";
}
{
__unkeyed-1 = "<leader>u";
mode = "n";
group = "+ui";
}
{
__unkeyed-1 = "<leader>w";
mode = "n";
group = "+windows";
}
];
win = {
border = "none";
wo.winblend = 0;
};
};
};
};
}

57
config/utils/wilder.nix Normal file
View File

@ -0,0 +1,57 @@
{
lib,
config,
...
}: {
options = {
wilder.enable = lib.mkEnableOption "Enable wilder module";
};
config = lib.mkIf config.wilder.enable {
plugins.wilder = {
enable = true;
modes = [
":"
"/"
"?"
];
pipeline = [
''
wilder.branch(
wilder.python_file_finder_pipeline({
file_command = function(ctx, arg)
if string.find(arg, '.') ~= nil then
return {'fd', '-tf', '-H'}
else
return {'fd', '-tf'}
end
end,
dir_command = {'fd', '-td'},
filters = {'cpsm_filter'},
}),
wilder.substitute_pipeline({
pipeline = wilder.python_search_pipeline({
skip_cmdtype_check = 1,
pattern = wilder.python_fuzzy_pattern({
start_at_boundary = 0,
}),
}),
}),
wilder.cmdline_pipeline({
language = 'python',
fuzzy = 1,
}),
{
wilder.check(function(ctx, x) return x == "" end),
wilder.history(),
},
wilder.python_search_pipeline({
pattern = wilder.python_fuzzy_pattern({
start_at_boundary = 0,
}),
})
)
''
];
};
};
}