feat:add_nixvim

This commit is contained in:
dichgrem
2025-09-21 15:54:31 +08:00
parent c36f91562d
commit 8016a1173d
64 changed files with 3608 additions and 30 deletions

View File

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

View File

@@ -0,0 +1,172 @@
{
plugins = {
bufferline = {
enable = true;
settings = {
highlights = {
background = {
bg = "#252434";
fg = "#605f6f";
};
buffer_selected = {
bg = "#1E1D2D";
fg = "#D9E0EE";
};
buffer_visible = {
fg = "#605f6f";
bg = "#252434";
};
error = {
fg = "#605f6f";
bg = "#252434";
};
error_diagnostic = {
fg = "#605f6f";
bg = "#252434";
};
close_button = {
fg = "#605f6f";
bg = "#252434";
};
close_button_visible = {
fg = "#605f6f";
bg = "#252434";
};
fill = {
bg = "#1E1D2D";
fg = "#605f6f";
};
indicator_selected = {
bg = "#1E1D2D";
fg = "#1E1D2D";
};
modified = {
fg = "#F38BA8";
bg = "#252434";
};
modified_visible = {
fg = "#F38BA8";
bg = "#252434";
};
modified_selected = {
fg = "#ABE9B3";
bg = "#1E1D2D";
};
separator = {
bg = "#252434";
fg = "#252434";
};
separator_visible = {
bg = "#252434";
fg = "#252434";
};
separator_selected = {
bg = "#252434";
fg = "#252434";
};
duplicate = {
fg = "NONE";
bg = "#252434";
};
duplicate_selected = {
fg = "#F38BA8";
bg = "#1E1D2D";
};
duplicate_visible = {
fg = "#89B4FA";
bg = "#252434";
};
};
options.offsets = [
{
filetype = "neo-tree";
text = "Neo-tree";
highlight = "Directory";
text_align = "left";
}
];
};
};
};
keymaps = [
{
mode = "n";
key = "<C-Tab>";
action = "<cmd>BufferLineCycleNext<cr>";
options = {
desc = "Cycle to next buffer";
};
}
{
mode = "n";
key = "<C-S-Tab>";
action = "<cmd>BufferLineCyclePrev<cr>";
options = {
desc = "Cycle to previous buffer";
};
}
{
mode = "n";
key = "<C-x>";
action = "<cmd>:bp | bd #<cr>";
options = {
desc = "Delete 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";
};
}
];
}

View File

@@ -0,0 +1,40 @@
{
plugins.flash = {
enable = true;
settings.label.uppercase = false;
};
keymaps = [
{
mode = [
"n"
"x"
"o"
];
key = "s";
action = "<cmd>lua require('flash').jump()<cr>";
options = {
desc = "Flash";
};
}
# {
# mode = [ "n" "x" "o" ];
# key = "S";
# action = "<cmd>lua require('flash').treesitter()<cr>";
# options = {
# desc = "Flash Treesitter";
# };
# }
{
mode = [
"x"
"o"
];
key = "R";
action = "<cmd>lua require('flash').treesitter_search()<cr>";
options = {
desc = "Treesitter Search";
};
}
];
}

View File

@@ -0,0 +1,10 @@
{
plugins = {
trim.enable = true;
neoscroll.enable = true;
dressing.enable = true;
todo-comments.enable = true;
web-devicons.enable = true;
nui.enable = true;
};
}

View File

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

View File

@@ -0,0 +1,129 @@
{
plugins.lualine = {
enable = true;
settings = {
options = {
always_divide_middle = true;
ignore_focus = ["neo-tree"];
globalstatus = true; # have a single statusline at bottom of neovim instead of one for every window
disabled_filetypes.statusline = [
"dashboard"
"alpha"
];
section_separators = {
left = "";
right = "";
};
};
extensions = ["fzf"];
sections = {
lualine_a = ["mode"];
lualine_b = ["branch"];
lualine_y = [
"progress"
{
separator = "";
}
"location"
{
padding = {
left = 0;
right = 1;
};
}
];
lualine_z = [''" " .. os.date("%R")''];
};
};
};
extraConfigLua = ''
local ui = {}
function ui.fg(name)
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
local fg = hl and (hl.fg or hl.foreground)
return fg and { fg = string.format("#%06x", fg) } or nil
end
---@param opts? {relative: "cwd"|"root", modified_hl: string?}
function ui.pretty_path(opts)
opts = vim.tbl_extend("force", {
relative = "cwd",
modified_hl = "Constant",
}, opts or {})
return function(self)
local path = vim.fn.expand("%:p") --[[@as string]]
if path == "" then
return ""
end
local bufname = vim.fn.bufname(vim.fn.bufnr())
local sep = package.config:sub(1, 1)
local root = (opts.relative == "root") and vim.fn.getcwd() or vim.fn.fnamemodify(bufname, ":h")
local cwd = vim.fn.getcwd()
path = (opts.relative == "cwd" and path:find(cwd, 1, true) == 1) and path:sub(#cwd + 2) or path:sub(#root + 2)
local parts = vim.split(path, "[\\/]")
if #parts > 3 then
parts = { parts[1], "", parts[#parts - 1], parts[#parts] }
end
if opts.modified_hl and vim.bo.modified then
local modified_hl_fg = ui.fg(opts.modified_hl)
if modified_hl_fg then
parts[#parts] = string.format("%%#%s#%s%%*", opts.modified_hl, parts[#parts])
end
end
return table.concat(parts, sep)
end
end
require("lualine").setup({
sections = {
lualine_c = {
{
"diagnostics",
symbols = {
error = " ",
warn = " ",
hint = " ",
info = " ",
},
},
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ ui.pretty_path() },
},
lualine_x = {
{
function() return require("noice").api.status.command.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
color = ui.fg("Statement"),
},
{
function() return require("noice").api.status.mode.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end,
color = ui.fg("Constant"),
},
{
function() return " " .. require("dap").status() end,
cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end,
color = ui.fg("Debug"),
},
{
"diff",
symbols = {
added = " ",
modified = " ",
removed= " ",
},
},
}
}
})
'';
}

View File

@@ -0,0 +1,38 @@
{
plugins.noice = {
enable = true;
settings = {
lsp = {
override = {
"vim.lsp.util.convert_input_to_markdown_lines" = true;
"vim.lsp.util.stylize_markdown" = true;
"cmp.entry.get_documentation" = true;
};
progress.enabled = true;
};
presets = {
bottom_search = true;
command_palette = true;
long_message_to_split = true;
inc_rename = true;
lsp_doc_border = true;
};
notify.enabled = true;
routes = [
{
filter = {
event = "msg_show";
any = [
{find = "%d+L, %d+B";}
{find = "; after #%d+";}
{find = "; before #%d+";}
];
};
view = "mini";
}
];
};
};
}

View File

@@ -0,0 +1,47 @@
{
plugins.notify = {
enable = true;
# remove animations for preformance
settings = {
stages = "static";
timeout = 4000;
};
};
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 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
'';
}

View File

@@ -0,0 +1,29 @@
{
plugins.precognition = {
enable = true;
settings = {
startVisible = false;
};
};
keymaps = [
{
mode = "n";
key = "<leader>up";
action.__raw = ''
function()
if require("precognition").toggle() then
vim.notify("Precognition on")
else
vim.notify("Precognition off")
end
end
'';
options = {
desc = "Precognition Toggle";
silent = true;
};
}
];
}

View File

@@ -0,0 +1,65 @@
{
plugins.toggleterm = {
enable = true;
settings = {
size = ''
function(term)
if term.direction == "horizontal" then
return 30
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end
'';
open_mapping = "[[<C-/>]]";
hide_numbers = true;
shade_terminals = true;
start_in_insert = true;
terminal_mappings = true;
persist_mode = true;
insert_mappings = true;
close_on_exit = true;
shell = "nu";
direction = "horizontal"; # 'vertical' | 'horizontal' | 'tab' | 'float'
float_opts = {
border = "single"; # 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
width = 80;
height = 20;
winblend = 0;
};
};
};
keymaps = [
{
mode = "t";
key = "<C-g>";
action = "<cmd>2ToggleTerm<cr>";
options.desc = "Open/Close Terminal 2";
}
{
mode = "t";
key = "<C-Left>";
action = "<cmd>wincmd h<cr>";
options.desc = "Go to Left window";
}
{
mode = "t";
key = "<C-Right>";
action = "<cmd>wincmd l<cr>";
options.desc = "Go to Right window";
}
{
mode = "t";
key = "<C-Up>";
action = "<cmd>wincmd k<cr>";
options.desc = "Go to Up window";
}
{
mode = "t";
key = "<C-Down>";
action = "<cmd>wincmd j<cr>";
options.desc = "Go to Down window";
}
];
}

View File

@@ -0,0 +1,95 @@
{lib, ...}: {
autoCmd = [
{
event = [
"BufEnter"
"BufNew"
];
desc = "disable statuscolumn for neo-tree and dashboard";
callback = lib.nixvim.mkRaw ''
function()
local ft_ignore = { "dashboard", "neo-tree" }
if vim.tbl_contains(ft_ignore, vim.bo.filetype) then
vim.cmd("setlocal foldcolumn=0")
end
end
'';
}
];
plugins = {
statuscol = {
enable = true;
settings = {
relculright = true;
ft_ignore = [
"dashboard"
"neo-tree"
];
segments = [
{
click = "v:lua.ScFa";
text = [(lib.nixvim.mkRaw "require('statuscol.builtin').foldfunc")];
}
{
click = "v:lua.ScSa";
text = [" %s"];
}
{
click = "v:lua.ScLa";
text = [
(lib.nixvim.mkRaw "require('statuscol.builtin').lnumfunc")
" "
];
}
];
};
};
nvim-ufo = {
enable = true;
settings = {
provider_selector =
# lua
''
function()
return { "lsp", "indent" }
end
'';
preview.mappings = {
close = "q";
switch = "K";
};
};
};
};
opts = {
foldcolumn = "1";
foldlevel = 99;
foldlevelstart = 99;
foldenable = true;
fillchars = lib.nixvim.mkRaw "[[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]";
};
keymaps = [
{
mode = "n";
key = "zR";
action = lib.nixvim.mkRaw "function() require('ufo').openAllFolds() end";
options.desc = "open all folds";
}
{
mode = "n";
key = "zM";
action = lib.nixvim.mkRaw "function() require('ufo').closeAllFolds() end";
options.desc = "close all folds";
}
{
mode = "n";
key = "zK";
action = lib.nixvim.mkRaw "function() local winid = require('ufo').peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end end";
options.desc = "Peek Folded Lines";
}
];
}