1
0
Fork 0

Reorganize common configuration

This commit is contained in:
Avery 2025-06-21 20:02:48 +02:00
parent b0435707e4
commit 84dfefcb45
Signed by: Avery
GPG key ID: B684FD451B692E04
18 changed files with 81 additions and 128 deletions

View file

@ -0,0 +1,11 @@
{ pkgs, ... }: {
imports = [ ./development.nix ./zsh.nix ];
home = {
username = "avery";
homeDirectory = "/home/avery";
stateVersion = "24.05";
packages = with pkgs; [ rclone xdg-utils ];
sessionVariables = { EDITOR = "nvim"; };
};
programs.home-manager.enable = true;
}

View file

@ -0,0 +1,51 @@
{ pkgs, ... }: {
imports = [ ./nixvim ];
home = { packages = with pkgs; [ git-credential-manager gnupg pass ]; };
programs = {
git = {
enable = true;
extraConfig = {
credential = {
credentialStore = "gpg";
helper = "${pkgs.git-credential-manager}/bin/git-credential-manager";
"https://codeberg.org".provider = "generic";
"https://git.rcia.dev".provider = "generic";
};
init.defaultBranch = "main";
merge.tool = "nvimdiff";
};
signing = {
key = "B684FD451B692E04";
signByDefault = true;
};
userEmail = "aveeryy@protonmail.com";
userName = "Avery";
};
lazygit = {
enable = true;
settings = {
gui.theme = {
activeBorderColor = [ "#89b4fa" "bold" ];
inactiveBorderColor = [ "#a6adc8" ];
optionsTextColor = [ "#89b4fa" ];
selectedLineBgColor = [ "#313244" ];
selectedRangeBgColor = [ "#313244" ];
cherryPickedCommitBgColor = [ "#45475a" ];
cherryPickedCommitFgColor = [ "#89b4fa" ];
unstagedChangesColor = [ "#f38ba8" ];
defaultFgColor = [ "#cdd6f4" ];
searchingActiveBorderColor = [ "#f9e2af" ];
};
};
};
};
services = {
gpg-agent = {
defaultCacheTtl = 3600;
enable = true;
enableSshSupport = true;
enableZshIntegration = true;
pinentry.package = pkgs.pinentry-qt;
};
};
}

View file

@ -0,0 +1,104 @@
{ lib, ... }: {
programs.nixvim = {
extraConfigLua = ''
function has_words_before()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
function leave_snippet()
if
((vim.v.event.old_mode == "s" and vim.v.event.new_mode == "n") or vim.v.event.old_mode == "i")
and require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end
-- stop snippets when you leave to normal mode
vim.api.nvim_command([[
autocmd ModeChanged * lua leave_snippet()
]])
'';
plugins = {
cmp = {
enable = true;
settings = {
formatting.format = lib.mkForce ''
function(entry, vim_item)
if vim.tbl_contains({ "path" }, entry.source.name) then
local icon, hl_group =
require("nvim-web-devicons").get_icon(entry:get_completion_item().label)
if icon then
vim_item.kind = icon
vim_item.kind_hl_group = hl_group
return vim_item
end
end
return require("lspkind").cmp_format({ with_text = true })(entry, vim_item)
end
'';
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = false })";
"<Tab>" = ''
cmp.mapping(
function(callback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_locally_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
callback()
end
end
, {"i", "s"})
'';
"<S-Tab>" = ''
cmp.mapping(
function(callback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
callback()
end
end
, {"i", "s"})
'';
};
snippet.expand = ''
function(args)
require("luasnip").lsp_expand(args.body)
end
'';
sources = [
{
name = "luasnip";
priority = 40;
}
{
name = "nvim_lsp";
priority = 30;
entry_filter = ''
function(entry, _)
return entry:get_kind() ~= require("cmp").lsp.CompletionItemKind.Text
end
'';
}
];
};
};
lspkind = { enable = true; };
luasnip = {
enable = true;
fromVscode = [ { } ];
};
friendly-snippets.enable = true;
};
};
}

View file

@ -0,0 +1,49 @@
{ pkgs, ... }: {
imports = [
./completion.nix
./lsp.nix
./lualine.nix
./neo-tree.nix
./none-ls.nix
./treesitter.nix
./telescope.nix
./trouble.nix
];
programs.nixvim = {
enable = true;
colorschemes.catppuccin = {
enable = true;
settings = {
flavour = "mocha";
no_italic = true;
transparent_background = true;
integrations = {
cmp = true;
neotree = true;
};
};
};
globals.mapleader = " ";
opts = {
number = true;
cursorline = true;
tabstop = 4;
shiftwidth = 4;
expandtab = true;
ttyfast = true;
wrap = false;
mousemoveevent = true;
signcolumn = "yes";
};
plugins = {
web-devicons.enable = true;
nvim-autopairs.enable = true;
};
extraPlugins = with pkgs.vimPlugins; [ nvim-web-devicons ];
};
}

View file

@ -0,0 +1,44 @@
{ ... }: {
programs.nixvim.plugins = {
lsp = {
enable = true;
keymaps.lspBuf."<leader>ca" = "code_action";
luaConfig.post = ''
local signs = {
Error = "",
Warn = "",
Hint = "",
Info = ""
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, {text = icon, texthl = hl, numhl = hl})
end
'';
servers = {
cssls.enable = true;
dartls.enable = true;
jdtls.enable = true;
nil_ls.enable = true;
pyright.enable = true;
ts_ls.enable = true;
rust_analyzer = {
enable = true;
installCargo = false;
installRustc = false;
};
svelte.enable = true;
volar = {
enable = true;
tslsIntegration = true;
# extraOptions.init_options.vue.hybridMode = false;
};
};
};
# nvim-jdtls = {
# enable = true;
# data = "~/.cache/jdtls/workspace";
# };
};
}

View file

@ -0,0 +1,16 @@
{ ... }: {
programs.nixvim.plugins.lualine = {
enable = true;
settings.options = {
component_separators = {
left = "";
right = "";
};
section_separators = {
left = "";
right = "";
};
disabled_filetypes.statusline = [ "neo-tree" ];
};
};
}

View file

@ -0,0 +1,175 @@
{ ... }: {
programs.nixvim = {
keymaps = [{
action = "<cmd>Neotree toggle<CR>";
key = "<leader>fi";
}];
plugins.neo-tree = {
enable = true;
closeIfLastWindow = true;
enableGitStatus = true;
enableDiagnostics = true;
sourceSelector = {
winbar = true;
statusline = false;
tabsLayout = "equal";
sources = [{
source = "filesystem";
displayName = " 󰉓 Archivos ";
}];
};
defaultComponentConfigs = {
container = { enableCharacterFade = true; };
indent = {
indentSize = 2;
padding = 1;
withMarkers = true;
indentMarker = "";
lastIndentMarker = "";
highlight = "NeoTreeIndentMarker";
withExpanders = true;
expanderCollapsed = "";
expanderExpanded = "";
expanderHighlight = "NeoTreeExpander";
};
icon = {
folderClosed = "";
folderOpen = "";
folderEmpty = "";
default = " ";
highlight = "NeoTreeFileIcon";
};
modified = {
symbol = "[+]";
highlight = "NeoTreeModified";
};
name = {
trailingSlash = false;
useGitStatusColors = true;
highlight = "NeoTreeFileName";
};
gitStatus = {
symbols = {
added = "";
modified = "";
deleted = "";
renamed = "";
untracked = "";
ignored = "";
unstaged = "";
staged = "";
conflict = "";
};
};
diagnostics = {
symbols = {
error = "";
warn = "";
hint = "";
info = "";
};
highlights = {
hint = "DiagnosticSignHint";
info = "DiagnosticSignInfo";
warn = "DiagnosticSignWarn";
error = "DiagnosticSignError";
};
};
};
window = {
position = "left";
width = 40;
mappingOptions = {
noremap = true;
nowait = true;
};
};
filesystem = {
bindToCwd = true;
filteredItems = {
visible = false;
hideDotfiles = false;
hideGitignored = false;
hideByName = [ "nodeModules" ];
};
groupEmptyDirs = false;
useLibuvFileWatcher = true;
};
buffers = { groupEmptyDirs = true; };
renderers = {
directory = [
"indent"
"icon"
"current_filter"
{
name = "container";
content = [
{
name = "name";
zindex = 10;
}
{
name = "symlink_target";
zindex = 10;
highlight = "NeoTreeSymbolicLinkTarget";
}
{
name = "clipboard";
zindex = 10;
}
{
name = "diagnostics";
errorsOnly = true;
zindex = 20;
align = "right";
hideWhenExpanded = false;
}
{
name = "git_status";
zindex = 10;
align = "right";
hideWhenExpanded = true;
}
];
}
];
file = [
"indent"
"icon"
{
name = "container";
content = [
{
name = "name";
zindex = 10;
}
{
name = "clipboard";
zindex = 10;
}
{
name = "bufnr";
zindex = 10;
}
{
name = "modified";
zindex = 20;
align = "right";
}
{
name = "diagnostics";
zindex = 20;
align = "right";
}
{
name = "git_status";
zindex = 15;
align = "right";
}
];
}
];
};
};
};
}

View file

@ -0,0 +1,32 @@
{ ... }: {
programs.nixvim.plugins.none-ls = {
enable = true;
settings.on_attach = ''
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({ async = false })
end,
})
end
end
'';
sources = {
formatting = {
black.enable = true;
dart_format.enable = true;
nixfmt.enable = true;
prettier = {
enable = true;
disableTsServerFormatter = true;
settings = { extra_filetypes = [ "svelte" ]; };
};
xmllint.enable = true;
};
};
};
}

View file

@ -0,0 +1,9 @@
{ ... }: {
programs.nixvim.plugins.telescope = {
enable = true;
keymaps = {
"<leader>ff" = "find_files";
"<leader>bb" = "buffers";
};
};
}

View file

@ -0,0 +1,10 @@
{ ... }: {
programs.nixvim.plugins.treesitter = {
enable = true;
settings = {
indent.enable = true;
highlight.enable = true;
};
nixvimInjections = true;
};
}

View file

@ -0,0 +1,31 @@
{ ... }: {
programs.nixvim = {
plugins.trouble = {
enable = true;
settings = {
auto_refresh = true;
focus = true;
follow = false;
keys = {
"<cr>" = "jump_close";
"s" = "jump_vsplit";
"S" = "jump_split";
};
win = {
type = "float";
border = "rounded";
};
};
};
keymaps = [
{
action = "<cmd>Trouble diagnostics toggle<cr>";
key = "<leader>dg";
}
{
action = "<cmd>Trouble symbols toggle auto_close=true focus=true<cr>";
key = "<leader>sy";
}
];
};
}

View file

@ -0,0 +1,45 @@
{ config, lib, ... }: {
programs = {
zsh = {
enable = true;
initContent = let
earlyInit = lib.mkBefore ''
setopt AUTO_PUSHD
setopt SHARE_HISTORY
setopt MENUCOMPLETE
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[OA" history-beginning-search-backward-end
bindkey "^[OB" history-beginning-search-forward-end
bindkey "^r" history-incremental-search-backward
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name \'\'
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
'';
postInit = lib.mkAfter ''
if [ -x "$(command -v fastfetch)" ]; then
fastfetch
fi
'';
in lib.mkMerge [ earlyInit postInit ];
history.path = "${config.xdg.dataHome}/zhistory";
syntaxHighlighting.enable = true;
};
starship = {
enable = true;
settings = {
add_newline = true;
};
};
};
}

View file

@ -1,14 +0,0 @@
{ pkgs, ... }: {
home = {
username = "avery";
homeDirectory = "/home/avery";
stateVersion = "24.05";
packages = with pkgs; [ python3 rclone xdg-utils ];
sessionVariables = {
EDITOR = "nvim";
DOTNET_ROOT = "${pkgs.dotnet-sdk_8}";
};
sessionPath = [ "$HOME/.dotnet/tools" ];
};
programs.home-manager.enable = true;
}

View file

@ -1,40 +0,0 @@
{ config, lib, ... }: {
programs = {
zsh = {
enable = true;
initContent = lib.mkBefore ''
setopt AUTO_PUSHD
setopt SHARE_HISTORY
setopt MENUCOMPLETE
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[OA" history-beginning-search-backward-end
bindkey "^[OB" history-beginning-search-forward-end
bindkey "^r" history-incremental-search-backward
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name \'\'
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
fastfetch
'';
history.path = "${config.xdg.dataHome}/zhistory";
syntaxHighlighting.enable = true;
};
starship = {
enable = true;
settings = {
add_newline = true;
};
};
};
}