From 71f7586a617281094737554d6cb1a3ff8f1a4e95 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 10 Jan 2023 02:38:06 +0100 Subject: [PATCH] Added so much stuff --- .gitignore | 2 + dotfiles/neovim/.neoconf.json | 17 + dotfiles/neovim/README.md | 128 ++++++++ dotfiles/neovim/ftdetect/hkf.lua | 7 + dotfiles/neovim/ftplugin/hkf.lua | 1 + dotfiles/neovim/ftplugin/lua.lua | 25 ++ dotfiles/neovim/ftplugin/nix.lua | 9 + dotfiles/neovim/ftplugin/purescript.lua | 32 ++ dotfiles/neovim/ftplugin/tex.lua | 178 +++++++++++ dotfiles/neovim/init.lua | 18 ++ dotfiles/neovim/lazy-lock.json | 64 ++++ dotfiles/neovim/lua/.luarc.json | 4 + dotfiles/neovim/lua/my/abbreviations.lua | 19 ++ dotfiles/neovim/lua/my/helpers.lua | 19 ++ dotfiles/neovim/lua/my/helpers/env.lua | 40 +++ dotfiles/neovim/lua/my/helpers/math/mod.lua | 15 + .../neovim/lua/my/helpers/wrapMovement.lua | 15 + dotfiles/neovim/lua/my/init.lua | 10 + dotfiles/neovim/lua/my/keymaps.lua | 103 ++++++ dotfiles/neovim/lua/my/lazy.lua | 39 +++ dotfiles/neovim/lua/my/neovide.lua | 13 + dotfiles/neovim/lua/my/options.lua | 44 +++ dotfiles/neovim/lua/my/plugins/catppuccin.lua | 18 ++ .../neovim/lua/my/plugins/clipboard-image.lua | 39 +++ dotfiles/neovim/lua/my/plugins/cmp.lua | 117 +++++++ dotfiles/neovim/lua/my/plugins/dashboard.lua | 14 + dotfiles/neovim/lua/my/plugins/firenvim.lua | 19 ++ dotfiles/neovim/lua/my/plugins/hydra.lua | 127 ++++++++ dotfiles/neovim/lua/my/plugins/idris.lua | 44 +++ dotfiles/neovim/lua/my/plugins/init.lua | 217 +++++++++++++ dotfiles/neovim/lua/my/plugins/iron.lua | 63 ++++ dotfiles/neovim/lua/my/plugins/lean.lua | 22 ++ dotfiles/neovim/lua/my/plugins/leap.lua | 15 + dotfiles/neovim/lua/my/plugins/lspconfig.lua | 220 +++++++++++++ dotfiles/neovim/lua/my/plugins/lualine.lua | 29 ++ dotfiles/neovim/lua/my/plugins/luasnip.lua | 34 ++ dotfiles/neovim/lua/my/plugins/mind.lua | 29 ++ dotfiles/neovim/lua/my/plugins/moonwalk.lua | 20 ++ dotfiles/neovim/lua/my/plugins/neoconf.lua | 12 + dotfiles/neovim/lua/my/plugins/null-ls.lua | 27 ++ dotfiles/neovim/lua/my/plugins/nvim-tree.lua | 20 ++ dotfiles/neovim/lua/my/plugins/surround.lua | 12 + dotfiles/neovim/lua/my/plugins/telescope.lua | 80 +++++ dotfiles/neovim/lua/my/plugins/treesitter.lua | 105 ++++++ dotfiles/neovim/lua/my/plugins/vimtex.lua | 26 ++ dotfiles/neovim/lua/my/plugins/vimux.lua | 40 +++ dotfiles/neovim/lua/my/plugins/whichkey.lua | 36 +++ .../lua/telescope/extensions/unicode.lua | 92 ++++++ dotfiles/neovim/neoconf.json | 1 + dotfiles/neovim/syntax/hkf.vim | 32 ++ dotfiles/neovim/tl/my/plugins/chunk.tl | 3 + dotfiles/vscode-snippets/README.md | 3 + dotfiles/vscode-snippets/package.json | 49 +++ .../vscode-snippets/snippets/latex/core.json | 300 ++++++++++++++++++ .../snippets/latex/explain.json | 77 +++++ .../vscode-snippets/snippets/lua/core.json | 33 ++ .../snippets/purescript/deriving.json | 77 +++++ .../snippets/purescript/imports.json | 62 ++++ .../snippets/purescript/other.json | 61 ++++ flake.lock | 217 +++++++++++++ flake.nix | 37 ++- home/adrielus/features/cli/bat.nix | 6 + home/adrielus/features/cli/default.nix | 27 ++ home/adrielus/features/cli/fish.nix | 75 +++++ home/adrielus/features/cli/git.nix | 26 ++ home/adrielus/features/cli/ssh.nix | 7 + home/adrielus/features/cli/starship.nix | 5 + home/adrielus/features/cli/tmux/default.nix | 36 +++ home/adrielus/features/cli/tmux/tmux.conf | 62 ++++ .../desktop/common/polybar/default.nix | 28 ++ .../desktop/common/polybar/polybar.ini | 111 +++++++ .../features/desktop/common/rofi/config.rasi | 98 ++++++ .../features/desktop/common/rofi/default.nix | 20 ++ home/adrielus/features/desktop/xmonad.nix | 3 + home/adrielus/features/neovim/default.nix | 89 ++++++ home/adrielus/global/default.nix | 48 +++ home/adrielus/tethys.nix | 30 +- hosts/nixos/common/global/default.nix | 25 ++ hosts/nixos/common/global/fish.nix | 10 + hosts/nixos/common/global/locale.nix | 4 + hosts/nixos/common/global/nix.nix | 59 ++++ hosts/nixos/common/global/openssh.nix | 51 +++ hosts/nixos/common/global/wireless.nix | 43 +++ hosts/nixos/common/optional/pipewire.nix | 23 ++ hosts/nixos/common/optional/touchpad.nix | 21 ++ hosts/nixos/common/optional/xmonad/Main.hs | 73 +++++ .../nixos/common/optional/xmonad/default.nix | 43 +++ hosts/nixos/common/optional/xserver.nix | 8 + hosts/nixos/common/users/adrielus.nix | 37 +++ hosts/nixos/tethys/boot.nix | 34 ++ hosts/nixos/tethys/default.nix | 20 ++ hosts/nixos/tethys/hardware-configuration.nix | 47 +++ hosts/nixos/tethys/ssh_host_ed25519_key.pub | 1 + hosts/tethys/default.nix | 1 - pkgs/default.nix | 2 +- scripts/hm-activate.sh | 7 + scripts/hm-rebuild.sh | 4 + secrets/adrielus_password.age | 8 + secrets/secrets.nix | 7 + secrets/wifi_passwords.age | 7 + 100 files changed, 4404 insertions(+), 33 deletions(-) create mode 100644 dotfiles/neovim/.neoconf.json create mode 100644 dotfiles/neovim/README.md create mode 100644 dotfiles/neovim/ftdetect/hkf.lua create mode 100644 dotfiles/neovim/ftplugin/hkf.lua create mode 100644 dotfiles/neovim/ftplugin/lua.lua create mode 100644 dotfiles/neovim/ftplugin/nix.lua create mode 100644 dotfiles/neovim/ftplugin/purescript.lua create mode 100644 dotfiles/neovim/ftplugin/tex.lua create mode 100644 dotfiles/neovim/init.lua create mode 100644 dotfiles/neovim/lazy-lock.json create mode 100644 dotfiles/neovim/lua/.luarc.json create mode 100644 dotfiles/neovim/lua/my/abbreviations.lua create mode 100644 dotfiles/neovim/lua/my/helpers.lua create mode 100644 dotfiles/neovim/lua/my/helpers/env.lua create mode 100644 dotfiles/neovim/lua/my/helpers/math/mod.lua create mode 100644 dotfiles/neovim/lua/my/helpers/wrapMovement.lua create mode 100644 dotfiles/neovim/lua/my/init.lua create mode 100644 dotfiles/neovim/lua/my/keymaps.lua create mode 100644 dotfiles/neovim/lua/my/lazy.lua create mode 100644 dotfiles/neovim/lua/my/neovide.lua create mode 100644 dotfiles/neovim/lua/my/options.lua create mode 100644 dotfiles/neovim/lua/my/plugins/catppuccin.lua create mode 100644 dotfiles/neovim/lua/my/plugins/clipboard-image.lua create mode 100644 dotfiles/neovim/lua/my/plugins/cmp.lua create mode 100644 dotfiles/neovim/lua/my/plugins/dashboard.lua create mode 100644 dotfiles/neovim/lua/my/plugins/firenvim.lua create mode 100644 dotfiles/neovim/lua/my/plugins/hydra.lua create mode 100644 dotfiles/neovim/lua/my/plugins/idris.lua create mode 100644 dotfiles/neovim/lua/my/plugins/init.lua create mode 100644 dotfiles/neovim/lua/my/plugins/iron.lua create mode 100644 dotfiles/neovim/lua/my/plugins/lean.lua create mode 100644 dotfiles/neovim/lua/my/plugins/leap.lua create mode 100644 dotfiles/neovim/lua/my/plugins/lspconfig.lua create mode 100644 dotfiles/neovim/lua/my/plugins/lualine.lua create mode 100644 dotfiles/neovim/lua/my/plugins/luasnip.lua create mode 100644 dotfiles/neovim/lua/my/plugins/mind.lua create mode 100644 dotfiles/neovim/lua/my/plugins/moonwalk.lua create mode 100644 dotfiles/neovim/lua/my/plugins/neoconf.lua create mode 100644 dotfiles/neovim/lua/my/plugins/null-ls.lua create mode 100644 dotfiles/neovim/lua/my/plugins/nvim-tree.lua create mode 100644 dotfiles/neovim/lua/my/plugins/surround.lua create mode 100644 dotfiles/neovim/lua/my/plugins/telescope.lua create mode 100644 dotfiles/neovim/lua/my/plugins/treesitter.lua create mode 100644 dotfiles/neovim/lua/my/plugins/vimtex.lua create mode 100644 dotfiles/neovim/lua/my/plugins/vimux.lua create mode 100644 dotfiles/neovim/lua/my/plugins/whichkey.lua create mode 100644 dotfiles/neovim/lua/telescope/extensions/unicode.lua create mode 100644 dotfiles/neovim/neoconf.json create mode 100644 dotfiles/neovim/syntax/hkf.vim create mode 100644 dotfiles/neovim/tl/my/plugins/chunk.tl create mode 100644 dotfiles/vscode-snippets/README.md create mode 100644 dotfiles/vscode-snippets/package.json create mode 100644 dotfiles/vscode-snippets/snippets/latex/core.json create mode 100644 dotfiles/vscode-snippets/snippets/latex/explain.json create mode 100644 dotfiles/vscode-snippets/snippets/lua/core.json create mode 100644 dotfiles/vscode-snippets/snippets/purescript/deriving.json create mode 100644 dotfiles/vscode-snippets/snippets/purescript/imports.json create mode 100644 dotfiles/vscode-snippets/snippets/purescript/other.json create mode 100644 flake.lock create mode 100644 home/adrielus/features/cli/bat.nix create mode 100644 home/adrielus/features/cli/default.nix create mode 100644 home/adrielus/features/cli/fish.nix create mode 100644 home/adrielus/features/cli/git.nix create mode 100644 home/adrielus/features/cli/ssh.nix create mode 100644 home/adrielus/features/cli/starship.nix create mode 100644 home/adrielus/features/cli/tmux/default.nix create mode 100644 home/adrielus/features/cli/tmux/tmux.conf create mode 100644 home/adrielus/features/desktop/common/polybar/default.nix create mode 100644 home/adrielus/features/desktop/common/polybar/polybar.ini create mode 100644 home/adrielus/features/desktop/common/rofi/config.rasi create mode 100644 home/adrielus/features/desktop/common/rofi/default.nix create mode 100644 home/adrielus/features/desktop/xmonad.nix create mode 100644 home/adrielus/features/neovim/default.nix create mode 100644 home/adrielus/global/default.nix create mode 100644 hosts/nixos/common/global/default.nix create mode 100644 hosts/nixos/common/global/fish.nix create mode 100644 hosts/nixos/common/global/locale.nix create mode 100644 hosts/nixos/common/global/nix.nix create mode 100644 hosts/nixos/common/global/openssh.nix create mode 100644 hosts/nixos/common/global/wireless.nix create mode 100644 hosts/nixos/common/optional/pipewire.nix create mode 100644 hosts/nixos/common/optional/touchpad.nix create mode 100644 hosts/nixos/common/optional/xmonad/Main.hs create mode 100644 hosts/nixos/common/optional/xmonad/default.nix create mode 100644 hosts/nixos/common/optional/xserver.nix create mode 100644 hosts/nixos/common/users/adrielus.nix create mode 100644 hosts/nixos/tethys/boot.nix create mode 100644 hosts/nixos/tethys/default.nix create mode 100644 hosts/nixos/tethys/hardware-configuration.nix create mode 100644 hosts/nixos/tethys/ssh_host_ed25519_key.pub delete mode 100644 hosts/tethys/default.nix create mode 100755 scripts/hm-activate.sh create mode 100755 scripts/hm-rebuild.sh create mode 100644 secrets/adrielus_password.age create mode 100644 secrets/secrets.nix create mode 100644 secrets/wifi_passwords.age diff --git a/.gitignore b/.gitignore index 4bd4a91..68dee6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules ./secrets.nix +result +*.qcow2 diff --git a/dotfiles/neovim/.neoconf.json b/dotfiles/neovim/.neoconf.json new file mode 100644 index 0000000..a0d5a68 --- /dev/null +++ b/dotfiles/neovim/.neoconf.json @@ -0,0 +1,17 @@ +{ + "neoconf": { + "plugins": { + "sumneko_lua": { + "enabled": true + } + } + }, + "neodev": { + "library": { + "enabled": true, + "types": true, + "plugins": false, + "runtime": true + } + } +} diff --git a/dotfiles/neovim/README.md b/dotfiles/neovim/README.md new file mode 100644 index 0000000..818970d --- /dev/null +++ b/dotfiles/neovim/README.md @@ -0,0 +1,128 @@ +# Neovim config + +## Articles + +- [Textobjects](https://blog.carbonfive.com/vim-text-objects-the-definitive-guide/) +- [Registers](https://www.brianstorti.com/vim-registers/) +- [Markers](https://vim.fandom.com/wiki/Using_marks) + +## Keybinds + +Table of my own keybinds. Here as documentation for myself. I am yet to include any of the keybinds for cmp here. + +> Things written using italics are chords +> (aka all the keys need to be pressed at the same time) + +| Keybind | Description | Plugins | +| ------------ | ----------------------------------- | ------------------ | +| _vs_ | Create vertical split | | +| _cp_ | Use system clipboard | | +| _jl_ | Save | | +| _jk_ | Exit insert mode | | +| _rw_ | Rename word under cursor | | +| _\k_ | Insert digraph | | +| _\a_ | Swap last 2 used buffers | | +| C-n | Open tree | nvim-tree | +| _vc_ | Clear vimux window | vimux | +| _vl_ | Rerun last vimux command | vimux | +| _vp_ | Run command in another tmux pane | vimux | +| C-hjkl | Navigation between vim & tmux panes | vim-tmux-navigator | +| J | Show line diagnostics | lspconfig | +| K | Show hover info | lspconfig | +| L | Signature help (?) | lspconfig | +| gD | Go to declaration | lspconfig | +| gd | Go to definition | lspconfig | +| gi | Go to implementation | lspconfig | +| \rn | Rename | lspconfig | +| \f | format | lspconfig | +| \ca | code actions | lspconfig | + +### Telescope + +| Keybind | Description | Plugins | +| ----------- | ------------------------------ | ---------------------- | +| Ctrl-P | Find files | | +| Ctrl-F | Grep in project | | +| \d | Diagnostics | lspconfig | +| \ca | Code actions | lspconfig | +| \t | Show builtin pickers | | +| \s | Show symbols using tree-sitter | | +| \gj | List git commits | | +| \gk | List git branches | | +| _jp_ | Interactive file broswer | telescope-file-browser | +| _ui_ | Insert unicode char | | + +### Idris + +> The idris and arpeggio plugins are implicit here + +| Keybind | Description | +| ------- | ------------------- | +| _isc_ | Case split | +| _imc_ | Make case | +| _iml_ | Make lemma | +| _ies_ | Expression search | +| _igd_ | Generate definition | +| _irh_ | Refine hole | +| _iac_ | Add clause | + +### Purescript + +| Keybind | Description | +| ------- | ------------------------------------------- | +| _vb_ | Make tmux run spago build in sepearate pane | +| _vt_ | Make tmux run spago test in separate pane | + +### Nix + +| Keybind | Description | +| ------- | ------------------------------------ | +| _ug_ | Run nix-fetchgit on the current file | + +### Lean + +- Extra brackets: ⟨⟩ + +## Some cool vim keybinds I sometimes forget about + +Documentation for myself + +| Keybind | Description | Plugins | +| ------- | ----------------------- | ------- | +| zz | Center the current line | | + +## Important plugins I use the default mappins of + +- paperplanes + +| Keybind | Description | +| ------- | ------------------------- | +| :PP | Create pastebin-like link | + +- nvim-comment + +| Keybind | Description | +| ------- | ----------------- | +| gcc | Comment line | +| gc | Comment selection | + +- neogit + +| Keybind | Description | +| ------- | ----------- | +| C-g | Open neogit | + +- gitlinker + +| Keybind | Description | +| ---------- | ------------------ | +| gy | Create remote link | + +- nvim-surround + +| Keybind | Description | Mode | +| -------- | ----------------------------------- | ---- | +| cs[a][b] | Change surrounding pair from a to b | n | +| ds[a] | Delete surrounding pair of a | n | +| ys[m][a] | Surround the motion m with a | n | +| S[a] | Surround selected code with a | v | diff --git a/dotfiles/neovim/ftdetect/hkf.lua b/dotfiles/neovim/ftdetect/hkf.lua new file mode 100644 index 0000000..fdca1d4 --- /dev/null +++ b/dotfiles/neovim/ftdetect/hkf.lua @@ -0,0 +1,7 @@ +vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { + group = vim.api.nvim_create_augroup("Detect hkf", {}), + pattern = "*.hkf", + callback = function() + vim.opt.filetype = "hkf" + end +}) diff --git a/dotfiles/neovim/ftplugin/hkf.lua b/dotfiles/neovim/ftplugin/hkf.lua new file mode 100644 index 0000000..c8e8ccc --- /dev/null +++ b/dotfiles/neovim/ftplugin/hkf.lua @@ -0,0 +1 @@ +vim.api.nvim_buf_set_option(0, "commentstring", "-- %s") diff --git a/dotfiles/neovim/ftplugin/lua.lua b/dotfiles/neovim/ftplugin/lua.lua new file mode 100644 index 0000000..b8b77cb --- /dev/null +++ b/dotfiles/neovim/ftplugin/lua.lua @@ -0,0 +1,25 @@ +local opts = function(desc) + return { desc = desc, buffer = true } +end + +vim.keymap.set("n", "lf", ":source %", opts("Run [l]ua [f]ile ")) +vim.keymap.set("n", "ls", function() + local path = vim.api.nvim_buf_get_name(0) + local status, M = pcall(dofile, path) + + if status then + if M ~= nil then + if type(M.setup) == "function" then + M.setup() + print("M.setup() executed succesfully!") + else + print("Module does not return a setup function") + end + else + print("Module returned nil") + end + else + print("Cannot import current file :(") + end +end, opts("Run .setup() in current file")) + diff --git a/dotfiles/neovim/ftplugin/nix.lua b/dotfiles/neovim/ftplugin/nix.lua new file mode 100644 index 0000000..991dbac --- /dev/null +++ b/dotfiles/neovim/ftplugin/nix.lua @@ -0,0 +1,9 @@ +-- Use _lg_ to fetchgit stuff +vim.keymap.set("n", "lg", function() + require("my.helpers").saveCursor(function() + vim.cmd(":%!update-nix-fetchgit") + end) +end, { buffer = true, desc = "Update all fetchgit calls" }) + +-- Idk why this isn't here by default +vim.api.nvim_buf_set_option(0, "commentstring", "# %s") diff --git a/dotfiles/neovim/ftplugin/purescript.lua b/dotfiles/neovim/ftplugin/purescript.lua new file mode 100644 index 0000000..04e24c2 --- /dev/null +++ b/dotfiles/neovim/ftplugin/purescript.lua @@ -0,0 +1,32 @@ +local A = require("my.abbreviations") + +-- Use vt to test +vim.keymap.set( + "n", + "vt", + ':VimuxRunCommand "clear && spago test"', + { desc = "[V]imtex run [t]ests", buffer = true } +) + +-- Use vb to build +vim.keymap.set( + "n", + "vb", + ':VimuxRunCommand "clear && spago build"', + { desc = "[V]imtex [b]uild", buffer = true } +) + +vim.opt.expandtab = true -- Use spaces for the tab char + +local abbreviations = { + { "land", "/\\" }, + { "lor", "\\/" }, + { "tto", "->" }, + { "iip", "=>" }, + { "frl", "forall" }, + { "ott", "<-" }, -- opposite of tto +} + +A.manyLocalAbbr(abbreviations) + + diff --git a/dotfiles/neovim/ftplugin/tex.lua b/dotfiles/neovim/ftplugin/tex.lua new file mode 100644 index 0000000..8a24551 --- /dev/null +++ b/dotfiles/neovim/ftplugin/tex.lua @@ -0,0 +1,178 @@ +local A = require("my.abbreviations") +local scrap = require("scrap") + +require("my.helpers.wrapMovement").setup() + +vim.opt.conceallevel = 0 +vim.opt.wrap = true + +-- vim.opt.foldcolumn = "1" +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +vim.opt.foldmethod = "expr" + +-- vim.keymap.set("n", "lg", function() +-- if not pcall(function() +-- local a = tonumber(vim.fn.input("A: ")) +-- local b = tonumber(vim.fn.input("B: ")) +-- +-- local g, x, y = require("my.helpers.math.mod").gcd(a, b) +-- +-- vim.fn.input("Result: " .. g .. " " .. x .. " " .. y) +-- end) then vim.fn.input("No results exist") end +-- end, { buffer = true, desc = "Gcd calculator" }) +-- +-- vim.keymap.set("n", "li", function() +-- if not pcall(function() +-- local class = tonumber(vim.fn.input("Mod class: ")) +-- local num = tonumber(vim.fn.input("Number: ")) +-- +-- vim.fn.input("Result: " .. require("my.helpers.math.mod").modinverse(num, class)) +-- end) then vim.fn.input("No results exist") end +-- end, { buffer = true, desc = "Mod inverse calculator" }) + +local abbreviations = { + -- Greek chars + { "eps", "\\epsilon" }, + { "delta", "\\delta" }, + { "Delta", "\\Delta" }, + { "pi", "\\pi" }, + { "psi", "\\psi" }, + { "alpha", "\\alpha" }, + { "beta", "\\beta" }, + { "theta", "\\theta" }, + { "gamma", "\\gamma" }, + { "lam", "\\lambda" }, + { "nuls", "\\varnothing" }, -- Other fancy symvols + + { "tmat", "^T" }, -- Tranpose of a matrix + { "cmat", "^*" }, -- Conjugate of a matrix + { "ortco", "^{\\bot}" }, -- Orthogonal complement + { "sinter", "^{\\circ}" }, -- Interior of a set + + -- Basic commands + { "mangle", "\\measuredangle" }, + { "aangle", "\\angle" }, + + { "sdiff", "\\setminus" }, + { "sst", "\\subset" }, + { "sseq", "\\subseteq" }, + { "nin", "\\not\\in" }, + { "iin", "\\in" }, + { "tto", "\\to" }, + { "iip", "\\implies" }, + { "iff", "\\iff" }, + { "land", "\\land" }, + { "lor", "\\lor" }, + { "ssin", "\\sin" }, + { "ccos", "\\cos" }, + { "ttan", "\\ttan" }, + { "ssec", "\\sec" }, + { "lln", "\\ln" }, + { "frl", "\\forall" }, + { "exs", "\\exists" }, + { "iinf", "\\infty" }, + { "ninf", "-\\infty" }, + { "nlnl", "\\pm" }, -- had this as npnp first but it was hard-ish to type + { "ccup", "\\cup" }, + { "ccap", "\\cap" }, + { "nope", "\\bot" }, + { "yee", "\\top" }, + { "ccan", "\\cancel" }, + { "comp", "\\circ" }, + { "mul", "\\cdot" }, + { "smul", "\\times" }, + { "card", "\\#" }, + { "div", "\\|" }, + { "ndiv", "\\not\\|\\:" }, + + -- words + { "rref", "reduced row echalon form" } +} + +---@type ExpansionOptions +local no_capitalization = { capitalized = false } + +-- Todo: convert exponents and subscripts +-- to use this more concise notation. +---@type ExpansionInput[] +local abolishAbbreviations = { + -- General phrases + { "thrf", "therefore" }, + { "bcla", "by contradiction let's assume" }, + { "wlg", "without loss of generality" }, + { "stam{,s}", "statement{}" }, + + -- Calculus + { "ib{p,s}", "integration by {parts,substitution}" }, + + -- Linear algebra + { "eg{va,ve,p}{,s}", "eigen{value,vector,pair}{}" }, + { "mx{,s}", "matri{x,ces}" }, + { "dete{,s}", "determinant{}" }, + { "ort{n,g}", "orto{normal,gonal}" }, + { "l{in,de}", "linearly {independent,dependent}" }, + + -- My own operator syntax: + -- - Any operator can be prefixed with "a" to + -- align in aligned mode + -- - Any operator can be prefixed with cr to + -- start a new line and align in aligned mode + { + "{cr,a,}{eq,neq,leq,geq,lt,gt}", + "{\\\\\\&,&,}{=,\\neq,\\leq,\\geq,<,>}", + options = no_capitalization + }, + + -- Exponents and subscripts: + -- {operation}{argument} + -- - operation = e (exponent) | s (subscript) + -- - argument = t{special} | {basic} + -- - basic = 0-9|n|i|t|k + -- - special = + -- - "p" => + + -- - "m" => - + -- - "i" => -1 + { + "{e,s}{{0,1,2,3,4,5,6,7,8,9,n,i,t,k},t{i,m,p}}", + "{^,_}{{},{\\{-1\\},-,+}}", + options = no_capitalization + }, + + -- Set symbols + -- - nats => naturals + -- - ints => integers + -- - rats => rationals + -- - irats => irationals + -- - rrea => reals + -- - comp => complex + -- - ppri => primes + -- - ffie => fields + { + "{nats,ints,rats,irats,rrea,comp,ppri,ffie}", + "\\mathbb\\{{N,Z,Q,I,R,C,P,F}\\}", + options = no_capitalization + }, + + -- Function calls: + -- {function-name}{modifier?}{argument}{argument-modifier?} + -- + -- - function-name = f/g/h/P + -- - modifier: + -- - d => derivative + -- - 2 => squared + -- - 3 => cubed + -- - i => inverse + -- - argument = x/y/z/a/t/i/n/k + -- - argument-modifier: + -- - n => subscript n + { "{f,g,h,P}{d,2,3,i,}{x,y,z,a,t,i,n,k}{n,}", "{}{',^2,^3,^\\{-1\\},}({}{_n,})" }, +} + +local expanded = scrap.expand_many(abolishAbbreviations) + +-- print("Expanded") +A.manyLocalAbbr(abbreviations) +A.manyLocalAbbr(expanded) + +vim.keymap.set("n", "lc", "VimtexCompile", + { desc = "Compile current buffer using vimtex", buffer = true }) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua new file mode 100644 index 0000000..bfbdf18 --- /dev/null +++ b/dotfiles/neovim/init.lua @@ -0,0 +1,18 @@ +-- bootstrap from github +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--single-branch", + "git@github.com:folke/lazy.nvim.git", + lazypath, + }) +end + +vim.opt.runtimepath:prepend(lazypath) + +-- Start the actual init process +require("my.init").setup() diff --git a/dotfiles/neovim/lazy-lock.json b/dotfiles/neovim/lazy-lock.json new file mode 100644 index 0000000..4d4af27 --- /dev/null +++ b/dotfiles/neovim/lazy-lock.json @@ -0,0 +1,64 @@ +{ + "LuaSnip": { "branch": "master", "commit": "5570fd797eae0790affb54ea669a150cad76db5d" }, + "abbreinder.nvim": { "branch": "main", "commit": "5b2b5ff08a9ada42238d733aeebc6d3d96314d77" }, + "abbremand.nvim": { "branch": "main", "commit": "d633341f632b0b2666dfc6dfe6b9842ba1610a1d" }, + "catppuccin": { "branch": "main", "commit": "3020af75aae098a77737d91ee37c7147c8450d99" }, + "clipboard-image.nvim": { "branch": "main", "commit": "d1550dc26729b7954f95269952e90471b838fa25" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "dashboard-nvim": { "branch": "master", "commit": "e517188dab55493fb9034b4d4f1a508ccacfcd45" }, + "dhall-vim": { "branch": "master", "commit": "68500ef46ff3706f46c99db3be7a0c8abcf6a3ae" }, + "dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" }, + "fidget.nvim": { "branch": "main", "commit": "44585a0c0085765195e6961c15529ba6c5a2a13b" }, + "firenvim": { "branch": "master", "commit": "17a189f0f1e2d4197e00cd56dbeaed8c268bac8c" }, + "gitlinker.nvim": { "branch": "master", "commit": "c68d4873a14d2ae614875685ccca2e49472989e8" }, + "glow.nvim": { "branch": "main", "commit": "20d1cd087f8728f21a048a3b6259f6177237b39e" }, + "hydra.nvim": { "branch": "master", "commit": "7e2aa29f88d534371c6b0263d3abbfac7c2376ce" }, + "idris2-nvim": { "branch": "main", "commit": "dd850c1c67bcacd2395121b0898374fe9cdd228f" }, + "inc-rename.nvim": { "branch": "main", "commit": "48c4aa2be19f79e79b465a9bb37ee9fbe6c606f5" }, + "iron.nvim": { "branch": "master", "commit": "f4131638454aeb96cbd92652dd8c396e48eb4118" }, + "kmonad-vim": { "branch": "master", "commit": "37978445197ab00edeb5b731e9ca90c2b141723f" }, + "knap": { "branch": "main", "commit": "62eae7803d9d87d33513b3b565c6f5791f1de1ea" }, + "kotlin-vim": { "branch": "master", "commit": "53fe045906df8eeb07cb77b078fc93acda6c90b8" }, + "lazy.nvim": { "branch": "main", "commit": "85173dcc4d7a39e67370571316a6290f31a0de4a" }, + "leap": { "branch": "main", "commit": "e0145906c5f004b23eb6ec876fad55ffd3382ec9" }, + "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lualine.nvim": { "branch": "master", "commit": "32a7382a75a52e8ad05f4cec7eeb8bbfbe80d461" }, + "mind.nvim": { "branch": "master", "commit": "5aa39d57d1091999ca5bdcdd056a27a032156c2d" }, + "neoconf.nvim": { "branch": "main", "commit": "590ff74e81694088c43f1f73982dcb7aa51c03ff" }, + "neodev.nvim": { "branch": "main", "commit": "c045c0fe93b1f9c78443d0f3b88660fffbcf64a7" }, + "neogit": { "branch": "master", "commit": "0d6002c6af432343937283fb70791fc76fa7227c" }, + "nui.nvim": { "branch": "main", "commit": "4939282919885e1c83aff68ecb35b3cadf6015a9" }, + "null-ls.nvim": { "branch": "main", "commit": "d09d7d82cc26d63673cef85cb62895dd68aab6d8" }, + "nvim-autopairs": { "branch": "master", "commit": "03580d758231956d33c8dd91e2be195106a79fa4" }, + "nvim-cmp": { "branch": "main", "commit": "c49ad26e894e137e401b1d294948c46327877eaf" }, + "nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" }, + "nvim-lspconfig": { "branch": "master", "commit": "6b43ce561d97412cc512b569db6938e44529293e" }, + "nvim-tree.lua": { "branch": "master", "commit": "951b6e7e55da8aee9566cc0b17c11f9451cec349" }, + "nvim-treesitter": { "branch": "master", "commit": "12e95e160d7d45b76a36bca6303dd8447ab77490" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "d816761ec1ea4a605689bc5f4111088459cf74d4" }, + "nvim-web-devicons": { "branch": "master", "commit": "05e1072f63f6c194ac6e867b567e6b437d3d4622" }, + "nvim_context_vt": { "branch": "master", "commit": "31436f34f3f95e4e70853cd653fdf78246cb0e85" }, + "paperplanes.nvim": { "branch": "master", "commit": "d704b2e1e594b32d454cc7e0c5f2cf9b391e3cc1" }, + "plenary.nvim": { "branch": "master", "commit": "4b7e52044bbb84242158d977a50c4cbcd85070c7" }, + "presence.nvim": { "branch": "main", "commit": "c1c54758824cbecd4e18065d37191f7666fdd097" }, + "purescript-vim": { "branch": "main", "commit": "7af25a840d38dc6767c85edd1f35c1f835618071" }, + "scrap.nvim": { "branch": "main", "commit": "16db44ae9403ec9c4b140394f294475d1af80a18" }, + "smart-splits.nvim": { "branch": "master", "commit": "fdd158ce7554dc830fb86e0fe952cd9476cdf726" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "304508fb7bea78e3c0eeddd88c4837501e403ae8" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "fab3e2212e206f4f8b3bbaa656e129443c9b802e" }, + "telescope.nvim": { "branch": "master", "commit": "e960efa60e97df58e089b00270f09d60f27202c8" }, + "venn.nvim": { "branch": "main", "commit": "c114563960b8fb1197695d42798d1f3e7190b798" }, + "vim-abolish": { "branch": "master", "commit": "3f0c8faadf0c5b68bcf40785c1c42e3731bfa522" }, + "vim-sleuth": { "branch": "master", "commit": "8332f123a63c739c870c96907d987cc3ff719d24" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-teal": { "branch": "master", "commit": "d2aa107b257879e774680792a2aebaf9cd5742e0" }, + "vim-tmux-navigator": { "branch": "master", "commit": "18f0c7fc1e7181e6422247505727d7111c5da544" }, + "vim-wakatime": { "branch": "master", "commit": "7d8ca4667f46e783388609ca7f04a65e4389338a" }, + "vimux": { "branch": "master", "commit": "616fcb4799674a7a809b14ca2dc155bb6ba25788" }, + "which-key.nvim": { "branch": "main", "commit": "8682d3003595017cd8ffb4c860a07576647cc6f8" } +} \ No newline at end of file diff --git a/dotfiles/neovim/lua/.luarc.json b/dotfiles/neovim/lua/.luarc.json new file mode 100644 index 0000000..e1b9d70 --- /dev/null +++ b/dotfiles/neovim/lua/.luarc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.workspace.checkThirdParty": false +} \ No newline at end of file diff --git a/dotfiles/neovim/lua/my/abbreviations.lua b/dotfiles/neovim/lua/my/abbreviations.lua new file mode 100644 index 0000000..919c6fe --- /dev/null +++ b/dotfiles/neovim/lua/my/abbreviations.lua @@ -0,0 +1,19 @@ +local M = {} + +function M.localAbbr(lhs, rhs) + -- Create abbreviation + vim.cmd(":iabbrev " .. lhs .. " " .. rhs) +end + +function M.manyLocalAbbr(abbreviations) + for _, value in pairs(abbreviations) do + M.localAbbr(value[1], value[2]) + end +end + +function M.abbr(lhs, rhs) + -- Create abbreviation + vim.cmd(":iabbrev " .. lhs .. " " .. rhs) +end + +return M diff --git a/dotfiles/neovim/lua/my/helpers.lua b/dotfiles/neovim/lua/my/helpers.lua new file mode 100644 index 0000000..e9158b5 --- /dev/null +++ b/dotfiles/neovim/lua/my/helpers.lua @@ -0,0 +1,19 @@ +local M = {} + +function M.mergeTables(t1, t2) + local t3 = {} + + if t1 ~= nil then for k, v in pairs(t1) do t3[k] = v end end + + if t2 ~= nil then for k, v in pairs(t2) do t3[k] = v end end + + return t3 +end + +function M.saveCursor(callback) + local cursor = vim.api.nvim_win_get_cursor(0) + callback() + vim.api.nvim_win_set_cursor(0, cursor) +end + +return M diff --git a/dotfiles/neovim/lua/my/helpers/env.lua b/dotfiles/neovim/lua/my/helpers/env.lua new file mode 100644 index 0000000..5c6d32a --- /dev/null +++ b/dotfiles/neovim/lua/my/helpers/env.lua @@ -0,0 +1,40 @@ +local function makeEnv(cond) + return { + active = cond, + not_active = function() + return not cond() + end, + unless = function(f) + if not cond() then + f() + end + end, + when = function(f) + if cond() then + f() + end + end, + } +end + +return { + vscode = makeEnv(function() + return vim.g.vscode ~= nil + end), + neovide = makeEnv(function() + return vim.g.neovide ~= nil or os.getenv("INSIDE_NEOVIDE") == "1" + end), + firenvim = makeEnv(function() + return vim.g.started_by_firenvim ~= nil + end), + _and = function(a, b) + return makeEnv(function() + return a.active() and b.active() + end) + end, + _or = function(a, b) + return makeEnv(function() + return a.active() or b.active() + end) + end +} diff --git a/dotfiles/neovim/lua/my/helpers/math/mod.lua b/dotfiles/neovim/lua/my/helpers/math/mod.lua new file mode 100644 index 0000000..50de361 --- /dev/null +++ b/dotfiles/neovim/lua/my/helpers/math/mod.lua @@ -0,0 +1,15 @@ +local M = {} + +function M.modinverse(b, m) + local g, x, _ = M.gcd(b, m) + if g ~= 1 then return nil end + return x % m +end + +function M.gcd(a, b) + if a == 0 then return b, 0, 1 end + local g, x1, y1 = M.gcd(b % a, a) + return g, y1 - (math.floor(b / a)) * x1, x1 +end + +return M diff --git a/dotfiles/neovim/lua/my/helpers/wrapMovement.lua b/dotfiles/neovim/lua/my/helpers/wrapMovement.lua new file mode 100644 index 0000000..45b81ad --- /dev/null +++ b/dotfiles/neovim/lua/my/helpers/wrapMovement.lua @@ -0,0 +1,15 @@ +local M = {} + +local function swap(key) + vim.keymap.set({ "n", "v" }, key, "g" .. key, { buffer = true }) + vim.keymap.set({ "n", "v" }, "g" .. key, key, { buffer = true }) +end + +function M.setup() + swap("j") + swap("k") + swap("0") + swap("$") +end + +return M diff --git a/dotfiles/neovim/lua/my/init.lua b/dotfiles/neovim/lua/my/init.lua new file mode 100644 index 0000000..3886f9b --- /dev/null +++ b/dotfiles/neovim/lua/my/init.lua @@ -0,0 +1,10 @@ +local M = {} + +function M.setup() + -- Import my other files + require("my.options").setup() + require('my.keymaps').setup() + require('my.lazy').setup() +end + +return M diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua new file mode 100644 index 0000000..92dceb0 --- /dev/null +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -0,0 +1,103 @@ +local helpers = require("my.helpers") + +local M = {} + +-- {{{ Helpers +---Performs a basic move operation +---Moves a keybind to a different set of keys. +---Useful for moving built in keybinds out of the way. +---@param from string +---@param to string +---@param opts table|nil +function M.move(from, to, opts) + vim.keymap.set("n", to, from, opts) + vim.keymap.set("n", from, "") +end + +---Create a textobject defined by some delimiters +---@param from string +---@param to string +---@param name string +---@param perhapsOpts table|nil +function M.delimitedTextobject(from, to, name, perhapsOpts) + local opts = helpers.mergeTables(perhapsOpts or {}, { desc = name }) + + vim.keymap.set({ "v", "o" }, "i" .. from, "i" .. to, opts) + vim.keymap.set({ "v", "o" }, "a" .. from, "a" .. to, opts) +end + +---Helper to create a normal mode mapping and give it some description. +---@param from string +---@param to string|function +---@param desc string +---@param silent boolean|nil +function M.nmap(from, to, desc, silent) + if silent == nil then + silent = true + end + vim.keymap.set("n", from, to, { desc = desc }) +end + +-- }}} + +function M.setup() + -- {{{ Free up q and Q + M.move("q", "yq", { desc = "Record macro" }) + M.move("Q", "yQ") + -- }}} + -- {{{ Easier access to + M.move("", "a", { desc = "[A]lternate file" }) + -- }}} + -- {{{ Quit current buffer / all buffers + vim.keymap.set({ "n", "v" }, "q", function() + local buf = vim.api.nvim_win_get_buf(0) + + -- Only save if file is writable + if vim.bo[buf].modifiable and not vim.bo[buf].readonly then + vim.cmd([[write]]) + end + + vim.cmd("q") + end, { desc = "[Q]uit current buffer" }) + + M.nmap("Q", ":wqa", "Save all files and [q]uit") + -- }}} + -- {{{ Replace word in file + M.nmap("rw", ":%s//", "[R]eplace [w]ord in file") + -- }}} + -- {{{ Text objects + M.delimitedTextobject("q", '"', "[q]uotes") + M.delimitedTextobject("a", "'", "[a]postrophes") + M.delimitedTextobject("r", "[", "squa[r]e brackets") + -- }}} + -- {{{Diagnostic keymaps + M.nmap("[d", vim.diagnostic.goto_prev, "Goto previous [d]iagnostic") + M.nmap("]d", vim.diagnostic.goto_next, "Goto next [d]iagnostic") + M.nmap("J", vim.diagnostic.open_float, "Open current diagnostic") + M.nmap("D", vim.diagnostic.setloclist, "[D]iagnostic loclist") + -- }}} + -- {{{ Chords (save, clipboard) + -- Different chords get mapped to f keys by a custom script of mine. + -- In the future, I might get this on my keyboard firmware. + vim.keymap.set({ "i", "v" }, "", '', { desc = "Exit insert mode" }) -- Exit inset mode using *jk* + vim.keymap.set({ "n", "v" }, "", '"+', { desc = "Use global clipboard" }) -- Use global clipboard with *cp* + M.nmap("", ":silent write", "Save current file") -- Save using *ji* + -- }}} + -- {{{ Allow quiting basic buffers with "q" + vim.api.nvim_create_autocmd("FileType", { + pattern = { "help" }, + callback = function(event) + vim.keymap.set( + "n", + "q", + "close", + { buffer = event.buf, silent = true, desc = "[q]uit current buffer" } + ) + end, + }) + -- }}} + + return M +end + +return M diff --git a/dotfiles/neovim/lua/my/lazy.lua b/dotfiles/neovim/lua/my/lazy.lua new file mode 100644 index 0000000..1dabc58 --- /dev/null +++ b/dotfiles/neovim/lua/my/lazy.lua @@ -0,0 +1,39 @@ +local M = {} + +function M.setup() + require("lazy").setup("my.plugins", { + defaults = { lazy = true }, + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + install = { + -- install missing plugins on startup. This doesn't increase startup time. + missing = true, + -- try to load one of these colorschemes when starting an installation during startup + colorscheme = { "catpuccin" }, + }, + change_detection = { + enabled = false, + notify = false, + }, + performance = { + rtp = { + paths = { + -- Extra runtime path specified by nix + os.getenv("NVIM_EXTRA_RUNTIME") or "", + }, + }, + }, + }) +end + +vim.keymap.set("n", "L", "Lazy", { desc = "[L]azy ui" }) + +return M diff --git a/dotfiles/neovim/lua/my/neovide.lua b/dotfiles/neovim/lua/my/neovide.lua new file mode 100644 index 0000000..eb81548 --- /dev/null +++ b/dotfiles/neovim/lua/my/neovide.lua @@ -0,0 +1,13 @@ +local M = {} + +function M.setup() + local default_length = 0.04 + vim.g.neovide_floating_blur_amount_x = 3.0 + vim.g.neovide_floating_blur_amount_y = 3.0 + vim.g.neovide_transparency = 1.0 + vim.g.pumblend = 30 + vim.g.neovide_cursor_animation_length = default_length + vim.g.neovide_cursor_animate_in_insert_mode = false +end + +return M diff --git a/dotfiles/neovim/lua/my/options.lua b/dotfiles/neovim/lua/my/options.lua new file mode 100644 index 0000000..e4915d1 --- /dev/null +++ b/dotfiles/neovim/lua/my/options.lua @@ -0,0 +1,44 @@ +local M = {} + +function M.setup() + -- Disable filetype.vim + vim.g.do_filetype_lua = true + vim.g.did_load_filetypes = false + + -- Basic options + vim.opt.joinspaces = false -- No double spaces with join + vim.opt.list = true -- Show some invisible characters + vim.opt.cmdheight = 0 -- Hide command line when it's not getting used + + -- Line numbers + vim.opt.number = true -- Show line numbers + vim.opt.relativenumber = true -- Relative line numbers + + -- TODO: only do this for specific filestypes + vim.opt.expandtab = true -- Use spaces for the tab char + + vim.opt.scrolloff = 4 -- Lines of context + vim.opt.shiftround = true -- Round indent + vim.opt.shiftwidth = 2 -- Size of an indent + vim.opt.termguicolors = true -- True color support + + vim.opt.ignorecase = true -- Ignore case + vim.opt.smartcase = true -- Do not ignore case with capitals + + vim.opt.smartindent = true -- Insert indents automatically + + vim.opt.splitbelow = true -- Put new windows below current + vim.opt.splitright = true -- Put new windows right of current + + vim.opt.wrap = false -- Disable line wrap (by default) + vim.opt.wildmode = { 'list', 'longest' } -- Command-line completion mode + vim.opt.completeopt = { "menu", "menuone", "noselect" } + + -- Set leader + vim.g.mapleader = " " + + -- Folding + vim.opt.foldmethod = "marker" +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/catppuccin.lua b/dotfiles/neovim/lua/my/plugins/catppuccin.lua new file mode 100644 index 0000000..8171318 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/catppuccin.lua @@ -0,0 +1,18 @@ +local M = { + "catppuccin/nvim", name = "catppuccin", + lazy = false +} + +function M.config() + local catppuccin = require("catppuccin") + vim.g.catppuccin_flavour = os.getenv("CATPPUCCIN_FLAVOUR") + + catppuccin.setup({ transparent_background = false, integrations = { nvimtree = true } }) + + vim.cmd [[highlight NotifyINFOIcon guifg=#d6b20f]] + vim.cmd [[highlight NotifyINFOTitle guifg=#d6b20f]] + + vim.cmd [[colorscheme catppuccin]] +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/clipboard-image.lua b/dotfiles/neovim/lua/my/plugins/clipboard-image.lua new file mode 100644 index 0000000..b09fb82 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/clipboard-image.lua @@ -0,0 +1,39 @@ +local M = { + -- paste images from clipbaord + "ekickx/clipboard-image.nvim", + cmd = "PasteImg", +} + +local function img_name() + vim.fn.inputsave() + local name = vim.fn.input("Name: ") + vim.fn.inputrestore() + + if name == nil or name == "" then + return os.date("%y-%m-%d-%H-%M-%S") + end + return name +end + +function M.init() + vim.keymap.set( + "n", + "p", + ":PasteImg", + { desc = "[P]aste image from clipboard" } + ) +end + +function M.config() + require("clipboard-image").setup({ + default = { + img_name = img_name, + }, + tex = { + img_dir = { "%:p:h", "img" }, + affix = "\\includegraphics[width=\\textwidth]{%s}", + }, + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/cmp.lua b/dotfiles/neovim/lua/my/plugins/cmp.lua new file mode 100644 index 0000000..0ea0dc4 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/cmp.lua @@ -0,0 +1,117 @@ +local env = require("my.helpers.env") + +local M = { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "onsails/lspkind.nvim", -- show icons in lsp completion menus + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-emoji", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + "L3MON4D3/LuaSnip", -- snippeting engine + }, + cond = env.vscode.not_active(), +} + +local function has_words_before() + 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 M.config() + vim.o.completeopt = "menuone,noselect" + + local cmp = require("cmp") + local lspkind = require("lspkind") + + local options = { + window = { + completion = { + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None", + col_offset = -3, + side_padding = 0, + completeopt = "menu,menuone,noinsert", + }, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + local kind = lspkind.cmp_format({ + mode = "symbol", + maxwidth = 50, + symbol_map = { + Text = ".", + }, + })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + + kind.kind = " " .. strings[1] .. " " + kind.menu = "" + + return kind + end, + }, + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffers" }, + { name = "emoji" }, + { name = "path" }, + -- { name = 'omni' }, + }), + } + + cmp.setup(options) + + -- Use buffer source for `/` + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- Use cmdline & path source for ':' + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + { name = "cmdline" }, + }), + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/dashboard.lua b/dotfiles/neovim/lua/my/plugins/dashboard.lua new file mode 100644 index 0000000..85b3535 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/dashboard.lua @@ -0,0 +1,14 @@ +local env = require("my.helpers.env") + +local M = { + "glepnir/dashboard-nvim", + lazy = false, + cond = env.vscode.not_active() and env.firenvim.not_active(), +} + +function M.config() + local db = require("dashboard") + db.custom_header = {} +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/firenvim.lua b/dotfiles/neovim/lua/my/plugins/firenvim.lua new file mode 100644 index 0000000..8192c83 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/firenvim.lua @@ -0,0 +1,19 @@ +local env = require("my.helpers.env") + +local M = { + "glacambre/firenvim", -- vim inside chrome + lazy = false, + cond = env.firenvim.active(), +} + +function M.setup() + vim.g.firenvim_config = { + localSettings = { + [".*"] = { + filename = "/tmp/firenvim_{hostname}_{pathname%10}_{timestamp%32}.{extension}", + }, + }, + } +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/hydra.lua b/dotfiles/neovim/lua/my/plugins/hydra.lua new file mode 100644 index 0000000..151df7d --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/hydra.lua @@ -0,0 +1,127 @@ +local M = { + -- keybinds where you only hit the head once + "anuvyklack/hydra.nvim", + dependencies = { + "jbyuki/venn.nvim", -- draw ascii diagrams + "mrjones2014/smart-splits.nvim", -- the name says it all + }, + keys = { "", "v" }, +} + +local venn_hint = [[ + Arrow^^^^^^ Select region with + ^ ^ _K_ ^ ^ _f_: surround it with box + _H_ ^ ^ _L_ + ^ ^ _J_ ^ ^ __ +]] + +local window_hint = [[ + ^^^^^^^^^^^^ Move ^^ Size ^^ ^^ Split + ^^^^^^^^^^^^------------- ^^-----------^^ ^^--------------- + ^ ^ _k_ ^ ^ ^ ^ _K_ ^ ^ ^ __ ^ _s_: horizontally + _h_ ^ ^ _l_ _H_ ^ ^ _L_ __ __ _v_: vertically + ^ ^ _j_ ^ ^ ^ ^ _J_ ^ ^ ^ __ ^ _q_: close + focus^^^^^^ window^^^^^^ ^_=_: equalize^ _o_: close remaining +]] + +function M.config() + local Hydra = require("hydra") + local pcmd = require("hydra.keymap-util").pcmd + local splits = require("smart-splits") + + Hydra({ + name = "Draw Diagram", + hint = venn_hint, + config = { + color = "pink", + invoke_on_body = true, + hint = { + border = "rounded", + }, + on_enter = function() + vim.o.virtualedit = "all" + end, + }, + mode = "n", + body = "v", + heads = { + { "H", "h:VBox" }, + { "J", "j:VBox" }, + { "K", "k:VBox" }, + { "L", "l:VBox" }, + { "f", ":VBox", { mode = "v" } }, + { "", nil, { exit = true } }, + }, + }) + + vim.keymap.set("n", "", "") + + Hydra({ + name = "Windows", + hint = window_hint, + config = { + invoke_on_body = true, + hint = { + border = "rounded", + offset = -1, + }, + }, + mode = "n", + body = "", + heads = { + { "h", "h" }, + { "j", "j" }, + { "k", "k" }, + { "l", "l" }, + + { "H", "H" }, + { "J", "J" }, + { "K", "K" }, + { "L", "L" }, + + { + "", + function() + splits.resize_left(2) + end, + }, + { + "", + function() + splits.resize_down(2) + end, + }, + { + "", + function() + splits.resize_up(2) + end, + }, + { + "", + function() + splits.resize_right(2) + end, + }, + { "=", "=", { desc = "equalize" } }, + + { "s", pcmd("split", "E36") }, + { "", pcmd("split", "E36"), { desc = false } }, + { "v", pcmd("vsplit", "E36") }, + { "", pcmd("vsplit", "E36"), { desc = false } }, + + { "w", "w", { exit = true, desc = false } }, + { "", "w", { exit = true, desc = false } }, + + { "o", "o", { exit = true, desc = "remain only" } }, + { "", "o", { exit = true, desc = false } }, + + { "q", pcmd("close", "E444"), { desc = "close window" } }, + { "", pcmd("close", "E444"), { desc = false } }, + + { "", nil, { exit = true, desc = false } }, + }, + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/idris.lua b/dotfiles/neovim/lua/my/plugins/idris.lua new file mode 100644 index 0000000..ad566e6 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/idris.lua @@ -0,0 +1,44 @@ +local env = require("my.helpers.env") +local lspconfig = require("my.plugins.lspconfig") + +local M = { + "ShinKage/idris2-nvim", + dependencies = {"nui.nvim", "nvim-lspconfig"}, + ft = { "idris2", "lidris2", "ipkg" }, + cond = env.vscode.not_active(), +} + +function M.config() + local idris2 = require("idris2") + + idris2.setup({ + server = { + on_attach = function(client, bufnr) + lspconfig.on_attach(client, bufnr) + + local function nmap(from, to, desc) + vim.keymap.set("n", "I" .. from, function() + require("idris2.code_action")[to]() + end, { desc = desc, bufnr = true }) + end + + nmap("C", "make_case", "Make [c]plit") + nmap("L", "make_lemma", "Make [l]emma") + nmap("c", "add_clause", "Add [c]lause") + nmap("s", "expr_search", "Expression [s]earch") + nmap("d", "generate_def", "Generate [d]efinition") + nmap("s", "case_split", "Case [s]plit") + nmap("h", "refine_hole", "Refine [h]ole") + + local status, wk = pcall(require, "which-key") + + if status then + wk.register({ ["I"] = { name = "[I]dris", buffer = bufnr } }) + end + end, + }, + client = { hover = { use_split = true } }, + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua new file mode 100644 index 0000000..96a363a --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -0,0 +1,217 @@ +local env = require("my.helpers.env") + +if env.neovide.active() then + require("my.neovide").setup() +end + +return { + --{{{ Language support + { + "purescript-contrib/purescript-vim", + ft = "purescript", + cond = env.vscode.not_active(), + }, + + { + "teal-language/vim-teal", + ft = "teal", + cond = env.vscode.not_active(), + }, + + { + "udalov/kotlin-vim", + ft = "kotlin", + cond = env.vscode.not_active(), + }, + + { + "kmonad/kmonad-vim", + ft = "kbd", + cond = env.vscode.not_active(), + }, + + { + "vmchale/dhall-vim", + ft = "dhall", + cond = env.vscode.not_active(), + }, + --}}} + + { + -- Better ui for inputs/selects + "stevearc/dressing.nvim", + config = true, + -- https://github.com/folke/dot/blob/master/config/nvim/lua/config/plugins/init.lua + init = function() + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.select = function(...) + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.select(...) + end + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.input = function(...) + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.input(...) + end + end, + cond = env.vscode.not_active(), + }, + + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup() + end, + }, + + -- Helper libs + { + "nvim-lua/plenary.nvim", + }, + + "MunifTanjim/nui.nvim", + + { + "terrortylor/nvim-comment", + keys = { "gc", "gcc", { "gc", mode = "v" } }, + config = function() + require("nvim_comment").setup() + end, + }, + + -- nice looking icons + "kyazdani42/nvim-web-devicons", + + { + -- easly switch between tmux and vim panes + "christoomey/vim-tmux-navigator", + keys = { "", "", "", "" }, + cond = env.vscode.not_active() + and env.neovide.not_active() + and env.firenvim.not_active(), + }, + + { + -- track time usage + "wakatime/vim-wakatime", + event = "VeryLazy", + cond = env.vscode.not_active() and env.firenvim.not_active(), + }, + + { + -- smooth scrolling + "psliwka/vim-smoothie", + -- enabled = env.neovide.not_active(), + enabled = false, + event = "VeryLazy", + }, + + { + -- show context on closing parenthesis + -- TODO: move this to treesitter file + "haringsrob/nvim_context_vt", + event = "BufReadPost", + cond = env.vscode.not_active(), + }, + + { + -- show progress for lsp stuff + "j-hui/fidget.nvim", + event = "BufReadPre", + cond = env.vscode.not_active(), + config = true, + }, + + { + -- export to pastebin like services + "rktjmp/paperplanes.nvim", + config = { + provider = "paste.rs", + }, + keys = { "PP" }, + }, + + { + -- case switching + the subvert command + "tpope/vim-abolish", + event = "VeryLazy", + }, + + { + -- reminds you of abbreviations + "0styx0/abbreinder.nvim", + dependencies = "0styx0/abbremand.nvim", + event = "InsertEnter", + }, + + { + -- md preview (in terminal) + "ellisonleao/glow.nvim", + cmd = "Glow", + cond = env.vscode.not_active(), + }, + + { + "frabjous/knap", -- md preview + cond = env.vscode.not_active(), + }, + + { + -- automatically set options based on current file + "tpope/vim-sleuth", + event = "BufRead", + cond = env.vscode.not_active(), + }, + + -- vim-abolish rewrite + "mateiadrielrafael/scrap.nvim", + + { + "ruifm/gitlinker.nvim", -- generate permalinks for code + -- dependencies = { "plenary.nvim" }, + config = { + mappings = "yg" + }, + init = function() + local status, wk = pcall(require, "which-key") + + if status then + wk.register({ + ["yg"] = { + desc = "[Y]ank [g]it remote url", + }, + }) + end + end, + cond = env.firenvim.not_active(), + keys = "yg", + }, + + { + -- magit clone + "TimUntersberger/neogit", + -- dependencies = { "plenary.nvim" }, + cmd = "Neogit", + enabled = env.firenvim.not_active() and env.vscode.not_active(), + init = function() + vim.keymap.set( + "n", + "", + "Neogit", + { desc = "Open neo[g]it" } + ) + end, + config = true, + }, + + { + -- discord rich presence + "andweeb/presence.nvim", + cond = env.vscode.not_active() and env.firenvim.not_active(), + config = function() + require("presence"):setup() + end, + lazy = false, + }, +} diff --git a/dotfiles/neovim/lua/my/plugins/iron.lua b/dotfiles/neovim/lua/my/plugins/iron.lua new file mode 100644 index 0000000..6629de0 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/iron.lua @@ -0,0 +1,63 @@ +local env = require("my.helpers.env") + +local M = { + "hkupty/iron.nvim", -- repl support + cond = env.vscode.not_active(), + cmd = "IronRepl", +} + +function M.init() + -- iron also has a list of commands, see :h iron-commands for all available commands + vim.keymap.set("n", "iss", "IronRepl") + vim.keymap.set("n", "ir", "IronRestart") + vim.keymap.set("n", "if", "IronFocus") + vim.keymap.set("n", "ih", "IronHide") + + local status, wk = pcall(require, "which-key") + + if status then + wk.register({ + ["i"] = { + name = "[I]ron repl", + s = { name = "[s]end" }, + m = { name = "[m]ark" }, + }, + }) + end +end + +function M.config() + local iron = require("iron.core") + + iron.setup({ + config = { + -- Your repl definitions come here + repl_definition = {}, + -- How the repl window will be displayed + -- See below for more information + repl_open_cmd = require("iron.view").right(40), + }, + -- Iron doesn't set keymaps by default anymore. + -- You can set them here or manually add keymaps to the functions in iron.core + keymaps = { + send_motion = "isc", + visual_send = "is", + send_file = "isf", + send_line = "isl", + send_mark = "ism", + mark_motion = "imc", + mark_visual = "imc", + remove_mark = "imd", + cr = "is", + interrupt = "is", + exit = "isq", + clear = "isr", + }, + -- If the highlight is on, you can change how it looks + -- For the available options, check nvim_set_hl + highlight = { italic = true }, + ignore_blank_lines = true, -- ignore blank lines when sending visual select lines + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/lean.lua b/dotfiles/neovim/lua/my/plugins/lean.lua new file mode 100644 index 0000000..cc2a850 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/lean.lua @@ -0,0 +1,22 @@ +local env = require("my.helpers.env") +local lspconfig = require("my.plugins.lspconfig") + +local M = { + "Julian/lean.nvim", -- lean support + dependencies = { "neovim/nvim-lspconfig", "nvim-lua/plenary.nvim", "hrsh7th/nvim-cmp" }, + ft = "lean", + config = function() + require("lean").setup({ + abbreviations = { builtin = true, cmp = true }, + lsp = { + on_attach = lspconfig.on_attach, + capabilities = lspconfig.capabilities(), + }, + lsp3 = false, + mappings = true, + }) + end, + cond = env.vscode.not_active(), +} + +return {} diff --git a/dotfiles/neovim/lua/my/plugins/leap.lua b/dotfiles/neovim/lua/my/plugins/leap.lua new file mode 100644 index 0000000..ca6c8af --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/leap.lua @@ -0,0 +1,15 @@ +local M = { + -- removes the need for spamming w or e + "ggandor/leap.nvim", + name = "leap", + event = "VeryLazy" +} + +function M.config() + require("leap").add_default_mappings() +end + +-- (something) +-- something + +return M diff --git a/dotfiles/neovim/lua/my/plugins/lspconfig.lua b/dotfiles/neovim/lua/my/plugins/lspconfig.lua new file mode 100644 index 0000000..9aa95fe --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/lspconfig.lua @@ -0,0 +1,220 @@ +local helpers = require("my.helpers") +local env = require("my.helpers.env") + +local lspconfig = { + "neovim/nvim-lspconfig", + event = "BufReadPre", + dependencies = { + "folke/neoconf.nvim", + { + "folke/neodev.nvim", + config = true, + }, + "hrsh7th/cmp-nvim-lsp", + }, + cond = env.vscode.not_active(), +} + +local M = { + lspconfig, + { + "smjonas/inc-rename.nvim", + cmd = "IncRename", + config = { + input_buffer_type = "dressing", + }, + dependencies = { + "dressing.nvim", + }, + cond = env.vscode.not_active(), + }, +} + +function M.on_attach(client, bufnr) + -- {{{ Auto format + local function format() + vim.lsp.buf.format({ async = false, bufnr = bufnr }) + end + + if false and client.supports_method("textDocument/formatting") then + vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }), + buffer = bufnr, + callback = format, + }) + end + -- }}} + -- {{{ Keymap helpers + local opts = function(desc) + return { noremap = true, silent = true, desc = desc, buffer = bufnr } + end + + local nmap = function(from, to, desc) + vim.keymap.set("n", from, to, opts(desc)) + end + -- }}} + -- {{{ Go to declaration / definition / implementation + nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition") + nmap("gi", vim.lsp.buf.implementation, "[G]o to [i]mplementation") + nmap("gr", vim.lsp.buf.references, "[G]o to [r]eferences") + -- }}} + -- {{{ Hover + -- Note: diagnostics are already covered in keymaps.lua + nmap("K", vim.lsp.buf.hover, "Hover") + nmap("L", vim.lsp.buf.signature_help, "Signature help") + -- }}} + -- {{{ Code actions + nmap("c", vim.lsp.buf.code_action, "[C]ode actions") + nmap("F", format, "[F]ormat") + nmap("li", "LspInfo", "[L]sp [i]nfo") + + vim.keymap.set("n", "rn", function() + return ":IncRename " .. vim.fn.expand("") + end, helpers.mergeTables(opts("[R]e[n]ame"), { expr = true })) + + vim.keymap.set( + "v", + "c", + ":'<,'> lua vim.lsp.buf.range_code_action()", + opts("[C]ode actions") + ) + -- }}} + -- {{{ Workspace stuff + nmap( + "wa", + vim.lsp.buf.add_workspace_folder, + "[W]orkspace [A]dd Folder" + ) + nmap( + "wr", + vim.lsp.buf.remove_workspace_folder, + "[W]orkspace [R]emove Folder" + ) + nmap("wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, "[W]orkspace [L]ist Folders") + -- }}} +end + +-- {{{ General server config +---@type lspconfig.options +local servers = { + -- {{{ Typescript + tsserver = { + on_attach = function(client, bufnr) + -- We handle formatting using null-ls and prettierd + client.server_capabilities.documentFormattingProvider = false + M.on_attach(client, bufnr) + end, + }, + -- }}} + -- {{{ Purescript + purescriptls = { + settings = { + purescript = { + censorWarnings = { "UnusedName", "ShadowedName", "UserDefinedWarning" }, + formatter = "purs-tidy", + }, + }, + }, + -- }}} + -- {{{ Haskell + hls = { + haskell = { + -- set formatter + formattingProvider = "ormolu", + }, + }, + -- }}} + -- {{{ Lua + sumneko_lua = { + cmd = { + "lua-language-server", + "--logpath=/home/adrielus/.local/share/lua-language-server/log", + }, + }, + -- }}} + -- {{{ Latex + texlab = { + settings = { + texlab = { + build = { + args = { + -- Here by default: + "-pdf", + "-interaction=nonstopmode", + "-synctex=1", + "%f", + -- Required for syntax highlighting inside the generated pdf aparently + "-shell-escape", + }, + executable = "latexmk", + forwardSearchAfter = true, + onSave = true, + }, + }, + }, + }, + -- }}} + rnix = {}, + cssls = {}, + jsonls = {}, + rust_analyzer = {}, + dhall_lsp_server = {}, +} +-- }}} +-- {{{ Capabilities +M.capabilities = function() + -- require("lazy").load({ plugins = "hrsh7th/cmp-nvim-lsp" }) + local c = require("cmp_nvim_lsp").default_capabilities() + -- Add folding capabilities + c.textDocument.foldingRange = + { dynamicRegistration = false, lineFoldingOnly = true } + return c +end +-- }}} +-- {{{ Nice diagnostic icons +-- See https://github.com/folke/dot/blob/master/config/nvim/lua/config/plugins/lsp/diagnostics.lua +local function diagnostics_icons() + 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 = "" }) + end +end + +--}}} +-- {{{ Main config function +function lspconfig.config() + diagnostics_icons() + -- {{{ Change on-hover borders + vim.lsp.handlers["textDocument/hover"] = + vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }) + vim.lsp.handlers["textDocument/signatureHelp"] = + vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" }) + -- }}} + + local capabilities = M.capabilities() + -- Setup basic language servers + for lsp, details in pairs(servers) do + if details.on_attach == nil then + -- Default setting for on_attach + details.on_attach = M.on_attach + end + + require("lspconfig")[lsp].setup({ + on_attach = details.on_attach, + settings = details.settings, -- Specific per-language settings + flags = { + debounce_text_changes = 150, -- This will be the default in neovim 0.7+ + }, + cmd = details.cmd, + capabilities = capabilities, + }) + end +end + +--}}} + +return M diff --git a/dotfiles/neovim/lua/my/plugins/lualine.lua b/dotfiles/neovim/lua/my/plugins/lualine.lua new file mode 100644 index 0000000..5e6d6cd --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/lualine.lua @@ -0,0 +1,29 @@ +local env = require("my.helpers.env") + +local M = { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + cond = env.vscode.not_active(), +} + +function M.config() + require("lualine").setup({ + options = { + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + theme = "catppuccin", + }, + sections = { + lualine_a = { "branch" }, + lualine_b = { "filename" }, + lualine_c = { "filetype" }, + lualine_x = { "diagnostics" }, + lualine_y = {}, + lualine_z = {}, + }, + -- Integration with other plugins + extensions = { "nvim-tree" }, + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/luasnip.lua b/dotfiles/neovim/lua/my/plugins/luasnip.lua new file mode 100644 index 0000000..8b9a869 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/luasnip.lua @@ -0,0 +1,34 @@ +local env = require("my.helpers.env") + +local M = { + "L3MON4D3/LuaSnip", -- snippeting engine + cond = env.vscode.not_active() +} + +local function reload() + require("luasnip.loaders.from_vscode").lazy_load() +end + +function M.config() + local luasnip = require("luasnip") + + vim.keymap.set("i", "", function() + if luasnip.jumpable(1) then + return "lua require('luasnip').jump(1)" + else + return "" + end + end, { expr = true }) + + vim.keymap.set("i", "", function() + luasnip.jump(-1) + end) + + vim.keymap.set("n", "rs", reload, { + desc = "[R]eload [s]nippets", + }) + + reload() +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/mind.lua b/dotfiles/neovim/lua/my/plugins/mind.lua new file mode 100644 index 0000000..f31e58d --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/mind.lua @@ -0,0 +1,29 @@ +local M = { + "phaazon/mind.nvim", -- Organize shit as trees + cmd = "MindOpenMain", +} + +function M.init() + vim.keymap.set( + "n", + "m", + "MindOpenMain", + { desc = "[M]ind panel" } + ) +end + +function M.config() + local mind = require("mind") + + mind.setup({ + persistence = { + state_path = "~/Mind/mind.json", + data_dir = "~/Mind/data", + }, + ui = { + width = 50, + }, + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/moonwalk.lua b/dotfiles/neovim/lua/my/plugins/moonwalk.lua new file mode 100644 index 0000000..d98a6ff --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/moonwalk.lua @@ -0,0 +1,20 @@ +local M = {} + +-- function M.setup() + -- require("moonwalk").add_loader("tl", function(src, path) + -- local tl = require("tl") + -- local errs = {} + -- local _, program = tl.parse_program(tl.lex(src), errs) + -- + -- if #errs > 0 then + -- error( + -- path .. ":" .. errs[1].y .. ":" .. errs[1].x .. ": " .. errs[1].msg, + -- 0 + -- ) + -- end + -- + -- return tl.pretty_print_ast(program) + -- end) +-- end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/neoconf.lua b/dotfiles/neovim/lua/my/plugins/neoconf.lua new file mode 100644 index 0000000..49dfbf0 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/neoconf.lua @@ -0,0 +1,12 @@ +return { + "folke/neoconf.nvim", + cmd = "Neoconf", + config = { + -- import existing settings from other plugins + import = { + vscode = true, -- local .vscode/settings.json + coc = false, -- global/local coc-settings.json + nlsp = false, -- global/local nlsp-settings.nvim json settings + }, + }, +} diff --git a/dotfiles/neovim/lua/my/plugins/null-ls.lua b/dotfiles/neovim/lua/my/plugins/null-ls.lua new file mode 100644 index 0000000..6254a40 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/null-ls.lua @@ -0,0 +1,27 @@ +local env = require("my.helpers.env") + +local M = { + "jose-elias-alvarez/null-ls.nvim", -- generic language server + event = "BufReadPre", + dependencies = "neovim/nvim-lspconfig", + cond = env.vscode.not_active(), +} + +function M.config() + local lspconfig = require("my.plugins.lspconfig") + local null_ls = require("null-ls") + + local sources = { + null_ls.builtins.formatting.prettierd.with({ extra_filetypes = {} }), -- format ts files + null_ls.builtins.formatting.stylua.with({}), -- format lua code + -- null_ls.builtins.formatting.lua_format.with({}), -- format lua code + } + + null_ls.setup({ + sources = sources, + on_attach = lspconfig.on_attach, + debug = true, + }) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/nvim-tree.lua b/dotfiles/neovim/lua/my/plugins/nvim-tree.lua new file mode 100644 index 0000000..5849055 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/nvim-tree.lua @@ -0,0 +1,20 @@ +local env = require("my.helpers.env") + +local M = { + "kyazdani42/nvim-tree.lua", + cmd = "NvimTreeToggle", + config = true, + cond = env.vscode.not_active() and env.firenvim.not_active(), +} + +function M.init() + -- Toggle nerdtree with Control-n + vim.keymap.set( + "n", + "", + ":NvimTreeToggle", + { desc = "Toggle [n]vim-tree" } + ) +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/surround.lua b/dotfiles/neovim/lua/my/plugins/surround.lua new file mode 100644 index 0000000..b32b42d --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/surround.lua @@ -0,0 +1,12 @@ +local M = { + -- work with brackets, quotes, tags, etc + "tpope/vim-surround", + event = "VeryLazy", +} + +function M.config() + vim.g.surround_113 = '"\r"' + vim.g.surround_97 = "'\r'" +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/telescope.lua b/dotfiles/neovim/lua/my/plugins/telescope.lua new file mode 100644 index 0000000..1f526ca --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/telescope.lua @@ -0,0 +1,80 @@ +local env = require("my.helpers.env") + +local telescope = { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + dependencies = { + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-telescope/telescope-file-browser.nvim", + "nvim-lua/plenary.nvim" + }, + version = "0.1.x", + pin = true, + cond = env.vscode.not_active(), +} + +local M = telescope + +local function find_files_by_extension(extension) + return "find_files find_command=rg,--files,--glob=**/*." .. extension +end + +local function with_theme(base, theme) + return base .. " theme=" .. theme +end + +local defaultTheme = "ivy" + +local keybinds = { + { "", "find_files", "Find files" }, + { "ft", find_files_by_extension("tex"), "[F]ind [t]ex files" }, + { "fl", find_files_by_extension("lua"), "[F]ind [l]ua files" }, + { + "fp", + find_files_by_extension("purs"), + "[F]ind [p]urescript files", + }, + { "d", "diagnostics", "[D]iagnostics" }, + { "", "live_grep", "[F]ind in project" }, + { "", "file_browser", "[F]ile browser" }, + { "t", "builtin", "[T]elescope pickers" }, +} + +local function mkAction(action) + if not string.find(action, "theme=") then + action = with_theme(action, defaultTheme) + end + + if not string.find(action, "winblend=") and env.neovide.active() then + action = action .. " winblend=45" + end + + return "Telescope " .. action .. "" +end + +function telescope.init() + for _, mapping in pairs(keybinds) do + vim.keymap.set("n", mapping[1], mkAction(mapping[2]), { desc = mapping[3] }) + end +end + +function telescope.config() + local settings = { + defaults = { mappings = { i = { [""] = "which_key" } } }, + pickers = { find_files = { hidden = true } }, + extensions = { + file_browser = { path = "%:p:h" }, + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + }, + }, + } + + require("telescope").setup(settings) + require("telescope").load_extension("fzf") + require("telescope").load_extension("file_browser") +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/treesitter.lua b/dotfiles/neovim/lua/my/plugins/treesitter.lua new file mode 100644 index 0000000..5215980 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/treesitter.lua @@ -0,0 +1,105 @@ +local M = { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufReadPost", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function() + require("nvim-treesitter.configs").setup({ + --{{{Languages + ensure_installed = { + "bash", + "javascript", + "typescript", + "c", + "cpp", + "css", + "dockerfile", + "elixir", + "fish", + "html", + "json", + "jsonc", + "latex", + "python", + "rust", + "scss", + "toml", + "tsx", + "vim", + "yaml", + "nix", + }, + sync_install = false, + --}}} + --{{{ Highlighting + highlight = { + enable = true, + disable = { "kotlin" }, + additional_vim_regex_highlighting = false, + }, + --}}} + --{{{ Incremental selection + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + --}}} + --{{{ Textsubjects + textsubjects = { + enable = true, + keymaps = { + ["."] = "textsubjects-smart", + [";"] = "textsubjects-container-outer", + }, + }, + --}}} + textobjects = { + --{{{ Select + select = { + enable = true, + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + --}}} + --{{{ Move + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]f"] = "@function.outer", + ["]c"] = "@class.outer", + }, + goto_next_end = { + ["]F"] = "@function.outer", + ["]C"] = "@class.outer", + }, + goto_previous_start = { + ["[f"] = "@function.outer", + ["[c"] = "@class.outer", + }, + goto_previous_end = { + ["[F"] = "@function.outer", + ["[C"] = "@class.outer", + }, + }, + --}}} + }, + indent = { enable = true }, + }) + end, +} + +return M diff --git a/dotfiles/neovim/lua/my/plugins/vimtex.lua b/dotfiles/neovim/lua/my/plugins/vimtex.lua new file mode 100644 index 0000000..580c1b6 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/vimtex.lua @@ -0,0 +1,26 @@ +local M = { + "lervag/vimtex", -- latex support + ft = "tex", + enabled = false +} + +function M.config() + vim.g.vimtex_view_method = "zathura" + vim.g.Tex_DefaultTargetFormat = "pdf" + vim.g.vimtex_compiler_latexmk = { + options = { + "-pdf", + "-shell-escape", + "-verbose", + "-file-line-error", + "-synctex=1", + "-interaction=nonstopmode", + }, + } + + vim.g.vimtex_fold_enabled = 0 + vim.g.vimtex_imaps_enabled = 0 + vim.g.vimtex_syntax_conceal_disable = 1 +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/vimux.lua b/dotfiles/neovim/lua/my/plugins/vimux.lua new file mode 100644 index 0000000..fd6e7d2 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/vimux.lua @@ -0,0 +1,40 @@ +local K = require("my.keymaps") +local env = require("my.helpers.env") + +local M = { + "preservim/vimux", -- interact with tmux from within vim + cmd = { "VimuxPromptCommand", "VimuxRunCommand", "VimuxRunLastCommand" }, + -- TODO: only enable when actually inside tmux + cond = env.vscode.not_active() + and env.neovide.not_active() + and env.firenvim.not_active(), +} + +function M.init() + --{{{ Register keybinds + K.nmap( + "vp", + ":VimuxPromptCommand", + "[V]imux: [p]rompt for command" + ) + K.nmap("vc", ':VimuxRunCommand "clear"', "[V]imux: [c]lear pane") + K.nmap( + "vl", + ":VimuxRunLastCommand", + "[V]imux: rerun [l]ast command" + ) + --}}} + --{{{ Register which-key docs + local status, wk = pcall(require, "which-key") + + if status then + wk.register({ + ["v"] = { + name = "[V]imux", + }, + }) + end + --}}} +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/whichkey.lua b/dotfiles/neovim/lua/my/plugins/whichkey.lua new file mode 100644 index 0000000..5100e57 --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/whichkey.lua @@ -0,0 +1,36 @@ +local env = require("my.helpers.env") +local M = { + "folke/which-key.nvim", + event = "VeryLazy", +} + +function M.config() + local wk = require("which-key") + + local winblend = 0 + + if env.neovide.active() then + winblend = 30 + end + + wk.setup({ + window = { + winblend = winblend, + }, + layout = { align = "center" }, + }) + + wk.register({ + [""] = { + f = { name = "[F]iles" }, + g = { name = "[G]o to" }, + r = { name = "[R]ename / [R]eplace / [R]eload" }, + l = { name = "[L]ocal" }, + w = { name = "[W]orkspace" }, + y = { name = "[Y]ank" }, + v = "which_key_ignore", + }, + }) +end + +return M diff --git a/dotfiles/neovim/lua/telescope/extensions/unicode.lua b/dotfiles/neovim/lua/telescope/extensions/unicode.lua new file mode 100644 index 0000000..10f15a4 --- /dev/null +++ b/dotfiles/neovim/lua/telescope/extensions/unicode.lua @@ -0,0 +1,92 @@ +local M = {} +local pickers = require "telescope.pickers" +local finders = require "telescope.finders" +local conf = require("telescope.config").values +local actions = require "telescope.actions" +local action_state = require "telescope.actions.state" +local previewers = require "telescope.previewers" +local utils = require "telescope.utils" + +local add_abbreviations = false + +local unicodeChars = { + nats = "ℕ", + rationals = "ℚ", + reals = "ℝ", + integers = "ℤ", + forall = "∀", + lambda = "λ", + arrow = "→", + compose = "∘", + inverse = "⁻¹", + dots = "…", + alpha = "ɑ", + beta = "β", + pi = "π", + Pi = 'Π', + sigma = "σ", + Sigma = "Σ", + tau = "τ", + theta = "θ", + gamma = "γ", + Gamma = "Γ", + context = "Γ" +} + +-- our picker function for unicode chars +function M.picker(opts) + opts = opts or {} + local results = {} + + for key, value in pairs(unicodeChars) do + -- Name: char pair + table.insert(results, { key, value }) + end + + print(results) + + pickers.new(opts, { + prompt_title = "Unicode characters", + finder = finders.new_table { + results = results, + entry_maker = function(entry) + return { value = entry, display = entry[1], ordinal = entry[1] } + end + }, + sorter = conf.generic_sorter(opts), + previewer = previewers.new { + preview_fn = function(_, entry) return entry.value[2] end + }, + attach_mappings = function(prompt_bufnr) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + + if selection == nil then + utils.__warn_no_selection "my.abbreviations" + return + end + + vim.api.nvim_put({ selection.value[2] }, "", false, true) + vim.cmd("startinsert") + end) + return true + end + }):find() +end + +function M.setupAbbreviations(prefix, ending) + prefix = prefix or "" + ending = ending or "" + + if not add_abbreviations then return end + + local abbreviate = require("my.abbreviations").abbr + + for key, value in pairs(unicodeChars) do + -- By default abbreviations are triggered using "_" + abbreviate(prefix .. key .. ending, value) + end +end + +return M diff --git a/dotfiles/neovim/neoconf.json b/dotfiles/neovim/neoconf.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/dotfiles/neovim/neoconf.json @@ -0,0 +1 @@ +{} diff --git a/dotfiles/neovim/syntax/hkf.vim b/dotfiles/neovim/syntax/hkf.vim new file mode 100644 index 0000000..8ed4297 --- /dev/null +++ b/dotfiles/neovim/syntax/hkf.vim @@ -0,0 +1,32 @@ +if exists("b:current_syntax") + finish +endif + +syntax keyword kfKeyword alias template layer using path name input output assume fun as import exporting module unsafe def +syntax keyword kfFunction LayerTemplate Sequence Chord Keycode Layer Broken + +syntax match kfComment "\v--.*$" + +syntax match kfOperator "\v_" +syntax match kfOperator "\v\," +syntax match kfOperator "\v\." +syntax match kfOperator "\v\:" +syntax match kfOperator "\v\|" +syntax match kfOperator "\v\=" +syntax match kfOperator "\v\=\>" +syntax match kfOperator "\v\-\>" +syntax match kfOperator "\v→" +syntax match kfOperator "\v\*" +syntax match kfOperator "\v\(" +syntax match kfOperator "\v\)" +syntax match kfOperator "\vλ" + +syntax region kfString start=/\v"/ skip=/\v\\./ end=/\v"/ + +highlight link kfKeyword Keyword +highlight link kfFunction Function +highlight link kfComment Comment +highlight link kfOperator Operator +highlight link kfString String + +let b:current_syntax = "hkf" diff --git a/dotfiles/neovim/tl/my/plugins/chunk.tl b/dotfiles/neovim/tl/my/plugins/chunk.tl new file mode 100644 index 0000000..20b638e --- /dev/null +++ b/dotfiles/neovim/tl/my/plugins/chunk.tl @@ -0,0 +1,3 @@ +function hi() + print("Hello world!") +end diff --git a/dotfiles/vscode-snippets/README.md b/dotfiles/vscode-snippets/README.md new file mode 100644 index 0000000..0028aa9 --- /dev/null +++ b/dotfiles/vscode-snippets/README.md @@ -0,0 +1,3 @@ +# Vscode snippets + +These are snippets usable both in vscode and neovim, defined in vscode format. diff --git a/dotfiles/vscode-snippets/package.json b/dotfiles/vscode-snippets/package.json new file mode 100644 index 0000000..7735f3c --- /dev/null +++ b/dotfiles/vscode-snippets/package.json @@ -0,0 +1,49 @@ +{ + "name": "adriels-snippets", + "engines": { + "vscode": "^1.11.0" + }, + "contributes": { + "snippets": [ + { + "language": [ + "purs", + "purescript" + ], + "path": "./snippets/purescript/other.json" + }, + { + "language": [ + "purs", + "purescript" + ], + "path": "./snippets/purescript/imports.json" + }, + { + "language": [ + "purs", + "purescript" + ], + "path": "./snippets/purescript/deriving.json" + }, + { + "language": [ + "tex" + ], + "path": "./snippets/latex/core.json" + }, + { + "language": [ + "tex" + ], + "path": "./snippets/latex/explain.json" + }, + { + "language": [ + "lua" + ], + "path": "./snippets/lua/core.json" + } + ] + } +} diff --git a/dotfiles/vscode-snippets/snippets/latex/core.json b/dotfiles/vscode-snippets/snippets/latex/core.json new file mode 100644 index 0000000..07d494c --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/latex/core.json @@ -0,0 +1,300 @@ +{ + "Begin": { + "prefix": "begin", + "description": "Begin anything", + "body": ["\\begin{$1}", "\t$0", "\\end{$1}"] + }, + "Set": { + "prefix": "set", + "description": "Set I guess", + "body": "\\{$1\\\\}$0" + }, + "Absolute value": { + "prefix": "abs", + "description": "Absolute values", + "body": "\\abs{$1}$0" + }, + "Lemma": { + "prefix": "lemma", + "description": "Create a lemma", + "body": ["\\begin{lemma}[$1] \\label{lem:$1}", "\t$0", "\\end{lemma}"] + }, + "Example*": { + "prefix": "example*", + "description": "Create an example*", + "body": ["\\begin{example*}", "\t$0", "\\end{example*}"] + }, + "Example": { + "prefix": "example", + "description": "Create an example", + "body": ["\\begin{example}[$1] \\label{exp:$1}", "\t$0", "\\end{example}"] + }, + "Theorem": { + "prefix": "theorem", + "description": "Create a theorem", + "body": ["\\begin{theorem}[$1] \\label{thm:$1}", "\t$0", "\\end{theorem}"] + }, + "Exercise": { + "prefix": "exercise", + "description": "Create a exercise", + "body": ["\\begin{exercise}[$1] \\label{exe:$1}", "\t$0", "\\end{exercise}"] + }, + "Definition": { + "prefix": "definition", + "description": "Create a definition", + "body": [ + "\\begin{definition}[$1] \\label{def:$1}", + "\t$0", + "\\end{definition}" + ] + }, + "Display math": { + "prefix": "dm", + "description": "Display math section", + "body": ["\\[", "$0", "\\]"] + }, + "Subscript": { + "prefix": "ss", + "description": "Subscript", + "body": "_{$1}$0" + }, + "Exponent": { + "prefix": "ee", + "description": "Exponent", + "body": "^{$1}$0" + }, + "Nth derivative": { + "prefix": "dd", + "description": "Nth derivative", + "body": "^{($1)}$0" + }, + "Overline": { + "prefix": "ol", + "description": "Overline", + "body": "\\overline{$1}$0" + }, + "Z Mod": { + "prefix": "zmod", + "description": "The set of Z/nZ", + "body": "\\mathbb{Z}/$1\\mathbb{Z}$0" + }, + "Section": { + "prefix": "section", + "description": "Add section", + "body": ["\\section{$1}", "$0"] + }, + "Subsection": { + "prefix": "subsection", + "description": "Add subsection", + "body": ["\\subsection{$1}", "$0"] + }, + "Subsubsection": { + "prefix": "subsubsection", + "description": "Add subsubsection", + "body": ["\\subsubsection{$1}", "$0"] + }, + "Chapter": { + "prefix": "chapter", + "description": "Add chapter", + "body": ["\\chapter{$1}", "$0"] + }, + "Proof": { + "prefix": "proof", + "description": "Create proof", + "body": ["\\begin{proof}", "\t$0", "\\end{proof}"] + }, + "Itemize": { + "prefix": "item", + "body": ["\\\\begin{itemize}", "\t\\item $0", "\\\\end{itemize}"], + "description": "Itemize env" + }, + "Enumerate": { + "prefix": "enum", + "body": ["\\\\begin{enumerate}", "\t\\item $0", "\\\\end{enumerate}"], + "description": "Enumerate env" + }, + "Reference definition": { + "prefix": "rdef", + "description": "Reference a definition", + "body": "\\ref{def:$1}$0" + }, + "Reference lemma": { + "prefix": "rlemma", + "description": "Reference a lemma", + "body": "\\ref{lem:$1}$0" + }, + "Reference theorem": { + "prefix": "rtheorem", + "description": "Reference a theorem", + "body": "\\ref{thm:$1}$0" + }, + "Sigma sum": { + "prefix": "bsum", + "description": "Create a sum using sigma notation", + "body": "\\sum_{$1 = $2}^{$3}$0" + }, + "Pi product": { + "prefix": "bproduct", + "description": "Create a produt using pi notation", + "body": "\\prod_{$1 = $2}^{$3}$0" + }, + "Fraction": { + "prefix": "frac", + "description": "Create a fraction", + "body": "\\frac{$1}{$2}$0" + }, + "Choose": { + "prefix": "binom", + "description": "Create a (n choose k) thingy", + "body": "\\binom{$1}{$2}$0" + }, + "Limit": { + "prefix": "lim", + "description": "Create a limit", + "body": "\\lim _{$1 \\to $2}$0" + }, + "Limit to infinity": { + "prefix": "ilim", + "description": "Create a limit as a variable goes to infinity", + "body": "\\lim _{$1 \\to \\infty}$0" + }, + "Limit to negative infinity": { + "prefix": "nlim", + "description": "Create a limit as a variable goes to negative infinity", + "body": "\\lim _{$1 \\to -\\infty}$0" + }, + "Limit to zero": { + "prefix": "zlim", + "description": "Create a limit as a variable goes to 0", + "body": "\\lim _{$1 \\to 0}$0" + }, + "Sqrt": { + "prefix": "sqrt", + "description": "Create a sqrt", + "body": "\\sqrt[$1]{$2}$0" + }, + "Sin": { + "prefix": "sin", + "description": "Create a sin call", + "body": "\\sin($1)$0" + }, + "Cos": { + "prefix": "cos", + "description": "Create a cos call", + "body": "\\cos($1)$0" + }, + "Ln": { + "prefix": "ln", + "description": "Create a ln call", + "body": "\\ln($1)$0" + }, + "Aligned": { + "prefix": "aligned", + "description": "Create an aligned environment", + "body": ["\\begin{aligned}", "\t$0", "\\end{aligned}"] + }, + "Text explanation in math mode": { + "prefix": "texpl", + "description": "Explain a step using text in math mode", + "body": "&& \\text{($1)}$0" + }, + "Explanation in math mode": { + "prefix": "expl", + "description": "Explain a step in math mode", + "body": "&& ($1) $0" + }, + "Let": { + "prefix": "let", + "description": "Let something equal something else", + "body": "Let $$1 = $2$. $0" + }, + "Force newline": { + "prefix": "cr", + "description": "Force newline in math mode", + "body": "{\\ \\\\\\\\}" + }, + "Aligned display math": { + "prefix": "maligned", + "description": "Create an aligned display math environment", + "body": ["\\[", "\t\\begin{aligned}", "\t\t$0", "\t\\end{aligned}", "\\]"] + }, + "System of equations": { + "prefix": "eqsystem", + "description": "Create a system of equations", + "body": [ + "\\left\\{", + "\t\\begin{array}{rl}", + "\t\t$0", + "\t\\end{array}", + "\\right\\\\\\}" + ] + }, + "Aligned equation": { + "prefix": "aleq", + "description": "Aligned equation", + "body": ["\\\\\\ $1 &= $2", "$0"] + }, + "2x2 matrices": { + "prefix": "mat22", + "description": "Create a 2x2 matrix", + "body": [ + "\\begin{bmatrix}", + " ${1:1} & ${2:0}", + "\\\\\\ ${3:0} & ${4:1}", + "\\end{bmatrix}$0" + ] + }, + "3x3 matrices": { + "prefix": "mat33", + "description": "Create a 3x3 matrix", + "body": [ + "\\begin{bmatrix}", + " ${1:1} & ${2:0} & ${3:0}", + "\\\\\\ ${4:0} & ${5:1} & ${6:0}", + "\\\\\\ ${7:0} & ${8:0} & ${9:1}", + "\\end{bmatrix}$0" + ] + }, + "3x3 determinants": { + "prefix": "det33", + "description": "Create a 3x3 determinant", + "body": [ + "\\begin{vmatrix}", + " $1 & $2 & $3", + "\\\\\\ $4 & $5 & $6", + "\\\\\\ $7 & $8 & $9", + "\\end{vmatrix}$0" + ] + }, + "2x2 determinants": { + "prefix": "det22", + "description": "Create a 2x2 determinant", + "body": [ + "\\begin{vmatrix}", + " $1 & $2", + "\\\\\\ $3 & $4", + "\\end{vmatrix}$0" + ] + }, + "Definite integral": { + "prefix": "dintegral", + "description": "Definite integral", + "body": "\\int_{$1}^{$2} $3 d${4:x}$0" + }, + "Indefinite integral": { + "prefix": "integral", + "description": "Integral", + "body": "\\int $1 d${2:x}$0" + }, + "Iff cases": { + "prefix": "ciff", + "description": "Prove an equivalence in both directions", + "body": [ + "\\begin{enumerate}", + "\t\\item[$\\implies$]$1", + "\t\\item[$\\impliedby$]$2", + "\\end{enumerate}", + "$0" + ] + } +} diff --git a/dotfiles/vscode-snippets/snippets/latex/explain.json b/dotfiles/vscode-snippets/snippets/latex/explain.json new file mode 100644 index 0000000..0f0582a --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/latex/explain.json @@ -0,0 +1,77 @@ +{ + "Text explanation in math mode": { + "prefix": "texpl", + "description": "Explain a step using text in math mode", + "body": "&& \\text{($1)}$0" + }, + "Explanation in math mode": { + "prefix": "expl", + "description": "Explain a step in math mode", + "body": "&& ($1) $0" + }, + "Explain division": { + "prefix": "exdiv", + "description": "Explain a division inside an equation", + "body": "&& \\left(\\frac{\\square}{$1}\\right)$0" + }, + "Explain fraction": { + "prefix": "exfract", + "description": "Explain a step which wraps both sides of an equation by a fraction", + "body": "&& \\left(\\frac{$1}{$2} \\right)$0" + }, + "Explain right multiplication": { + "prefix": "exmul", + "description": "Explain a right multiplication inside an equation", + "body": "&& \\left(\\square \\cdot $1 \\right)$0" + }, + "Explain left multiplication": { + "prefix": "exlmul", + "description": "Explain a left multiplication inside an equation", + "body": "&& \\left($1 \\cdot \\square\\right)$0" + }, + "Explain differentiation": { + "prefix": "exdiff", + "description": "Explain a step which differentiates both sides of an equation", + "body": "&& \\left( \\frac{d \\square} {d $1} \\right)$0" + }, + "Explain integration": { + "prefix": "exint", + "description": "Explain a step which integrates both sides of an equation", + "body": "&& \\left(\\int \\square d$1 \\right)$0" + }, + "Explain definite integration": { + "prefix": "exdint", + "description": "Explain a step which applies a definite integral to both sides of an equation", + "body": "&& \\left(\\int _{$1} ^{$2} \\square d$3 \\right)$0" + }, + "Explain addition": { + "prefix": "exadd", + "description": "Explain a step which adds to both sides of an equation", + "body": "&& \\left( \\square + $1 \\right)$0" + }, + "Explain subtraction": { + "prefix": "exsub", + "description": "Explain a step which subtracts from both sides of an equation", + "body": "&& \\left( \\square - $1 \\right)$0" + }, + "Explain negation": { + "prefix": "exneg", + "description": "Explain a step which negates both sides of an equation", + "body": "&& (- \\square )$0" + }, + "Explain power": { + "prefix": "expow", + "description": "Explain a step which raises both sides of an equation to a given power", + "body": "&& \\left( \\square ^{$1} \\right)$0" + }, + "Explain exponentiation": { + "prefix": "exexp", + "description": "Explain a step which raises a given value to both sides of an equation", + "body": "&& \\left( $1 ^{\\square} \\right)$0" + }, + "Explain natural logarithm": { + "prefix": "exln", + "description": "Explain a step which applies the ln function to both sides of an equation", + "body": "&& \\left( \\ln $1 \\right)$0" + } +} diff --git a/dotfiles/vscode-snippets/snippets/lua/core.json b/dotfiles/vscode-snippets/snippets/lua/core.json new file mode 100644 index 0000000..ab3c56f --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/lua/core.json @@ -0,0 +1,33 @@ +{ + "Lua setup-module": { + "prefix": "msetup", + "description": "Create lua module with setup function inside", + "body": [ + "local M = {}", + "", + "function M.setup()", + " $0", + "end", + "", + "return M" + ] + }, + "Busted describe": { + "prefix": "describe", + "description": "Create a describe call for a busted test", + "body": [ + "describe(\"$1\", function ()", + "\t$0", + "end)" + ] + }, + "Busted it": { + "prefix": "it", + "description": "Create an it call for a busted test", + "body": [ + "it(\"$1\", function ()", + "\t$0", + "end)" + ] + } +} diff --git a/dotfiles/vscode-snippets/snippets/purescript/deriving.json b/dotfiles/vscode-snippets/snippets/purescript/deriving.json new file mode 100644 index 0000000..0154d85 --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/purescript/deriving.json @@ -0,0 +1,77 @@ +{ + "Derive newtype instance": { + "prefix": "gnderive", + "description": "Use newtype deriving on any typeclass", + "body": "derive newtype instance $0 $3 $2" + }, + "Generate json instances": { + "prefix": "json", + "description": "Generate the deriving of the EncodeJson and DecodeJson typeclasses", + "body": [ + "derive newtype instance EncodeJson $1", + "derive newtype instance DecodeJson $1" + ] + }, + "Generic": { + "prefix": "dgeneric", + "description": "Generate the generic instance for a type", + "body": "derive instance Generic $1 _" + }, + "Generic Show": { + "prefix": "gshow", + "description": "Generate generic show instances", + "body": [ + "instance Show $1 where", + " show = genericShow" + ] + }, + "Generic Debug": { + "prefix": "gdebug", + "description": "Generate generic debug instances", + "body": [ + "instance Debug $1 where", + " debug = genericDebug" + ] + }, + "Generic json": { + "prefix": "gjson", + "description": "Generate generic json instances", + "body": [ + "instance EncodeJson $1 where", + " encodeJson = genericEncodeJson", + "instance DecodeJson $1 where", + " decodeJson = genericDecodeJson" + ] + }, + "Instance": { + "prefix": "instance", + "description": "Declare typeclass instance", + "body": [ + "instance $2 $3 where", + " $0" + ] + }, + "Functor": { + "prefix": "dfunctor", + "description": "Derive a Functor instance", + "body": "derive instance Functor $1$0" + }, + "Eq": { + "prefix": "deq", + "description": "Derive an Eq instance", + "body": "derive instance Eq $1$0" + }, + "Ord": { + "prefix": "dord", + "description": "Derive an Ord instance", + "body": "derive instance Ord $1$0" + }, + "Eq & Ord": { + "prefix": "deqord", + "description": "Derive an Eq and an Ord instance", + "body": [ + "derive instance Eq $1", + "derive instance Ord $1$0" + ] + } +} diff --git a/dotfiles/vscode-snippets/snippets/purescript/imports.json b/dotfiles/vscode-snippets/snippets/purescript/imports.json new file mode 100644 index 0000000..896b018 --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/purescript/imports.json @@ -0,0 +1,62 @@ +{ + "Tuple constructors": { + "prefix": "imptuple", + "description": "Import tuple constructors", + "body": "import Data.Tuple.Nested (type (/\\), (/\\))" + }, + "Map": { + "prefix": "impmap", + "description": "Import Map module", + "body": "import Data.Map as Map" + }, + "HashMap": { + "prefix": "imphashmap", + "description": "Import HashMap module", + "body": "import Data.HashMap as HashMap" + }, + "FRP Event": { + "prefix": "impevent", + "description": "Import FRP.Event module", + "body": "import FRP.Event as E" + }, + "List": { + "prefix": "implist", + "description": "Import List module", + "body": "import Data.List as List" + }, + "Array": { + "prefix": "imparray", + "description": "import Array module", + "body": "import Data.Array as Array" + }, + "AVar": { + "prefix": "impavar", + "description": "import AVar module", + "body": "import Effect.Aff.AVar as AV" + }, + "Object": { + "prefix": "impobject", + "description": "import Foreign.Object module", + "body": "import Foreign.Object as Object" + }, + "STObject": { + "prefix": "impstobject", + "description": "import STObject module", + "body": "import Foreign.Object.ST as STObject" + }, + "Ref": { + "prefix": "impref", + "description": "import Effect.Ref module", + "body": "import Effect.Ref as Ref" + }, + "Int": { + "prefix": "impint", + "description": "import Data.Int module", + "body": "import Data.Int as Int" + }, + "Number": { + "prefix": "impnumber", + "description": "import Data.Number module", + "body": "import Data.Number as Number" + } +} diff --git a/dotfiles/vscode-snippets/snippets/purescript/other.json b/dotfiles/vscode-snippets/snippets/purescript/other.json new file mode 100644 index 0000000..e382243 --- /dev/null +++ b/dotfiles/vscode-snippets/snippets/purescript/other.json @@ -0,0 +1,61 @@ +{ + "Definition": { + "prefix": "definition", + "description": "Basic purescript definition", + "body": ["$1 :: $2", "$1 = $3"] + }, + "SProxy": { + "prefix": "sproxy", + "description": "Generate a proxy constant", + "body": ["_$1 :: Proxy \"$1\"", "_$1 = Proxy"] + }, + "Proxy": { + "prefix": "proxy", + "description": "Generate a proxy constant", + "body": ["_$1 :: Proxy $1", "_$1 = Proxy"] + }, + "Prop": { + "prefix": "prop", + "description": "Prop lens", + "body": ["_$1 :: Lens' $2 $3", "_$1 = prop (Proxy :: _ \"$1\")"] + }, + "Variant constructor": { + "prefix": "inj", + "description": "Generate a constructor for a variant an inline sproxy", + "body": [ + "$1 :: forall r a. a -> Variant ( $1 :: a | r)", + "$1 = inj (SProxy :: SProxy \"$1\")" + ] + }, + "Full variant constructor": { + "prefix": "injf", + "description": "Generate a constructor for a variant with an external sproxy definition", + "body": [ + "$1 :: forall r a. a -> Variant ( $1 :: a | r)", + "$1 = inj _$1", + "", + "_$1 :: Proxy \"$1\"", + "_$1 = Proxy" + ] + }, + "Example code": { + "prefix": "ex", + "description": "Provide example usage for some piece of code", + "body": ["-- |", "-- | Ex:", "-- | ```purs", "-- | $0", "-- | ```"] + }, + "Section": { + "prefix": "section", + "description": "Delimit a section using 10 dashes", + "body": "---------- $0" + }, + "Typeclass instances": { + "prefix": "sinstances", + "description": "Delimit a section which declares typeclass instances", + "body": ["---------- Typeclass instances", "$0"] + }, + "If": { + "prefix": "if", + "description": "If then else expression", + "body": ["if $1", "\tthen $2", "\telse $3"] + } +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c7fe661 --- /dev/null +++ b/flake.lock @@ -0,0 +1,217 @@ +{ + "nodes": { + "agenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1665870395, + "narHash": "sha256-Tsbqb27LDNxOoPLh0gw2hIb6L/6Ow/6lIBvqcHzEKBI=", + "owner": "ryantm", + "repo": "agenix", + "rev": "a630400067c6d03c9b3e0455347dc8559db14288", + "type": "github" + }, + "original": { + "owner": "ryantm", + "repo": "agenix", + "type": "github" + } + }, + "base16": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658847131, + "narHash": "sha256-X6Mml7cT0YR3WCD5fkUhpRVV5ZPcwdcDsND8r8xMqTE=", + "owner": "SenchoPens", + "repo": "base16.nix", + "rev": "6b404cda2e04ca3cf5ca7b877af9c469e1386acb", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "base16.nix", + "type": "github" + } + }, + "catppuccin-base16": { + "flake": false, + "locked": { + "lastModified": 1665586920, + "narHash": "sha256-fZDsmJ+xFjOJDoI+bPki9W7PEI5lT5aGoCYtkatcZ8A=", + "owner": "catppuccin", + "repo": "base16", + "rev": "ca74b4070d6ead4213e92da1273fcc1853de7af8", + "type": "github" + }, + "original": { + "owner": "catppuccin", + "repo": "base16", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1671966569, + "narHash": "sha256-jbLgfSnmLchARBNFRvCic63CFQ9LAyvlXnBpc2kwjQc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c55fa26ce05fee8e063db22918d05a73d430b2ea", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "locked": { + "lastModified": 1668668915, + "narHash": "sha256-QjY4ZZbs9shwO4LaLpvlU2bO9J1juYhO9NtV3nrbnYQ=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "5df9108b346f8a42021bf99e50de89c9caa251c3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "neovim-flake": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "dir": "contrib", + "lastModified": 1673238050, + "narHash": "sha256-PEOcZLLChNoFVPTaveIWRABKXw6p6ow9du9Fe/bypro=", + "owner": "neovim", + "repo": "neovim", + "rev": "c19bd47c0a2e3cc77d7f5e41ed184edb41685bd3", + "type": "github" + }, + "original": { + "dir": "contrib", + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-nightly-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "neovim-flake": "neovim-flake", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673252101, + "narHash": "sha256-9ewLxnRQhkWzDcO6aZAsYFHzKw6Y4ahLbZ1TUFOAmNE=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "8becc470aeb9d50d6a4b2e6025000cc4d18b967d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1671883564, + "narHash": "sha256-C15oAtyupmLB3coZY7qzEHXjhtUx/+77olVdqVMruAg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "dac57a4eccf1442e8bf4030df6fcbb55883cb682", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "agenix": "agenix", + "base16": "base16", + "catppuccin-base16": "catppuccin-base16", + "home-manager": "home-manager", + "impermanence": "impermanence", + "neovim-nightly-overlay": "neovim-nightly-overlay", + "nixpkgs": "nixpkgs" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index a4a319a..2e63ec5 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,25 @@ # Home manager home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # Agenix + agenix.url = "github:ryantm/agenix"; + agenix.inputs.nixpkgs.follows = "nixpkgs"; + + # Base16-nix + base16.url = github:SenchoPens/base16.nix; + base16.inputs.nixpkgs.follows = "nixpkgs"; + + # Catpuccin base16 color schemes + catppuccin-base16.url = github:catppuccin/base16; + catppuccin-base16.flake = false; + + # Impermanence + impermanence.url = "github:nix-community/impermanence"; + + # Neovim nightly + neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; + neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, home-manager, ... }@inputs: @@ -20,6 +39,11 @@ "aarch64-darwin" "x86_64-darwin" ]; + + specialArgs = { + inherit inputs outputs; + paths.dotfiles = "~/Projects/satellite/dotfiles"; + }; in rec { # Acessible through 'nix build', 'nix shell', etc @@ -48,9 +72,16 @@ # Available through 'nixos-rebuild --flake .#... nixosConfigurations = { tethys = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + inherit specialArgs; + modules = [ - ./hosts/tethys + home-manager.nixosModules.home-manager + { + home-manager.users.adrielus = import ./home/adrielus/tethys.nix; + home-manager.extraSpecialArgs = specialArgs; + home-manager.useUserPackages = true; + } + ./hosts/nixos/tethys ]; }; }; @@ -60,7 +91,7 @@ homeConfigurations = { "adrielus@tethys" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; - extraSpecialArgs = { inherit inputs outputs; }; + extraSpecialArgs = specialArgs; modules = [ ./home/adrielus/tethys.nix ]; diff --git a/home/adrielus/features/cli/bat.nix b/home/adrielus/features/cli/bat.nix new file mode 100644 index 0000000..145895e --- /dev/null +++ b/home/adrielus/features/cli/bat.nix @@ -0,0 +1,6 @@ +{ + programs.bat = { + enable = true; + config.theme = "base16"; + }; +} diff --git a/home/adrielus/features/cli/default.nix b/home/adrielus/features/cli/default.nix new file mode 100644 index 0000000..302ba3d --- /dev/null +++ b/home/adrielus/features/cli/default.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: { + imports = [ ./bat.nix ./git.nix ./ssh.nix ./fish.nix ./tmux ./starship.nix ]; + + # Enable bash + programs.bash.enable = true; + + # Enable direnv + programs.direnv.enable = true; + programs.direnv.nix-direnv.enable = true; + + # Install clis + home.packages = with pkgs; [ + tree # Print directory structure + ranger # Terminal file explorer + comma # Intstall and run programs by sticking a , before them + bc # Calculator + ncdu # TUI disk usage + exa # Better ls + ripgrep # Better grep + fd # Better find + httpie # Better curl + mkpasswd # Hash passwords + neofetch # Display system information + unzip # For working with .zip files + unrar # For extracting shit from rars + ]; +} diff --git a/home/adrielus/features/cli/fish.nix b/home/adrielus/features/cli/fish.nix new file mode 100644 index 0000000..0b36fdc --- /dev/null +++ b/home/adrielus/features/cli/fish.nix @@ -0,0 +1,75 @@ +{ config, pkgs, ... }: +let + base16-fish = pkgs.fetchFromGitHub { + owner = "tomyun"; + repo = "base16-fish"; + sha256 = "142fmqm324gy3qsv48vijm5k81v6mw85ym9mmhnvyv2q2ndg5rix"; + rev = "2f6dd973a9075dabccd26f1cded09508180bf5fe"; + }; +in +{ + programs.fish = { + enable = true; + + shellAbbrs = { + ls = "exa -la"; + cat = "bat"; + }; + + shellAliases = { + # Print available battery + battery = "acpi"; + + # Rebuild nixos + rebuild = "sudo -u adrielus nixos-rebuild switch --flake ~/Projects/nixos-config/"; + }; + + plugins = with pkgs.fishPlugins; [ + # Jump to directories by typing "z " + { + name = "z"; + src = pkgs.fetchFromGitHub { + owner = "jethrokuan"; + repo = "z"; + rev = "85f863f20f24faf675827fb00f3a4e15c7838d76"; + sha256 = "1kaa0k9d535jnvy8vnyxd869jgs0ky6yg55ac1mxcxm8n0rh2mgq"; + }; + } + ]; + + interactiveShellInit = + # Start tmux if not already inside tmux + '' + if status is-interactive + and not set -q TMUX + exec tmux attach -t Welcome || tmux || echo "Something went wrong trying to start tmux" + end + '' + + # Sets cursor based on vim mode + '' + set fish_cursor_default block # Set the normal and visual mode cursors to a block + set fish_cursor_insert line # Set the insert mode cursor to a line + set fish_cursor_replace_one underscore # Set the replace mode cursor to an underscore + + # Force fish to skip some checks (I think) + set fish_vi_force_cursor + '' + + # Use vim-style keybinds + '' + function fish_user_key_bindings + # Use the vim keybinds + fish_vi_key_bindings + + bind -e -M insert -k f10 # unbinds f10 + bind -M insert -m default -k f10 'commandline -f repaint' # Exit insert mode with + end + '' + + # Starship hook + '' + starship init fish | source + '' + + # Theming + (builtins.readFile (config.scheme base16-fish)) + ; + }; +} diff --git a/home/adrielus/features/cli/git.nix b/home/adrielus/features/cli/git.nix new file mode 100644 index 0000000..33c6885 --- /dev/null +++ b/home/adrielus/features/cli/git.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: { + programs.git = { + enable = true; + package = pkgs.gitFull; + + aliases = { + graph = "log --decorate --oneline --graph"; + }; + + userName = "Matei Adriel"; + userEmail = "rafaeladriel11@gmail.com"; + + extraConfig = { + github.user = "Mateiadrielrafael"; + hub.protocol = "ssh"; + core.editor = "nvim"; + rebase.autoStash = true; + }; + }; + + home.packages = with pkgs; [ + # Two github clis + gh + hub + ]; +} diff --git a/home/adrielus/features/cli/ssh.nix b/home/adrielus/features/cli/ssh.nix new file mode 100644 index 0000000..2624ddd --- /dev/null +++ b/home/adrielus/features/cli/ssh.nix @@ -0,0 +1,7 @@ +{ ... }: { + programs.ssh.enable = true; + + # home.persistence = { + # "/persist/home/adrielus".directories = [ ".ssh" ]; + # }; +} diff --git a/home/adrielus/features/cli/starship.nix b/home/adrielus/features/cli/starship.nix new file mode 100644 index 0000000..bd61e79 --- /dev/null +++ b/home/adrielus/features/cli/starship.nix @@ -0,0 +1,5 @@ +{ + programs.starship = { +enable = true; + }; + } diff --git a/home/adrielus/features/cli/tmux/default.nix b/home/adrielus/features/cli/tmux/default.nix new file mode 100644 index 0000000..fa0d9d3 --- /dev/null +++ b/home/adrielus/features/cli/tmux/default.nix @@ -0,0 +1,36 @@ +{ pkgs, config, ... }: +let + base16-tmux = pkgs.fetchFromGitHub { + owner = "tinted-theming"; + repo = "base16-tmux"; + sha256 = "1p6czpd9f0sbibdsph1hdw4ljp6zzjij2159bks16wbfbg3p1hhx"; + rev = "3312bb2cbb26db7eeb2d2235ae17d4ffaef5e59b"; + }; +in +{ + programs.tmux = { + enable = true; + + clock24 = true; # 24h clock format + historyLimit = 10000; # increase amount of saved lines + + plugins = with pkgs.tmuxPlugins; [ + sessionist # Nicer workflow for switching around between sessions + resurrect # Save / restore tmux sessions + { + plugin = continuum; # Automatically restore tmux sessions + extraConfig = '' + set -g @continuum-restore 'on' + set -g @continuum-boot 'on' + ''; + } + ]; + + extraConfig = '' + source ${./tmux.conf} + + # Theme + ${builtins.readFile (config.scheme base16-tmux)} + ''; + }; +} diff --git a/home/adrielus/features/cli/tmux/tmux.conf b/home/adrielus/features/cli/tmux/tmux.conf new file mode 100644 index 0000000..faa5c72 --- /dev/null +++ b/home/adrielus/features/cli/tmux/tmux.conf @@ -0,0 +1,62 @@ +# {{{ Remap prefix to Control + a +set -g prefix C-a +unbind C-b +bind C-a send-prefix +# }}} +# {{{ Hide status bar +set -g status off +# }}} +# {{{ Don't rename windows automatically +set-option -g allow-rename off +# }}} +# {{{ Fix slow esc +set -sg escape-time 10 +# }}} +# {{{ Visual stuff +set -g default-terminal "screen-256color" +set -ga terminal-overrides ",xterm-256color:Tc" +# }}} +# {{{ Split panes with \ and - +bind \\ split-window -h +bind - split-window -v +unbind '"' +unbind % +# }}} +# {{{ Zoom with C-z +unbind C-z +bind -n C-z resize-pane -Z +# }}} +# {{{ Vim-mode +set-window-option -g mode-keys vi +# }}} +# {{{ Vim like keybinds for leaving insert mode +unbind [ # unbind the default way to copy text +bind -T prefix j copy-mode # allow exiting insert mode with C-a j +# }}} +# {{{ Vim like keybinds for copying and pasting +bind -T copy-mode-vi p paste-buffer +bind -T copy-mode-vi V send-keys -X rectangle-toggle # Check if this works +bind -T copy-mode-vi v send-keys -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-selection +# }}} +# {{{ Smart pane switching with awareness of Vim splits. +# See: https://github.com/christoomey/vim-tmux-navigator +# Also see: https://github.com/christoomey/vim-tmux-navigator/issues/264 +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|\.?n?vim?x?(-wrapped)?)(diff)?$'" +bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' +bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' +bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' +bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' +tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' +if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" +if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + +bind-key -T copy-mode-vi 'C-h' select-pane -L +bind-key -T copy-mode-vi 'C-j' select-pane -D +bind-key -T copy-mode-vi 'C-k' select-pane -U +bind-key -T copy-mode-vi 'C-l' select-pane -R +bind-key -T copy-mode-vi 'C-\' select-pane -l +# }}} diff --git a/home/adrielus/features/desktop/common/polybar/default.nix b/home/adrielus/features/desktop/common/polybar/default.nix new file mode 100644 index 0000000..1cfa5fb --- /dev/null +++ b/home/adrielus/features/desktop/common/polybar/default.nix @@ -0,0 +1,28 @@ +{ pkgs, lib, paths, config, ... }: +let + base16-polybar = pkgs.fetchFromGitHub { + owner = "tinted-theming"; + repo = "base16-polybar"; + sha256 = "142fmqm324gy3qsv48vijm5k81v6mw85ym9mmhnvyv2q2ndg5rix"; + rev = "2f6dd973a9075dabccd26f1cded09508180bf5fe"; + }; +in +{ + services.polybar = { + enable = true; + extraConfig = '' + ; Generated theme + ${builtins.readFile (config.scheme base16-polybar)} + + ; Actual config + include-file = ${paths.dotfiles}/polybar/config.ini + ''; + }; + + xsession = { + enable = true; + initExtra = '' + polybar main & + ''; + }; +} diff --git a/home/adrielus/features/desktop/common/polybar/polybar.ini b/home/adrielus/features/desktop/common/polybar/polybar.ini new file mode 100644 index 0000000..dd2f6a3 --- /dev/null +++ b/home/adrielus/features/desktop/common/polybar/polybar.ini @@ -0,0 +1,111 @@ +[module/battery] +type = internal/battery + +; Use the following command to list batteries and adapters: +; $ ls -1 /sys/class/power_supply/ +battery = BAT0 +adapter = AC + +format-charging = +format-discharging = +format-low = + +; Only applies if is used +animation-charging-0 =  +animation-charging-1 =  +animation-charging-2 =  +animation-charging-3 =  +animation-charging-4 =  +; Framerate in milliseconds +animation-charging-framerate = 750 + +; Only applies if is used +animation-discharging-0 =  +animation-discharging-1 =  +animation-discharging-2 =  +animation-discharging-3 =  +animation-discharging-4 =  +; Framerate in milliseconds +animation-discharging-framerate = 500 + +; Only applies if is used +; New in version 3.6.0 +animation-low-0 = ! +animation-low-1 = +animation-low-framerate = 200 + +[module/cpu] +type = internal/cpu + +[module/date] +type = internal/date +date = %d-%m-%Y% +time = %H:%M +label =  %date%  %time% + +[module/wireless-network] +type = internal/network +interface = wlp0s20f3 + +format-connected = +format-packetloss = +format-disconnected = + +label-connected =  %essid%  %downspeed%  %upspeed% +label-disconnected = 睊 +label-packetloss = %essid% + +animation-packetloss-0 = ⚠ +animation-packetloss-0-foreground = #ffa64c +animation-packetloss-1 = 📶 +animation-packetloss-1-foreground = #000000 +animation-packetloss-framerate = 500 + +[module/ewmh] +type = internal/xworkspaces +icon-0 = 1:dev; +icon-1 = 2:browser; +icon-2 = 3:chat;ﭮ +icon-3 = 4:terminal; +icon-4 = 5:reading; +icon-default =  + +format = + +label-active = %icon% +label-active-background = ${color.base05} +label-active-foreground = ${color.base00} +label-active-padding = 2 + +label-urgent = %icon% +label-urgent-background = ${color.base09} +label-urgent-foreground = ${color.base00} +label-urgent-padding = 2 + +label-occupied = %icon% +label-occupied-padding = 2 + +label-empty = + +[bar/main] +font-0 = FiraCode Nerd Font:style=Regular +font-1 = Source Code Pro Nerd Font:style=Regular + +modules-left = date battery +modules-center = ewmh +modules-right = wireless-network + +padding-right = 2 +padding-left = 2 +padding-top = 4 +module-margin = 2 + +height=4% + +border-top-size = 1 +border-top-color = ${color.base05} + +background = ${color.base00} +foreground = ${color.base05} + +bottom = true diff --git a/home/adrielus/features/desktop/common/rofi/config.rasi b/home/adrielus/features/desktop/common/rofi/config.rasi new file mode 100644 index 0000000..f7a798e --- /dev/null +++ b/home/adrielus/features/desktop/common/rofi/config.rasi @@ -0,0 +1,98 @@ +configuration { + location: 0; + cycle: true; + font: "Source Code Pro 16"; + + modi: "run,drun,window"; + icon-theme: "Oranchelo"; + show-icons: true; + terminal: "alacritty"; + drun-display-format: "{icon} {name}"; + disable-history: false; + hide-scrollbar: true; + display-drun: "  Apps "; + display-run: "  Run "; + display-window: " 﩯 Window"; + display-Network: " 󰤨 Network"; + sidebar-mode: true; +} + +listview { + columns: 1; +} + +* { + width: 600; + font: "JetBrainsMono Nerd Font 14"; +} + +element-text, element-icon , mode-switcher { + background-color: inherit; + text-color: inherit; +} + +window { + border: 3px; + + height: 50%; + width: 50%; +} + +inputbar { + children: [prompt,entry]; + border-radius: 5px; + padding: 2px; +} + +prompt { + padding: 6px; + border-radius: 3px; + margin: 20px 0px 0px 20px; +} + +textbox-prompt-colon { + expand: false; + str: ":"; +} + +entry { + padding: 6px; + margin: 20px 0px 0px 10px; +} + +listview { + border: 0px 0px 0px; + padding: 6px 0px 0px; + margin: 10px 0px 0px 20px; + columns: 2; + lines: 5; +} + +element { + padding: 5px; +} + +element-icon { + size: 25px; +} + +mode-switcher { + spacing: 0; +} + +button { + padding: 10px; + vertical-align: 0.5; + horizontal-align: 0.5; +} + +message { + margin: 2px; + padding: 2px; + border-radius: 5px; +} + +textbox { + padding: 6px; + margin: 20px 0px 0px 20px; +} diff --git a/home/adrielus/features/desktop/common/rofi/default.nix b/home/adrielus/features/desktop/common/rofi/default.nix new file mode 100644 index 0000000..fa3a210 --- /dev/null +++ b/home/adrielus/features/desktop/common/rofi/default.nix @@ -0,0 +1,20 @@ +{ pkgs, config, ... }: +let + base16-rofi = pkgs.fetchFromGitHub { + owner = "tinted-theming"; + repo = "base16-rofi"; + sha256 = "03y4ydnd6sijscrrp4qdvckrckscd39r8gyhpzffs60a1w4n76j5"; + rev = "3f64a9f8d8cb7db796557b516682b255172c4ab4"; + }; +in +{ + home.packages = with pkgs; [ rofi ]; + + xdg.configFile."rofi/config.rasi".text = '' + // Manual config + ${builtins.readFile ./config.rasi} + + // Theme + ${builtins.readFile (config.scheme base16-rofi)} + ''; +} diff --git a/home/adrielus/features/desktop/xmonad.nix b/home/adrielus/features/desktop/xmonad.nix new file mode 100644 index 0000000..671773b --- /dev/null +++ b/home/adrielus/features/desktop/xmonad.nix @@ -0,0 +1,3 @@ +{ + imports = [ ./common/rofi ]; +} diff --git a/home/adrielus/features/neovim/default.nix b/home/adrielus/features/neovim/default.nix new file mode 100644 index 0000000..61d9617 --- /dev/null +++ b/home/adrielus/features/neovim/default.nix @@ -0,0 +1,89 @@ +{ pkgs, lib, config, paths, ... }: +let + devMode = false; + extraPackages = with pkgs; [ + # Language servers + nodePackages.typescript-language-server # typescript + nodePackages_latest.purescript-language-server # purescript + sumneko-lua-language-server # lua + rnix-lsp # nix + haskell-language-server # haskell + tectonic # something related to latex (?) + texlab # latex + nodePackages_latest.vscode-langservers-extracted + + # Formatters + luaformatter # Lua + stylua # Lua + ormolu # Haskell + nodePackages_latest.purs-tidy # Purescript + nodePackages_latest.prettier_d_slim # Js & friends + + # Others + nodePackages.typescript # typescript + wakatime # time tracking + fd # file finder + ripgrep # Grep rewrite + update-nix-fetchgit # Useful for nix stuff + tree-sitter # Syntax highlighting + libstdcxx5 # Required by treesitter aparently + zathura # Pdf reader + xdotool # For zathura reverse search or whatever it's called + lua # For repls and whatnot + glow #Mmd preview in terminal + pandoc # Md processing + libsForQt5.falkon # Aparently needed for md preview + + texlive.combined.scheme-full # Latex stuff + python38Packages.pygments # required for latex syntax highlighting + ]; +in +let + simlink = config.lib.file.mkOutOfStoreSymlink; + + extraRuntime = [ + (if devMode + then simlink "${paths.dotfiles}/vscode-snippets" + else ../../../../dotfiles/vscode-snippets) + ]; + + # Wraps a neovim client, providing the dependencies + # and setting some flags: + # + # TODO: change this to a more general thing like "NVIM_CLIENT_NAME" + # - INSIDE_NEOVIDE is used to detect when running inside neovide, + # before the in-client flag gets set (this was causing me problems in the past) + # + # - NVIM_EXTRA_RUNTIME provides extra directories to add to the runtimepath. + # I cannot just install those dirs using the builtin package support because + # my package manager (lazy.nvim) disables those. + wrapClient = { base, name }: + pkgs.symlinkJoin { + inherit (base) name meta; + paths = [ base ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/${name} \ + --prefix PATH : ${lib.makeBinPath extraPackages} \ + --set INSIDE_NEOVIDE ${if name == "neovide" then "1" else "0"} \ + --set NVIM_EXTRA_RUNTIME ${lib.strings.concatStringsSep "," extraRuntime} + ''; + }; + + neovim = wrapClient { base = pkgs.neovim-nightly; name = "nvim"; }; + neovide = wrapClient { base = pkgs.neovide; name = "neovide"; }; +in +{ + # Do not manage neovim via nix + programs.neovim.enable = false; + + home.file.".config/nvim".source = + if devMode then + simlink "${paths.dotfiles}/neovim" else + ../../../../dotfiles/neovim; + + home.packages = [ + neovim + neovide + ]; +} diff --git a/home/adrielus/global/default.nix b/home/adrielus/global/default.nix new file mode 100644 index 0000000..1dc4c15 --- /dev/null +++ b/home/adrielus/global/default.nix @@ -0,0 +1,48 @@ +{ inputs, lib, pkgs, config, outputs, ... }: +let + imports = [ + # inputs.impermanence.nixosModules.home-manager.impermanence + inputs.base16.homeManagerModule + + ../features/cli + ../features/neovim + ]; + + # Import all modules defined in modules/home-manager + moduleImports = builtins.attrValues outputs.homeManagerModules; +in +{ + imports = imports ++ moduleImports; + + nixpkgs = { + # Add all overlays defined in the overlays directory + overlays = builtins.attrValues outputs.overlays ++ + [ + inputs.neovim-nightly-overlay.overlay + ]; + + # Allow unfree packages + config = { + allowUnfree = true; + allowUnfreePredicate = (_: true); + }; + }; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # Enable the home-manager and git clis + programs = { + home-manager.enable = true; + git.enable = true; + }; + + scheme = lib.mkDefault "${inputs.catppuccin-base16}/base16/latte.yaml"; + + # Set reasonable defaults for some settings + home = { + username = lib.mkDefault "adrielus"; + homeDirectory = lib.mkDefault "/home/${config.home.username}"; + stateVersion = lib.mkDefault "22.11"; + }; +} diff --git a/home/adrielus/tethys.nix b/home/adrielus/tethys.nix index 8327fda..bafead4 100644 --- a/home/adrielus/tethys.nix +++ b/home/adrielus/tethys.nix @@ -1,32 +1,6 @@ { inputs, outputs, lib, config, pkgs, ... }: { imports = [ - + ./global + ./features/desktop/xmonad.nix ]; - - nixpkgs = { - # You can add overlays here - overlays = [ - ]; - - # Configure your nixpkgs instance - config = { - allowUnfree = true; - allowUnfreePredicate = (_: true); - }; - }; - - home = { - username = "rafael"; - homeDirectory = "/home/rafael"; - }; - - # Enable home-manager and git - programs.home-manager.enable = true; - programs.git.enable = true; - - # Nicely reload system units when changing configs - systemd.user.startServices = "sd-switch"; - - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "22.11"; } diff --git a/hosts/nixos/common/global/default.nix b/hosts/nixos/common/global/default.nix new file mode 100644 index 0000000..8216c51 --- /dev/null +++ b/hosts/nixos/common/global/default.nix @@ -0,0 +1,25 @@ +# Configuration pieces included on all (nixos) hosts +{ inputs, outputs, ... }: { + imports = [ + inputs.agenix.nixosModule + # inputs.impermanence.nixosModule + + ./nix.nix + ./openssh.nix + ./fish.nix + ./locale.nix + ./wireless.nix + ]; + + nixpkgs = { + # Add all overlays defined in the overlays directory + overlays = builtins.attrValues outputs.overlays ++ [ + inputs.neovim-nightly-overlay.overlay + ]; + + config = { + allowUnfree = true; + }; + }; + +} diff --git a/hosts/nixos/common/global/fish.nix b/hosts/nixos/common/global/fish.nix new file mode 100644 index 0000000..e53f255 --- /dev/null +++ b/hosts/nixos/common/global/fish.nix @@ -0,0 +1,10 @@ +{ + programs.fish = { + enable = true; + vendor = { + completions.enable = true; + config.enable = true; + functions.enable = true; + }; + }; +} diff --git a/hosts/nixos/common/global/locale.nix b/hosts/nixos/common/global/locale.nix new file mode 100644 index 0000000..494d209 --- /dev/null +++ b/hosts/nixos/common/global/locale.nix @@ -0,0 +1,4 @@ +{ pkgs, ... }: { + i18n.defaultLocale = "en_US.UTF-8"; + time.timeZone = "Europe/Amsterdam"; +} diff --git a/hosts/nixos/common/global/nix.nix b/hosts/nixos/common/global/nix.nix new file mode 100644 index 0000000..1470a33 --- /dev/null +++ b/hosts/nixos/common/global/nix.nix @@ -0,0 +1,59 @@ +{ config, lib, pkgs, inputs, ... }: { + nix = { + # Flake support and whatnot + package = pkgs.nixUnstable; + + # Weekly clean up the store, I think + gc = { + automatic = true; + dates = "weekly"; + }; + + # Protect nix shell from garbage collection + extraOptions = '' + keep-outputs = true + keep-derivations = true + ''; + + # TODO: look into what this does, + # and why it was here in my old config + optimise.automatic = true; + + # This will add each flake input as a registry + # To make nix3 commands consistent with your flake + registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + + # This will additionally add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + + settings = { + # Enable flakes and new 'nix' command + experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + + # Disable warning when rebuilding before commiting + warn-dirty = false; + + # Deduplicate and optimize nix store + auto-optimise-store = true; + + # TODO: what is a trusted user? + trusted-users = [ "root" "@wheel" ]; + + # {{{ Caching and whatnot + substituters = [ + "https://cache.nixos.org" # Default nixos cache + "https://nix-community.cachix.org" # I think I need this for neovim-nightly? + "https://cm-idris2-pkgs.cachix.org" # Idris packages + "https://danth.cachix.org" # stylix + ]; + + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "cm-idris2-pkgs.cachix.org-1:YB2oJSEsD5oMJjAESxolC2GQtE6B5I6jkWhte2gtXjk=" + "danth.cachix.org-1:wpodfSL7suXRc/rJDZZUptMa1t4MJ795hemRN0q84vI=" + ]; + # }}} + }; + }; +} diff --git a/hosts/nixos/common/global/openssh.nix b/hosts/nixos/common/global/openssh.nix new file mode 100644 index 0000000..03908af --- /dev/null +++ b/hosts/nixos/common/global/openssh.nix @@ -0,0 +1,51 @@ +# This setups a SSH server. +{ outputs, config, lib, ... }: +let + # Record containing all the hosts + hosts = outputs.nixosConfigurations; + + # Name of the current hostname + hostname = config.networking.hostName; + + # Function from hostname to relative path to public ssh key + pubKey = host: ../../${host}/ssh_host_ed25519_key.pub; +in +{ + services.openssh = { + enable = true; + + # Forbid root login through SSH. + permitRootLogin = "no"; + + # Use keys only. Remove if you want to SSH using password (not recommended) + passwordAuthentication = false; + + # Automatically remove stale sockets + extraConfig = '' + StreamLocalBindUnlink yes + ''; + + # TODO: look into what this does + # Allow forwarding ports to everywhere + gatewayPorts = "clientspecified"; + + # Generate ssh key + hostKeys = [{ + path = "/persist/etc/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + }]; + }; + + # Passwordless sudo when SSH'ing with keys + security.pam.enableSSHAgentAuth = true; + + # Add each host in this repo to the knownHosts list + programs.ssh = { + knownHosts = builtins.mapAttrs + (name: _: { + publicKeyFile = pubKey name; + extraHostNames = lib.optional (name == hostname) "localhost"; + }) + hosts; + }; +} diff --git a/hosts/nixos/common/global/wireless.nix b/hosts/nixos/common/global/wireless.nix new file mode 100644 index 0000000..8ab7694 --- /dev/null +++ b/hosts/nixos/common/global/wireless.nix @@ -0,0 +1,43 @@ +{ config, lib, ... }: { + # Wireless secrets stored through agenix + age.secrets.wireless = { + file = ../../../../secrets/wifi_passwords.age; + }; + + networking.wireless = { + enable = true; + fallbackToWPA2 = false; + + # Declarative + environmentFile = config.age.secrets.wireless.path; + networks = { + "Neptune".psk = "@PHONE_HOTSPOT_PASS@"; + "TP-Link_522C".psk = "@TG_HOME_PASS@"; + }; + + # Imperative + allowAuxiliaryImperativeNetworks = true; + userControlled = { + enable = true; + group = "network"; + }; + + # TODO: look into what this does + extraConfig = '' + update_config=1 + ''; + }; + + # Ensure group exists + users.groups.network = { }; + + # Convenient alias for connecting to wifi + environment.shellAliases.wifi = "sudo nmcli con up id"; + + # Persist imperative config + # environment.persistence = { + # "/persist".files = [ + # "/etc/wpa_supplicant.conf" + # ]; + # }; +} diff --git a/hosts/nixos/common/optional/pipewire.nix b/hosts/nixos/common/optional/pipewire.nix new file mode 100644 index 0000000..e031a1c --- /dev/null +++ b/hosts/nixos/common/optional/pipewire.nix @@ -0,0 +1,23 @@ +{ + security.rtkit.enable = true; + hardware.pulseaudio.enable = false; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + + # Volume controls + environment.shellAliases = { + # Relative + "v-up" = "pactl set-sink-volume @DEFAULT_SINK@ +5%"; + "v-down" = "pactl set-sink-volume @DEFAULT_SINK@ +5%"; + + # Absolute + "v-min" = "pactl set-sink-volume @DEFAULT_SINK@ 0%"; + "v-mid" = "pactl set-sink-volume @DEFAULT_SINK@ 50%"; + "v-max" = "pactl set-sink-volume @DEFAULT_SINK@ 100%"; + }; +} diff --git a/hosts/nixos/common/optional/touchpad.nix b/hosts/nixos/common/optional/touchpad.nix new file mode 100644 index 0000000..b5e119f --- /dev/null +++ b/hosts/nixos/common/optional/touchpad.nix @@ -0,0 +1,21 @@ +# My touchpad configuration +{ ... }: { + services.xserver.libinput = { + enable = true; + + touchpad = { + # How fast we should scroll I think + accelSpeed = "3.5"; + + # #TODO: I forgor what this did + naturalScrolling = true; + + # Dsiable the touchpad while typing + disableWhileTyping = true; + + # This is the most evil setting ever. + # I cannot imagine living with this on + tappingDragLock = false; + }; + }; +} diff --git a/hosts/nixos/common/optional/xmonad/Main.hs b/hosts/nixos/common/optional/xmonad/Main.hs new file mode 100644 index 0000000..0bcea73 --- /dev/null +++ b/hosts/nixos/common/optional/xmonad/Main.hs @@ -0,0 +1,73 @@ +{-# LANGUAGE BlockArguments #-} + +import Control.Monad (forM_, join) +import Data.Function ((&)) +import System.Environment +import System.Process +import XMonad +import XMonad.Actions.SpawnOn +import XMonad.Config +import XMonad.Hooks.EwmhDesktops (ewmh, fullscreenEventHook) +import XMonad.Hooks.ManageDocks +import XMonad.Layout.NoBorders +import XMonad.Layout.Spacing +import XMonad.Layout.ThreeColumns +import XMonad.Operations +import XMonad.Util.EZConfig + +main = + xmonad $ + ewmh $ + docks $ + def + { modMask = mod4Mask, + terminal = myTerminal, + workspaces = myWorkspaces, + borderWidth = 5, + focusedBorderColor = "#4c4f69", + normalBorderColor = "#4c4f69", + startupHook = startup, + layoutHook = avoidStruts myLayoutHook, + manageHook = manageDocks <+> manageSpawn <+> manageHook def, + handleEventHook = fullscreenEventHook <+> docksEventHook <+> handleEventHook def + } + `additionalKeysP` keymap + where + myWorkspaces = + ["1:dev", "2:browser", "3:chat", "4:terminal", "5:reading", "6:gaming"] + + myTerminal = "alacritty" + myBrowser = "google-chrome-stable" + + keymap = + [ ("M-p", spawn "rofi -show drun"), + ("M-w", spawn "rofi -show window"), + ("M-g", spawn myBrowser), + ("M-d", spawn "Discord"), + ("M-v", spawn "alacritty -e vimclip"), + ("M-s", spawn "spectacle -rcb"), + ("M-S-s", spawn "spectacle -mcb"), + ("M-C-s", spawn "spectacle -ucb"), + ("M-f", sendMessage ToggleStruts), + ("M-c", kill) + ] + + uniformBorder = join $ join $ join Border + border = uniformBorder 0 + spacingHook = spacingRaw False border False border True + + tall = Tall 1 (3 / 100) (1 / 2) + + layouts = tall ||| Full + myLayoutHook = spacingHook layouts + + startupApps = + [ (0, "alacritty"), + (1, "google-chrome-stable"), + (2, "Discord") + ] + + startup :: X () + startup = do + forM_ startupApps \(index, app) -> do + spawnOn (myWorkspaces !! index) app diff --git a/hosts/nixos/common/optional/xmonad/default.nix b/hosts/nixos/common/optional/xmonad/default.nix new file mode 100644 index 0000000..ba79ee9 --- /dev/null +++ b/hosts/nixos/common/optional/xmonad/default.nix @@ -0,0 +1,43 @@ +{ pkgs, ... }: +let + catpuccin-sddm = pkgs.fetchFromGitHub { + owner = "catppuccin"; + repo = "sddm"; + sha256 = "1lg10dyxgz080qfcp6k3zk6374jlj067s6p5fgx5r135ivy8mrki"; + rev = "bde6932e1ae0f8fdda76eff5c81ea8d3b7d653c0"; + }; + + sddm-theme = "${catpuccin-sddm}/src/caputccin-latte"; +in +{ + services.xserver = { + enable = true; + + # Enable xmonad + windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + config = ./Main.hs; + }; + + displayManager = { + # make xmonad session the default + defaultSession = "none+xmonad"; + + # enable sddm + # sddm = { + # enable = true; + # theme = sddm-theme; + # }; + + # enable startx + startx.enable = true; + + # autoLogin = { + # enable = true; + # user = "adrielus"; + # }; + }; + }; +} + diff --git a/hosts/nixos/common/optional/xserver.nix b/hosts/nixos/common/optional/xserver.nix new file mode 100644 index 0000000..4cdfdba --- /dev/null +++ b/hosts/nixos/common/optional/xserver.nix @@ -0,0 +1,8 @@ +{ + services.xserver = { + enable = true; + + # keyboard layout + xkbOptions = "eurosign:e"; + }; +} diff --git a/hosts/nixos/common/users/adrielus.nix b/hosts/nixos/common/users/adrielus.nix new file mode 100644 index 0000000..c4141c4 --- /dev/null +++ b/hosts/nixos/common/users/adrielus.nix @@ -0,0 +1,37 @@ +{ pkgs, config, ... }: +{ + # Password file stored through agenix + age.secrets.adrielusPassword = { + file = ../../../../secrets/adrielus_password.age; + }; + + users = { + # Configure users through nix only + mutableUsers = false; + + # Create an user named adrielus + users.adrielus = { + # File containing my password, managed by agenix + passwordFile = config.age.secrets.adrielusPassword.path; + + # Add user to the following groups + extraGroups = [ + "wheel" # access to sudo + "network" # for wireless stuff + "networkmanager" # I assume this let's me access network stuff? + "lp" # Allows me to use printers + "docker" # Allows me to use docker (?) + "audio" # Allows me to use audio devices + "video" # Allows me to use a webcam + + # TODO: find out why I added these here a long time ago + "sound" + "input" + "tty" + ]; + + # Adds me to some default groups, and creates the home dir + isNormalUser = true; + }; + }; +} diff --git a/hosts/nixos/tethys/boot.nix b/hosts/nixos/tethys/boot.nix new file mode 100644 index 0000000..83d5ad3 --- /dev/null +++ b/hosts/nixos/tethys/boot.nix @@ -0,0 +1,34 @@ +# This file contains arcane configurations copied from a random old wiki entry +# One day I shall revisit this and see what's needed and what isn't +{...}: { + boot.loader = { + efi = { + canTouchEfiVariables = true; + # assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends). + efiSysMountPoint = "/boot"; + }; + grub = { + # despite what the configuration.nix manpage seems to indicate, + # as of release 17.09, setting device to "nodev" will still call + # `grub-install` if efiSupport is true + # (the devices list is not used by the EFI grub install, + # but must be set to some value in order to pass an assert in grub.nix) + devices = [ "nodev" ]; + efiSupport = true; + enable = true; + # set $FS_UUID to the UUID of the EFI partition + extraEntries = '' + menuentry "Windows" { + insmod part_gpt + insmod fat + insmod search_fs_uuid + insmod chain + search --fs-uuid --set=root $FS_UUID + chainloader /EFI/Microsoft/Boot/bootmgfw.efi + } + ''; + + version = 2; + }; + }; +} diff --git a/hosts/nixos/tethys/default.nix b/hosts/nixos/tethys/default.nix new file mode 100644 index 0000000..13c0773 --- /dev/null +++ b/hosts/nixos/tethys/default.nix @@ -0,0 +1,20 @@ +{ inputs, outputs, lib, config, pkgs, ... }: { + imports = [ + ../common/global + ../common/users/adrielus.nix + + ../common/optional/pipewire.nix + ../common/optional/touchpad.nix + ../common/optional/xserver.nix + ../common/optional/xmonad + + ./hardware-configuration.nix + ./boot.nix + ]; + + networking.hostName = "tethys"; + hardware.opengl.enable = true; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "22.11"; +} diff --git a/hosts/nixos/tethys/hardware-configuration.nix b/hosts/nixos/tethys/hardware-configuration.nix new file mode 100644 index 0000000..ed25357 --- /dev/null +++ b/hosts/nixos/tethys/hardware-configuration.nix @@ -0,0 +1,47 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/57846041-f177-45eb-aff3-503006bac638"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/01E6-A013"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/5cf4167c-77f4-4afe-b978-65ed5472e3d0"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.br-0bc5903170c6.useDHCP = lib.mkDefault true; + # networking.interfaces.br-53c5ffb3733e.useDHCP = lib.mkDefault true; + # networking.interfaces.br-8b13cd8694f3.useDHCP = lib.mkDefault true; + # networking.interfaces.docker0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; + # networking.interfaces.ham0.useDHCP = lib.mkDefault true; + # networking.interfaces.veth544819a.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/nixos/tethys/ssh_host_ed25519_key.pub b/hosts/nixos/tethys/ssh_host_ed25519_key.pub new file mode 100644 index 0000000..fcb8d99 --- /dev/null +++ b/hosts/nixos/tethys/ssh_host_ed25519_key.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINmdOiG0elKHvJ5yoUMd8I5qQdygvjdq45bxv65K230G tethys diff --git a/hosts/tethys/default.nix b/hosts/tethys/default.nix deleted file mode 100644 index 32e84c8..0000000 --- a/hosts/tethys/default.nix +++ /dev/null @@ -1 +0,0 @@ -{ pkgs, ... }: { } diff --git a/pkgs/default.nix b/pkgs/default.nix index 8c5e910..b003518 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -2,5 +2,5 @@ # You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' { pkgs ? (import ../nixpkgs.nix) { } }: { - # example = pkgs.callPackage ./example { }; + # example = pkgs.callPackage (import ./example.nix) {}; } diff --git a/scripts/hm-activate.sh b/scripts/hm-activate.sh new file mode 100755 index 0000000..0847a4c --- /dev/null +++ b/scripts/hm-activate.sh @@ -0,0 +1,7 @@ +#!/run/current-system/sw/bin/bash +if [ $# -eq 0 ] + then + ~/.local/share/hm-result/activate + else + ~/.local/share/hm-result/specialization/$1/activate +fi diff --git a/scripts/hm-rebuild.sh b/scripts/hm-rebuild.sh new file mode 100755 index 0000000..ee88444 --- /dev/null +++ b/scripts/hm-rebuild.sh @@ -0,0 +1,4 @@ +#!/run/current-system/sw/bin/bash +home-manager build --flake .#$1 +rm -rf result ~/.local/share/hm-result/$1 +mv result ~/.local/share/hm-result/$1 diff --git a/secrets/adrielus_password.age b/secrets/adrielus_password.age new file mode 100644 index 0000000..ff33936 --- /dev/null +++ b/secrets/adrielus_password.age @@ -0,0 +1,8 @@ +age-encryption.org/v1 +-> ssh-ed25519 UUF9JQ AWyd+vbllVT7QeD8xfu8D4NhxEA1RxwYCKwxGIrkIEw +m7/XC6vhyhHW5vY+48bxmBsb6Zfhof+mavhq1fdpd+U +-> E-grease s%$ F5jZ"f E(>8 x|#B"9 +dilxxi2WlTIReh+uvkscDubze9MyfGaW7Tn22L6p8X8YZ40muPOtVaWkgQBv1OLo +SkccszU/cr1NEJm62YOPZGnmK96MwxA/ZWnlG5Ls/my47MqymDq7/1ySWKU5xA +--- wOqvODKflq/JZT0/Qssb8FEl/IDNou+yKMGPn/nI81Q +m>Wu!N@ϋyB"GɳL'A)+)E zQ$"Z;w- \ No newline at end of file diff --git a/secrets/secrets.nix b/secrets/secrets.nix new file mode 100644 index 0000000..d6cf285 --- /dev/null +++ b/secrets/secrets.nix @@ -0,0 +1,7 @@ +let + tethys = builtins.readFile ../hosts/nixos/tethys/ssh_host_ed25519_key.pub; +in +{ + "wifi_passwords.age".publicKeys = [ tethys ]; + "adrielus_password.age".publicKeys = [ tethys ]; +} diff --git a/secrets/wifi_passwords.age b/secrets/wifi_passwords.age new file mode 100644 index 0000000..182addc --- /dev/null +++ b/secrets/wifi_passwords.age @@ -0,0 +1,7 @@ +age-encryption.org/v1 +-> ssh-ed25519 UUF9JQ Qc1AgNo+N/kjGhMVHa/QDPt5nRCtuC8BvNdxuwHHKRA +ZnOW8dIH2Sd5WDlvVA27hpp5AVHieJXIpwCmtg+dcp0 +-> rD3(ZZw-grease ZvlDZ7| G|:Xj NsbyfDh L\' +hZeXb1QaqOPfJKTKYdB60pMyHt6G42sIEmfzNqRI/w +--- RFPqwBq0YPAoxa/g0gEmJmWTiYH6c77ZYR0snUIx0vE +S_!s_i?>ry V|^:>LˉQ~3W O9e(