refactor: make the whole thing more generic

This commit is contained in:
2024-04-02 16:28:57 +02:00
parent 7b648e1955
commit 651f3ad808
193 changed files with 763 additions and 521 deletions

View File

@@ -0,0 +1,47 @@
{ pkgs, config, ... }: {
programs = {
home-manager.enable = true;
rbw = {
enable = true;
settings = {
base_url = "pw.theaninova.de";
email = "pw@theaninova.de";
pinentry = pkgs.pinentry-gnome3;
};
};
git = import ./git.nix;
lazygit.enable = true;
nixvim = import ./nixvim { inherit pkgs; };
firefox = import ./firefox.nix { inherit pkgs; };
gpg.enable = true;
btop = {
enable = true;
settings = { vim_keys = true; };
};
zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
defaultKeymap = "viins";
};
fish = {
enable = true;
shellInit = ''
fish_vi_key_bindings
'';
interactiveShellInit = ''
set fish_greeting
'';
};
oh-my-posh = {
enable = true;
useTheme = "pararussel";
enableFishIntegration = true;
};
direnv = {
enable = true;
nix-direnv.enable = true;
};
};
}

View File

@@ -0,0 +1,81 @@
{ pkgs }: {
enable = true;
package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
extraPolicies = {
CaptivePortal = false;
DisableFirefoxStudies = true;
DisablePocket = true;
DisableTelemetry = true;
DisableFirefoxAccounts = true;
NoDefaultBookmarks = true;
OfferToSaveLogins = false;
OfferToSaveLoginsDefault = false;
PasswordManagerEnabled = false;
FirefoxHome = {
Search = true;
Pocket = false;
Snippets = false;
TopSites = true;
Highlights = false;
};
UserMessaging = {
ExtensionRecommendations = false;
SkipOnboarding = true;
};
};
};
profiles.default = {
id = 0;
name = "default";
isDefault = true;
bookmarks = [
{
name = "Monkeytype";
url = "https://monkeytype.com/";
}
{
name = "YouTube";
url = "https://youtube.com/";
}
];
search = {
force = true;
default = "Google";
engines = {
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}];
icon =
"${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@np" ];
};
"NixOS Wiki" = {
urls = [{
template = "https://nixos.wiki/index.php?search={searchTerms}";
}];
iconUpdateURL = "https://nixos.wiki/favicon.png";
updateInterval = 24 * 60 * 60 * 1000;
definedAliases = [ "@nw" ];
};
"Wikipedia (en)".metaData.alias = "@wiki";
};
};
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
ublock-origin
ublacklist
sponsorblock
bitwarden
];
};
}

View File

@@ -0,0 +1,23 @@
{
enable = true;
userName = "Thea Schöbl";
userEmail = "dev@theaninova.de";
signing = {
key = "6C9E EFC5 1AE0 0131 78DE B9C8 68FF FB1E C187 88CA";
signByDefault = true;
};
extraConfig = {
pull.rebase = true;
merge = {
tool = "nvim-mergetool";
conflictstyle = "diff3";
};
mergetool.nvim-mergetool = {
cmd = ''
nvim -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE"
'';
trustExitCode = true;
};
mergetool.prompt = false;
};
}

View File

@@ -0,0 +1,4 @@
{ pkgs, ... }: {
home.packages = [ pkgs.neovide ];
xdg.configFile."neovide/config.toml".source = ./neovide.toml;
}

View File

@@ -0,0 +1,20 @@
maximized = false
srgb = true
[font]
normal = ["FiraCode Nerd Font"]
size = 16
edging = "subpixelantialias"
[font.features]
"FiraCode Nerd Font" = [
"+zero",
"+onum",
"+ss04",
"+cv19",
"+cv23",
"+ss09",
"+ss06",
"+ss07",
"+ss10",
]

View File

@@ -0,0 +1,65 @@
function(colors)
return {
CmpItemKindCopilot = { fg = colors.teal },
CmpItemKindNpm = { fg = colors.maroon },
-- IntelliJ Theme
Constant = { fg = colors.mauve },
Character = { link = "Keyword" },
Number = { fg = colors.sapphire },
Boolean = { link = "Keyword" },
Identifier = { fg = colors.text },
Function = { fg = colors.blue },
Statement = { fg = colors.text },
Conditional = { link = "Keyword" },
Repeat = { link = "Keyword" },
Label = { link = "Keyword" },
Operator = { fg = colors.text },
Keyword = { fg = colors.peach },
Exception = { link = "Keyword" },
Include = { link = "Keyword" },
Structure = { fg = colors.yellow },
Type = { fg = colors.teal },
SpellBad = { sp = colors.green, style = { "underdotted" } },
SpellCap = { sp = colors.green, style = { "underdotted" } },
SpellLocal = { sp = colors.green, style = { "underdotted" } },
SpellRare = { sp = colors.green, style = { "underdotted" } },
["@constructor"] = { link = "Keyword" },
["@constructor.typescript"] = { link = "@constructor" },
["@parameter"] = { link = "Identifier" },
["@tag"] = { link = "Structure" },
["@tag.delimiter"] = { link = "Structure" },
["@tag.attribute"] = { fg = colors.mauve, style = { "italic" } }, -- Constant
["@keyword.function"] = { link = "Keyword" },
["@keyword.operator"] = { link = "Keyword" },
["@keyword.return"] = { link = "Keyword" },
["@keyword.export"] = { link = "Keyword" },
["@punctuation.special"] = { link = "Operator" },
["@conditional.ternary"] = { link = "Operator" },
["@type.builtin"] = { link = "Keyword" },
["@variable.builtin"] = { link = "Keyword" },
["@lsp.typemod.class.defaultLibrary"] = { fg = colors.yellow, style = { "bold" } }, -- Structure
["@lsp.typemod.variable.defaultLibrary"] = { fg = colors.mauve, style = { "bold" } }, -- Constant
["@lsp.typemod.function.defaultLibrary"] = { fg = colors.blue, style = { "bold" } }, -- Function
["@variable"] = { link = "Constant" },
["@field"] = { link = "Constant" },
["@label.json"] = { link = "Constant" },
["@label.jsonc"] = { link = "Constant" },
["@property"] = { link = "Constant" },
["@property.typescript"] = { link = "@property" },
["@lsp.type.property"] = { link = "Constant" },
["@lsp.type.interface"] = { link = "Structure" },
["@lsp.type.namespace"] = { link = "Structure" },
["@attribute.typescript"] = { link = "Structure" },
["@lsp.mod.local"] = { fg = colors.text },
["@lsp.mod.readonly"] = { style = { "italic" } },
}
end

View File

@@ -0,0 +1,464 @@
{ pkgs }:
let
darkman = pkgs.vimUtils.buildVimPlugin {
name = "darkman";
src = pkgs.buildGoModule rec {
pname = "darkman.nvim";
version = "0.0.1";
vendorHash = "sha256-HpyKzvKVN9hVRxxca4sdWRo91H32Ha9gxitr7Qg5MY8=";
src = pkgs.fetchFromGitHub {
owner = "4e554c4c";
repo = "darkman.nvim";
rev = "150aa63a13837c44abd87ff20d3a806321a17b2d";
sha256 = "sha256-ssEYdM460I1rufjgh63CEkLi4K+bEWbwku/6gQbytno=";
};
postInstall = ''
cp -r lua $out
'';
};
};
in {
enable = true;
defaultEditor = true;
options = {
number = true;
relativenumber = true;
tabstop = 2;
softtabstop = 2;
shiftwidth = 2;
expandtab = true;
smartindent = true;
signcolumn = "yes";
undodir = { __raw = "os.getenv('HOME') .. '/.config/nvim/undodir'"; };
undofile = true;
scrolloff = 12;
termguicolors = true;
hlsearch = false;
incsearch = true;
updatetime = 50;
fillchars.eob = " ";
};
keymaps = import ./keymaps.nix;
globals = {
minimap_width = 10;
minimap_auto_start = 1;
minimap_auto_start_win_enter = 1;
minimap_close_buftypes = [ "nofile" ];
minimap_block_filetypes = [ "NvimTree" ];
mapleader = ";";
mergetool_layout = "mr";
mergetool_prefer_revision = "local";
neovide_transparency = 0.8;
neovide_padding_top = 10;
neovide_padding_bottom = 10;
neovide_padding_left = 10;
neovide_padding_right = 10;
neovide_floating_blur_amount_x = 10;
neovide_floating_blur_amount_y = 10;
neovide_floating_shadow = false;
neovide_cursor_vfx_mode = "pixiedust";
};
clipboard = {
register = "unnamedplus";
providers.wl-copy.enable = true;
};
extraConfigVim = ''
if !exists("g:neovide")
hi Normal guibg=NONE ctermbg=NONE
endif
set noshowmode
'';
extraConfigLua = builtins.readFile ./extra-config.lua;
colorschemes.catppuccin = {
enable = true;
terminalColors = true;
transparentBackground = true;
background = {
dark = "frappe";
light = "latte";
};
integrations.native_lsp.underlines = {
errors = [ "undercurl" ];
warnings = [ "undercurl" ];
};
customHighlights = builtins.readFile ./custom-highlights.lua;
};
plugins = {
lualine = {
enable = true;
theme = "catppuccin";
globalstatus = true;
sectionSeparators = {
left = "";
right = "";
};
componentSeparators = {
left = "";
right = "";
};
sections = {
lualine_a = [{
name = "mode";
separator = {
right = "";
left = "";
};
icon = "";
}];
lualine_x = [
"(vim.g.disable_autoformat or vim.b.disable_autoformat) and '󱌓' or nil"
{ name = "filetype"; }
];
lualine_z = [{
name = "location";
separator = {
right = "";
left = "";
};
}];
};
};
auto-save = {
enable = true;
triggerEvents = [ "FocusLost" "BufLeave" ];
};
indent-blankline = {
enable = true;
settings = {
indent.char = "";
scope.show_start = false;
};
};
illuminate.enable = true;
nvim-autopairs.enable = true;
nvim-colorizer.enable = true;
neo-tree = {
enable = true;
filesystem.filteredItems.visible = true;
eventHandlers = {
file_opened = ''
function()
require('neo-tree').close_all()
end
'';
};
};
undotree.enable = true;
notify = {
enable = true;
backgroundColour = "#000000";
};
toggleterm = {
enable = true;
direction = "vertical";
size = 60;
};
luasnip.enable = true;
ts-autotag.enable = true;
leap.enable = true;
harpoon = {
enable = true;
enableTelescope = true;
keymaps = {
addFile = "hm";
navNext = "hn";
navPrev = "hp";
};
};
project-nvim = {
enable = true;
enableTelescope = true;
};
telescope = {
enable = true;
keymaps = {
"<leader>ff" = "git_files";
"<leader>fa" = "find_files";
"<leader>fg" = "live_grep";
"<leader>fb" = "buffers";
"<leader>sr" = "lsp_references";
"<leader>sd" = "lsp_definitions";
"<leader>si" = "lsp_implementations";
"<leader>ss" = "lsp_document_symbols";
"<leader>sw" = "lsp_workspace_symbols";
"<leader>st" = "lsp_type_definitions";
"<leader>sh" = "diagnostics";
};
};
trouble = {
enable = true;
settings.use_diagnostic_signs = true;
};
treesitter = {
enable = true;
indent = true;
grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars;
nixvimInjections = true;
};
conform-nvim = {
enable = true;
formattersByFt = {
lua = [ "stylua" ];
javascript = [ "prettier" ];
markdown = [ "prettier" ];
typescript = [ "prettier" ];
json = [ "prettier" ];
yaml = [ "prettier" ];
html = [ "prettier" ];
angular = [ "prettier" ];
css = [ "prettier" ];
scss = [ "prettier" ];
less = [ "prettier" ];
svelte = [ "prettier" ];
rust = [ "rustfmt" ];
bash = [ "shfmt" ];
nix = [ "nixfmt" ];
};
formatOnSave = ''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_fallback = true };
end
'';
};
lint = {
enable = true;
lintersByFt = {
javascript = [ "eslint" ];
typescript = [ "eslint" ];
css = [ "stylelint" ];
scss = [ "stylelint" ];
less = [ "stylelint" ];
bash = [ "shellcheck" ];
};
autoCmd.event = "TextChanged";
};
lsp = {
enable = true;
keymaps = { diagnostic = { }; };
enabledServers = [{
name = "angularls";
extraOptions = {
cmd = [
"ngserver"
"--stdio"
"--tsProbeLocations"
""
"--ngProbeLocations"
""
];
on_new_config = {
__raw = ''
function(new_config, new_root_dir)
new_config.cmd = {
new_root_dir .. "/node_modules/@angular/language-server/bin/ngserver",
"--stdio",
"--tsProbeLocations",
new_root_dir .. "/node_modules",
"--ngProbeLocations",
new_root_dir .. "/node_modules",
}
end
'';
};
filetypes = [
"typescript"
"html"
"typescriptreact"
"typescript.tsx"
"angular"
"html.angular"
];
on_attach = {
__raw = ''
function(client, bufnr)
if vim.bo[bufnr].filetype == "html" then
vim.bo[bufnr].filetype = "angular"
end
end
'';
};
};
}];
servers = {
html.enable = true;
cssls.enable = true;
svelte.enable = true;
tsserver.enable = true;
yamlls.enable = true;
jsonls.enable = true;
taplo.enable = true;
rust-analyzer = {
enable = true;
installCargo = false;
installRustc = false;
};
pylsp.enable = true;
clangd = {
enable = true;
cmd = [ "clangd" "--offset-encoding=utf-16" ];
};
nixd.enable = true;
lua-ls.enable = true;
bashls.enable = true;
};
};
lspkind = {
enable = true;
mode = "symbol_text";
cmp = {
after = ''
function(entry, vim_item, kind)
if entry.source.name == "npm" then
kind.kind = ""
kind.kind_hl_group = "CmpItemKindNpm"
end
kind.kind = kind.kind .. " "
return kind
end
'';
};
symbolMap = { Copilot = ""; };
};
cmp = {
enable = true;
settings = {
mapping = {
"<C-n>" =
"cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select})";
"<C-p>" =
"cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select})";
"<C-Space>" = "cmp.mapping.confirm({select = true})";
"<C-Enter>" = "cmp.mapping.complete()";
};
sources = [
{ name = "path"; }
{ name = "luasnip"; }
{
name = "npm";
keywordLength = 4;
priority = 10;
}
{ name = "nvim_lsp"; }
{ name = "nvim_lsp_signature_help"; }
{ name = "nvim_lsp_document_symbol"; }
];
formatting.fields = [ "abbr" "kind" ];
snippet.expand =
"function(args) require('luasnip').lsp_expand(args.body) end";
window = {
completion.border = "rounded";
documentation.border = "rounded";
};
};
};
which-key = {
enable = true;
registrations = {
"<leader>p" = "Paste Keep Buffer";
"<leader>n" = "Hover";
"<leader>g" = "Git";
"<leader>u" = "Undotree";
"<leader>s" = {
name = "LSP";
r = "References";
d = "Definitions";
i = "Implementations";
s = "Document Symbols";
w = "Workspace Symbols";
t = "Type Definitions";
h = "Diagnostics";
a = "Code Actions";
f = "Auto Formatting";
};
"<leader>x" = {
name = "Trouble";
x = "Toggle";
w = "Workspace Diagnostics";
d = "Document Diagnostics";
q = "Quickfix";
l = "Loclist";
};
"<leader>f" = {
name = "Find";
t = "Tree";
f = "File";
a = "Untracked Files";
g = "Grep";
b = "Buffer";
};
h = {
name = "Harpoon";
m = "Mark";
n = "Next";
p = "Prev";
};
};
};
copilot-lua = {
enable = true;
suggestion.autoTrigger = true;
};
openscad = {
enable = true;
fuzzyFinder = "fzf";
};
nix.enable = true;
};
extraPackages = [
pkgs.nodePackages.typescript-language-server
pkgs.nodePackages.stylelint
pkgs.nodePackages.prettier
pkgs.jq
pkgs.html-tidy
pkgs.nixfmt
pkgs.stylua
pkgs.shfmt
pkgs.fzf
];
extraPlugins = with pkgs.vimPlugins; [
vim-mergetool
darkman
rest-nvim
plenary-nvim
actions-preview-nvim
];
}

View File

@@ -0,0 +1,70 @@
require("darkman").setup()
require("cmp-npm").setup({})
require("rest-nvim").setup({})
require("actions-preview").setup({})
if vim.g.neovide then
vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
callback = function()
local flavour = require("catppuccin").options.background[vim.o.background]
local palette = require("catppuccin.palettes").get_palette(flavour)
vim.cmd("hi Normal guibg=" .. palette.base)
vim.cmd("set pumblend=100")
end,
})
-- no idea why this is needed
vim.opt.linespace = -1
end
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "󰌵" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
vim.diagnostic.config({
virtual_text = true,
signs = true,
underline = true,
update_in_insert = true,
severity_sort = false,
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({
cmd = "lazygit",
dir = "git_dir",
direction = "float",
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
end,
on_close = function(term)
vim.cmd("startinsert!")
end,
})
function _lazygit_toggle()
lazygit:toggle()
end
vim.api.nvim_set_keymap("n", "<leader>g", "<cmd>lua _lazygit_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_create_user_command("ConformToggle", function(args)
if args.bang then
vim.b.disable_autoformat = not vim.b.disable_autoformat
else
vim.g.disable_autoformat = not vim.g.disable_autoformat
end
end, {
desc = "Disable autoformat-on-save",
bang = true,
})

View File

@@ -0,0 +1,113 @@
[
{
key = "<leader>u";
mode = "n";
action = "<cmd>:UndotreeToggle<CR>";
}
# Find/Navigate
{
key = "<leader>ft";
action = "<cmd>:Neotree toggle<CR>";
}
{
key = "J";
mode = "v";
action = ":m '>+1<CR>gv=gv";
}
{
key = "K";
mode = "v";
action = ":m '<-2<CR>gv=gv";
}
{
key = "<C-d>";
mode = "n";
action = "<C-d>zz";
}
{
key = "<C-u>";
mode = "n";
action = "<C-u>zz";
}
{
key = "<leader>p";
mode = "x";
action = ''"_dP'';
}
{
key = "<leader>p";
mode = "n";
action = ''"_dP'';
}
{
key = "<leader>p";
mode = "v";
action = ''"_dP'';
}
{
key = "<leader>n";
mode = "n";
options.silent = true;
action = "vim.lsp.buf.hover";
lua = true;
}
{
key = "hh";
mode = "n";
action = ":Telescope harpoon marks<CR>";
}
{
key = "<leader>fp";
mode = "n";
options.silent = true;
lua = true;
action = "require('telescope').extensions.projects.projects";
}
# LSP Actions
{
key = "<leader>sa";
mode = "n";
options.silent = true;
lua = true;
action = "require('actions-preview').code_actions";
}
{
key = "<leader>sf";
mode = "n";
options.silent = true;
action = "<cmd>:ConformToggle<CR>";
}
# Trouble
{
key = "<leader>xx";
mode = "n";
lua = true;
action = "require('trouble').toggle";
}
{
key = "<leader>xw";
mode = "n";
lua = true;
action =
"function() require('trouble').toggle('workspace_diagnostics') end";
}
{
key = "<leader>xd";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('document_diagnostics') end";
}
{
key = "<leader>xq";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('quickfix') end";
}
{
key = "<leader>xl";
mode = "n";
lua = true;
action = "function() require('trouble').toggle('loclist') end";
}
]