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,167 @@
{
lib,
config,
...
}: {
options = {
bufferline = {
enable = lib.mkEnableOption "Enable bufferline module";
keymaps = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable default keymaps";
};
enableHL = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable keymaps for switching buffers with h and l";
};
enableTab = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable keymaps for switching buffers with Tab and S-Tab";
};
};
};
};
config = let
cfg = config.bufferline;
in
lib.mkIf cfg.enable {
plugins = {
bufferline = {
enable = true;
settings = {
options = {
separatorStyle = "thick"; # “slant”, “padded_slant”, “slope”, “padded_slope”, “thick”, “thin“
offsets = [
{
filetype = "neo-tree";
text = "Neo-tree";
highlight = "Directory";
text_align = "left";
}
];
};
};
};
};
keymaps =
lib.mkIf cfg.keymaps.enable
([
{
mode = "n";
key = "<leader>bd";
action = "<cmd>bdelete<cr>";
options = {
desc = "Delete buffer";
};
}
{
mode = "n";
key = "<leader>bb";
action = "<cmd>e #<cr>";
options = {
desc = "Switch to Other Buffer";
};
}
# {
# mode = "n";
# key = "<leader>`";
# action = "<cmd>e #<cr>";
# options = {
# desc = "Switch to Other Buffer";
# };
# }
{
mode = "n";
key = "<leader>br";
action = "<cmd>BufferLineCloseRight<cr>";
options = {
desc = "Delete buffers to the right";
};
}
{
mode = "n";
key = "<leader>bl";
action = "<cmd>BufferLineCloseLeft<cr>";
options = {
desc = "Delete buffers to the left";
};
}
{
mode = "n";
key = "<leader>bo";
action = "<cmd>BufferLineCloseOthers<cr>";
options = {
desc = "Delete other buffers";
};
}
{
mode = "n";
key = "<leader>bp";
action = "<cmd>BufferLineTogglePin<cr>";
options = {
desc = "Toggle pin";
};
}
{
mode = "n";
key = "<leader>bP";
action = "<Cmd>BufferLineGroupClose ungrouped<CR>";
options = {
desc = "Delete non-pinned buffers";
};
}
]
++ (lib.optionals cfg.keymaps.enableTab [
{
mode = "n";
key = "<Tab>";
action = "<cmd>BufferLineCycleNext<cr>";
options = {
desc = "Cycle to next buffer";
};
}
{
mode = "n";
key = "<S-Tab>";
action = "<cmd>BufferLineCyclePrev<cr>";
options = {
desc = "Cycle to previous buffer";
};
}
])
++ (lib.optionals cfg.keymaps.enableHL [
{
mode = "n";
key = "<S-l>";
action = "<cmd>BufferLineCycleNext<cr>";
options = {
desc = "Cycle to next buffer";
};
}
{
mode = "n";
key = "<S-h>";
action = "<cmd>BufferLineCyclePrev<cr>";
options = {
desc = "Cycle to previous buffer";
};
}
]));
};
}

View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./bufferline.nix
];
options = {
bufferlines.enable = lib.mkEnableOption "Enable bufferlines module";
};
config = lib.mkIf config.bufferlines.enable {
bufferline.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,19 @@
{
lib,
config,
...
}: {
options = {
ayu.enable = lib.mkEnableOption "Enable ayu module";
};
config = lib.mkIf config.ayu.enable {
colorschemes = {
ayu = {
enable = true;
settings = {
mirage = true;
};
};
};
};
}

View File

@ -0,0 +1,17 @@
{
lib,
config,
...
}: {
options = {
base16.enable = lib.mkEnableOption "Enable base16 module";
};
config = lib.mkIf config.base16.enable {
colorschemes = {
base16 = {
enable = true;
colorscheme = "ayu-mirage";
};
};
};
}

View File

@ -0,0 +1,57 @@
{
lib,
config,
...
}: {
options = {
catppuccin.enable = lib.mkEnableOption "Enable catppuccin module";
};
config = lib.mkIf config.catppuccin.enable {
colorschemes = {
catppuccin = {
enable = true;
settings = {
background = {
light = "macchiato";
dark = "mocha";
};
flavour = "mocha"; # "latte", "mocha", "frappe", "macchiato" or raw lua code
disable_bold = false;
disable_italic = false;
disable_underline = false;
transparent_background = true;
term_colors = true;
integrations = {
cmp = true;
noice = true;
notify = true;
neotree = true;
harpoon = true;
gitsigns = true;
which_key = true;
illuminate = {
enabled = true;
};
treesitter = true;
treesitter_context = true;
telescope.enabled = true;
indent_blankline.enabled = true;
mini.enabled = true;
native_lsp = {
enabled = true;
inlay_hints = {
background = true;
};
underlines = {
errors = ["underline"];
hints = ["underline"];
information = ["underline"];
warnings = ["underline"];
};
};
};
};
};
};
};
}

View File

@ -0,0 +1,22 @@
{
lib,
config,
...
}: {
imports = [
./ayu.nix
./base16.nix
./catppuccin.nix
./rose-pine.nix
];
options = {
colorschemes.enable = lib.mkEnableOption "Enable colorschemes module";
};
config = lib.mkIf config.colorschemes.enable {
ayu.enable = lib.mkDefault true;
base16.enable = lib.mkDefault false;
catppuccin.enable = lib.mkDefault false;
rose-pine.enable = lib.mkDefault false;
};
}

View File

@ -0,0 +1,23 @@
{
lib,
config,
...
}: {
options = {
rose-pine.enable = lib.mkEnableOption "Enable rose-pine module";
};
config = lib.mkIf config.rose-pine.enable {
colorschemes = {
rose-pine = {
enable = true;
settings = {
styles = {
italic = true;
bold = true;
transparency = false;
};
};
};
};
};
}

174
config/completion/cmp.nix Normal file
View File

@ -0,0 +1,174 @@
{
lib,
config,
...
}: {
options = {
cmp.enable = lib.mkEnableOption "Enable cmp module";
};
config = lib.mkIf config.cmp.enable {
plugins = {
cmp-nvim-lsp = {
enable = true;
}; # lsp
cmp-buffer = {
enable = true;
};
cmp-path = {
enable = true;
}; # file system paths
cmp-cmdline = {
enable = true;
}; # autocomplete for cmdline
cmp_luasnip = {
enable = true;
}; # snippets
copilot-cmp = {
enable = true;
}; # copilot suggestions
cmp = {
enable = true;
autoEnableSources = false;
settings = {
experimental = {
ghost_text = true;
};
mapping = {
"<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()";
"<Tab>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" })
'';
"<S-Tab>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
'';
"<C-e>" = "cmp.mapping.abort()";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-Space>" = "cmp.mapping.complete()";
"<CR>" = "cmp.mapping.confirm({ select = false })"; # Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
"<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })";
};
sources = [
{
name = "nvim_lsp";
}
{
name = "buffer";
keyword_length = 5;
}
{name = "copilot";}
{
name = "path";
keyword_length = 3;
}
{
name = "luasnip";
keyword_length = 3;
}
];
# Enable pictogram icons for lsp/autocompletion
formatting = {
fields = [
"kind"
"abbr"
"menu"
];
expandable_indicator = true;
};
performance = {
debounce = 60;
fetching_timeout = 200;
max_view_entries = 30;
};
window = {
completion = {
border = "rounded";
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None";
};
documentation = {
border = "rounded";
};
};
};
};
};
extraConfigLua = ''
luasnip = require("luasnip")
kind_icons = {
Text = "󰊄",
Method = "",
Function = "󰡱",
Constructor = "",
Field = "",
Variable = "󱀍",
Class = "",
Interface = "",
Module = "󰕳",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
local cmp = require'cmp'
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({'/', "?" }, {
sources = {
{ name = 'buffer' }
}
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
})
'';
};
}

View File

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

View File

@ -0,0 +1,55 @@
{
lib,
config,
...
}: {
options = {
copilot.enable = lib.mkEnableOption "Enable copilot module";
};
config = lib.mkIf config.copilot.enable {
plugins.copilot-lua = {
enable = true;
panel = {
enabled = false;
autoRefresh = true;
keymap = {
jumpPrev = "[[";
jumpNext = "]]";
accept = "<CR>";
refresh = "gr";
open = "<M-CR>";
};
layout = {
position = "bottom"; # | top | left | right
ratio = 0.4;
};
};
suggestion = {
enabled = false;
autoTrigger = true;
debounce = 75;
keymap = {
accept = "<M-l>";
acceptWord = false;
acceptLine = false;
next = "<M-]>";
prev = "<M-[>";
dismiss = "<C-]>";
};
};
filetypes = {
yaml = false;
markdown = false;
help = false;
gitcommit = false;
gitrebase = false;
hgcommit = false;
svn = false;
cvs = false;
"." = false;
};
copilotNodeCommand = "node"; # Node.js version must be > 18.x
serverOptsOverrides = {};
};
};
}

View File

@ -0,0 +1,22 @@
{
lib,
config,
...
}: {
imports = [
./cmp.nix
./codeium.nix
./copilot.nix
./lspkind.nix
];
options = {
completion.enable = lib.mkEnableOption "Enable completion module";
};
config = lib.mkIf config.completion.enable {
cmp.enable = lib.mkDefault true;
codeium.enable = lib.mkDefault false;
copilot.enable = lib.mkDefault false;
lspkind.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,21 @@
{
lib,
config,
...
}: {
options = {
lspkind.enable = lib.mkEnableOption "Enable lspkind module";
};
config = lib.mkIf config.lspkind.enable {
plugins.lspkind = {
enable = true;
symbolMap = {
Copilot = "";
};
extraOptions = {
maxwidth = 50;
ellipsis_char = "...";
};
};
};
}

16
config/dap/default.nix Normal file
View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./nvim-dap.nix
];
options = {
dap.enable = lib.mkEnableOption "Enable dap module";
};
config = lib.mkIf config.dap.enable {
nvim-dap.enable = lib.mkDefault true;
};
}

237
config/dap/nvim-dap.nix Normal file
View File

@ -0,0 +1,237 @@
{
lib,
config,
...
}: {
options = {
nvim-dap.enable = lib.mkEnableOption "Enable Debug Adapter Protocol module";
};
config = lib.mkIf config.nvim-dap.enable {
plugins.dap = {
enable = true;
signs = {
dapBreakpoint = {
text = "";
texthl = "DapBreakpoint";
};
dapBreakpointCondition = {
text = "";
texthl = "DapBreakpointCondition";
};
dapLogPoint = {
text = "";
texthl = "DapLogPoint";
};
};
extensions = {
dap-python = {
enable = true;
};
dap-ui = {
enable = true;
floating.mappings = {
close = [
"<ESC>"
"q"
];
};
};
dap-virtual-text = {
enable = true;
};
};
configurations = {
java = [
{
type = "java";
request = "launch";
name = "Debug (Attach) - Remote";
hostName = "127.0.0.1";
port = 5005;
}
];
};
};
keymaps = [
{
mode = "n";
key = "<leader>dB";
action = "
<cmd>lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>
";
options = {
silent = true;
desc = "Breakpoint Condition";
};
}
{
mode = "n";
key = "<leader>db";
action = ":DapToggleBreakpoint<cr>";
options = {
silent = true;
desc = "Toggle Breakpoint";
};
}
{
mode = "n";
key = "<leader>dc";
action = ":DapContinue<cr>";
options = {
silent = true;
desc = "Continue";
};
}
{
mode = "n";
key = "<leader>da";
action = "<cmd>lua require('dap').continue({ before = get_args })<cr>";
options = {
silent = true;
desc = "Run with Args";
};
}
{
mode = "n";
key = "<leader>dC";
action = "<cmd>lua require('dap').run_to_cursor()<cr>";
options = {
silent = true;
desc = "Run to cursor";
};
}
{
mode = "n";
key = "<leader>dg";
action = "<cmd>lua require('dap').goto_()<cr>";
options = {
silent = true;
desc = "Go to line (no execute)";
};
}
{
mode = "n";
key = "<leader>di";
action = ":DapStepInto<cr>";
options = {
silent = true;
desc = "Step into";
};
}
{
mode = "n";
key = "<leader>dj";
action = "
<cmd>lua require('dap').down()<cr>
";
options = {
silent = true;
desc = "Down";
};
}
{
mode = "n";
key = "<leader>dk";
action = "<cmd>lua require('dap').up()<cr>";
options = {
silent = true;
desc = "Up";
};
}
{
mode = "n";
key = "<leader>dl";
action = "<cmd>lua require('dap').run_last()<cr>";
options = {
silent = true;
desc = "Run Last";
};
}
{
mode = "n";
key = "<leader>do";
action = ":DapStepOut<cr>";
options = {
silent = true;
desc = "Step Out";
};
}
{
mode = "n";
key = "<leader>dO";
action = ":DapStepOver<cr>";
options = {
silent = true;
desc = "Step Over";
};
}
{
mode = "n";
key = "<leader>dp";
action = "<cmd>lua require('dap').pause()<cr>";
options = {
silent = true;
desc = "Pause";
};
}
{
mode = "n";
key = "<leader>dr";
action = ":DapToggleRepl<cr>";
options = {
silent = true;
desc = "Toggle REPL";
};
}
{
mode = "n";
key = "<leader>ds";
action = "<cmd>lua require('dap').session()<cr>";
options = {
silent = true;
desc = "Session";
};
}
{
mode = "n";
key = "<leader>dt";
action = ":DapTerminate<cr>";
options = {
silent = true;
desc = "Terminate";
};
}
{
mode = "n";
key = "<leader>du";
action = "<cmd>lua require('dapui').toggle()<cr>";
options = {
silent = true;
desc = "Dap UI";
};
}
{
mode = "n";
key = "<leader>dw";
action = "<cmd>lua require('dap.ui.widgets').hover()<cr>";
options = {
silent = true;
desc = "Widgets";
};
}
{
mode = [
"n"
"v"
];
key = "<leader>de";
action = "<cmd>lua require('dapui').eval()<cr>";
options = {
silent = true;
desc = "Eval";
};
}
];
};
}

44
config/default.nix Normal file
View File

@ -0,0 +1,44 @@
{
lib,
config,
...
}: {
# Import all your configuration modules here
imports = [
./bufferlines
./colorschemes
./completion
./dap
./filetrees
./git
./keys.nix
./languages
./lsp
./none-ls
./pluginmanagers
./sets
./snippets
./statusline
./telescope
./ui
./utils
];
bufferlines.enable = lib.mkDefault true;
colorschemes.enable = lib.mkDefault false;
completion.enable = lib.mkDefault true;
dap.enable = lib.mkDefault true;
filetrees.enable = lib.mkDefault false;
git.enable = lib.mkDefault true;
keys.enable = true;
languages.enable = true;
lsp.enable = lib.mkDefault true;
none-ls.enable = lib.mkDefault false;
sets.enable = lib.mkDefault true;
pluginmanagers.enable = lib.mkDefault true;
snippets.enable = lib.mkDefault true;
statusline.enable = lib.mkDefault true;
telescope.enable = lib.mkDefault true;
ui.enable = lib.mkDefault true;
utils.enable = lib.mkDefault true;
}

View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./neo-tree.nix
];
options = {
filetrees.enable = lib.mkEnableOption "Enable filetrees module";
};
config = lib.mkIf config.filetrees.enable {
neo-tree.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,73 @@
{
lib,
config,
...
}: {
options = {
neo-tree.enable = lib.mkEnableOption "Enable neo-tree module";
};
config = lib.mkIf config.neo-tree.enable {
plugins.neo-tree = {
enable = true;
enableDiagnostics = true;
enableGitStatus = true;
enableModifiedMarkers = true;
enableRefreshOnWrite = true;
closeIfLastWindow = true;
popupBorderStyle = "rounded"; # Type: null or one of “NC”, “double”, “none”, “rounded”, “shadow”, “single”, “solid” or raw lua code
buffers = {
bindToCwd = false;
followCurrentFile = {
enabled = true;
};
};
window = {
width = 40;
height = 15;
autoExpandWidth = false;
mappings = {
"<space>" = "none";
};
};
};
# keymaps = [
# {
# mode = "n";
# key = "<leader>e";
# action = ":Neotree toggle reveal_force_cwd<cr>";
# options = {
# silent = true;
# desc = "Explorer NeoTree (root dir)";
# };
# }
# {
# mode = "n";
# key = "<leader>E";
# action = "<cmd>Neotree toggle<CR>";
# options = {
# silent = true;
# desc = "Explorer NeoTree (cwd)";
# };
# }
# {
# mode = "n";
# key = "<leader>be";
# action = ":Neotree buffers<CR>";
# options = {
# silent = true;
# desc = "Buffer explorer";
# };
# }
# {
# mode = "n";
# key = "<leader>ge";
# action = ":Neotree git_status<CR>";
# options = {
# silent = true;
# desc = "Git explorer";
# };
# }
# ];
};
}

22
config/git/default.nix Normal file
View File

@ -0,0 +1,22 @@
{
lib,
config,
...
}: {
imports = [
./diffview.nix
./gitsigns.nix
./lazygit.nix
./neogit.nix
];
options = {
git.enable = lib.mkEnableOption "Enable git module";
};
config = lib.mkIf config.git.enable {
diffview.enable = lib.mkDefault true;
gitsigns.enable = lib.mkDefault true;
lazygit.enable = lib.mkDefault true;
neogit.enable = lib.mkDefault false;
};
}

14
config/git/diffview.nix Normal file
View File

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

110
config/git/gitsigns.nix Normal file
View File

@ -0,0 +1,110 @@
{
lib,
config,
...
}: {
options = {
gitsigns.enable = lib.mkEnableOption "Enable gitsigns module";
};
config = lib.mkIf config.gitsigns.enable {
plugins.gitsigns = {
enable = true;
settings = {
trouble = true;
current_line_blame = false;
};
};
keymaps = [
{
mode = [
"n"
"v"
];
key = "<leader>gh";
action = "gitsigns";
options = {
silent = true;
desc = "+hunks";
};
}
{
mode = "n";
key = "<leader>ghb";
action = ":Gitsigns blame_line<CR>";
options = {
silent = true;
desc = "Blame line";
};
}
{
mode = "n";
key = "<leader>ghd";
action = ":Gitsigns diffthis<CR>";
options = {
silent = true;
desc = "Diff This";
};
}
{
mode = "n";
key = "<leader>ghp";
action = ":Gitsigns preview_hunk<CR>";
options = {
silent = true;
desc = "Preview hunk";
};
}
{
mode = "n";
key = "<leader>ghR";
action = ":Gitsigns reset_buffer<CR>";
options = {
silent = true;
desc = "Reset Buffer";
};
}
{
mode = [
"n"
"v"
];
key = "<leader>ghr";
action = ":Gitsigns reset_hunk<CR>";
options = {
silent = true;
desc = "Reset Hunk";
};
}
{
mode = [
"n"
"v"
];
key = "<leader>ghs";
action = ":Gitsigns stage_hunk<CR>";
options = {
silent = true;
desc = "Stage Hunk";
};
}
{
mode = "n";
key = "<leader>ghS";
action = ":Gitsigns stage_buffer<CR>";
options = {
silent = true;
desc = "Stage Buffer";
};
}
{
mode = "n";
key = "<leader>ghu";
action = ":Gitsigns undo_stage_hunk<CR>";
options = {
silent = true;
desc = "Undo Stage Hunk";
};
}
];
};
}

29
config/git/lazygit.nix Normal file
View File

@ -0,0 +1,29 @@
{
lib,
config,
...
}: {
options = {
lazygit.enable = lib.mkEnableOption "Enable lazygit module";
};
config = lib.mkIf config.lazygit.enable {
plugins.lazygit = {
enable = true;
};
extraConfigLua = ''
require("telescope").load_extension("lazygit")
'';
keymaps = [
{
mode = "n";
key = "<leader>gg";
action = "<cmd>LazyGit<CR>";
options = {
desc = "LazyGit (root dir)";
};
}
];
};
}

21
config/git/neogit.nix Normal file
View File

@ -0,0 +1,21 @@
{
lib,
config,
...
}: {
options = {
neogit.enable = lib.mkEnableOption "Enable neogit module";
};
config = lib.mkIf config.neogit.enable {
plugins.neogit = {
enable = false;
};
keymaps = [
{
mode = "n";
key = "<leader>gg";
action = "<cmd>Neogit<CR>";
}
];
};
}

494
config/keys.nix Normal file
View File

@ -0,0 +1,494 @@
# Thanks for the keybinds primeagen and folke!
{
lib,
config,
...
}: {
options = {
keys.enable = lib.mkEnableOption "Enable keys module";
};
config = lib.mkIf config.keys.enable {
globals.mapleader = " ";
keymaps = [
# Disable arrow keys
# {
# mode = [
# "n"
# "i"
# ];
# key = "<Up>";
# action = "<Nop>";
# options = {
# silent = true;
# noremap = true;
# desc = "Disable Up arrow key";
# };
# }
# {
# mode = [
# "n"
# "i"
# ];
# key = "<Down>";
# action = "<Nop>";
# options = {
# silent = true;
# noremap = true;
# desc = "Disable Down arrow key";
# };
# }
# {
# mode = [
# "n"
# "i"
# ];
# key = "<Right>";
# action = "<Nop>";
# options = {
# silent = true;
# noremap = true;
# desc = "Disable Right arrow key";
# };
# }
# {
# mode = [
# "n"
# "i"
# ];
# key = "<Left>";
# action = "<Nop>";
# options = {
# silent = true;
# noremap = true;
# desc = "Disable Left arrow key";
# };
# }
{
mode = ["n" "i"];
key = "<Up>";
action = "g<Up>";
}
{
mode = ["n" "i"];
key = "<Down>";
action = "g<Down>";
}
# Tabs
{
mode = "n";
key = "<leader><tab>l";
action = "<cmd>tablast<cr>";
options = {
silent = true;
desc = "Last tab";
};
}
{
mode = "n";
key = "<leader><tab>f";
action = "<cmd>tabfirst<cr>";
options = {
silent = true;
desc = "First Tab";
};
}
{
mode = "n";
key = "<leader><tab><tab>";
action = "<cmd>tabnew<cr>";
options = {
silent = true;
desc = "New Tab";
};
}
{
mode = "n";
key = "<leader><tab>]";
action = "<cmd>tabnext<cr>";
options = {
silent = true;
desc = "Next Tab";
};
}
{
mode = "n";
key = "<leader><tab>d";
action = "<cmd>tabclose<cr>";
options = {
silent = true;
desc = "Close tab";
};
}
{
mode = "n";
key = "<leader><tab>[";
action = "<cmd>tabprevious<cr>";
options = {
silent = true;
desc = "Previous Tab";
};
}
# Windows
{
mode = "n";
key = "<leader>ww";
action = "<C-W>p";
options = {
silent = true;
desc = "Other window";
};
}
{
mode = "n";
key = "<leader>wd";
action = "<C-W>c";
options = {
silent = true;
desc = "Delete window";
};
}
{
mode = "n";
key = "<leader>w-";
action = "<C-W>s";
options = {
silent = true;
desc = "Split window below";
};
}
{
mode = "n";
key = "<leader>w|";
action = "<C-W>v";
options = {
silent = true;
desc = "Split window right";
};
}
# {
# mode = "n";
# key = "<leader>-";
# action = "<C-W>s";
# options = {
# silent = true;
# desc = "Split window below";
# };
# }
# {
# mode = "n";
# key = "<leader>|";
# action = "<C-W>v";
# options = {
# silent = true;
# desc = "Split window right";
# };
# }
{
mode = "n";
key = "<C-s>";
action = "<cmd>w<cr><esc>";
options = {
silent = true;
desc = "Save file";
};
}
# Quit/Session
{
mode = "n";
key = "<leader>qq";
action = "<cmd>quitall<cr><esc>";
options = {
silent = true;
desc = "Quit all";
};
}
{
mode = "n";
key = "<leader>qs";
action = ":lua require('persistence').load()<cr>";
options = {
silent = true;
desc = "Restore session";
};
}
{
mode = "n";
key = "<leader>ql";
action = "<cmd>lua require('persistence').load({ last = true })<cr>";
options = {
silent = true;
desc = "Restore last session";
};
}
{
mode = "n";
key = "<leader>qd";
action = "<cmd>lua require('persistence').stop()<cr>";
options = {
silent = true;
desc = "Don't save current session";
};
}
# Toggle
{
mode = "n";
key = "<leader>ul";
action = ":lua ToggleLineNumber()<cr>";
options = {
silent = true;
desc = "Toggle Line Numbers";
};
}
{
mode = "n";
key = "<leader>uL";
action = ":lua ToggleRelativeLineNumber()<cr>";
options = {
silent = true;
desc = "Toggle Relative Line Numbers";
};
}
{
mode = "n";
key = "<leader>uw";
action = ":lua ToggleWrap()<cr>";
options = {
silent = true;
desc = "Toggle Line Wrap";
};
}
# Inlay Hints
{
mode = "n";
key = "<leader>uh";
action = ":lua ToggleInlayHints()<cr>";
options = {
silent = true;
desc = "Toggle Inlay Hints";
};
}
{
mode = "v";
key = "J";
action = ":m '>+1<CR>gv=gv";
options = {
silent = true;
desc = "Move up when line is highlighted";
};
}
{
mode = "v";
key = "K";
action = ":m '<-2<CR>gv=gv";
options = {
silent = true;
desc = "Move down when line is highlighted";
};
}
{
mode = "n";
key = "J";
action = "mzJ`z";
options = {
silent = true;
desc = "Allow cursor to stay in the same place after appeding to current line";
};
}
{
mode = "v";
key = "<";
action = "<gv";
options = {
silent = true;
desc = "Indent while remaining in visual mode.";
};
}
{
mode = "v";
key = ">";
action = ">gv";
options = {
silent = true;
desc = "Indent while remaining in visual mode.";
};
}
{
mode = "n";
key = "<C-d>";
action = "<C-d>zz";
options = {
silent = true;
desc = "Allow <C-d> and <C-u> to keep the cursor in the middle";
};
}
{
mode = "n";
key = "<C-u>";
action = "<C-u>zz";
options = {
desc = "Allow C-d and C-u to keep the cursor in the middle";
};
}
# Remap for dealing with word wrap and adding jumps to the jumplist.
{
mode = "n";
key = "j";
action.__raw = "
[[(v:count > 1 ? 'm`' . v:count : 'g') . 'j']]
";
options = {
expr = true;
desc = "Remap for dealing with word wrap and adding jumps to the jumplist.";
};
}
{
mode = "n";
key = "k";
action.__raw = "
[[(v:count > 1 ? 'm`' . v:count : 'g') . 'k']]
";
options = {
expr = true;
desc = "Remap for dealing with word wrap and adding jumps to the jumplist.";
};
}
{
mode = "n";
key = "n";
action = "nzzzv";
options = {
desc = "Allow search terms to stay in the middle";
};
}
{
mode = "n";
key = "N";
action = "Nzzzv";
options = {
desc = "Allow search terms to stay in the middle";
};
}
# Paste stuff without saving the deleted word into the buffer
{
mode = "x";
key = "<leader>p";
action = "\"_dP";
options = {
desc = "Deletes to void register and paste over";
};
}
# Copy stuff to system clipboard with <leader> + y or just y to have it just in vim
{
mode = [
"n"
"v"
];
key = "<leader>y";
action = "\"+y";
options = {
desc = "Copy to system clipboard";
};
}
{
mode = [
"n"
"v"
];
key = "<leader>Y";
action = "\"+Y";
options = {
desc = "Copy to system clipboard";
};
}
# Delete to void register
{
mode = [
"n"
"v"
];
key = "<leader>D";
action = "\"_d";
options = {
desc = "Delete to void register";
};
}
# <C-c> instead of pressing esc just because
{
mode = "i";
key = "<C-c>";
action = "<Esc>";
}
{
mode = "n";
key = "<C-d>";
action = "<C-d>zz";
}
{
mode = "n";
key = "<C-u>";
action = "<C-u>zz";
}
{
mode = "n";
key = "n";
action = "nzzzv";
}
{
mode = "n";
key = "N";
action = "Nzzzv";
}
{
mode = "n";
key = "<C-f>";
action = "!tmux new tmux-sessionizer<CR>";
options = {
desc = "Switch between projects";
};
}
# Set highlight on search, but clear on pressing <Esc> in normal mode
{
mode = "n";
key = "<Esc>";
action = "<cmd>nohlsearch<CR>";
}
];
};
}

View File

@ -0,0 +1,22 @@
{
lib,
config,
...
}: {
imports = [
./treesitter-nvim.nix
./nvim-jdtls.nix
./nvim-lint.nix
./rainbow-delimeters.nix
];
options = {
languages.enable = lib.mkEnableOption "Enable languages module";
};
config = lib.mkIf config.languages.enable {
treesitter-nvim.enable = lib.mkDefault true;
nvim-jdtls.enable = lib.mkDefault false;
nvim-lint.enable = lib.mkDefault true;
rainbow-delimeters.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,90 @@
{
lib,
config,
...
}: let
javaTestPath = "/nix/store/j3nvmhvj2pmnykw5pbm51dn0bz4cv6j3-vscode-extension-vscjava-vscode-java-test-0.38.2023032402/share/vscode/extensions/vscjava.vscode-java-test/server/com.microsoft.java.test.plugin-0.38.2.jar
";
in {
options = {
nvim-jdtls.enable = lib.mkEnableOption "Enable nvim-jdtls module";
};
config = lib.mkIf config.nvim-jdtls.enable {
plugins.nvim-jdtls = {
enable = true;
cmd = [
"/nix/store/20h2hjjm94gbskqhbwikbgxbblv1xpf2-jdt-language-server-1.31.0/bin/jdtls"
];
# configuration = "/path/to/configuration";
data = "~/.cache/jdtls/workspace";
settings = {
java = {
signatureHelp = true;
completion = true;
};
};
initOptions = {
bundles = [
"/nix/store/b9ib40q36wxjl4xs5lng263lflz1fsi7-vscode-extension-vscjava-vscode-java-debug-0.49.2023032407/share/vscode/extensions/vscjava.vscode-java-debug/server/com.microsoft.java.debug.plugin-0.44.0.jar"
"${javaTestPath}"
];
};
};
};
}
#
# extraConfigLua = ''
# local jdtls = require("jdtls")
# local cmp_nvim_lsp = require("cmp_nvim_lsp")
#
# local root_dir = require("jdtls.setup").find_root({ "packageInfo" }, "Config")
# local home = os.getenv("HOME")
# local eclipse_workspace = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t")
#
# local ws_folders_jdtls = {}
# if root_dir then
# local file = io.open(root_dir .. "/.bemol/ws_root_folders")
# if file then
# for line in file:lines() do
# table.insert(ws_folders_jdtls, "file://" .. line)
# end
# file:close()
# end
# end
#
# -- for completions
# local client_capabilities = vim.lsp.protocol.make_client_capabilities()
# local capabilities = cmp_nvim_lsp.default_capabilities(client_capabilities)
#
# local config = {
# capabilities = capabilities,
# cmd = {
# "${pkgs.jdt-language-server}/bin/jdt-language-server",
# "--jvm-arg=-javaagent:" .. home .. "/Developer/lombok.jar",
# "-data",
# eclipse_workspace,
# "--add-modules=ALL-SYSTEM",
# },
# root_dir = root_dir,
# init_options = {
# workspaceFolders = ws_folders_jdtls,
# },
# settings = {
# java = {
# signatureHelp = { enabled = true},
# completion = { enabled = true },
# },
# },
# on_attach = function(client, bufnr)
# local opts = { silent = true, buffer = bufnr }
# vim.keymap.set('n', "<leader>lo", jdtls.organize_imports, { desc = 'Organize imports', buffer = bufnr })
# vim.keymap.set('n', "<leader>df", jdtls.test_class, opts)
# vim.keymap.set('n', "<leader>dn", jdtls.test_nearest_method, opts)
# vim.keymap.set('n', '<leader>rv', jdtls.extract_variable_all, { desc = 'Extract variable', buffer = bufnr })
# vim.keymap.set('n', '<leader>rc', jdtls.extract_constant, { desc = 'Extract constant', buffer = bufnr })
# end
# }
#
# jdtls.start_or_attach(config)
# '';

View File

@ -0,0 +1,30 @@
{
lib,
config,
...
}: {
options = {
nvim-lint.enable = lib.mkEnableOption "Enable nvim-lint module";
};
config = lib.mkIf config.nvim-lint.enable {
plugins.lint = {
enable = true;
lintersByFt = {
c = ["cpplint"];
cpp = ["cpplint"];
go = ["golangci-lint"];
nix = ["statix"];
lua = ["selene"];
python = ["flake8"];
javascript = ["eslint_d"];
javascriptreact = ["eslint_d"];
typescript = ["eslint_d"];
typescriptreact = ["eslint_d"];
json = ["jsonlint"];
java = ["checkstyle"];
haskell = ["hlint"];
bash = ["shellcheck"];
};
};
};
}

View File

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

View File

@ -0,0 +1,128 @@
{
lib,
config,
...
}: {
options = {
treesitter-nvim.enable = lib.mkEnableOption "Enable treesitter-nvim module";
};
config = lib.mkIf config.treesitter-nvim.enable {
plugins.treesitter = {
enable = true;
settings = {
highlight = {
enable = true;
};
indent = {
enable = true;
};
autopairs = {
enable = true;
};
folding = {
enable = true;
};
ensure_installed = [
"bash"
"c"
# "html"
# "css"
# "javascript"
# "jsdoc"
"json"
"lua"
"luadoc"
# "luap"
"nix"
"rust"
# "java"
"markdown"
# "markdown_inline"
"python"
# "query"
# "regex"
# "tsx"
# "typescript"
"typst"
"vim"
"vimdoc"
"toml"
"yaml"
];
auto_install = true;
incremental_selection = {
enable = true;
keymaps = {
init_selection = "<C-space>";
node_incremental = "<C-space>";
scope_incremental = false;
node_decremental = "<bs>";
};
};
};
nixvimInjections = true;
};
plugins.treesitter-textobjects = {
enable = true;
select = {
enable = true;
lookahead = true;
keymaps = {
"aa" = "@parameter.outer";
"ia" = "@parameter.inner";
"af" = "@function.outer";
"if" = "@function.inner";
"ac" = "@class.outer";
"ic" = "@class.inner";
"ii" = "@conditional.inner";
"ai" = "@conditional.outer";
"il" = "@loop.inner";
"al" = "@loop.outer";
"at" = "@comment.outer";
};
};
move = {
enable = true;
gotoNextStart = {
"]m" = "@function.outer";
"]]" = "@class.outer";
};
gotoNextEnd = {
"]M" = "@function.outer";
"][" = "@class.outer";
};
gotoPreviousStart = {
"[m" = "@function.outer";
"[[" = "@class.outer";
};
gotoPreviousEnd = {
"[M" = "@function.outer";
"[]" = "@class.outer";
};
};
swap = {
enable = true;
swapNext = {
"<leader>a" = "@parameters.inner";
};
swapPrevious = {
"<leader>A" = "@parameter.outer";
};
};
};
plugins.ts-autotag = {
enable = true;
};
plugins.treesitter-context = {
enable = true;
};
plugins.ts-context-commentstring = {
enable = true;
disableAutoInitialization = false;
};
};
}

115
config/lsp/conform.nix Normal file
View File

@ -0,0 +1,115 @@
{
lib,
config,
...
}: {
options = {
conform.enable = lib.mkEnableOption "Enable conform module";
};
config = lib.mkIf config.conform.enable {
plugins.conform-nvim = {
enable = true;
settings = {
notify_on_error = true;
# default_format_opts = {
# lsp_format = "fallback";
# };
# format_after_save = {
# lsp_format = "fallback";
# };
format_on_save = ''
function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_format = 'fallback' }
end
'';
formatters_by_ft = {
html = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
css = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
javascript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
javascriptreact = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
typescript = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
typescriptreact = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
java = ["google-java-format"];
python = ["black"];
lua = ["stylua"];
nix = ["alejandra"];
typst = ["typstfmt"];
markdown = {
__unkeyed-1 = "prettierd";
__unkeyed-2 = "prettier";
stop_after_first = true;
};
rust = ["rustfmt"];
};
};
};
keymaps = [
{
mode = "n";
key = "<leader>uf";
action = ":FormatToggle<CR>";
options = {
desc = "Toggle Format Globally";
silent = true;
};
}
{
mode = "n";
key = "<leader>uF";
action = ":FormatToggle!<CR>";
options = {
desc = "Toggle Format Locally";
silent = true;
};
}
{
mode = "n";
key = "<leader>cf";
action = "<cmd>lua require('conform').format()<cr>";
options = {
silent = true;
desc = "Format Buffer";
};
}
{
mode = "v";
key = "<leader>cF";
action = "<cmd>lua require('conform').format()<cr>";
options = {
silent = true;
desc = "Format Lines";
};
}
];
};
}

24
config/lsp/default.nix Normal file
View File

@ -0,0 +1,24 @@
{
lib,
config,
...
}: {
imports = [
./conform.nix
./fidget.nix
./lsp-nvim.nix
./lspsaga.nix
./trouble.nix
];
options = {
lsp.enable = lib.mkEnableOption "Enable lsp module";
};
config = lib.mkIf config.dap.enable {
conform.enable = lib.mkDefault true;
fidget.enable = lib.mkDefault true;
lsp-nvim.enable = lib.mkDefault true;
lspsaga.enable = lib.mkDefault false;
trouble.enable = lib.mkDefault true;
};
}

108
config/lsp/fidget.nix Normal file
View File

@ -0,0 +1,108 @@
{
lib,
config,
...
}: {
options = {
fidget.enable = lib.mkEnableOption "Enable fidget module";
};
config = lib.mkIf config.fidget.enable {
plugins.fidget = {
enable = true;
logger = {
level = "warn"; # “off”, “error”, “warn”, “info”, “debug”, “trace”
floatPrecision = 1.0e-2; # Limit the number of decimals displayed for floats
};
progress = {
pollRate = 0; # How and when to poll for progress messages
suppressOnInsert = true; # Suppress new messages while in insert mode
ignoreDoneAlready = false; # Ignore new tasks that are already complete
ignoreEmptyMessage = false; # Ignore new tasks that don't contain a message
clearOnDetach =
# Clear notification group when LSP server detaches
''
function(client_id)
local client = vim.lsp.get_client_by_id(client_id)
return client and client.name or nil
end
'';
notificationGroup =
# How to get a progress message's notification group key
''
function(msg) return msg.lsp_client.name end
'';
ignore = []; # List of LSP servers to ignore
lsp = {
progressRingbufSize = 0; # Configure the nvim's LSP progress ring buffer size
};
display = {
renderLimit = 16; # How many LSP messages to show at once
doneTtl = 3; # How long a message should persist after completion
doneIcon = ""; # Icon shown when all LSP progress tasks are complete
doneStyle = "Constant"; # Highlight group for completed LSP tasks
progressTtl = lib.nixvim.mkRaw "math.huge"; # How long a message should persist when in progress
progressIcon = {
pattern = "dots";
period = 1;
}; # Icon shown when LSP progress tasks are in progress
progressStyle = "WarningMsg"; # Highlight group for in-progress LSP tasks
groupStyle = "Title"; # Highlight group for group name (LSP server name)
iconStyle = "Question"; # Highlight group for group icons
priority = 30; # Ordering priority for LSP notification group
skipHistory = true; # Whether progress notifications should be omitted from history
formatMessage = ''
require ("fidget.progress.display").default_format_message
''; # How to format a progress message
formatAnnote = ''
function (msg) return msg.title end
''; # How to format a progress annotation
formatGroupName = ''
function (group) return tostring (group) end
''; # How to format a progress notification group's name
overrides = {
rust_analyzer = {
name = "rust-analyzer";
};
}; # Override options from the default notification config
};
};
notification = {
pollRate = 10; # How frequently to update and render notifications
filter = "info"; # “off”, “error”, “warn”, “info”, “debug”, “trace”
historySize = 128; # Number of removed messages to retain in history
overrideVimNotify = true;
redirect = lib.nixvim.mkRaw ''
function(msg, level, opts)
if opts and opts.on_open then
return require("fidget.integration.nvim-notify").delegate(msg, level, opts)
end
end
'';
configs = {
default = lib.nixvim.mkRaw "require('fidget.notification').default_config";
};
window = {
normalHl = "Comment";
winblend = 0;
border = "none"; # none, single, double, rounded, solid, shadow
zindex = 45;
maxWidth = 0;
maxHeight = 0;
xPadding = 1;
yPadding = 0;
align = "bottom";
relative = "editor";
};
view = {
stackUpwards = true; # Display notification items from bottom to top
iconSeparator = " "; # Separator between group name and icon
groupSeparator = "---"; # Separator between notification groups
groupSeparatorHl =
# Highlight group used for group separator
"Comment";
};
};
};
};
}

214
config/lsp/lsp-nvim.nix Normal file
View File

@ -0,0 +1,214 @@
{
lib,
config,
...
}: {
options = {
lsp-nvim.enable = lib.mkEnableOption "Enable lsp-nvim module";
};
config = lib.mkIf config.lsp-nvim.enable {
plugins = {
lsp-format = {
enable = false; # Enable it if you want lsp-format integration for none-ls
};
lsp = {
enable = true;
capabilities = "offsetEncoding = 'utf-16'";
servers = {
clangd = {
enable = true;
};
lua_ls = {
enable = true;
extraOptions = {
settings = {
Lua = {
completion = {
callSnippet = "Replace";
};
diagnostics = {
globals = ["vim"];
};
telemetry = {
enabled = false;
};
hint = {
enable = true;
};
};
};
};
};
nil_ls = {
enable = false;
};
nixd = {
enable = true;
};
tinymist = {
enable = true;
};
eslint = {
enable = false;
};
pyright = {
enable = false;
};
ruff = {
enable = false;
};
rust_analyzer = {
enable = true;
installCargo = true;
installRustc = true;
settings = {
checkOnSave = true;
check = {
command = "clippy";
};
# inlayHints = {
# enable = true;
# showParameterNames = true;
# parameterHintsPrefix = "<- ";
# otherHintsPrefix = "=> ";
# };
procMacro = {
enable = true;
};
};
};
};
keymaps = {
silent = true;
lspBuf = {
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>" = {
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";
};
};
};
onAttach = ''
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(false)
end
vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
end,
})
'';
};
};
extraConfigLua = ''
local _border = "rounded"
require('lspconfig.ui.windows').default_options = {
border = _border
}
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 = "rounded" },
virtual_text = {
prefix = "",
},
signs = true,
underline = true,
update_in_insert = true,
})
-- vim.api.nvim_create_autocmd("LspAttach", {
-- group = vim.api.nvim_create_augroup("UserLspConfig", {}),
-- callback = function(args)
-- local client = vim.lsp.get_client_by_id(args.data.client_id)
-- if client.server_capabilities.inlayHintProvider then
-- vim.lsp.inlay_hint.enable(false)
-- end
-- vim.bo[args.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
--
-- local opts = { buffer = args.buf }
-- vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
-- vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
-- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
-- vim.keymap.set("n", "gI", vim.lsp.buf.implementation, opts)
-- vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts)
-- vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
-- vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
-- vim.keymap.set("n", "<space>cw", vim.lsp.buf.workspace_symbol, opts)
-- vim.keymap.set("n", "<space>cr", vim.lsp.buf.rename, opts)
-- vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, opts)
-- vim.keymap.set("n", "<space>cf", function()
-- vim.lsp.buf.format({ async = true })
-- end, opts)
-- vim.keymap.set("n", "<space>cd", vim.diagnostic.open_float, opts)
-- vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts)
-- vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts)
-- end,
-- })
'';
};
}

201
config/lsp/lspsaga.nix Normal file
View File

@ -0,0 +1,201 @@
{
lib,
config,
...
}: {
options = {
lspsaga.enable = lib.mkEnableOption "Enable lspsaga module";
};
config = lib.mkIf config.lspsaga.enable {
plugins.lspsaga = {
enable = true;
beacon = {
enable = true;
};
ui = {
border = "rounded"; # One of none, single, double, rounded, solid, shadow
codeAction = "💡"; # Can be any symbol you want 💡
};
hover = {
openCmd = "!floorp"; # Choose your browser
openLink = "gx";
};
diagnostic = {
borderFollow = true;
diagnosticOnlyCurrent = false;
showCodeAction = true;
};
symbolInWinbar = {
enable = true; # Breadcrumbs
};
codeAction = {
extendGitSigns = false;
showServerName = true;
onlyInCursor = true;
numShortcut = true;
keys = {
exec = "<CR>";
quit = [
"<Esc>"
"q"
];
};
};
lightbulb = {
enable = false;
sign = false;
virtualText = true;
};
implement = {
enable = false;
};
rename = {
autoSave = false;
keys = {
exec = "<CR>";
quit = [
"<C-k>"
"<Esc>"
];
select = "x";
};
};
outline = {
autoClose = true;
autoPreview = true;
closeAfterJump = true;
layout = "normal"; # normal or float
winPosition = "right"; # left or right
keys = {
jump = "e";
quit = "q";
toggleOrJump = "o";
};
};
scrollPreview = {
scrollDown = "<C-f>";
scrollUp = "<C-b>";
};
};
# keymaps = [
# {
# mode = "n";
# key = "gd";
# action = "<cmd>Lspsaga finder def<CR>";
# options = {
# desc = "Goto Definition";
# silent = true;
# };
# }
# {
# mode = "n";
# key = "gr";
# action = "<cmd>Lspsaga finder ref<CR>";
# options = {
# desc = "Goto References";
# silent = true;
# };
# }
#
# # {
# # mode = "n";
# # key = "gD";
# # action = "<cmd>Lspsaga show_line_diagnostics<CR>";
# # options = {
# # desc = "Goto Declaration";
# # silent = true;
# # };
# # }
#
# {
# mode = "n";
# key = "gI";
# action = "<cmd>Lspsaga finder imp<CR>";
# options = {
# desc = "Goto Implementation";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "gT";
# action = "<cmd>Lspsaga peek_type_definition<CR>";
# options = {
# desc = "Type Definition";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "K";
# action = "<cmd>Lspsaga hover_doc<CR>";
# options = {
# desc = "Hover";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "<leader>cw";
# action = "<cmd>Lspsaga outline<CR>";
# options = {
# desc = "Outline";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "<leader>cr";
# action = "<cmd>Lspsaga rename<CR>";
# options = {
# desc = "Rename";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "<leader>ca";
# action = "<cmd>Lspsaga code_action<CR>";
# options = {
# desc = "Code Action";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "<leader>cd";
# action = "<cmd>Lspsaga show_line_diagnostics<CR>";
# options = {
# desc = "Line Diagnostics";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "[d";
# action = "<cmd>Lspsaga diagnostic_jump_next<CR>";
# options = {
# desc = "Next Diagnostic";
# silent = true;
# };
# }
#
# {
# mode = "n";
# key = "]d";
# action = "<cmd>Lspsaga diagnostic_jump_prev<CR>";
# options = {
# desc = "Previous Diagnostic";
# silent = true;
# };
# }
# ];
};
}

61
config/lsp/trouble.nix Normal file
View File

@ -0,0 +1,61 @@
{
lib,
config,
...
}: {
options = {
trouble.enable = lib.mkEnableOption "Enable trouble module";
};
config = lib.mkIf config.trouble.enable {
plugins.trouble = {
enable = true;
settings = {
auto_close = true;
};
};
# TODO: Add keybinds to close trouble (q would be nice), rn I need to use :x to close it...
keymaps = [
{
mode = "n";
key = "<leader>x";
action = "+diagnostics/quickfix";
}
{
mode = "n";
key = "<leader>xx";
action = "<cmd>Trouble diagnostics toggle<cr>";
options = {
silent = true;
desc = "Diagnostics (Trouble)";
};
}
{
mode = "n";
key = "<leader>xX";
action = "<cmd>Trouble diagnostics toggle filter.buf=0<cr>";
options = {
silent = true;
desc = "Buffer Diagnostics (Trouble)";
};
}
{
mode = "n";
key = "<leader>xt";
action = "<cmd>Trouble todo<cr>";
options = {
silent = true;
desc = "Todo (Trouble)";
};
}
{
mode = "n";
key = "<leader>xQ";
action = "<cmd>Trouble qflist toggle<cr>";
options = {
silent = true;
desc = "Quickfix List (Trouble)";
};
}
];
};
}

View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./none-ls-nvim.nix
];
options = {
none-ls.enable = lib.mkEnableOption "Enable none-ls module";
};
config = lib.mkIf config.none-ls.enable {
none-ls-nvim.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,87 @@
{
lib,
config,
...
}: {
options = {
none-ls-nvim.enable = lib.mkEnableOption "Enable none-ls-nvim module";
};
config = lib.mkIf config.none-ls-nvim.enable {
plugins.none-ls = {
enable = true;
settings = {
enableLspFormat = false;
updateInInsert = false;
onAttach = ''
function(client, bufnr)
if client.supports_method "textDocument/formatting" then
vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr }
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format { bufnr = bufnr }
end,
})
end
end
'';
};
sources = {
code_actions = {
gitsigns.enable = true;
statix.enable = true;
};
diagnostics = {
checkstyle = {
enable = true;
};
statix = {
enable = true;
};
};
formatting = {
alejandra = {
enable = false;
};
nixfmt = {
enable = true;
};
prettier = {
enable = true;
settings = ''
{
extra_args = { "--no-semi", "--single-quote" },
}
'';
};
google_java_format = {
enable = true;
};
stylua = {
enable = true;
};
black = {
enable = true;
settings = ''
{
extra_args = { "--fast" },
}
'';
};
};
};
};
# keymaps = [
# {
# mode = [ "n" "v" ];
# key = "<leader>cf";
# action = "<cmd>lua vim.lsp.buf.format()<cr>";
# options = {
# silent = true;
# desc = "Format";
# };
# }
# ];
};
}

View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./lazy-nvim.nix
];
options = {
pluginmanagers.enable = lib.mkEnableOption "Enable pluginmanagers module";
};
config = lib.mkIf config.pluginmanagers.enable {
lazy-nvim.enable = lib.mkDefault true;
};
}

View File

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

16
config/sets/default.nix Normal file
View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./set.nix
];
options = {
sets.enable = lib.mkEnableOption "Enable sets module";
};
config = lib.mkIf config.utils.enable {
set.enable = lib.mkDefault true;
};
}

148
config/sets/set.nix Normal file
View File

@ -0,0 +1,148 @@
{
lib,
config,
...
}: {
options = {
set.enable = lib.mkEnableOption "Enable set module";
};
config = lib.mkIf config.set.enable {
opts = {
# Enable relative line numbers
number = true;
relativenumber = true;
# Set tabs to 2 spaces
tabstop = 2;
softtabstop = 2;
showtabline = 2;
expandtab = true;
# Enable auto indenting and set it to spaces
smartindent = true;
shiftwidth = 2;
# Enable smart indenting (see https://stackoverflow.com/questions/1204149/smart-wrap-in-vim)
breakindent = true;
# Enable incremental searching
hlsearch = true;
incsearch = true;
# Enable text wrap
wrap = true;
# Better splitting
splitbelow = true;
splitright = true;
# Enable mouse mode
mouse = "a"; # Mouse
# Enable ignorecase + smartcase for better searching
ignorecase = true;
smartcase = true; # Don't ignore case with capitals
grepprg = "rg --vimgrep";
grepformat = "%f:%l:%c:%m";
# Decrease updatetime
updatetime = 50; # faster completion (4000ms default)
# Set completeopt to have a better completion experience
completeopt = [
"menuone"
"noselect"
"noinsert"
]; # mostly just for cmp
# Enable persistent undo history
swapfile = false;
backup = false;
undofile = true;
# Enable 24-bit colors
termguicolors = true;
# Enable the sign column to prevent the screen from jumping
signcolumn = "yes";
# Enable cursor line highlight
cursorline = false; # Highlight the line where the cursor is located
# Set fold settings
# These options were reccommended by nvim-ufo
# See: https://github.com/kevinhwang91/nvim-ufo#minimal-configuration
foldcolumn = "0";
foldlevel = 99;
foldlevelstart = 99;
foldenable = true;
foldmethod = "expr";
foldexpr = "v:lua.vim.treesitter.foldexpr()";
# Always keep 8 lines above/below cursor unless at start/end of file
scrolloff = 8;
# Place a column line
colorcolumn = "80";
# Reduce which-key timeout
timeoutlen = 200;
# Set encoding type
encoding = "utf-8";
fileencoding = "utf-8";
# Change cursor options
guicursor = [
"n-v-c:block" # Normal, visual, command-line: block cursor
"i-ci-ve:block" # Insert, command-line insert, visual-exclude: vertical bar cursor with block cursor, use "ver25" for 25% width
"r-cr:hor20" # Replace, command-line replace: horizontal bar cursor with 20% height
"o:hor50" # Operator-pending: horizontal bar cursor with 50% height
"a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor" # All modes: blinking settings
"sm:block-blinkwait175-blinkoff150-blinkon175" # Showmatch: block cursor with specific blinking settings
];
# Enable chars list
list = false; # Show invisible characters (tabs, eol, ...)
listchars = "eol:,tab:|->,lead:·,space: ,trail:,extends:,precedes:,nbsp:";
# More space in the neovim command line for displaying messages
cmdheight = 2;
# We don't need to see things like INSERT anymore
showmode = false;
# Maximum number of items to show in the popup menu (0 means "use available screen space")
pumheight = 0;
# Use conform-nvim for gq formatting. ('formatexpr' is set to vim.lsp.formatexpr(), so you can format lines via gq if the language server supports it)
formatexpr = "v:lua.require'conform'.formatexpr()";
laststatus = 3; # (https://neovim.io/doc/user/options.html#'laststatus')
inccommand = "split"; # (https://neovim.io/doc/user/options.html#'inccommand')
};
extraConfigLua = ''
local opt = vim.opt
local g = vim.g
local o = vim.o
-- Neovide
if g.neovide then
g.neovide_fullscreen = false
g.neovide_hide_mouse_when_typing = false
g.neovide_refresh_rate = 165
g.neovide_cursor_vfx_mode = "ripple"
g.neovide_cursor_animate_command_line = true
g.neovide_cursor_animate_in_insert_mode = true
g.neovide_cursor_vfx_particle_lifetime = 5.0
g.neovide_cursor_vfx_particle_density = 14.0
g.neovide_cursor_vfx_particle_speed = 12.0
g.neovide_transparency = 0.8
-- Neovide Fonts
o.guifont = "Iosevka Nerd Font:h14:Medium:i"
end
'';
};
}

View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./luasnip.nix
];
options = {
snippets.enable = lib.mkEnableOption "Enable snippets module";
};
config = lib.mkIf config.snippets.enable {
luasnip.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,25 @@
{
lib,
config,
pkgs,
...
}: {
options = {
luasnip.enable = lib.mkEnableOption "Enable luasnip module";
};
config = lib.mkIf config.luasnip.enable {
plugins.luasnip = {
enable = true;
settings = {
enable_autosnippets = true;
store_selection_keys = "<Tab>";
};
fromVscode = [
{
lazyLoad = true;
paths = "${pkgs.vimPlugins.friendly-snippets}";
}
];
};
};
}

View File

@ -0,0 +1,18 @@
{
lib,
config,
...
}: {
imports = [
./lualine.nix
./staline.nix
];
options = {
statusline.enable = lib.mkEnableOption "Enable statusline module";
};
config = lib.mkIf config.dap.enable {
lualine.enable = lib.mkDefault true;
staline.enable = lib.mkDefault false;
};
}

View File

@ -0,0 +1,115 @@
{
lib,
config,
...
}: {
options = {
lualine.enable = lib.mkEnableOption "Enable lualine module";
};
config = lib.mkIf config.lualine.enable {
plugins.lualine = {
enable = true;
settings = {
alwaysDivideMiddle = true;
globalstatus = true;
ignoreFocus = ["neo-tree"];
extensions = ["fzf"];
theme = "auto";
componentSeparators = {
left = "|";
right = "|";
};
sectionSeparators = {
left = ""; # 
right = ""; # 
};
sections = {
lualine_a = ["mode"];
lualine_b = [
"branch"
""
"diff"
"diagnostics"
];
lualine_c = ["filename"];
lualine_x = ["filetype"];
lualine_y = ["progress"];
lualine_z = [''" " .. os.date("%R")''];
};
};
};
extraConfigLua = ''
config = function()
local harpoon = require("harpoon.mark")
local function truncate_branch_name(branch)
if not branch or branch == "" then
return ""
end
-- Match the branch name to the specified format
local user, team, ticket_number = string.find(branch, "(%w+)%/(%w+)%-(%d+)%-")
-- If the branch name matches the format, display sko-{ticket_number}, otherwise display the full branch name
if ticket_number then
return user .. "/" .. team .. "-" .. ticket_number
else
return branch
end
end
local function harpoon_component()
local total_marks = harpoon.get_length()
if total_marks == 0 then
return ""
end
local current_mark = ""
local mark_idx = harpoon.get_current_index()
if mark_idx ~= nil then
current_mark = tostring(mark_idx)
end
return string.format("󱡅 %s/%d", current_mark, total_marks)
end
local function get_lsp_client(_)
---@type any?{}
local client_names = {}
local msg = "No Active Lsp"
local clients = vim.lsp.get_clients({ bufnr = 0 })
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
table.insert(client_names, client.name)
end
return #client_names == 0 and msg or table.concat(client_names, " | ")
end
local function wordcount()
return tostring(vim.fn.wordcount().words) .. " words"
end
local function readingtime()
return tostring(math.ceil(vim.fn.wordcount().words / 200.0)) .. " min"
end
local function is_markdown()
return vim.bo.filetype == "markdown" or vim.bo.filetype == "asciidoc"
end
local function navic()
return require("nvim-navic").get_location()
end
local function navic_is_available()
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
end
local cmd_mode = function()
return require("noice").api.status.mode.get()
end
local show_mode = function()
return package.loaded["noice"] and require("noice").api.status.mode.has() or ""
end
end
'';
};
}

View File

@ -0,0 +1,75 @@
{
lib,
config,
pkgs,
...
}: {
options = {
staline.enable = lib.mkEnableOption "Enable staline module";
};
config = lib.mkIf config.staline.enable {
extraPlugins = with pkgs.vimUtils; [
(buildVimPlugin {
pname = "staline.nvim";
version = "2024-02-05";
src = pkgs.fetchFromGitHub {
owner = "tamton-aquib";
repo = "staline.nvim";
rev = "a53f869278b8b186a5afd6f21680cd103c381599";
hash = "sha256-GDMKzxFDtQk5LL+rMsxTGTyLv69w5NUd+u19noeO5ws=";
};
})
];
extraConfigLua = ''
require("staline").setup({
sections = {
left = { "-mode", " ", "branch" },
mid = { "lsp_name" },
right = { "file_name", "line_column" },
},
inactive_sections = {
left = { "-mode", " ", "branch" },
mid = { "lsp_name" },
right = { "file_name", "line_column" },
},
defaults = {
left_separator = " ",
right_separator = " ",
branch_symbol = " ",
mod_symbol = "",
line_column = "[%l/%L]",
inactive_color = "#80a6f2", --#303030 is the default
inactive_bgcolor = "none",
},
special_table = {
lazy = { "Plugins", "💤 " },
TelescopePrompt = { "Telescope", " " },
oil = { "Oil", "󰏇 " },
lazygit = { "LazyGit", " " },
},
mode_icons = {
["n"] = "NORMAL",
["no"] = "NORMAL",
["nov"] = "NORMAL",
["noV"] = "NORMAL",
["niI"] = "NORMAL",
["niR"] = "NORMAL",
["niV"] = "NORMAL",
["i"] = "INSERT",
["ic"] = "INSERT",
["ix"] = "INSERT",
["s"] = "INSERT",
["S"] = "INSERT",
["v"] = "VISUAL",
["V"] = "VISUAL",
[""] = "VISUAL",
["r"] = "REPLACE",
["r?"] = "REPLACE",
["R"] = "REPLACE",
["c"] = "COMMAND",
["t"] = "TERMINAL",
},
})
'';
};
}

View File

@ -0,0 +1,16 @@
{
lib,
config,
...
}: {
imports = [
./telescope-nvim.nix
];
options = {
telescope.enable = lib.mkEnableOption "Enable telescope module";
};
config = lib.mkIf config.telescope.enable {
telescope-nvim.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,162 @@
{
lib,
config,
...
}: {
options = {
telescope-nvim.enable = lib.mkEnableOption "Enable telescope-nvim module";
};
config = lib.mkIf config.telescope-nvim.enable {
plugins.telescope = {
enable = true;
extensions = {
fzf-native = {
enable = true;
settings = {
fuzzy = true;
override_generic_sorter = true;
override_file_sorter = true;
case_mode = "smart_case";
};
};
ui-select = {
enable = true;
settings = {
specific_opts = {
codeactions = 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 = {
mappings = {
i = {
"<esc>" = {
__raw = ''
function(...)
return require("telescope.actions").close(...)
end'';
};
};
};
};
pickers = {
colorscheme = {
enable_preview = true;
};
# find_files = {
# theme = "ivy";
# };
};
};
keymaps = {
"<leader><space>" = {
action = "find_files";
options.desc = "Find project files";
};
"<leader>/" = {
action = "live_grep";
options.desc = "Grep (root dir)";
};
"<leader>:" = {
action = "command_history";
options.desc = "Command History";
};
"<leader>b" = {
action = "buffers";
options.desc = "+buffer";
};
"<leader>ff" = {
action = "find_files";
options.desc = "Find project files";
};
"<leader>fr" = {
action = "oldfiles";
options.desc = "Recent";
};
"<leader>fb" = {
action = "buffers";
options.desc = "Buffers";
};
"<C-p>" = {
action = "git_files";
options.desc = "Search git files";
};
"<leader>gc" = {
action = "git_commits";
options.desc = "Commits";
};
"<leader>gs" = {
action = "git_status";
options.desc = "Status";
};
"<leader>sa" = {
action = "autocommands";
options.desc = "Auto Commands";
};
"<leader>sb" = {
action = "current_buffer_fuzzy_find";
options.desc = "Buffer";
};
"<leader>sc" = {
action = "command_history";
options.desc = "Command History";
};
"<leader>sC" = {
action = "commands";
options.desc = "Commands";
};
"<leader>sD" = {
action = "diagnostics";
options.desc = "Workspace diagnostics";
};
"<leader>sh" = {
action = "help_tags";
options.desc = "Help pages";
};
"<leader>sH" = {
action = "highlights";
options.desc = "Search Highlight Groups";
};
"<leader>sk" = {
action = "keymaps";
options.desc = "Keymaps";
};
"<leader>sM" = {
action = "man_pages";
options.desc = "Man pages";
};
"<leader>sm" = {
action = "marks";
options.desc = "Jump to Mark";
};
"<leader>so" = {
action = "vim_options";
options.desc = "Options";
};
"<leader>sR" = {
action = "resume";
options.desc = "Resume";
};
"<leader>uC" = {
action = "colorscheme";
options.desc = "Colorscheme preview";
};
"<leader>fp" = {
action = "projects";
options.desc = "Projects";
};
"<leader>sd" = {
action = "diagnostics bufnr=0";
options.desc = "Document Diagnostics";
};
"<leader>st" = {
action = "todo-comments";
options.desc = "Todo (Telescope)";
};
};
};
};
}

207
config/ui/alpha.nix Normal file
View File

@ -0,0 +1,207 @@
{
lib,
config,
...
}: {
options = {
alpha.enable = lib.mkEnableOption "Enable alpha module";
};
config = lib.mkIf config.alpha.enable {
plugins.alpha = {
enable = true;
theme = null;
layout = let
padding = val: {
type = "padding";
inherit val;
};
in [
(padding 4)
{
opts = {
hl = "AlphaHeader";
position = "center";
};
type = "text";
val = [
" :::::: :::: ::: :::::::::: ::::::::: ::: ::: ::: ::: :::::::::: :::::: "
" :+: :+:+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: "
" +:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ "
" +#+ +#+ +:+ +#+ +#++:++# +#++:++#+ +#+ +:+ +#+ +#++:++#++: +#++:++# +#+ "
" +#+ +#+ +#+#+# +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ "
" #+# #+# #+#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# "
" ###### ### #### ########## ######### ######## ########## ### ### ########## ###### "
];
}
(padding 2)
{
type = "button";
val = " Find File";
on_press = {
__raw = "function() require('telescope.builtin').find_files() end";
};
opts = {
# hl = "comment";
keymap = [
"n"
"f"
":Telescope find_files <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "f";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = " New File";
on_press = {
__raw = "function() vim.cmd[[ene]] end";
};
opts = {
# hl = "comment";
keymap = [
"n"
"n"
":ene <BAR> startinsert <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "n";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = "󰈚 Recent Files";
on_press = {
__raw = "function() require('telescope.builtin').oldfiles() end";
};
opts = {
# hl = "comment";
keymap = [
"n"
"r"
":Telescope oldfiles <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "r";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = "󰈭 Find Word";
on_press = {
__raw = "function() require('telescope.builtin').live_grep() end";
};
opts = {
# hl = "comment";
keymap = [
"n"
"g"
":Telescope live_grep <CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "g";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = " Restore Session";
on_press = {
__raw = "function() require('persistence').load() end";
};
opts = {
# hl = "comment";
keymap = [
"n"
"s"
":lua require('persistence').load()<cr>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "s";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
(padding 1)
{
type = "button";
val = " Quit Neovim";
on_press = {
__raw = "function() vim.cmd[[qa]] end";
};
opts = {
# hl = "comment";
keymap = [
"n"
"q"
":qa<CR>"
{
noremap = true;
silent = true;
nowait = true;
}
];
shortcut = "q";
position = "center";
cursor = 3;
width = 38;
align_shortcut = "right";
hl_shortcut = "Keyword";
};
}
];
};
};
}

34
config/ui/barbecue.nix Normal file
View File

@ -0,0 +1,34 @@
{
lib,
config,
...
}: {
options = {
barbecue.enable = lib.mkEnableOption "Enable barbecue module";
};
config = lib.mkIf config.barbecue.enable {
plugins.barbecue = {
enable = true;
settings = {
create_autocmd = false;
theme = "auto";
};
};
extraConfigLua = ''
vim.api.nvim_create_autocmd({
"WinScrolled", -- or WinResized on NVIM-v0.9 and higher
"BufWinEnter",
"CursorHold",
"InsertLeave",
-- include this if you have set `show_modified` to `true`
"BufModifiedSet",
}, {
group = vim.api.nvim_create_augroup("barbecue.updater", {}),
callback = function()
require("barbecue.ui").update()
end,
})
'';
};
}

30
config/ui/default.nix Normal file
View File

@ -0,0 +1,30 @@
{
lib,
config,
...
}: {
imports = [
./alpha.nix
./barbecue.nix
./dressing-nvim.nix
./indent-blankline.nix
./noice.nix
./nui.nix
./notify.nix
./web-devicons.nix
];
options = {
ui.enable = lib.mkEnableOption "Enable ui module";
};
config = lib.mkIf config.ui.enable {
alpha.enable = lib.mkDefault true;
barbecue.enable = lib.mkDefault true;
dressing-nvim.enable = lib.mkDefault true;
indent-blankline.enable = lib.mkDefault true;
noice.enable = lib.mkDefault false;
notify.enable = lib.mkDefault true;
nui.enable = lib.mkDefault true;
web-devicons.enable = lib.mkDefault true;
};
}

181
config/ui/dressing-nvim.nix Normal file
View File

@ -0,0 +1,181 @@
{
lib,
config,
pkgs,
...
}: {
options = {
dressing-nvim.enable = lib.mkEnableOption "Enable dressing-nvim module";
};
config = lib.mkIf config.dressing-nvim.enable {
extraPlugins = with pkgs.vimPlugins; [
dressing-nvim
];
extraConfigLua = ''
require("dressing").setup({
input = {
-- Set to false to disable the vim.ui.input implementation
enabled = true,
-- Default prompt string
default_prompt = "Input",
-- Trim trailing `:` from prompt
trim_prompt = true,
-- Can be 'left', 'right', or 'center'
title_pos = "left",
-- When true, <Esc> will close the modal
insert_only = true,
-- When true, input will start in insert mode.
start_in_insert = true,
-- These are passed to nvim_open_win
border = "rounded",
-- 'editor' and 'win' will default to being centered
relative = "cursor",
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
prefer_width = 40,
width = nil,
-- min_width and max_width can be a list of mixed types.
-- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
max_width = { 140, 0.9 },
min_width = { 20, 0.2 },
buf_options = {},
win_options = {
-- Disable line wrapping
wrap = false,
-- Indicator for when text exceeds window
list = true,
listchars = "precedes:,extends:",
-- Increase this for more context when text scrolls off the window
sidescrolloff = 0,
},
-- Set to `false` to disable
mappings = {
n = {
["<Esc>"] = "Close",
["<CR>"] = "Confirm",
},
i = {
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
["<Up>"] = "HistoryPrev",
["<Down>"] = "HistoryNext",
},
},
override = function(conf)
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
return conf
end,
-- see :help dressing_get_config
get_config = nil,
},
select = {
-- Set to false to disable the vim.ui.select implementation
enabled = true,
-- Priority list of preferred vim.select implementations
backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" },
-- Trim trailing `:` from prompt
trim_prompt = true,
-- Options for telescope selector
-- These are passed into the telescope picker directly. Can be used like:
-- telescope = require('telescope.themes').get_ivy({...})
telescope = nil,
-- Options for fzf selector
fzf = {
window = {
width = 0.5,
height = 0.4,
},
},
-- Options for fzf-lua
fzf_lua = {
-- winopts = {
-- height = 0.5,
-- width = 0.5,
-- },
},
-- Options for nui Menu
nui = {
position = "50%",
size = nil,
relative = "editor",
border = {
style = "rounded",
},
buf_options = {
swapfile = false,
filetype = "DressingSelect",
},
win_options = {
winblend = 0,
},
max_width = 80,
max_height = 40,
min_width = 40,
min_height = 10,
},
-- Options for built-in selector
builtin = {
-- Display numbers for options and set up keymaps
show_numbers = true,
-- These are passed to nvim_open_win
border = "rounded",
-- 'editor' and 'win' will default to being centered
relative = "editor",
buf_options = {},
win_options = {
cursorline = true,
cursorlineopt = "both",
},
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- the min_ and max_ options can be a list of mixed types.
-- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total"
width = nil,
max_width = { 140, 0.8 },
min_width = { 40, 0.2 },
height = nil,
max_height = 0.9,
min_height = { 10, 0.2 },
-- Set to `false` to disable
mappings = {
["<Esc>"] = "Close",
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
},
override = function(conf)
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
return conf
end,
},
-- Used to override format_item. See :help dressing-format
format_item_override = {},
-- see :help dressing_get_config
get_config = nil,
},
}) '';
};
}

View File

@ -0,0 +1,45 @@
{
lib,
config,
...
}: {
options = {
indent-blankline.enable = lib.mkEnableOption "Enable indent-blankline module";
};
config = lib.mkIf config.indent-blankline.enable {
plugins = {
indent-blankline = {
enable = true;
settings = {
indent = {
char = ""; # "│" or "▎"
};
scope = {
enabled = true;
show_start = true;
};
exclude = {
buftypes = [
"terminal"
"nofile"
];
filetypes = [
"help"
"alpha"
"dashboard"
"neo-tree"
"Trouble"
"trouble"
"lazy"
"mason"
"notify"
"toggleterm"
"lazyterm"
"nvterm"
];
};
};
};
};
};
}

59
config/ui/noice.nix Normal file
View File

@ -0,0 +1,59 @@
{
lib,
config,
...
}: {
options = {
noice.enable = lib.mkEnableOption "Enable noice module";
};
config = lib.mkIf config.noice.enable {
plugins.noice = {
enable = true;
notify = {
enabled = false;
};
messages = {
enabled = true; # Adds a padding-bottom to neovim statusline when set to false for some reason
};
lsp = {
message = {
enabled = true;
};
progress = {
enabled = false;
view = "mini";
};
};
popupmenu = {
enabled = true;
backend = "nui";
};
format = {
filter = {
pattern = [
":%s*%%s*s:%s*"
":%s*%%s*s!%s*"
":%s*%%s*s/%s*"
"%s*s:%s*"
":%s*s!%s*"
":%s*s/%s*"
];
icon = "";
lang = "regex";
};
replace = {
pattern = [
":%s*%%s*s:%w*:%s*"
":%s*%%s*s!%w*!%s*"
":%s*%%s*s/%w*/%s*"
"%s*s:%w*:%s*"
":%s*s!%w*!%s*"
":%s*s/%w*/%s*"
];
icon = "󱞪";
lang = "regex";
};
};
};
};
}

146
config/ui/notify.nix Normal file
View File

@ -0,0 +1,146 @@
{
lib,
config,
...
}: {
options = {
notify.enable = lib.mkEnableOption "Enable notify module";
};
config = lib.mkIf config.notify.enable {
plugins.notify = {
enable = true;
backgroundColour = "#000000";
fps = 60;
render = "default";
timeout = 500;
topDown = true;
};
keymaps = [
{
mode = "n";
key = "<leader>un";
action = ''
<cmd>lua require("notify").dismiss({ silent = true, pending = true })<cr>
'';
options = {
desc = "Dismiss All Notifications";
};
}
];
extraConfigLua = ''
local notify = require("notify")
local function show_notification(message, level)
notify(message, level, { title = "conform.nvim" })
end
function ToggleLineNumber()
if vim.wo.number then
vim.wo.number = false
show_notification("Line numbers disabled", "info")
else
vim.wo.number = true
vim.wo.relativenumber = false
show_notification("Line numbers enabled", "info")
end
end
function ToggleRelativeLineNumber()
if vim.wo.relativenumber then
vim.wo.relativenumber = false
show_notification("Relative line numbers disabled", "info")
else
vim.wo.relativenumber = true
vim.wo.number = false
show_notification("Relative line numbers enabled", "info")
end
end
function ToggleWrap()
if vim.wo.wrap then
vim.wo.wrap = false
show_notification("Wrap disabled", "info")
else
vim.wo.wrap = true
vim.wo.number = false
show_notification("Wrap enabled", "info")
end
end
function ToggleInlayHints()
local is_enabled = vim.lsp.inlay_hint.is_enabled()
vim.lsp.inlay_hint.enable(not is_enabled)
if is_enabled then
show_notification("Inlay Hints disabled", "info")
else
show_notification("Inlay Hints enabled", "info")
end
end
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local current_dir = vim.fn.getcwd()
local is_nixpkgs = current_dir:match("nixpkgs$")
if is_nixpkgs then
vim.b.disable_autoformat = true
show_notification("Autoformat-on-save disabled for nixpkgs", "info")
else
vim.b.disable_autoformat = false
end
end,
})
vim.api.nvim_create_user_command("FormatToggle", function(args)
local is_global = not args.bang
local current_dir = vim.fn.getcwd()
local is_nixpkgs = current_dir:match("nixpkgs$")
if is_global then
vim.g.disable_autoformat = not vim.g.disable_autoformat
if vim.g.disable_autoformat then
show_notification("Autoformat-on-save disabled globally", "info")
else
show_notification("Autoformat-on-save enabled globally", "info")
end
elseif is_nixpkgs then
vim.b.disable_autoformat = not vim.b.disable_autoformat
if vim.b.disable_autoformat then
show_notification("Autoformat-on-save disabled for nixpkgs", "info")
else
show_notification("Autoformat-on-save enabled for nixpkgs", "info")
end
else
vim.b.disable_autoformat = not vim.b.disable_autoformat
if vim.b.disable_autoformat then
show_notification("Autoformat-on-save disabled for this buffer", "info")
else
show_notification("Autoformat-on-save enabled for this buffer", "info")
end
end
end, {
desc = "Toggle autoformat-on-save",
bang = true,
})
local filtered_message = { "No information available" }
-- Override notify function to filter out messages
---@diagnostic disable-next-line: duplicate-set-field
vim.notify = function(message, level, opts)
local merged_opts = vim.tbl_extend("force", {
on_open = function(win)
local buf = vim.api.nvim_win_get_buf(win)
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
end,
}, opts or {})
for _, msg in ipairs(filtered_message) do
if message == msg then
return
end
end
return notify(message, level, merged_opts)
end
'';
};
}

13
config/ui/nui.nix Normal file
View File

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

View File

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

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,
}),
})
)
''
];
};
};
}