From 428b91c3d55b85930554c13b9f51f6cc9496058c Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 10 Jul 2024 08:10:56 +0200 Subject: [PATCH] feat: import horsch config --- flake.nix | 12 ++ horsch/bat.nix | 13 ++ horsch/carapace.nix | 8 ++ horsch/direnv.nix | 11 ++ horsch/docs/Setup Log WSL+Alpine.md | 91 +++++++++++++ horsch/eza.nix | 8 ++ horsch/fzf.nix | 10 ++ horsch/git.nix | 126 ++++++++++++++++++ horsch/gpg/default.nix | 43 ++++++ horsch/gpg/horsch.pub.asc | 51 +++++++ horsch/gpg/molez.pub.asc | 52 ++++++++ horsch/gpg/vi-bim.pub.asc | 52 ++++++++ horsch/home.nix | 40 ++++++ horsch/neovim/auto-session.lua | 3 + horsch/neovim/commands.lua | 1 + horsch/neovim/comment.lua | 1 + horsch/neovim/dap.lua | 35 +++++ horsch/neovim/default.nix | 177 ++++++++++++++++++++++++ horsch/neovim/gitsigns.lua | 1 + horsch/neovim/illuminate.lua | 8 ++ horsch/neovim/indent-blankline.lua | 5 + horsch/neovim/keymaps.lua | 69 ++++++++++ horsch/neovim/lspconfig.lua | 200 ++++++++++++++++++++++++++++ horsch/neovim/lualine.lua | 7 + horsch/neovim/luasnip.lua | 1 + horsch/neovim/neorg.lua | 16 +++ horsch/neovim/notify.lua | 2 + horsch/neovim/nvim-cmp.lua | 87 ++++++++++++ horsch/neovim/options.lua | 61 +++++++++ horsch/neovim/project-nvim.lua | 1 + horsch/neovim/tabline.lua | 1 + horsch/neovim/telescope.lua | 29 ++++ horsch/neovim/themes.lua | 1 + horsch/neovim/toggleterm.lua | 1 + horsch/neovim/treesitter.lua | 93 +++++++++++++ horsch/picocom.nix | 5 + horsch/podman.nix | 5 + horsch/ripgrep.nix | 9 ++ horsch/rsync.nix | 5 + horsch/shell_aliases.nix | 11 ++ horsch/ssh.nix | 65 +++++++++ horsch/starship.nix | 11 ++ horsch/tree.nix | 5 + horsch/zoxide.nix | 9 ++ horsch/zsh.nix | 68 ++++++++++ 45 files changed, 1510 insertions(+) create mode 100644 horsch/bat.nix create mode 100644 horsch/carapace.nix create mode 100644 horsch/direnv.nix create mode 100644 horsch/docs/Setup Log WSL+Alpine.md create mode 100644 horsch/eza.nix create mode 100644 horsch/fzf.nix create mode 100644 horsch/git.nix create mode 100644 horsch/gpg/default.nix create mode 100644 horsch/gpg/horsch.pub.asc create mode 100644 horsch/gpg/molez.pub.asc create mode 100644 horsch/gpg/vi-bim.pub.asc create mode 100644 horsch/home.nix create mode 100644 horsch/neovim/auto-session.lua create mode 100644 horsch/neovim/commands.lua create mode 100644 horsch/neovim/comment.lua create mode 100644 horsch/neovim/dap.lua create mode 100644 horsch/neovim/default.nix create mode 100644 horsch/neovim/gitsigns.lua create mode 100644 horsch/neovim/illuminate.lua create mode 100644 horsch/neovim/indent-blankline.lua create mode 100644 horsch/neovim/keymaps.lua create mode 100644 horsch/neovim/lspconfig.lua create mode 100644 horsch/neovim/lualine.lua create mode 100644 horsch/neovim/luasnip.lua create mode 100644 horsch/neovim/neorg.lua create mode 100644 horsch/neovim/notify.lua create mode 100644 horsch/neovim/nvim-cmp.lua create mode 100644 horsch/neovim/options.lua create mode 100644 horsch/neovim/project-nvim.lua create mode 100644 horsch/neovim/tabline.lua create mode 100644 horsch/neovim/telescope.lua create mode 100644 horsch/neovim/themes.lua create mode 100644 horsch/neovim/toggleterm.lua create mode 100644 horsch/neovim/treesitter.lua create mode 100644 horsch/picocom.nix create mode 100644 horsch/podman.nix create mode 100644 horsch/ripgrep.nix create mode 100644 horsch/rsync.nix create mode 100644 horsch/shell_aliases.nix create mode 100644 horsch/ssh.nix create mode 100644 horsch/starship.nix create mode 100644 horsch/tree.nix create mode 100644 horsch/zoxide.nix create mode 100644 horsch/zsh.nix diff --git a/flake.nix b/flake.nix index fd43b76..50e0349 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,18 @@ theme = "dark"; }; }; + "mmandl@NB11313" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + modules = [ + ./horsch/home.nix + ]; + + extraSpecialArgs = { + username = "mmandl"; + theme = "dark"; + }; + }; }; }; } diff --git a/horsch/bat.nix b/horsch/bat.nix new file mode 100644 index 0000000..4e4b56a --- /dev/null +++ b/horsch/bat.nix @@ -0,0 +1,13 @@ +{ ... }: + +let + theme_name = "Solarized (dark)"; +in +{ + programs = { + bat = { + enable = true; + config.theme = theme_name; + }; + }; +} diff --git a/horsch/carapace.nix b/horsch/carapace.nix new file mode 100644 index 0000000..2705a18 --- /dev/null +++ b/horsch/carapace.nix @@ -0,0 +1,8 @@ +{ ... }: +{ + programs.carapace = { + enable = true; + enableZshIntegration = true; + }; +} + diff --git a/horsch/direnv.nix b/horsch/direnv.nix new file mode 100644 index 0000000..005868d --- /dev/null +++ b/horsch/direnv.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + programs = { + direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + }; +} diff --git a/horsch/docs/Setup Log WSL+Alpine.md b/horsch/docs/Setup Log WSL+Alpine.md new file mode 100644 index 0000000..87ed6cb --- /dev/null +++ b/horsch/docs/Setup Log WSL+Alpine.md @@ -0,0 +1,91 @@ +# Setup Log WSL/Alpine + +## User setup + +```bash +su - +apk add sudo +echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel +adduser mmandl sudo +passwd mmandl +logout +``` + +## Home-manager setup + +```bash +# Install nix package manager +sudo apk add curl xz openssh-client +curl -L https://nixos.org/nix/install | sh +echo ". /home/mmandl/.nix-profile/etc/profile.d/nix.sh" >> ~/.profile + +# Add home-manager channel and install +nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager +nix-channel --update +nix-shell '' -A install +``` + +## Home-manager config + +```bash +# Extract initial home-manager config +unzip /mnt/c/Users/mmandl/Downloads/home-manager-main.zip +mv home-manager-main home-manager +rm -rf .config/home-manager +ln -s ../home-manager .config/home-manager + +# Enable nix flakes support +mkdir -p .config/nix +echo "experimental-features = nix-command flakes" > .config/nix/nix.conf + +# Install and configure user environment +home-manager switch + +# Install zsh +sudo apk add zsh +chsh -s /bin/zsh + +# Install gpg and ssh private keys +gpg --import /mnt/c/Users/mmandl/OneDrive\ -\ Horsch\ Maschinen\ GmbH/Dokumente/GPG/Michael\ Mandl\ michael.mandl@horsch.com\ \(0x088ED38F036C7AF2\)\ pub-sec.asc + +# Switch to final home-manager config +rm -rf home-manager +git clone git@github.com:mmandl-horsch/home-manager.git +``` + +## Docker + +```bash +# Enable openrc on boot +echo "[boot]\ncommand = /sbin/openrc default" > /etc/wsl.conf + +# Install docker +sudo apk add docker +sudo rc-update add docker default +sudo adduser mmandl docker + +# Install buildserver CA +firefox https://confluence.horsch.com/display/DFEDOCU1/SE+Tools+-+Buildserver+-+SSL?preview=/114590403/114590426/20201123_horsch_buildserver_ca_install.sh +sudo sh 20201123_horsch_buildserver_ca_install.sh +``` + +## VSCode + +```bash +# Install vscode server runtime dependency +sudo apk add libstdc++ +``` + +## Yocto + +```bash +# Install non-busybox `readlink` +sudo apk add coreutils +``` + +## Kernel Module Autoloading + +```bash +sudo apk add alpine-config +sudo setup-devd udev +``` diff --git a/horsch/eza.nix b/horsch/eza.nix new file mode 100644 index 0000000..7422f80 --- /dev/null +++ b/horsch/eza.nix @@ -0,0 +1,8 @@ +{ ... }: +{ + programs.eza = { + enable = true; + git = true; + extraOptions = [ "--group-directories-first" ]; + }; +} diff --git a/horsch/fzf.nix b/horsch/fzf.nix new file mode 100644 index 0000000..0e83315 --- /dev/null +++ b/horsch/fzf.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs = { + fzf = { + enable = true; + enableZshIntegration = true; + }; + }; +} diff --git a/horsch/git.nix b/horsch/git.nix new file mode 100644 index 0000000..b843736 --- /dev/null +++ b/horsch/git.nix @@ -0,0 +1,126 @@ +{ pkgs, ... }: + +{ + programs = { + less.enable = true; + + git = { + enable = true; + + userName = "Michael Mandl"; + userEmail = "michael.mandl@horsch.com"; + + signing = { + key = "088ED38F036C7AF2"; + signByDefault = true; + }; + + difftastic = { + enable = true; + background = "light"; + }; + + lfs = { + enable = true; + }; + + extraConfig = { + core.editor = "nvim"; + core.pager = "less -FX"; + + credential.helper = "cache --timeout=3600"; + + diff.ignoreSubmodules = "none"; + + fetch.writeCommitGraph = true; + fetch.recurseSubmodules = true; + + format.pretty = "format:%C(yellow)%h %Cblue%>(12)%ad %C(red)%G? %Cgreen%<(7,trunc)%aN%Cred%d %Creset%s"; + + init.defaultBranch = "main"; + + log.date = "relative"; + + merge.ff = false; + merge.tool = "nvim"; + + mergetool.nvim.cmd = "nvim -f -c \"Gdiffsplit!\" \"$MERGED\""; + mergetool.prompt = false; + + pager.difftool = true; + + pull.rebase = true; + + push.recurseSubmodules = "on-demand"; + + rebase.autostash = true; + + rerere.enabled = true; + + status.submoduleSummary = true; + + submodule.recurse = true; + + worktree.guessRemote = true; + }; + + aliases = { + graph = "log --graph --all --max-count 32"; + }; + + ignores = [ + ".env" + ".direnv" + "*.swp" + ]; + }; + }; + + home.packages = with pkgs; [ + (writeShellScriptBin "git-clone-worktree" '' + + uri=''${1} + dir=''${2} + + if [[ -z ''${dir} ]]; then + dir=''$(basename ''${1} .git) + fi + + if [[ -e ''${dir} ]]; then + echo "error: directory ''${dir} already exists" + exit 1 + fi + + mkdir ''${dir} + git clone ''${uri} ''${dir}/.base + + branch=`git -C ''${dir}/.base symbolic-ref --short HEAD` + echo "default branch is ''${branch}" + + git -C ''${dir}/.base checkout --detach HEAD + git -C ''${dir}/.base worktree add ../''${branch} + '') + + (writeShellScriptBin "git-make-relative" '' + + gitfile=''${1} + + if [[ -z ''${gitfile} ]]; then + gitfile=".git" + fi + + if [[ ! -f ''${gitfile} ]]; then + echo "file ''${gitfile} does not exist" + exit 1 + fi + + gitdir=$(grep "gitdir:" ''${gitfile} | cut -d: -f2 | xargs) + rel_gitdir=$(realpath -s --relative-to=. ''${gitdir}) + + echo "relative path: ''${rel_gitdir}" + + sed -i -e "s,gitdir:.*,gitdir: ''${rel_gitdir}," ''${gitfile} + '') + ]; +} + diff --git a/horsch/gpg/default.nix b/horsch/gpg/default.nix new file mode 100644 index 0000000..9adcf94 --- /dev/null +++ b/horsch/gpg/default.nix @@ -0,0 +1,43 @@ +{ pkgs, ... }: + +{ + services.gpg-agent = { + enable = true; + enableZshIntegration = true; + pinentryPackage = pkgs.pinentry-curses; + enableSshSupport = true; + sshKeys = [ + "AEB2BF3FF9CF9529E9A3C6F1A202D21686FF9278" + ]; + defaultCacheTtl = 3600 * 12; + defaultCacheTtlSsh = 3600 * 12; + maxCacheTtl = 3600 * 12; + maxCacheTtlSsh = 3600 * 12; + extraConfig = '' + allow-loopback-pinentry + ''; + }; + + programs.gpg = { + enable = true; + mutableKeys = false; + mutableTrust = false; + settings = { + pinentry-mode = "loopback"; + }; + publicKeys = [ + { + source = ./molez.pub.asc; + trust = "ultimate"; + } + { + source = ./vi-bim.pub.asc; + trust = "ultimate"; + } + { + source = ./horsch.pub.asc; + trust = "ultimate"; + } + ]; + }; +} diff --git a/horsch/gpg/horsch.pub.asc b/horsch/gpg/horsch.pub.asc new file mode 100644 index 0000000..c48050b --- /dev/null +++ b/horsch/gpg/horsch.pub.asc @@ -0,0 +1,51 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGY9z3YBDACrIG26NDCvf+HV4V6LiePgvRoC4lEqaUvrf9USsTvbLA7WQdTm +KagTM4rI3H7R1VzJmbQSpFRdue1JaO4wAqTlbYTJNOxJrYdH/dBvMXq+flMGlbsq +jzsWmNW08XzGxC1OiYlnX+xId9EqWdvDH9apCL5MaWh3+c8k3+CSZdhQzcbIT+Lw +Tl2epyV5KytQmpK6Ov0XCt0doNqzwGelsQZudJ2APKTYYVob7BgYjZ4kv92eaCcp +0VoRRQV3kZrXwMRZ5vieIZQVIYlh3lXA8WKS18XBjsZqgSzF/PEHoH64f+KP8D0v +nh9H9zV+aKjc+lyptCB1mJNUfEprWVpvNImLlL+JC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+W9/8Aznmf85EqMagD1nF4+yaIiOGqYvyCy/+HWwRXsTd/QyYwrXQ5DMRmXOqAcYe +pe/diOTmFXH9OMyf6PkN589WD3DAYjWC5neYNsOoJjMzeWEOcXhuJhR6+ewmUhDe +5Ji9bwpK+Hlm32ptE6xk4XJOsls8jqcRCExcxmW2fqF9GjSUuCoNWN87Jloplcjm +WsoyoqWpxCTjcvm/OpKzzSVM20Cdov+H08eAzLsWATLqfSNrEfIaT7CuWTRvdLuS +q56wtFxsa8X2Id129EJuWyD/7yIfzuHrUdbVkCHpxU+h92RFmYfB6fcE4AydJWOc +50y5pZqcf58Ari+8NryHj0o252Gg2EXi6Wp2QdJxCdUr6baVAKd+olH1i0SP7Hvf +L0+VBbG59VWFuS3G/U0wzobNCP2284mLqkguj2t3sK3V/x4XEaEUPmuKR9PrbEok +K672Cz44DjvnnrXxlxvX7eFsjHgDvgRXoacBaZWyEss= +=oAoO +-----END PGP PUBLIC KEY BLOCK----- diff --git a/horsch/gpg/molez.pub.asc b/horsch/gpg/molez.pub.asc new file mode 100644 index 0000000..4531725 --- /dev/null +++ b/horsch/gpg/molez.pub.asc @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBF75iDUBEADKT7HJf29rKofixOegZt6C4fDWhgJuVa/tT/9CxBewpGuvt2an +JM9eTO2ZUWjcbYc4zNsMppANKyr0+i9tve7f+hA5sXDbUNXXjxJz0tu2L3qToTqK +fkvpy4D5dFQYB/N+9n1JKouXNcZKmoTzH9ur6gxmDTdrKcOzjsJQvFjg/nf3jLzT +kj1REcCFxCqXQBVbnWObnaM/+2coofA11XO8KcA/qyVf2014Vj+LCtg8cYUWwOGn +1nomHkJpqAD1k1wYfiEq+2wwgYP9Qvb1WhHzfpRmLT6C1RR9gqnWdNhkRPNrEXOV +2lIAdKg0JJ2jZaOvblGfSA5ObndgwjCMu+0eE5bwSTYAXKwFoZC8/q78t1q2Wrgt +s9+zUWFQiTltXtGhtwiaZLEmk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JDXV0GyytviSRB8BSvS0Ts+ayzbM0KgUqw6tb +p9ghej2vQImmzvkoF9RSBfe8oyRJ2qP17/uriaqUn4ETYoXyV65j8HPoxs+adyRY +I+yHlCfI27ft9rbTfZavEZSLLlUzqpzs2BfIqRLclwRm5QfIxbyZ2xwH6FCfjv0z +qH8WTFW5iSJpwCzIrVeAKyGawyHuU+Ww6qujJbhKDMzOl/UTyMtpNRnqqH+9sNaU +FuydeynUenih4/FBYwLGYIFM6rHVXCv0OYtOasyriNxCRDqbfT2NtSn8yj0Q8erp +GAcygR/FR37HTF3GRSXG3nlypzZOuaaD35OOpI6265LKPswZB5TbQB+Ggay2p2hU +EgMFmGaH+cxFjfD08CBuWaBQOlPv+1TTpnUAQc/Yx2HsnDJrtkznSN2JXrBNabfj +GBdIZ3fqpsYGf8J3EQf2/weT12oGFjXdjPRcOTu9Dord2AtgZYOdNwDNIJyBciB6 +0bwMRPpj0JE= +=B2N+ +-----END PGP PUBLIC KEY BLOCK----- diff --git a/horsch/gpg/vi-bim.pub.asc b/horsch/gpg/vi-bim.pub.asc new file mode 100644 index 0000000..9b1449f --- /dev/null +++ b/horsch/gpg/vi-bim.pub.asc @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBF75hKEBEADCK0qTyghmaW7P8xw01T7ENVZQknNlvKPpcTzOG50Tt5fzCZ4I +R+ymh1u6OysqNCaF+gAQ9t2hCkCogsTyFG+QovE5kxsbQ8hjRyb18k8a1PGZfijk +X8cm0JZZ8AgvIqrUInMn7gvCU8zXOW5QN53NoDLSHhone6knKjN0GoGcgQlsKlub +c0tUJjoX37A/+SHQk3Ju4kjBsRLL4IERs5CWmmMBconH/9/DNneiOlbEbzwokiTA +Jfr8Cm55zSOksCe6//KzcTuFSoYp6O/L1WnSZp3yT/B+DnzfPUP1ZmjITfa5YA/0 +0j9SAJVujJ90JBieyY+gYPy3uh+uqRmrqtDspuNHfAM7vAgu9AdaPel3IHC0MNIe +JM4b0/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1A4GIanjNoyzhRyeRTebSW3DVj3BtrA +0D7XdrvEQKF05qBwWGv9OwqzoZhX1MRNMqDicS2YFSTYM35jF/kOpeCI50X6UJh+ +TyDZ3CZljfxQf/zEQ0bU4x3SPVAMslzh3Z2qrk+0n8EFxPEhyiJ7HV3AwCjakczT +hv/dhTrG24YEcdpMq4Q3SUbIeM4FdjrDcAZGOsFlDDOt9j6SAWriTcgBTZtV5XvN +QgsTuNwDw1Z36cQtp5JKB8MuryZRd0uA8EU2wjyzKJzDMmON6UWZ0Srpr9GCSiiv +IFeIU2KdW3OH1QyIMn1JrpxRQPiw8AtPWG1kovVye1b3mA90/pfqsQa6u17zl03d +xOhd9UPlPnFPeWBQkVC98lZflOIaR3TgdCuIDkTZVCoRTX889YslErQ17re/Zbqd +ZJJ3wuBZt6CUBRCzG56K5G58adh2Z0oz9vsmPa4lfb6wpje/mIoWQoi/I7/4VAso +3ygTeUGteA== +=Ok46 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/horsch/home.nix b/horsch/home.nix new file mode 100644 index 0000000..84f0575 --- /dev/null +++ b/horsch/home.nix @@ -0,0 +1,40 @@ +{ pkgs, ... }: + +{ + home.username = "mmandl"; + home.homeDirectory = "/home/mmandl"; + + home.stateVersion = "24.05"; # Please read the comment before changing. + + home.sessionVariables = { + EDITOR = "nvim"; + }; + + programs.home-manager.enable = true; + + home.packages = with pkgs; [ + wsl-open + xdg-utils + ]; + + imports = [ + ./bat.nix + ./carapace.nix + ./direnv.nix + ./eza.nix + ./fzf.nix + ./git.nix + ./gpg + ./neovim + ./picocom.nix + ./podman.nix + ./ripgrep.nix + ./rsync.nix + ./shell_aliases.nix + ./ssh.nix + ./starship.nix + ./tree.nix + ./zoxide.nix + ./zsh.nix + ]; +} diff --git a/horsch/neovim/auto-session.lua b/horsch/neovim/auto-session.lua new file mode 100644 index 0000000..25036fa --- /dev/null +++ b/horsch/neovim/auto-session.lua @@ -0,0 +1,3 @@ +require("auto-session").setup { + log_level = "error", +} diff --git a/horsch/neovim/commands.lua b/horsch/neovim/commands.lua new file mode 100644 index 0000000..10e03a5 --- /dev/null +++ b/horsch/neovim/commands.lua @@ -0,0 +1 @@ +vim.api.nvim_create_user_command("BufOnly", "%bd|e#|bd#", {}) diff --git a/horsch/neovim/comment.lua b/horsch/neovim/comment.lua new file mode 100644 index 0000000..5060319 --- /dev/null +++ b/horsch/neovim/comment.lua @@ -0,0 +1 @@ +require('Comment').setup({}) diff --git a/horsch/neovim/dap.lua b/horsch/neovim/dap.lua new file mode 100644 index 0000000..a36d4ee --- /dev/null +++ b/horsch/neovim/dap.lua @@ -0,0 +1,35 @@ +local dap = require("dap") +local dapui = require("dapui") + +dapui.setup() + +vim.fn.sign_define("DapBreakpoint", { text = "🔴", texthl = "", linehl = "", numhl = "" }) + +-- debugging keymaps +vim.keymap.set("n", "", dap.continue, { noremap = true, silent = true }) +vim.keymap.set("n", "", dap.toggle_breakpoint, { noremap = true, silent = true }) +vim.keymap.set("n", "", dap.step_over, { noremap = true, silent = true }) +vim.keymap.set("n", "", dap.step_into, { noremap = true, silent = true }) + +vim.keymap.set("n", "", dap.step_out, { noremap = true, silent = true }) +vim.keymap.set("n", "", dap.step_out, { noremap = true, silent = true }) -- in kitty + +vim.keymap.set("n", "", dapui.eval, { noremap = true, silent = true }) + +-- trigger auto-completion in repl +vim.cmd([[ + augroup TriggerDapReplAutoCompletion + autocmd! + autocmd FileType dap-repl lua require("dap.ext.autocompl").attach() + augroup END +]]) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end diff --git a/horsch/neovim/default.nix b/horsch/neovim/default.nix new file mode 100644 index 0000000..c1501e2 --- /dev/null +++ b/horsch/neovim/default.nix @@ -0,0 +1,177 @@ +{ pkgs, ... }: +let + pkg_src = pkgs; +in +{ + + # symlink for a stable path + home.file.".vscode-extensions/vscode-lldb".source = pkg_src.vscode-extensions.vadimcn.vscode-lldb; + + programs = { + neovim = { + enable = true; + package = pkg_src.neovim-unwrapped; + defaultEditor = true; + plugins = with pkg_src.vimPlugins; [ + # theme + nvim-solarized-lua + + delimitMate + vim-bbye + ansible-vim + + # ui + dressing-nvim + + # session handling + project-nvim + auto-session + + # escape handling + better-escape-nvim + + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + markdown-preview-nvim # use({ "iamcco/markdown-preview.nvim", run = ":call mkdp#util#install()" }) + toggleterm-nvim + nvim-notify + comment-nvim + lualine-nvim + tabline-nvim + indent-blankline-nvim + plenary-nvim + vim-illuminate + registers-nvim + vim-surround + + editorconfig-nvim + + # git + gitsigns-nvim + vim-fugitive + vim-flog + git-blame-nvim + nvim-web-devicons # used by diffview-nvim + + # snippets + friendly-snippets + luasnip + + # auto-completion + nvim-cmp + cmp-nvim-lsp + cmp-buffer + cmp-path + cmp-cmdline + cmp-nvim-lua + cmp_luasnip + cmp-calc + cmp-nvim-lsp-signature-help + + # telescope + telescope-nvim + telescope-fzf-native-nvim + telescope-ui-select-nvim + + # LSP + nvim-lspconfig + lsp-status-nvim + rustaceanvim + neodev-nvim + null-ls-nvim + lsp_lines-nvim + lsp-inlayhints-nvim + + # debugging + nvim-dap + nvim-dap-ui + + # neorg + neorg + neorg-telescope + ]; + + withNodeJs = true; + + extraPackages = with pkg_src; [ + # language servers + lua-language-server + terraform-ls + tflint + bash-language-server + nodePackages.yaml-language-server + nodePackages.prettier + nodePackages.eslint_d + nodePackages.typescript-language-server + nodePackages.typescript + nodePackages.dockerfile-language-server-nodejs + nodePackages.vscode-langservers-extracted + vscode-extensions.vue.volar + lldb + vscode-extensions.vadimcn.vscode-lldb + marksman + clang-tools + cmake-language-server + texlab + nixd + nixpkgs-fmt + bitbake-language-server + (python3.withPackages (ps: with ps; [ + pep8 + autopep8 + python-lsp-server + ])) + pyright + + #clipboard + xclip + ]; + + extraLuaPackages = luaPackages: [ + luaPackages.lua-utils-nvim + luaPackages.pathlib-nvim + ]; + + extraConfig = '' + lua << EOF + vim.o.guifont = "DejaVu Sans Mono:h10" + + if vim.g.neovide then + vim.g.neovide_fullscreen = true + vim.g.neovide_cursor_animation_length = 0.01 + vim.g.neovide_cursor_trail_length = 0.01 + end + + ${builtins.readFile ./keymaps.lua } + ${builtins.readFile ./options.lua } + ${builtins.readFile ./commands.lua } + ${builtins.readFile ./treesitter.lua } + ${builtins.readFile ./lspconfig.lua } + ${builtins.readFile ./auto-session.lua } + ${builtins.readFile ./toggleterm.lua } + ${builtins.readFile ./notify.lua } + ${builtins.readFile ./comment.lua } + ${builtins.readFile ./lualine.lua } + ${builtins.readFile ./tabline.lua } + ${builtins.readFile ./indent-blankline.lua } + ${builtins.readFile ./gitsigns.lua } + ${builtins.readFile ./luasnip.lua } + ${builtins.readFile ./nvim-cmp.lua } + ${builtins.readFile ./telescope.lua } + + ${builtins.readFile ./themes.lua } + vim.opt.background = 'dark' + + ${builtins.readFile ./project-nvim.lua } + ${builtins.readFile ./dap.lua } + ${builtins.readFile ./neorg.lua } + ${builtins.readFile ./illuminate.lua } + + vim.g.gitblame_date_format = "%r" + EOF + ''; + }; + }; +} + + diff --git a/horsch/neovim/gitsigns.lua b/horsch/neovim/gitsigns.lua new file mode 100644 index 0000000..91fa65b --- /dev/null +++ b/horsch/neovim/gitsigns.lua @@ -0,0 +1 @@ +require('gitsigns').setup() diff --git a/horsch/neovim/illuminate.lua b/horsch/neovim/illuminate.lua new file mode 100644 index 0000000..b8dc894 --- /dev/null +++ b/horsch/neovim/illuminate.lua @@ -0,0 +1,8 @@ +local illuminate = require("illuminate") + +illuminate.configure({ + providers = { + "lsp", "treesitter", "regex", + }, + under_cursor = true, +}) diff --git a/horsch/neovim/indent-blankline.lua b/horsch/neovim/indent-blankline.lua new file mode 100644 index 0000000..6a6404f --- /dev/null +++ b/horsch/neovim/indent-blankline.lua @@ -0,0 +1,5 @@ +require("ibl").setup { + indent = { + char = "┊", + }, +} diff --git a/horsch/neovim/keymaps.lua b/horsch/neovim/keymaps.lua new file mode 100644 index 0000000..18b7360 --- /dev/null +++ b/horsch/neovim/keymaps.lua @@ -0,0 +1,69 @@ +local function nnoremap(key, command) + vim.api.nvim_set_keymap("n", key, command, { noremap = true }) +end + +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Move around windows +nnoremap("", ":wincmd h") +nnoremap("", ":wincmd j") +nnoremap("", ":wincmd k") +nnoremap("", ":wincmd l") + +-- Switch buffers +nnoremap("", ":TablineBufferNext") +nnoremap("", ":TablineBufferPrevious") + +-- fugitive +nnoremap("g", ":0Git") + +-- vim-flog +nnoremap("G", ":Flog -all -date=relative -open-cmd=new") + +-- telescope +local telescope = require("telescope.builtin") +local telescope_themes = require("telescope.themes") +local telescope_projects = require("telescope").extensions.projects + +local function map_telescope(key, telescope_function) + vim.api.nvim_set_keymap("n", key, "", { + noremap = true, + callback = function() + local theme = telescope_themes.get_dropdown({ layout_config = { width = 0.9 } }) + telescope_function(theme) + end, + }) +end + +map_telescope("ff", telescope.find_files) +map_telescope("fb", telescope.buffers) +map_telescope("fg", telescope.git_files) +map_telescope("fp", telescope_projects.projects) +map_telescope("fs", telescope.lsp_document_symbols) +map_telescope("fS", telescope.lsp_dynamic_workspace_symbols) +map_telescope("", telescope.grep_string) +map_telescope("", telescope.live_grep) + +-- terminal +vim.api.nvim_create_autocmd("TermOpen", { + pattern = "term://*", + callback = function() + local opts = { noremap = true } + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) + end, + desc = "Map terminal esc and window switch keys", +}) + +-- buffer closing +nnoremap("gq", ":Bdelete") + +-- toggle search highlighting +vim.cmd('nnoremap * v:hlsearch ? ":nohlsearch" : "*"') + +-- insert-map jj/jk to escape +require("better_escape").setup() diff --git a/horsch/neovim/lspconfig.lua b/horsch/neovim/lspconfig.lua new file mode 100644 index 0000000..5c63236 --- /dev/null +++ b/horsch/neovim/lspconfig.lua @@ -0,0 +1,200 @@ +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local on_attach = function(client, bufnr) + local function nnoremap(key, command) + vim.keymap.set("n", key, command, { noremap = true, silent = true, buffer = bufnr }) + end + + local function format_buffer() + vim.lsp.buf.format({ + timeout_ms = 3000, + async = false, + filter = function(formatter) + return formatter.name ~= "tsserver" and formatter.name ~= "volar" + end + }) + end + + require("lsp-inlayhints").on_attach(client, bufnr) + + local telescope = require("telescope.builtin") + + nnoremap("gD", vim.lsp.buf.declaration) + nnoremap("gd", telescope.lsp_definitions) + nnoremap("gt", telescope.lsp_type_definitions) + nnoremap("gi", telescope.lsp_implementations) + nnoremap("gr", telescope.lsp_references) + nnoremap("K", vim.lsp.buf.hover) + nnoremap("rn", vim.lsp.buf.rename) + nnoremap("ca", vim.lsp.buf.code_action) + nnoremap("f", format_buffer) + nnoremap("d", telescope.diagnostics) + nnoremap("D", require("lsp_lines").toggle) + nnoremap("", vim.diagnostic.goto_prev) + nnoremap("", vim.diagnostic.goto_next) + nnoremap("", ":ClangdSwitchSourceHeader") + + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = format_buffer, + }) + end +end + +require("lsp-inlayhints").setup({}) + +local lsp_status = require("lsp-status") +lsp_status.config({ + current_function = false, + show_filename = false, + diagnostics = true, + status_symbol = "", +}) +lsp_status.register_progress() + +-- setup lua language server for init.nvim and nvim plugin development +require("neodev").setup({ + override = function(root_dir, options) + if require("neodev.util").has_file(root_dir, "/etc/nixos") then + options.enabled = true + options.plugins = true + end + end, +}) + +local capabilities = require("cmp_nvim_lsp").default_capabilities(lsp_status.capabilities) + +local servers = { + ["bashls"] = {}, + ["bitbake_language_server"] = {}, + ["clangd"] = {}, + ["cmake"] = {}, + ["dockerls"] = {}, + ["eslint"] = {}, + ["html"] = {}, + ["jsonls"] = {}, + ["lua_ls"] = { + Lua = { + runtime = { + version = "LuaJIT", + }, + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + format = { + enable = true, + defaultConfig = { + indent_style = "space", + indent_size = "2", + }, + }, + }, + }, + ["marksman"] = {}, + ["nixd"] = {}, + ["pylsp"] = { + pylsp = { + plugins = { + autopep8 = { + enabled = true + }, + flake8 = { + enabled = true + }, + pycodestyle = { + maxLineLength = 120, + enabled = true, + } + } + } + }, + ["pyright"] = {}, + ["terraformls"] = {}, + ["texlab"] = {}, + ["tflint"] = {}, + ["tsserver"] = {}, + ["yamlls"] = { + yaml = { + keyOrdering = false + } + }, +} + +local lspconfig = require("lspconfig") + +for lsp, settings in pairs(servers) do + lspconfig[lsp].setup({ + settings = settings, + on_attach = on_attach, + capabilities = capabilities, + }) +end + +-- setup rustaceanvim +vim.g.rustaceanvim = { + server = { + on_attach = on_attach, + settings = { + ["rust-analyzer"] = { + cargo = { + loadOutDirsFromCheck = true, + }, + checkOnSave = { command = "clippy" }, + procMacro = { + enable = true, + }, + }, + }, + }, +} + +-- setup null-ls for markdown formatting +local null_ls = require("null-ls") +null_ls.setup({ + sources = { + null_ls.builtins.formatting.prettier, + null_ls.builtins.diagnostics.tsc, + }, + on_attach = on_attach, +}) + +-- setup lsp_lines +require("lsp_lines").setup() + +-- setup vim diagnostics +vim.diagnostic.config({ + virtual_text = false, + signs = true, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + border = "rounded", + source = true, + header = "", + prefix = "", + }, +}) + +-- setup diagnostics signs +local diagnostics_signs = { Error = "", Warn = "", Hint = "", Info = "" } +for type, icon in pairs(diagnostics_signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + +-- setup volar +lspconfig["volar"].setup({ + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' }, + on_attach = on_attach, + capabilities = capabilities, +}) diff --git a/horsch/neovim/lualine.lua b/horsch/neovim/lualine.lua new file mode 100644 index 0000000..0c20c9b --- /dev/null +++ b/horsch/neovim/lualine.lua @@ -0,0 +1,7 @@ +require('lualine').setup({ + options = { globalstatus = true }, + sections = { + lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" } + }, + extensions = { "toggleterm" } +}) diff --git a/horsch/neovim/luasnip.lua b/horsch/neovim/luasnip.lua new file mode 100644 index 0000000..80309d7 --- /dev/null +++ b/horsch/neovim/luasnip.lua @@ -0,0 +1 @@ +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/horsch/neovim/neorg.lua b/horsch/neovim/neorg.lua new file mode 100644 index 0000000..4b33c51 --- /dev/null +++ b/horsch/neovim/neorg.lua @@ -0,0 +1,16 @@ +local neorg = require("neorg") + +neorg.setup({ + load = { + ["core.defaults"] = {}, + ["core.concealer"] = {}, + ["core.dirman"] = { + config = { + workspaces = { + notes = "~/notes", + }, + default_workspace = "notes", + }, + }, + } +}) diff --git a/horsch/neovim/notify.lua b/horsch/neovim/notify.lua new file mode 100644 index 0000000..6fd7a22 --- /dev/null +++ b/horsch/neovim/notify.lua @@ -0,0 +1,2 @@ +require("notify").setup({ stages = "fade" }) +vim.notify = require("notify") diff --git a/horsch/neovim/nvim-cmp.lua b/horsch/neovim/nvim-cmp.lua new file mode 100644 index 0000000..6be73a3 --- /dev/null +++ b/horsch/neovim/nvim-cmp.lua @@ -0,0 +1,87 @@ +local has_words_before = function() + 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 + +local cmp = require("cmp") +local luasnip = require("luasnip") + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "nvim_lsp_signature_help" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer" }, + { name = "nvim-lua" }, + { name = "calc" }, + }), + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + 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() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + experimental = { ghost_text = true }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + fields = { "menu", "abbr", "kind" }, + format = function(entry, item) + local menu_icon = { + nvim_lsp = "λ", + luasnip = "⋗", + buffer = "Ω", + path = "🖿", + } + + item.menu = menu_icon[entry.source.name] + return item + end, + }, +}) + +-- `/` cmdline setup. +cmp.setup.cmdline("/", { + sources = cmp.config.sources( + { name = "buffer" } + ) +}) + +-- `:` cmdline setup. +cmp.setup.cmdline(":", { + sources = cmp.config.sources( + { name = "path" }, + { name = "cmdline" } + ) +}) diff --git a/horsch/neovim/options.lua b/horsch/neovim/options.lua new file mode 100644 index 0000000..3ac11ae --- /dev/null +++ b/horsch/neovim/options.lua @@ -0,0 +1,61 @@ +-- termguicolors +vim.opt.termguicolors = true + +-- line numbers +vim.opt.number = true + +-- tabwidth +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 + +-- indent with spaces +vim.opt.expandtab = true + +-- scroll offset +vim.opt.scrolloff = 4 + +-- don't warp lines +vim.opt.wrap = false + +-- split to right/below +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- presistent undo +vim.opt.undofile = true + +-- searching +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- preview commands +vim.opt.inccommand = "split" + +-- completion +vim.opt.completeopt = "menu,menuone,noselect" + +-- folding +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' +vim.opt.foldlevelstart = 99 + +-- disable mouse +vim.opt.mouse = "" + +-- set cursorline in active window +vim.cmd([[ + augroup CursorLine + autocmd! + autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline + autocmd WinLeave * setlocal nocursorline + augroup END +]]) + +-- configure terminal +vim.cmd([[ + augroup terminal_setup + autocmd! + autocmd TermOpen * startinsert + autocmd TermOpen * setlocal nonumber norelativenumber + augroup END +]]) diff --git a/horsch/neovim/project-nvim.lua b/horsch/neovim/project-nvim.lua new file mode 100644 index 0000000..3b5902f --- /dev/null +++ b/horsch/neovim/project-nvim.lua @@ -0,0 +1 @@ +require('project_nvim').setup({}) diff --git a/horsch/neovim/tabline.lua b/horsch/neovim/tabline.lua new file mode 100644 index 0000000..74da8bb --- /dev/null +++ b/horsch/neovim/tabline.lua @@ -0,0 +1 @@ +require('tabline').setup({ enable = true, options = { show_bufnr = true, show_filename_only = true } }) diff --git a/horsch/neovim/telescope.lua b/horsch/neovim/telescope.lua new file mode 100644 index 0000000..ef9245d --- /dev/null +++ b/horsch/neovim/telescope.lua @@ -0,0 +1,29 @@ +local telescope = require("telescope") +local actions = require("telescope.actions") +local themes = require("telescope.themes") + +telescope.setup({ + defaults = { + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.close, + [""] = actions.close + }, + n = { + [""] = actions.close, + [""] = actions.close + } + } + }, + extensions = { + ["ui-select"] = { + themes.get_dropdown({}) + }, + } +}) + +telescope.load_extension("fzf") +telescope.load_extension("ui-select") +telescope.load_extension("projects") diff --git a/horsch/neovim/themes.lua b/horsch/neovim/themes.lua new file mode 100644 index 0000000..8d0b48e --- /dev/null +++ b/horsch/neovim/themes.lua @@ -0,0 +1 @@ +vim.cmd("colorscheme solarized") diff --git a/horsch/neovim/toggleterm.lua b/horsch/neovim/toggleterm.lua new file mode 100644 index 0000000..37cbe4c --- /dev/null +++ b/horsch/neovim/toggleterm.lua @@ -0,0 +1 @@ +require("toggleterm").setup({ size = 32, open_mapping = [[]] }) diff --git a/horsch/neovim/treesitter.lua b/horsch/neovim/treesitter.lua new file mode 100644 index 0000000..a9750c6 --- /dev/null +++ b/horsch/neovim/treesitter.lua @@ -0,0 +1,93 @@ +require('nvim-treesitter.configs').setup({ + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + node_decremental = "", + scope_incremental = false, + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, + ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, + ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, + ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, + + ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" }, + ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" }, + + ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, + ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, + + ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, + ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, + + ["af"] = { query = "@call.outer", desc = "Select outer part of a function call" }, + ["if"] = { query = "@call.inner", desc = "Select inner part of a function call" }, + + ["am"] = { query = "@function.outer", desc = "Select outer part of a method/function definition" }, + ["im"] = { query = "@function.inner", desc = "Select inner part of a method/function definition" }, + + ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]f"] = { query = "@call.outer", desc = "Next function call start" }, + ["]m"] = { query = "@function.outer", desc = "Next method/function def start" }, + ["]c"] = { query = "@class.outer", desc = "Next class start" }, + ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, + ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, + + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_next_end = { + ["]F"] = { query = "@call.outer", desc = "Next function call end" }, + ["]M"] = { query = "@function.outer", desc = "Next method/function def end" }, + ["]C"] = { query = "@class.outer", desc = "Next class end" }, + ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, + ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, + }, + goto_previous_start = { + ["[f"] = { query = "@call.outer", desc = "Prev function call start" }, + ["[m"] = { query = "@function.outer", desc = "Prev method/function def start" }, + ["[c"] = { query = "@class.outer", desc = "Prev class start" }, + ["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" }, + ["[l"] = { query = "@loop.outer", desc = "Prev loop start" }, + }, + goto_previous_end = { + ["[F"] = { query = "@call.outer", desc = "Prev function call end" }, + ["[M"] = { query = "@function.outer", desc = "Prev method/function def end" }, + ["[C"] = { query = "@class.outer", desc = "Prev class end" }, + ["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" }, + ["[L"] = { query = "@loop.outer", desc = "Prev loop end" }, + }, + }, + lsp_interop = { + enable = true, + border = 'none', + floating_preview_opts = {}, + peek_definition_code = { + ["df"] = "@function.outer", + ["dF"] = "@class.outer", + }, + }, + }, + }, +}) diff --git a/horsch/picocom.nix b/horsch/picocom.nix new file mode 100644 index 0000000..3194059 --- /dev/null +++ b/horsch/picocom.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +{ + home.packages = [ pkgs.picocom ]; +} diff --git a/horsch/podman.nix b/horsch/podman.nix new file mode 100644 index 0000000..8cdbd28 --- /dev/null +++ b/horsch/podman.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +{ + home.packages = [ pkgs.podman ]; +} diff --git a/horsch/ripgrep.nix b/horsch/ripgrep.nix new file mode 100644 index 0000000..feb6335 --- /dev/null +++ b/horsch/ripgrep.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + programs = { + ripgrep = { + enable = true; + }; + }; +} diff --git a/horsch/rsync.nix b/horsch/rsync.nix new file mode 100644 index 0000000..f1cef88 --- /dev/null +++ b/horsch/rsync.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +{ + home.packages = [ pkgs.rsync ]; +} diff --git a/horsch/shell_aliases.nix b/horsch/shell_aliases.nix new file mode 100644 index 0000000..762ac23 --- /dev/null +++ b/horsch/shell_aliases.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + home.shellAliases = { + g = "git"; + gg = "git graph"; + gs = "git status"; + gd = "git diff"; + k = "kubectl"; + }; +} diff --git a/horsch/ssh.nix b/horsch/ssh.nix new file mode 100644 index 0000000..50a07a7 --- /dev/null +++ b/horsch/ssh.nix @@ -0,0 +1,65 @@ +{ ... }: + +{ + programs = { + ssh = { + enable = true; + matchBlocks = { + SmartCAN = { + host = "smartcan 192.168.5.1"; + user = "root"; + hostname = "192.168.5.1"; + checkHostIP = false; + extraOptions = { + StrictHostKeyChecking = "no"; + UserKnownHostsFile = "/dev/null"; + LogLevel = "ERROR"; + }; + }; + Fusion-USB = { + host = "fusion-usb fusion 172.16.0.1"; + user = "root"; + hostname = "172.16.0.1"; + checkHostIP = false; + extraOptions = { + StrictHostKeyChecking = "no"; + UserKnownHostsFile = "/dev/null"; + LogLevel = "ERROR"; + }; + }; + Fusion-Wifi = { + host = "fusion-wifi 172.16.1.1"; + user = "root"; + hostname = "172.16.1.1"; + checkHostIP = false; + extraOptions = { + StrictHostKeyChecking = "no"; + UserKnownHostsFile = "/dev/null"; + LogLevel = "ERROR"; + }; + }; + Fusion-TX = { + host = "fusion-tx 10.100.30.160"; + user = "root"; + hostname = "10.100.30.160"; + checkHostIP = false; + extraOptions = { + StrictHostKeyChecking = "no"; + UserKnownHostsFile = "/dev/null"; + LogLevel = "ERROR"; + }; + }; + hcvpnde = { + host = "hcvpnde hcvpnde.horsch.com"; + hostname = "hcvpnde.horsch.com"; + }; + smartcan-vpn = { + host = "smartcan3-*"; + user = "root"; + proxyJump = "hcvpnde"; + }; + }; + }; + }; +} + diff --git a/horsch/starship.nix b/horsch/starship.nix new file mode 100644 index 0000000..4cdc31f --- /dev/null +++ b/horsch/starship.nix @@ -0,0 +1,11 @@ +{ lib, ... }: + +{ + programs.starship = { + enable = true; + settings = { + format = lib.concatStrings [ "$all" "$directory" "$character" ]; + hostname.format = "[$ssh_symbol$hostname]($style) "; + }; + }; +} diff --git a/horsch/tree.nix b/horsch/tree.nix new file mode 100644 index 0000000..0a8fb13 --- /dev/null +++ b/horsch/tree.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +{ + home.packages = [ pkgs.tree ]; +} diff --git a/horsch/zoxide.nix b/horsch/zoxide.nix new file mode 100644 index 0000000..435b381 --- /dev/null +++ b/horsch/zoxide.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + programs.zoxide = { + enable = true; + enableZshIntegration = true; + }; +} + diff --git a/horsch/zsh.nix b/horsch/zsh.nix new file mode 100644 index 0000000..5588dff --- /dev/null +++ b/horsch/zsh.nix @@ -0,0 +1,68 @@ +{ ... }: +{ + programs.zsh = { + enable = true; + enableCompletion = true; + history.size = 10000; + + autosuggestion = { + enable = true; + highlight = "fg=10"; + }; + + syntaxHighlighting = { + enable = true; + }; + + initExtra = '' + if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; + then + source $HOME/.nix-profile/etc/profile.d/nix.sh + fi + + function sc-log { + ssh smartcan "SYSTEMD_COLORS=true journalctl --follow --no-tail --unit smartcan-''${1:-*}" + } + + function sc-restart { + ssh smartcan "systemctl restart smartcan-''${1}" + } + + function fu-reboot { + ssh fusion "reboot" + } + + function fu-flash { + local ssh_login="fusion" + local update_file=''${1} + + if [ -z ''${update_file} ]; then + update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1) + fi + + if [ -z ''${update_file} ]; then + echo "no file selected" + return 1 + fi + + if [ ! -f ''${update_file} ]; then + echo "file \"''${update_file}\" does not exist" + return 2 + fi + + echo "flashing ''${update_file} to device..." + cat "''${update_file}" | ssh ''${ssh_login} "swupdate-client -" + + if [ $? -ne 0 ]; then + echo "update failed" + return 3 + fi + + echo "rebooting device" + ssh ''${ssh_login} reboot + + echo "done." + } + ''; + }; +}