This commit is contained in:
EdenQwQ 2025-03-01 22:35:08 +08:00
commit 96895ec3aa
100 changed files with 6349 additions and 0 deletions

View file

@ -0,0 +1,11 @@
{ config, ... }:
{
imports = [
./misc.nix
./tex.nix
./python.nix
./neovide.nix
./zed.nix
./nixvim
];
}

View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
alejandra
nixfmt-rfc-style
texlab
nodePackages.prettier
];
}

View file

@ -0,0 +1,6 @@
{
programs.neovide = {
enable = true;
settings.neovim-bin = "nvim";
};
}

View file

@ -0,0 +1,117 @@
{ user, ... }:
{
programs.nixvim = {
plugins = {
copilot-lua = {
enable = true;
settings.panel.enabled = false;
settings.suggestion.enabled = false;
settings.filetypes.markdown = true;
};
copilot-chat.enable = true;
codecompanion = {
enable = true;
settings = {
adapters.copilot.__raw =
# lua
''
function()
return require("codecompanion.adapters").extend("copilot", {
schema = {
model = {
default = "claude-3.7-sonnet",
},
max_tokens = {
default = 65536,
}
}
})
end
'';
adapters.siliconflow.__raw =
# lua
''
function ()
local siliconflow_token_file = io.open("/home/${user}/Downloads/tokens/siliconflow_token", "r")
local siliconflow_api_key = siliconflow_token_file:read()
siliconflow_token_file:close()
return require("codecompanion.adapters").extend("openai_compatible", {
name = "deepseek",
env = {
url = "https://api.siliconflow.cn",
api_key = siliconflow_api_key,
},
schema = {
model = {
default = "Pro/deepseek-ai/DeepSeek-V3",
}
}
})
end
'';
adapters.gemini.__raw =
# lua
''
function()
local gemini_token_file = io.open("/home/${user}/Downloads/gemini_token", "r")
local gemini_api_key = gemini_token_file:read()
gemini_token_file:close()
return require("codecompanion.adapters").extend("gemini", {
env = {
api_key = gemini_api_key,
}
})
end
'';
strategies = {
inline = {
adapter = "siliconflow";
keymaps = {
accept_change.modes.n = "<Leader>ca";
reject_change.modes.n = "<Leader>cr";
};
};
chat = {
adapter = "siliconflow";
slash_commands.__raw = # lua
''
{
["file"] = {
opts = {
provider = "telescope",
},
},
},
{
["buffer"] = {
opts = {
provider = "telescope",
},
},
},
'';
};
agent.adapter = "siliconflow";
};
};
};
};
keymaps = [
{
mode = "n";
key = "<Leader>ca";
action = ":CodeCompanionActions<cr>";
}
{
mode = "n";
key = "<Leader>cc";
action = ":CodeCompanionChat Toggle<cr>";
}
{
mode = "n";
key = "<Leader>ci";
action = ":CodeCompanion ";
}
];
};
}

View file

@ -0,0 +1,36 @@
{
programs.nixvim = {
plugins.cmp = {
enable = true;
settings.sources = [
{ name = "buffer"; }
{ name = "path"; }
{ name = "spell"; }
{ name = "emoji"; }
{ name = "luasnip"; }
{ name = "nvim_lsp"; }
{ name = "copilot"; }
];
settings.mapping = {
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
"<CR>" = "cmp.mapping.confirm({ select = true })";
};
settings.window.completion.border = [
""
""
""
""
""
""
""
""
];
};
plugins.cmp-buffer.enable = true;
plugins.cmp-path.enable = true;
plugins.cmp-spell.enable = true;
plugins.cmp-emoji.enable = true;
plugins.cmp-nvim-lsp.enable = true;
};
}

View file

@ -0,0 +1,136 @@
{
config,
pkgs,
...
}:
{
imports = [
./lsp.nix
./cmp.nix
./ai.nix
./lualine.nix
./treesitter.nix
./hop.nix
./ui.nix
./mini.nix
];
stylix.targets.nixvim.enable = true;
programs.nixvim = {
enable = true;
defaultEditor = true;
performance.combinePlugins = {
enable = true;
standalonePlugins = [
"nvim-treesitter"
"copilot.lua"
];
};
globals = {
mapleader = " ";
maplocalleader = " ";
have_nerd_font = true;
};
highlightOverride = {
CursorLineNr = {
bg = "#${config.lib.stylix.colors.base01}";
fg = "#${config.lib.stylix.colors.base06}";
};
# LineNrAbove = {
# bg = "#${config.lib.stylix.colors.base00}";
# fg = "#${config.lib.stylix.colors.base06}";
# };
# LineNrBelow = {
# bg = "#${config.lib.stylix.colors.base00}";
# fg = "#${config.lib.stylix.colors.base07}";
# };
};
opts = {
number = true;
relativenumber = true;
mouse = "a";
showmode = false;
clipboard.providers.wl-copy.enable = true;
breakindent = true;
tabstop = 2;
shiftwidth = 2;
undofile = true;
ignorecase = true;
smartcase = true;
updatetime = 250;
timeoutlen = 300;
splitright = true;
splitbelow = true;
list = true;
listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '' }";
inccommand = "split";
cursorline = true;
hlsearch = true;
scrolloff = 10;
spell = true;
spelllang = [
"en_us"
"cjk"
];
spellsuggest = "best,4";
};
keymaps = [
{
mode = "n";
key = "S";
action = ":w<cr>";
}
{
mode = "n";
key = "Q";
action = ":bd<cr>";
}
{
mode = "n";
key = "<Leader>1";
action = ":BufferLineGoToBuffer 1<cr>";
}
{
mode = "n";
key = "<Leader>2";
action = ":BufferLineGoToBuffer 2<cr>";
}
{
mode = "n";
key = "<Leader>2";
action = ":BufferLineGoToBuffer 2<cr>";
}
{
mode = "n";
key = "<Leader>3";
action = ":BufferLineGoToBuffer 3<cr>";
}
{
mode = "n";
key = "<Leader>4";
action = ":BufferLineGoToBuffer 4<cr>";
}
{
mode = "t";
key = "<Esc><Esc>";
action = "<C-\\><C-n>";
}
{
mode = "n";
key = "<Leader>o";
action = ":lua MiniFiles.open()<cr>";
}
];
plugins = {
sleuth.enable = true; # automatically set shiftwidth and expandtab based on the file
nvim-surround.enable = true;
repeat.enable = true;
lastplace.enable = true;
nvim-autopairs.enable = true;
endwise.enable = true;
markdown-preview.enable = true;
};
extraPlugins = with pkgs.vimPlugins; [
fcitx-vim
];
};
}

View file

@ -0,0 +1,15 @@
{
programs.nixvim.plugins.hop.enable = true;
programs.nixvim.keymaps = [
{
mode = "n";
key = "<Leader>hw";
action = ":HopWord<CR>";
}
{
mode = "n";
key = "<Leader>hl";
action = ":HopLine<CR>";
}
];
}

View file

@ -0,0 +1,153 @@
{
pkgs,
lib,
inputs,
host,
user,
...
}:
{
programs.nixvim = {
plugins = {
lsp = {
enable = true;
inlayHints = true;
keymaps = {
diagnostic = {
"<leader>lE" = "open_float";
"[" = "goto_prev";
"]" = "goto_next";
};
lspBuf = {
"gD" = "declaration";
"gd" = "definition";
"gr" = "references";
"gI" = "implementation";
"gy" = "type_definition";
};
};
servers = {
pyright.enable = true;
lua_ls.enable = true;
bashls.enable = true;
nixd = {
enable = true;
package = inputs.nixd.packages.${pkgs.system}.nixd;
settings = {
formatting.command = [ "nixfmt" ];
nixd.nixpkgs.expr = "import <nixpkgs> { }";
options =
let
flake = # nix
''(builtins.getFlake "/home/${user}/.config/nixos")'';
in
{
nixos.expr = # nix
''${flake}.nixosConfigurations.${host}.options'';
home_manager.expr = # nix
''${flake}.homeConfigurations."${user}@${host}".options'';
};
};
};
nil_ls = {
enable = true;
package = inputs.nil.packages.${pkgs.system}.nil;
settings = {
# formatting.command = ["nixfmt"];
nix.flake = {
autoArchive = true;
};
};
};
texlab.enable = true;
};
};
conform-nvim = {
enable = true;
settings = {
format_on_save = {
lsp_fallback = "fallback";
timeout_ms = 500;
};
notify_on_error = true;
formatters_by_ft = {
bash = [
"shfmt"
"shellcheck"
"shellharden"
];
css = [ "prettier" ];
scss = [ "prettier" ];
html = [ "prettier" ];
json = [ "prettier" ];
jsonc = [ "prettier" ];
lua = [ "stylua" ];
markdown = [
"prettier"
"injected"
];
nix = [
"nixfmt"
"injected"
];
yaml = [ "yamlfmt" ];
python = [ "black" ];
tex = [ "latexindent" ];
};
formatters = {
injeced.lang_to_ext = {
lua = "lua";
};
shfmt.command = lib.getExe pkgs.shfmt;
shellcheck.command = lib.getExe pkgs.shellcheck;
shellharden.command = lib.getExe pkgs.shellharden;
stylua.command = lib.getExe pkgs.stylua;
latexindent.prepend_args = [ ''-y="defaultIndent=' '"'' ];
};
};
};
lsp-format = {
enable = true;
};
lspsaga = {
enable = true;
lightbulb.virtualText = true;
lightbulb.sign = false;
};
trouble.enable = true;
lsp-signature.enable = true;
otter.enable = true;
};
};
programs.nixvim.keymaps = [
{
mode = "n";
key = "K";
action = ":Lspsaga hover_doc<CR>";
}
{
mode = "n";
key = "<Leader>lo";
action = ":Lspsaga outline<CR>";
}
{
mode = "n";
key = "<Leader>lr";
action = ":Lspsaga rename<CR>";
}
{
mode = "n";
key = "<Leader>la";
action = ":Lspsaga code_action<CR>";
}
{
mode = "n";
key = "<Leader>lf";
action = ":Lspsaga finder<CR>";
}
];
programs.nixvim.extraPlugins = with pkgs.vimPlugins; [
nvim-docs-view
];
}

View file

@ -0,0 +1,128 @@
{ config, ... }:
let
colors = config.lib.stylix.colors;
in
{
programs.nixvim.plugins.lualine = {
enable = true;
settings = {
options = {
theme = {
normal = {
a = {
bg = "#nil";
};
b = {
bg = "nil";
};
c = {
bg = "nil";
};
z = {
bg = "nil";
};
y = {
bg = "nil";
};
};
};
globalstatus = true;
disabled_filetypes = {
statusline = [
"dashboard"
"alpha"
"starter"
"snacks_dashboard"
];
};
};
inactive_sections = {
lualine_x = [
"filename"
"filetype"
];
};
sections = {
lualine_a = [
{
__unkeyed = "mode";
fmt = "string.lower";
color = {
fg = colors.base0E;
bg = "nil";
};
separator.left = "";
separator.right = "";
}
];
lualine_b = [
{
__unkeyed = "branch";
icon.__unkeyed = "";
color = {
bg = "nil";
};
separator.left = "";
separator.right = "";
}
{
__unkeyed = "diff";
separator.left = "";
separator.right = "";
}
];
lualine_c = [
{
__unkeyed = "diagnostic";
symbols = {
error = " ";
warn = " ";
info = " ";
hint = "󰝶 ";
};
color = {
fg = colors.base08;
bg = "nil";
};
separator.left = "";
separator.right = "";
}
];
lualine_x = [ "" ];
lualine_y = [
# {
# __unkeyed = "filetype";
# icon_only = true;
# separator.left = "";
# separator.right = "";
# }
{
__unkeyed = "filename";
# symbols = {
# modified = "";
# readonly = "👁️";
# unnamed = "";
# };
color = {
fg = colors.base05;
bg = "nil";
};
separator.left = "";
separator.right = "";
}
];
lualine_z = [
{
__unkeyed = "location";
color = {
fg = colors.base0B;
bg = "nil";
};
separator.left = "";
separator.right = "";
}
];
};
};
};
}

View file

@ -0,0 +1,29 @@
{
programs.nixvim.plugins = {
mini.enable = true;
mini.modules = {
align = { };
files = {
mappings = {
close = "<Esc>";
};
};
hipatterns = {
hex_color = "hipatterns.gen_highlighter.hex_color()";
};
indentscope = { };
move = {
mappings = {
left = "<C-h>";
right = "<C-l>";
up = "<C-k>";
down = "<C-j>";
line_left = "<C-h>";
line_right = "<C-l>";
line_up = "<C-k>";
line_down = "<C-j>";
};
};
};
};
}

View file

@ -0,0 +1,30 @@
{ pkgs, ... }:
{
programs.nixvim.plugins.treesitter = {
enable = true;
settings.auto_install = true;
settings.ensure_installed = [
"diff"
"bash"
"fish"
"python"
"yaml"
"lua"
"json"
"nix"
"regex"
"toml"
"vim"
"markdown"
"rust"
"jsonc"
"glsl"
"css"
"hyprlang"
];
settings.highlight.enable = true;
settings.indent.enable = true;
};
programs.nixvim.plugins.hmts.enable = true;
programs.nixvim.plugins.rainbow-delimiters.enable = true;
}

View file

@ -0,0 +1,93 @@
{ pkgs, ... }:
{
programs.nixvim.plugins = {
web-devicons.enable = true;
telescope.enable = true;
bufferline.enable = true;
scrollview.enable = true;
cursorline.enable = true;
cursorline.settings.cursorword.enable = true;
fidget.enable = true;
indent-blankline.enable = true;
gitsigns.enable = true;
navbuddy.enable = true;
smartcolumn.enable = true;
fastaction.enable = true;
colorizer = {
enable = true;
settings.user_default_options = {
mode = "virtualtext";
css = true;
css_fn = true;
names = false;
virtualtext = "";
virtualtext_inline = true;
virtualtext_mode = "foreground";
};
};
which-key = {
enable = true;
settings.spec = [
{
__unkeyed = "<Leader>f";
name = "Telescope";
}
{
__unkeyed = "<Leader>l";
name = "LSP";
}
{
__unkeyed = "<Leader>m";
name = "Minimap";
}
{
__unkeyed = "<Leader>c";
name = "CodeCompanion";
}
{
__unkeyed = "<Leader>h";
name = "Hop";
}
];
};
render-markdown = {
enable = true;
settings.file_types = [
"markdown"
"codecompanion"
];
};
};
programs.nixvim.keymaps = [
{
mode = "n";
key = "<Leader>ff";
action = ":Telescope fd<CR>";
}
{
mode = "n";
key = "<Leader>fd";
action = ":Telescope diagnostics<CR>";
}
{
mode = "n";
key = "<Leader>fb";
action = ":Telescope buffers<CR>";
}
{
mode = "n";
key = "<Leader>fr";
action = ":Telescope registers<CR>";
}
];
programs.nixvim.extraPlugins = with pkgs.vimPlugins; [
codewindow-nvim
];
programs.nixvim.extraConfigLua =
# lua
''
local codewindow = require("codewindow")
codewindow.setup()
codewindow.apply_default_keybinds()
'';
}

View file

@ -0,0 +1,13 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
python312
python312Packages.pip
python312Packages.virtualenv
python312Packages.numpy
python312Packages.matplotlib
python312Packages.pandas
black
conda
];
}

View file

@ -0,0 +1,6 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
texlive.combined.scheme-full
];
}

View file

@ -0,0 +1,57 @@
{
programs.zed-editor = {
enable = true;
extensions = [
"latex"
"python"
];
userSettings = {
features = {
copilot = true;
};
vim_mode = true;
hover_popover_enabled = true;
confirm_quit = true;
show_completions_on_input = true;
show_completion_documentation = true;
auto_signature_help = true;
show_inline_completions_in_menu = true;
show_wrap_guides = true;
show_inline_completions = true;
show_whitespaces = "all";
vertical_scroll_margin = 5;
relative_line_numbers = true;
inlay_hints.enabled = true;
assistant = {
enabled = true;
# default_model = {
# provider = "deepseek";
# model = "deepseek-reasoner";
# };
};
enable_language_server = true;
format_on_save = "on";
telemetry = {
diagnostics = false;
metrics = false;
};
auto_update = false;
auto_install_extensions.html = false;
languages = {
Markdown.format_on_save = true;
};
# language_models.deepseek = {
# api_url = "https://api.deepseek.com";
# available_models = [
# {
# name = "deepseek-reasoner";
# display_name = "DeepSeek Reasoner";
# max_tokens = 64000;
# max_output_tokens = 4096;
# }
# ];
# };
};
};
stylix.targets.zed.enable = true;
}