From e6051a38a672182c7f7dfa083ca1e72b97803c94 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Fri, 25 Mar 2022 23:38:13 -0500 Subject: feat: migrated to gnu stow --- .stowrc | 4 + alacritty/.config/alacritty/alacritty.yml | 45 ++ alacritty/.config/alacritty/colors.yml | 60 +++ alacritty/.config/alacritty/fonts.yml | 13 + alacritty/alacritty.yml | 45 -- alacritty/colors.yml | 60 --- alacritty/fonts.yml | 13 - bash/.bashrc | 25 + bash/.config/bash/aliases.sh | 1 + bash/.config/bash/env.sh | 1 + bash/aliases.sh | 36 -- bash/env.sh | 19 - bashrc | 24 - bat.conf | 25 - bat/.config/bat/config | 25 + bin/fzf-tmux | 234 --------- bin/tm | 13 - bin/tmux-sessionizer | 26 - bin/tmux-windowizer | 14 - docs/git.md | 99 ---- docs/yubikey.md | 88 ---- git.md | 99 ++++ git/.gitconfig | 87 ++++ gitconfig | 87 ---- gnupg/.gnupg/gpg-agent.conf | 2 + gnupg/.gnupg/gpg.conf | 64 +++ gnupg/.gnupg/scdaemon.conf | 2 + gnupg/.gnupg/trustfile.txt | 3 + gnupg/gpg-agent.conf | 2 - gnupg/gpg.conf | 64 --- gnupg/scdaemon.conf | 2 - gnupg/trustfile.txt | 3 - install | 15 - install.conf.yaml | 185 ------- installers/docker-compose.sh | 10 - justfile | 105 +++- navi.yaml | 32 -- nvim/.config/nvim/init.lua | 7 + nvim/.config/nvim/lua/autocommands.lua | 55 +++ nvim/.config/nvim/lua/icons.lua | 106 ++++ nvim/.config/nvim/lua/mappings.lua | 193 ++++++++ nvim/.config/nvim/lua/options.lua | 75 +++ nvim/.config/nvim/lua/plugins.lua | 279 +++++++++++ nvim/.config/nvim/lua/plugins/alpha.lua | 56 +++ nvim/.config/nvim/lua/plugins/blankline.lua | 11 + nvim/.config/nvim/lua/plugins/bufferline.lua | 82 ++++ nvim/.config/nvim/lua/plugins/cmp.lua | 119 +++++ nvim/.config/nvim/lua/plugins/dap.lua | 89 ++++ nvim/.config/nvim/lua/plugins/git-blame.lua | 3 + nvim/.config/nvim/lua/plugins/git-worktree.lua | 14 + nvim/.config/nvim/lua/plugins/gitsigns.lua | 48 ++ nvim/.config/nvim/lua/plugins/lsp-installer.lua | 124 +++++ nvim/.config/nvim/lua/plugins/lsp-signature.lua | 59 +++ nvim/.config/nvim/lua/plugins/lspconfig.lua | 97 ++++ nvim/.config/nvim/lua/plugins/lspkind.lua | 34 ++ nvim/.config/nvim/lua/plugins/lspstatus.lua | 13 + nvim/.config/nvim/lua/plugins/lualine.lua | 113 +++++ nvim/.config/nvim/lua/plugins/luasnip.lua | 18 + nvim/.config/nvim/lua/plugins/neogit.lua | 6 + nvim/.config/nvim/lua/plugins/null-ls.lua | 47 ++ nvim/.config/nvim/lua/plugins/nvim-tree.lua | 111 +++++ nvim/.config/nvim/lua/plugins/project.lua | 13 + nvim/.config/nvim/lua/plugins/renamer.lua | 46 ++ nvim/.config/nvim/lua/plugins/session_manager.lua | 25 + nvim/.config/nvim/lua/plugins/telescope.lua | 55 +++ nvim/.config/nvim/lua/plugins/treesitter.lua | 14 + nvim/.config/nvim/lua/plugins/which-key.lua | 34 ++ nvim/.config/nvim/lua/utils.lua | 9 + nvim/.config/nvim/plugin/packer_compiled.lua | 572 ++++++++++++++++++++++ nvim/init.lua | 7 - nvim/lua/autocommands.lua | 55 --- nvim/lua/icons.lua | 106 ---- nvim/lua/mappings.lua | 193 -------- nvim/lua/options.lua | 75 --- nvim/lua/plugins.lua | 279 ----------- nvim/lua/plugins/alpha.lua | 56 --- nvim/lua/plugins/blankline.lua | 11 - nvim/lua/plugins/bufferline.lua | 82 ---- nvim/lua/plugins/cmp.lua | 119 ----- nvim/lua/plugins/dap.lua | 89 ---- nvim/lua/plugins/git-blame.lua | 3 - nvim/lua/plugins/git-worktree.lua | 14 - nvim/lua/plugins/gitsigns.lua | 48 -- nvim/lua/plugins/lsp-installer.lua | 124 ----- nvim/lua/plugins/lsp-signature.lua | 59 --- nvim/lua/plugins/lspconfig.lua | 97 ---- nvim/lua/plugins/lspkind.lua | 34 -- nvim/lua/plugins/lspstatus.lua | 13 - nvim/lua/plugins/lualine.lua | 113 ----- nvim/lua/plugins/luasnip.lua | 18 - nvim/lua/plugins/neogit.lua | 6 - nvim/lua/plugins/null-ls.lua | 47 -- nvim/lua/plugins/nvim-tree.lua | 111 ----- nvim/lua/plugins/project.lua | 13 - nvim/lua/plugins/renamer.lua | 46 -- nvim/lua/plugins/session_manager.lua | 25 - nvim/lua/plugins/telescope.lua | 55 --- nvim/lua/plugins/treesitter.lua | 14 - nvim/lua/plugins/which-key.lua | 34 -- nvim/lua/utils.lua | 9 - nvim/plugin/packer_compiled.lua | 572 ---------------------- scripts/.scripts/discord-relay.sh | 2 + scripts/.scripts/git-split.sh | 208 ++++++++ scripts/.scripts/gpg-test.sh | 102 ++++ scripts/.scripts/init-git.sh | 193 ++++++++ scripts/.scripts/init-latex.sh | 11 + scripts/.scripts/install-crate.sh | 235 +++++++++ scripts/.scripts/mega-dl.sh | 121 +++++ scripts/.scripts/mkln.sh | 115 +++++ scripts/.scripts/socket-relay.sh | 217 ++++++++ scripts/.scripts/td.sh | 151 ++++++ scripts/discord-relay.sh | 2 - scripts/git-split.sh | 208 -------- scripts/gpg-test.sh | 102 ---- scripts/init-git.sh | 193 -------- scripts/init-latex.sh | 11 - scripts/install-crate.sh | 235 --------- scripts/mega-dl.sh | 121 ----- scripts/mkln.sh | 115 ----- scripts/socket-relay.sh | 217 -------- scripts/td.sh | 151 ------ scripts/yt.sh | 5 - ssh/.ssh/config | 66 +++ ssh/config | 66 --- ssh/wsl2-ssh-pageant.exe | Bin 3613696 -> 0 bytes starship.toml | 123 ----- starship/.config/starship.toml | 123 +++++ tmux.conf | 18 - tmux/.local/bin/tm | 13 + tmux/.local/bin/tmux-sessionizer | 26 + tmux/.local/bin/tmux-windowizer | 14 + tmux/.tmux.conf | 18 + update | 5 - winget.json | 28 -- wsl.install | 68 --- wsl/.config/zsh/gpg.sh | 66 +++ wsl/.config/zsh/wsl.sh | 57 +++ wsl/.ssh/wsl2-ssh-pageant.exe | Bin 0 -> 3613696 bytes wsl/gpg.sh | 66 --- wsl/install.sh | 68 +++ wsl/install/winget.json | 28 ++ wsl/install/wt.json | 389 +++++++++++++++ wsl/wsl.sh | 57 --- wt.json | 389 --------------- yubikey.md | 88 ++++ zsh/.config/zsh/aliases.sh | 30 ++ zsh/.config/zsh/env.sh | 24 + zsh/.zshrc | 132 +++++ zsh/keybindings.zsh | 116 ----- zshrc | 65 --- 150 files changed, 5542 insertions(+), 6002 deletions(-) create mode 100644 .stowrc create mode 100644 alacritty/.config/alacritty/alacritty.yml create mode 100644 alacritty/.config/alacritty/colors.yml create mode 100644 alacritty/.config/alacritty/fonts.yml delete mode 100644 alacritty/alacritty.yml delete mode 100644 alacritty/colors.yml delete mode 100644 alacritty/fonts.yml create mode 100644 bash/.bashrc create mode 120000 bash/.config/bash/aliases.sh create mode 120000 bash/.config/bash/env.sh delete mode 100644 bash/aliases.sh delete mode 100644 bash/env.sh delete mode 100644 bashrc delete mode 100644 bat.conf create mode 100644 bat/.config/bat/config delete mode 100755 bin/fzf-tmux delete mode 100755 bin/tm delete mode 100755 bin/tmux-sessionizer delete mode 100755 bin/tmux-windowizer delete mode 100644 docs/git.md delete mode 100644 docs/yubikey.md create mode 100644 git.md create mode 100644 git/.gitconfig delete mode 100644 gitconfig create mode 100644 gnupg/.gnupg/gpg-agent.conf create mode 100755 gnupg/.gnupg/gpg.conf create mode 100755 gnupg/.gnupg/scdaemon.conf create mode 100644 gnupg/.gnupg/trustfile.txt delete mode 100644 gnupg/gpg-agent.conf delete mode 100755 gnupg/gpg.conf delete mode 100755 gnupg/scdaemon.conf delete mode 100644 gnupg/trustfile.txt delete mode 100755 install delete mode 100644 install.conf.yaml delete mode 100755 installers/docker-compose.sh delete mode 100644 navi.yaml create mode 100644 nvim/.config/nvim/init.lua create mode 100644 nvim/.config/nvim/lua/autocommands.lua create mode 100644 nvim/.config/nvim/lua/icons.lua create mode 100644 nvim/.config/nvim/lua/mappings.lua create mode 100644 nvim/.config/nvim/lua/options.lua create mode 100644 nvim/.config/nvim/lua/plugins.lua create mode 100644 nvim/.config/nvim/lua/plugins/alpha.lua create mode 100644 nvim/.config/nvim/lua/plugins/blankline.lua create mode 100644 nvim/.config/nvim/lua/plugins/bufferline.lua create mode 100644 nvim/.config/nvim/lua/plugins/cmp.lua create mode 100644 nvim/.config/nvim/lua/plugins/dap.lua create mode 100644 nvim/.config/nvim/lua/plugins/git-blame.lua create mode 100644 nvim/.config/nvim/lua/plugins/git-worktree.lua create mode 100644 nvim/.config/nvim/lua/plugins/gitsigns.lua create mode 100644 nvim/.config/nvim/lua/plugins/lsp-installer.lua create mode 100644 nvim/.config/nvim/lua/plugins/lsp-signature.lua create mode 100644 nvim/.config/nvim/lua/plugins/lspconfig.lua create mode 100644 nvim/.config/nvim/lua/plugins/lspkind.lua create mode 100644 nvim/.config/nvim/lua/plugins/lspstatus.lua create mode 100644 nvim/.config/nvim/lua/plugins/lualine.lua create mode 100644 nvim/.config/nvim/lua/plugins/luasnip.lua create mode 100644 nvim/.config/nvim/lua/plugins/neogit.lua create mode 100644 nvim/.config/nvim/lua/plugins/null-ls.lua create mode 100644 nvim/.config/nvim/lua/plugins/nvim-tree.lua create mode 100644 nvim/.config/nvim/lua/plugins/project.lua create mode 100644 nvim/.config/nvim/lua/plugins/renamer.lua create mode 100644 nvim/.config/nvim/lua/plugins/session_manager.lua create mode 100644 nvim/.config/nvim/lua/plugins/telescope.lua create mode 100644 nvim/.config/nvim/lua/plugins/treesitter.lua create mode 100644 nvim/.config/nvim/lua/plugins/which-key.lua create mode 100644 nvim/.config/nvim/lua/utils.lua create mode 100644 nvim/.config/nvim/plugin/packer_compiled.lua delete mode 100644 nvim/init.lua delete mode 100644 nvim/lua/autocommands.lua delete mode 100644 nvim/lua/icons.lua delete mode 100644 nvim/lua/mappings.lua delete mode 100644 nvim/lua/options.lua delete mode 100644 nvim/lua/plugins.lua delete mode 100644 nvim/lua/plugins/alpha.lua delete mode 100644 nvim/lua/plugins/blankline.lua delete mode 100644 nvim/lua/plugins/bufferline.lua delete mode 100644 nvim/lua/plugins/cmp.lua delete mode 100644 nvim/lua/plugins/dap.lua delete mode 100644 nvim/lua/plugins/git-blame.lua delete mode 100644 nvim/lua/plugins/git-worktree.lua delete mode 100644 nvim/lua/plugins/gitsigns.lua delete mode 100644 nvim/lua/plugins/lsp-installer.lua delete mode 100644 nvim/lua/plugins/lsp-signature.lua delete mode 100644 nvim/lua/plugins/lspconfig.lua delete mode 100644 nvim/lua/plugins/lspkind.lua delete mode 100644 nvim/lua/plugins/lspstatus.lua delete mode 100644 nvim/lua/plugins/lualine.lua delete mode 100644 nvim/lua/plugins/luasnip.lua delete mode 100644 nvim/lua/plugins/neogit.lua delete mode 100644 nvim/lua/plugins/null-ls.lua delete mode 100644 nvim/lua/plugins/nvim-tree.lua delete mode 100644 nvim/lua/plugins/project.lua delete mode 100644 nvim/lua/plugins/renamer.lua delete mode 100644 nvim/lua/plugins/session_manager.lua delete mode 100644 nvim/lua/plugins/telescope.lua delete mode 100644 nvim/lua/plugins/treesitter.lua delete mode 100644 nvim/lua/plugins/which-key.lua delete mode 100644 nvim/lua/utils.lua delete mode 100644 nvim/plugin/packer_compiled.lua create mode 100755 scripts/.scripts/discord-relay.sh create mode 100755 scripts/.scripts/git-split.sh create mode 100644 scripts/.scripts/gpg-test.sh create mode 100755 scripts/.scripts/init-git.sh create mode 100755 scripts/.scripts/init-latex.sh create mode 100755 scripts/.scripts/install-crate.sh create mode 100755 scripts/.scripts/mega-dl.sh create mode 100755 scripts/.scripts/mkln.sh create mode 100755 scripts/.scripts/socket-relay.sh create mode 100755 scripts/.scripts/td.sh delete mode 100755 scripts/discord-relay.sh delete mode 100755 scripts/git-split.sh delete mode 100644 scripts/gpg-test.sh delete mode 100755 scripts/init-git.sh delete mode 100755 scripts/init-latex.sh delete mode 100755 scripts/install-crate.sh delete mode 100755 scripts/mega-dl.sh delete mode 100755 scripts/mkln.sh delete mode 100755 scripts/socket-relay.sh delete mode 100755 scripts/td.sh delete mode 100755 scripts/yt.sh create mode 100644 ssh/.ssh/config delete mode 100644 ssh/config delete mode 100755 ssh/wsl2-ssh-pageant.exe delete mode 100644 starship.toml create mode 100644 starship/.config/starship.toml delete mode 100644 tmux.conf create mode 100755 tmux/.local/bin/tm create mode 100755 tmux/.local/bin/tmux-sessionizer create mode 100755 tmux/.local/bin/tmux-windowizer create mode 100644 tmux/.tmux.conf delete mode 100755 update delete mode 100755 winget.json delete mode 100755 wsl.install create mode 100755 wsl/.config/zsh/gpg.sh create mode 100644 wsl/.config/zsh/wsl.sh create mode 100755 wsl/.ssh/wsl2-ssh-pageant.exe delete mode 100755 wsl/gpg.sh create mode 100755 wsl/install.sh create mode 100755 wsl/install/winget.json create mode 100644 wsl/install/wt.json delete mode 100644 wsl/wsl.sh delete mode 100644 wt.json create mode 100644 yubikey.md create mode 100644 zsh/.config/zsh/aliases.sh create mode 100644 zsh/.config/zsh/env.sh create mode 100644 zsh/.zshrc delete mode 100644 zsh/keybindings.zsh delete mode 100644 zshrc diff --git a/.stowrc b/.stowrc new file mode 100644 index 0000000..1a2e9fc --- /dev/null +++ b/.stowrc @@ -0,0 +1,4 @@ +--verbose +--no-folding +--ignore=install +--ignore=install.sh \ No newline at end of file diff --git a/alacritty/.config/alacritty/alacritty.yml b/alacritty/.config/alacritty/alacritty.yml new file mode 100644 index 0000000..7a2a4f5 --- /dev/null +++ b/alacritty/.config/alacritty/alacritty.yml @@ -0,0 +1,45 @@ +import: + - ~/.config/alacritty/colors.yml + - ~/.config/alacritty/fonts.yml + - ~/AppData/Roaming/alacritty/colors.yml + - ~/AppData/Roaming/alacritty/fonts.yml + +env: + TERM: alacritty + +window: + dimensions: + columns: 120 + lines: 40 + dynamic_padding: false + decorations: full + title: Alacritty + +scrolling: + history: 10000 + multiplier: 3 + +selection: + semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" + save_to_clipboard: false + +cursor: + blinking: On + +mouse: + hide_when_typing: true + +live_config_reload: true + +shell: + program: C:\WINDOWS\system32\wsl.exe + args: + - -e + - '/bin/zsh -lc "source ~/.zshrc; tmux new -As main"' + +working_directory: '\\wsl$\Debian\home\tobyv' + +key_bindings: + - { key: Space, mods: Control, chars: "\x00" } + - { key: T, mods: Control|Shift, action: CreateNewWindow } + - { key: F, mods: Control|Shift, mode: ~Search, action: ReceiveChar } diff --git a/alacritty/.config/alacritty/colors.yml b/alacritty/.config/alacritty/colors.yml new file mode 100644 index 0000000..dbfcd0e --- /dev/null +++ b/alacritty/.config/alacritty/colors.yml @@ -0,0 +1,60 @@ +schemes: + codelight: &light + primary: + background: '#ffffff' + foreground: '#1e1e1e' + + cursor: + text: '#d4d4d4' + cursor: '#d4d4d4' + + normal: + black: '#1e1e1e' + red: '#c72e0f' + green: '#009000' + yellow: '#795e25' + blue: '#007acc' + magenta: '#af00db' + cyan: '#56b6c2' + white: '#d4d4d4' + + bright: + black: '#1e1e1e' + red: '#c72e0f' + green: '#009000' + yellow: '#795e25' + blue: '#007acc' + magenta: '#af00db' + cyan: '#56b6c2' + white: '#d4d4d4' + + codedark: &dark + primary: + background: '#1e1e1e' + foreground: '#d4d4d4' + + cursor: + text: '#d4d4d4' + cursor: '#d4d4d4' + + normal: + black: '#1e1e1e' + red: '#f44747' + green: '#608b4e' + yellow: '#dcdcaa' + blue: '#569cd6' + magenta: '#c678dd' + cyan: '#56b6c2' + white: '#d4d4d4' + + bright: + black: '#545454' + red: '#f44747' + green: '#608b4e' + yellow: '#dcdcaa' + blue: '#569cd6' + magenta: '#c678dd' + cyan: '#56b6c2' + white: '#d4d4d4' + +colors: *dark \ No newline at end of file diff --git a/alacritty/.config/alacritty/fonts.yml b/alacritty/.config/alacritty/fonts.yml new file mode 100644 index 0000000..70c9b2e --- /dev/null +++ b/alacritty/.config/alacritty/fonts.yml @@ -0,0 +1,13 @@ +font: + normal: + family: FiraCode NF + style: Regular + bold: + family: FiraCode NF + style: Bold + italic: + family: FiraCode NF + style: Italic + bold_italic: + family: FiraCode NF + style: Bold Italic diff --git a/alacritty/alacritty.yml b/alacritty/alacritty.yml deleted file mode 100644 index 7a2a4f5..0000000 --- a/alacritty/alacritty.yml +++ /dev/null @@ -1,45 +0,0 @@ -import: - - ~/.config/alacritty/colors.yml - - ~/.config/alacritty/fonts.yml - - ~/AppData/Roaming/alacritty/colors.yml - - ~/AppData/Roaming/alacritty/fonts.yml - -env: - TERM: alacritty - -window: - dimensions: - columns: 120 - lines: 40 - dynamic_padding: false - decorations: full - title: Alacritty - -scrolling: - history: 10000 - multiplier: 3 - -selection: - semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" - save_to_clipboard: false - -cursor: - blinking: On - -mouse: - hide_when_typing: true - -live_config_reload: true - -shell: - program: C:\WINDOWS\system32\wsl.exe - args: - - -e - - '/bin/zsh -lc "source ~/.zshrc; tmux new -As main"' - -working_directory: '\\wsl$\Debian\home\tobyv' - -key_bindings: - - { key: Space, mods: Control, chars: "\x00" } - - { key: T, mods: Control|Shift, action: CreateNewWindow } - - { key: F, mods: Control|Shift, mode: ~Search, action: ReceiveChar } diff --git a/alacritty/colors.yml b/alacritty/colors.yml deleted file mode 100644 index dbfcd0e..0000000 --- a/alacritty/colors.yml +++ /dev/null @@ -1,60 +0,0 @@ -schemes: - codelight: &light - primary: - background: '#ffffff' - foreground: '#1e1e1e' - - cursor: - text: '#d4d4d4' - cursor: '#d4d4d4' - - normal: - black: '#1e1e1e' - red: '#c72e0f' - green: '#009000' - yellow: '#795e25' - blue: '#007acc' - magenta: '#af00db' - cyan: '#56b6c2' - white: '#d4d4d4' - - bright: - black: '#1e1e1e' - red: '#c72e0f' - green: '#009000' - yellow: '#795e25' - blue: '#007acc' - magenta: '#af00db' - cyan: '#56b6c2' - white: '#d4d4d4' - - codedark: &dark - primary: - background: '#1e1e1e' - foreground: '#d4d4d4' - - cursor: - text: '#d4d4d4' - cursor: '#d4d4d4' - - normal: - black: '#1e1e1e' - red: '#f44747' - green: '#608b4e' - yellow: '#dcdcaa' - blue: '#569cd6' - magenta: '#c678dd' - cyan: '#56b6c2' - white: '#d4d4d4' - - bright: - black: '#545454' - red: '#f44747' - green: '#608b4e' - yellow: '#dcdcaa' - blue: '#569cd6' - magenta: '#c678dd' - cyan: '#56b6c2' - white: '#d4d4d4' - -colors: *dark \ No newline at end of file diff --git a/alacritty/fonts.yml b/alacritty/fonts.yml deleted file mode 100644 index 70c9b2e..0000000 --- a/alacritty/fonts.yml +++ /dev/null @@ -1,13 +0,0 @@ -font: - normal: - family: FiraCode NF - style: Regular - bold: - family: FiraCode NF - style: Bold - italic: - family: FiraCode NF - style: Italic - bold_italic: - family: FiraCode NF - style: Bold Italic diff --git a/bash/.bashrc b/bash/.bashrc new file mode 100644 index 0000000..05a7973 --- /dev/null +++ b/bash/.bashrc @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +export BASHDOTDIR=${XDG_CONFIG_HOME:-$HOME/.config}/bash +export BASHCOMPDIR=${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions + +if [ -d "$BASHDOTDIR" ]; then for f in $BASHDOTDIR/*; do source $f; done; fi +if [ -d "$BASHCOMPDIR" ]; then for f in $BASHCOMPDIR/*; do source $f; done; fi + +command -v starship >/dev/null 2>&1 && eval "$(starship init bash)" + +set_win_title() { + local prefix + + if [ "$USER" != "tobyv" ]; then + prefix="${USER} in " + fi + + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + prefix="${prefix/in/on}${HOST} in " + fi + + echo -ne "\033]0;${prefix}${PWD/$HOME/~}\007" +} + +starship_precmd_user_func="set_win_title" diff --git a/bash/.config/bash/aliases.sh b/bash/.config/bash/aliases.sh new file mode 120000 index 0000000..4fe3952 --- /dev/null +++ b/bash/.config/bash/aliases.sh @@ -0,0 +1 @@ +/home/tobyv/dotfiles/zsh/.config/zsh/aliases.sh \ No newline at end of file diff --git a/bash/.config/bash/env.sh b/bash/.config/bash/env.sh new file mode 120000 index 0000000..306408a --- /dev/null +++ b/bash/.config/bash/env.sh @@ -0,0 +1 @@ +/home/tobyv/dotfiles/zsh/.config/zsh/env.sh \ No newline at end of file diff --git a/bash/aliases.sh b/bash/aliases.sh deleted file mode 100644 index 2dd1b4e..0000000 --- a/bash/aliases.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -alias ls='ls --color=tty' -alias l='ls -lah' -alias la='ls -lAh' -alias ll='ls -lh' -alias lla='ls -lA' -alias lsa='ls -lah' -alias grep='grep --color' -alias ipa="ip -s -c -h a" -alias untar="tar -zxvf" -alias td=". td.sh" -alias vim=nvim -# scripts -alias dfi=~/dotfiles/install -alias dfu=~/dotfiles/update -alias pluto="ssh root@foundry.tobyvin.com /root/foundry/update-plutonium.sh" -#python -alias pip=pip3 -alias python=python3 -# docker -alias dexec="docker exec -it" -alias dps="docker ps" -# docker compose -alias dc="docker compose" -alias dce="docker compose exec" -alias dcps="docker compose ps" -alias dcls="docker compose ls" -alias dcdn="docker compose down" -alias dcup="docker compose up" -alias dcupd="docker compose up -d" -alias dcl="docker compose logs" -alias dclf="docker compose logs -f" -# docker context -alias dct="docker context" -alias dcu="docker context use" diff --git a/bash/env.sh b/bash/env.sh deleted file mode 100644 index 725e07c..0000000 --- a/bash/env.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -export EDITOR="$(command -v vim 2>/dev/null || command -v vi)" -export VISUAL="code --wait" -export GPG_TTY=$(tty) -export MANPAGER="sh -c 'col -bx | bat -l man -p'" -export MANROFFOPT="-c" -export STARSHIP_LOG="error" -export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || tree -C {}" -export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_COMMAND) 2> /dev/null'" -export GOPATH=$HOME/.go - -export PATH=$PATH:$HOME/dotfiles/bin -export PATH=$PATH:$HOME/.local/bin -export PATH=$PATH:$HOME/.go/bin -export PATH=$PATH:$HOME/.dotnet/tools -export PATH=$PATH:$HOME/.cargo/bin -export PATH=$PATH:$HOME/dotfiles/scripts -export PATH=$PATH:/usr/local/texlive/2021/bin/x86_64-linux diff --git a/bashrc b/bashrc deleted file mode 100644 index c8ab133..0000000 --- a/bashrc +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -comp_dir=${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions - -if [ -d "~/.bash" ]; then for f in ~/.bash/*; do source $f; done; fi -if [ -d "$comp_dir" ]; then for f in "$comp_dir"/*; do source $f; done; fi - -command -v starship >/dev/null 2>&1 && eval "$(starship init bash)" - -set_win_title() { - local prefix - - if [ "$USER" != "tobyv" ]; then - prefix="${USER} in " - fi - - if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - prefix="${prefix/in/on}${HOST} in " - fi - - echo -ne "\033]0;${prefix}${PWD/$HOME/~}\007" -} - -starship_precmd_user_func="set_win_title" diff --git a/bat.conf b/bat.conf deleted file mode 100644 index df1d2f2..0000000 --- a/bat.conf +++ /dev/null @@ -1,25 +0,0 @@ -# This is `bat`s configuration file. Each line either contains a comment or -# a command-line option that you want to pass to `bat` by default. You can -# run `bat --help` to get a list of all possible configuration options. - -# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes` -# for a list of all available themes ---theme="Visual Studio Dark+" - -# Enable this to use italic text on the terminal. This is not supported on all -# terminal emulators (like tmux, by default): ---italic-text=always - -# Uncomment the following line to disable automatic paging: -#--paging=never - -# Uncomment the following line if you are using less version >= 551 and want to -# enable mouse scrolling support in `bat` when running inside tmux. This might -# disable text selection, unless you press shift. -#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse" - -# Syntax mappings: map a certain filename pattern to a language. -# Example 1: use the C++ syntax for .ino files -# Example 2: Use ".gitignore"-style highlighting for ".ignore" files -#--map-syntax "*.ino:C++" -#--map-syntax ".ignore:Git Ignore" diff --git a/bat/.config/bat/config b/bat/.config/bat/config new file mode 100644 index 0000000..df1d2f2 --- /dev/null +++ b/bat/.config/bat/config @@ -0,0 +1,25 @@ +# This is `bat`s configuration file. Each line either contains a comment or +# a command-line option that you want to pass to `bat` by default. You can +# run `bat --help` to get a list of all possible configuration options. + +# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes` +# for a list of all available themes +--theme="Visual Studio Dark+" + +# Enable this to use italic text on the terminal. This is not supported on all +# terminal emulators (like tmux, by default): +--italic-text=always + +# Uncomment the following line to disable automatic paging: +#--paging=never + +# Uncomment the following line if you are using less version >= 551 and want to +# enable mouse scrolling support in `bat` when running inside tmux. This might +# disable text selection, unless you press shift. +#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse" + +# Syntax mappings: map a certain filename pattern to a language. +# Example 1: use the C++ syntax for .ino files +# Example 2: Use ".gitignore"-style highlighting for ".ignore" files +#--map-syntax "*.ino:C++" +#--map-syntax ".ignore:Git Ignore" diff --git a/bin/fzf-tmux b/bin/fzf-tmux deleted file mode 100755 index 7daaf60..0000000 --- a/bin/fzf-tmux +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env bash -# fzf-tmux: starts fzf in a tmux pane -# usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] - -fail() { - echo >&2 "$1" - exit 2 -} - -fzf="$(command -v fzf 2>/dev/null)" || fzf="$(dirname "$0")/fzf" -[[ -x "$fzf" ]] || fail 'fzf executable not found' - -tmux_args=() -args=() -opt="" -skip="" -swap="" -close="" -term="" -[[ -n "$LINES" ]] && lines=$LINES || lines=$(tput lines) || lines=$(tmux display-message -p "#{pane_height}") -[[ -n "$COLUMNS" ]] && columns=$COLUMNS || columns=$(tput cols) || columns=$(tmux display-message -p "#{pane_width}") - -help() { - echo >&2 'usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] - - LAYOUT OPTIONS: - (default layout: -d 50%) - - Popup window (requires tmux 3.2 or above): - -p [WIDTH[%][,HEIGHT[%]]] (default: 50%) - -w WIDTH[%] - -h HEIGHT[%] - -x COL - -y ROW - - Split pane: - -u [HEIGHT[%]] Split above (up) - -d [HEIGHT[%]] Split below (down) - -l [WIDTH[%]] Split left - -r [WIDTH[%]] Split right -' - exit -} - -while [[ $# -gt 0 ]]; do - arg="$1" - shift - [[ -z "$skip" ]] && case "$arg" in - -) - term=1 - ;; - --help) - help - ;; - --version) - echo "fzf-tmux (with fzf $("$fzf" --version))" - exit - ;; - -p* | -w* | -h* | -x* | -y* | -d* | -u* | -r* | -l*) - if [[ "$arg" =~ ^-[pwhxy] ]]; then - [[ "$opt" =~ "-K -E" ]] || opt="-K -E" - elif [[ "$arg" =~ ^.[lr] ]]; then - opt="-h" - if [[ "$arg" =~ ^.l ]]; then - opt="$opt -d" - swap="; swap-pane -D ; select-pane -L" - close="; tmux swap-pane -D" - fi - else - opt="" - if [[ "$arg" =~ ^.u ]]; then - opt="$opt -d" - swap="; swap-pane -D ; select-pane -U" - close="; tmux swap-pane -D" - fi - fi - if [[ ${#arg} -gt 2 ]]; then - size="${arg:2}" - else - if [[ "$1" =~ ^[0-9%,]+$ ]] || [[ "$1" =~ ^[A-Z]$ ]]; then - size="$1" - shift - else - continue - fi - fi - - if [[ "$arg" =~ ^-p ]]; then - if [[ -n "$size" ]]; then - w=${size%%,*} - h=${size##*,} - opt="$opt -w$w -h$h" - fi - elif [[ "$arg" =~ ^-[whxy] ]]; then - opt="$opt ${arg:0:2}$size" - elif [[ "$size" =~ %$ ]]; then - size=${size:0:((${#size} - 1))} - if [[ -n "$swap" ]]; then - opt="$opt -p $((100 - size))" - else - opt="$opt -p $size" - fi - else - if [[ -n "$swap" ]]; then - if [[ "$arg" =~ ^.l ]]; then - max=$columns - else - max=$lines - fi - size=$((max - size)) - [[ $size -lt 0 ]] && size=0 - opt="$opt -l $size" - else - opt="$opt -l $size" - fi - fi - ;; - --) - # "--" can be used to separate fzf-tmux options from fzf options to - # avoid conflicts - skip=1 - tmux_args=("${args[@]}") - args=() - continue - ;; - *) - args+=("$arg") - ;; - esac - [[ -n "$skip" ]] && args+=("$arg") -done - -if [[ -z "$TMUX" ]]; then - "$fzf" "${args[@]}" - exit $? -fi - -# --height option is not allowed. CTRL-Z is also disabled. -args=("${args[@]}" "--no-height" "--bind=ctrl-z:ignore") - -# Handle zoomed tmux pane without popup options by moving it to a temp window -if [[ ! "$opt" =~ "-K -E" ]] && tmux list-panes -F '#F' | grep -q Z; then - zoomed_without_popup=1 - original_window=$(tmux display-message -p "#{window_id}") - tmp_window=$(tmux new-window -d -P -F "#{window_id}" "bash -c 'while :; do for c in \\| / - '\\;' do sleep 0.2; printf \"\\r\$c fzf-tmux is running\\r\"; done; done'") - tmux swap-pane -t $tmp_window \; select-window -t $tmp_window -fi - -set -e - -# Clean up named pipes on exit -id=$RANDOM -argsf="${TMPDIR:-/tmp}/fzf-args-$id" -fifo1="${TMPDIR:-/tmp}/fzf-fifo1-$id" -fifo2="${TMPDIR:-/tmp}/fzf-fifo2-$id" -fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id" -tmux_win_opts=($(tmux show-window-options remain-on-exit \; show-window-options synchronize-panes | sed '/ off/d; s/^/set-window-option /; s/$/ \\;/')) -cleanup() { - \rm -f $argsf $fifo1 $fifo2 $fifo3 - - # Restore tmux window options - if [[ "${#tmux_win_opts[@]}" -gt 0 ]]; then - eval "tmux ${tmux_win_opts[*]}" - fi - - # Remove temp window if we were zoomed without popup options - if [[ -n "$zoomed_without_popup" ]]; then - tmux display-message -p "#{window_id}" >/dev/null - tmux swap-pane -t $original_window \; \ - select-window -t $original_window \; \ - kill-window -t $tmp_window \; \ - resize-pane -Z - fi - - if [[ $# -gt 0 ]]; then - trap - EXIT - exit 130 - fi -} -trap 'cleanup 1' SIGUSR1 -trap 'cleanup' EXIT - -envs="export TERM=$TERM " -[[ "$opt" =~ "-K -E" ]] && FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS" -[[ -n "$FZF_DEFAULT_OPTS" ]] && envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")" -[[ -n "$FZF_DEFAULT_COMMAND" ]] && envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")" -echo "$envs;" >"$argsf" - -# Build arguments to fzf -opts=$(printf "%q " "${args[@]}") - -pppid=$$ -echo -n "trap 'kill -SIGUSR1 -$pppid' EXIT SIGINT SIGTERM;" >>$argsf -close="; trap - EXIT SIGINT SIGTERM $close" - -export TMUX=$(cut -d , -f 1,2 <<<"$TMUX") -mkfifo -m o+w $fifo2 -if [[ "$opt" =~ "-K -E" ]]; then - cat $fifo2 & - if [[ -n "$term" ]] || [[ -t 0 ]]; then - cat <<<"\"$fzf\" $opts > $fifo2; out=\$? $close; exit \$out" >>$argsf - else - mkfifo $fifo1 - cat <<<"\"$fzf\" $opts < $fifo1 > $fifo2; out=\$? $close; exit \$out" >>$argsf - cat <&0 >$fifo1 & - fi - - # tmux dropped the support for `-K`, `-R` to popup command - # TODO: We can remove this once tmux 3.2 is released - if [[ ! "$(tmux popup --help 2>&1)" =~ '-R shell-command' ]]; then - opt="${opt/-K/}" - else - opt="${opt} -R" - fi - - tmux popup -d "$PWD" "${tmux_args[@]}" $opt "bash $argsf" >/dev/null 2>&1 - exit $? -fi - -mkfifo -m o+w $fifo3 -if [[ -n "$term" ]] || [[ -t 0 ]]; then - cat <<<"\"$fzf\" $opts > $fifo2; echo \$? > $fifo3 $close" >>$argsf -else - mkfifo $fifo1 - cat <<<"\"$fzf\" $opts < $fifo1 > $fifo2; echo \$? > $fifo3 $close" >>$argsf - cat <&0 >$fifo1 & -fi -tmux set-window-option synchronize-panes off \; set-window-option remain-on-exit off \; split-window -c "$PWD" $opt "${tmux_args[@]}" "bash -c 'exec -a fzf bash $argsf'" $swap \ - >/dev/null 2>&1 || { - "$fzf" "${args[@]}" - exit $? -} -cat $fifo2 -exit "$(cat $fifo3)" diff --git a/bin/tm b/bin/tm deleted file mode 100755 index 5c976d3..0000000 --- a/bin/tm +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" -session=$( - tmux list-sessions -F "#{session_name}" 2>/dev/null | - sed "/^$(tmux display-message -p '#S' 2>/dev/null)$/d" | - fzf --query="$1" --select-1 --exit-0 -) && - tmux $change -t "$session" || - ( - tmux new-session -d -s $session && - tmux $change -t "$session" - ) diff --git a/bin/tmux-sessionizer b/bin/tmux-sessionizer deleted file mode 100755 index 020648e..0000000 --- a/bin/tmux-sessionizer +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -if [[ $# -eq 1 ]]; then - selected=$1 -else - selected=$(cat <(fd . ~/src ~/dkr --exact-depth 1 -td) <(echo $HOME/dotfiles) | sort | - fzf -d/ --with-nth 3.. --preview="tree -a -C -L 1 {}") -fi - -if [[ -z $selected ]]; then - exit 0 -fi - -selected_name=$(basename "$selected" | tr . _) -tmux_running=$(pgrep tmux) - -if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then - tmux new-session -s $selected_name -c $selected - exit 0 -fi - -if ! tmux has-session -t=$selected_name 2>/dev/null; then - tmux new-session -ds $selected_name -c $selected -fi - -tmux switch-client -t $selected_name diff --git a/bin/tmux-windowizer b/bin/tmux-windowizer deleted file mode 100755 index 6cee8b0..0000000 --- a/bin/tmux-windowizer +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -branch_name=$(basename $1) -session_name=$(tmux display-message -p "#S") -clean_name=$(echo $branch_name | tr "./" "__") -target="$session_name:$clean_name" - -if ! tmux has-session -t $target 2>/dev/null; then - tmux neww -dn $clean_name -fi - -shift -tmux send-keys -t $target "$* -" diff --git a/docs/git.md b/docs/git.md deleted file mode 100644 index c6ae4ac..0000000 --- a/docs/git.md +++ /dev/null @@ -1,99 +0,0 @@ -# Git - -My personal cheat sheet of commands for various tools and workflows - -- [Git](#git) - - [Split out subfolder into new repository](#split-out-subfolder-into-new-repository) - - [(Optional) Migrate original subdir to submodule](#optional-migrate-original-subdir-to-submodule) - -## Split out subfolder into new repository - -*Be sure you are inside the original repo* - -```sh -cd / -``` - -Set local variables for use - -```sh -username="$(git config user.username)" -subdir="$(git rev-parse --show-prefix)" -newrepo="$(basename $subdir)" -oldrepo="$(git rev-parse --show-toplevel)" -cd $oldrepo -``` - -Create a new branch containing only the sub-directory using `git subtree` - -```sh -git subtree split -P $subdir -b $newrepo -``` - -Create a temp git repo and pull in the newly created branch - -```sh -cd $(mktemp -d) - -git init && git pull $oldrepo $newrepo -``` - -Copy over the git artifacts from original repo's root directory - -```sh -cp -rt ./ $oldrepo/.gitignore $oldrepo/.gitattributes $oldrepo/.vscode -``` - -Commit changes - -```sh -git add -A && git commit -m "split out $newrepo into submodule" -``` - -Create a new remote repository using something like [gh](https://github.com/cli/cli) - -```sh -gh repo create $username/$newrepo -``` - -(Optional) You can also just create the new remote repository manually and set the new local repository's remote with - -```sh -git remote add origin https://github.com/$username/$newrepo -``` - -Push newly created repository to remote - -```sh -git push -u origin master -``` - -### (Optional) Migrate original subdir to submodule - -Switch back into the original repository - -```sh -cd $oldrepo -``` - -Remove the `subdir` from git and the filesystem - -```sh -git rm -rf $subdir -rm -rf $subdir -``` - -Add the newly created remote repository as a submodule at the `subdir`'s path - -```sh -git submodule add git@github.com:$username/$newrepo $subdir -git submodule update --init --recursive -``` - -Commit the changes to the original repository and push to remote - -```sh -git commit -m "split out $newrepo into submodule" -git push -u origin master -``` - diff --git a/docs/yubikey.md b/docs/yubikey.md deleted file mode 100644 index a6adfb4..0000000 --- a/docs/yubikey.md +++ /dev/null @@ -1,88 +0,0 @@ -# WSL2 YubiKey Setup - -- [WSL2 YubiKey Setup](#wsl2-yubikey-setup) - - [Intro](#Intro) - - [SSH Agent](#ssh-agent) - - [In Windows](#in-windows) - - [VS Code](#vs-code) - - [In WSL2](#in-wsl2) - -## Intro - -The following two sections are the result of a painstaking amount of google searches and GitHub issues followed by troubleshooting, tears, and tea breaks. Well, more accurately, the 20% came from the aforementioned alliteration. The 80% came from the following two guides. - - - [drduh/YubiKey-Guide](https://github.com/drduh/YubiKey-Guide) - - [The ultimate guide to YubiKey on WSL2](https://dev.to/dzerycz/series/11353) - - [Forwarding gpg-agent to a remote system over SSH](https://wiki.gnupg.org/AgentForwarding) - -The former is an incredibly detailed guide to setting up GPG keys using YubiKey as a smart card. The amount of information drduh has organized in that repository in immense, so I urge you to go star it if you find anything in this section helpful, as he deserves at least that much. - -The second guide was used more as a reference/verification source for the first guide but none-the-less I found it to be helpful, so I figured I would include it here. - -While I went down this rock filled rabbit hole for the purpose of getting my YubiKey working (seamlessly) in WSL2, the majority of this should be helpful even if you don't use a security key, as its specificity deals with getting the respective agents/sockets communicating between WSL2 and Windows. - - - - - -## Windows - -### SSH Agent - -Install [gpg-bridge](https://github.com/BusyJay/gpg-bridge) using cargo - -```powershell -# Powershell -cargo install -f --git https://github.com/busyjay/gpg-bridge -``` - -Set gpg-bridge to run on startup - -```powershell -# Powershell -$cmdl = "$HOME\.cargo\bin\gpg-bridge.exe gpg-bridge-ssh --extra 127.0.0.1:4321 --ssh \\.\pipe\gpg-bridge-ssh --detach" -$key = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -Force -New-ItemProperty -Path $key.PSPath -Name "gpg-bridge" -Value "$cmdl" -``` - -Set SSH_AUTH_SOCK to have ssh use the translated pipe - -```powershell -# Powershell -[System.Environment]::SetEnvironmentVariable('SSH_AUTH_SOCK',"\\.\pipe\gpg-bridge-ssh") -``` - -One-off to run gpg-bridge.exe without restarting - -```powershell -# Powershell -Invoke-Expression "& $cmdl" -``` - -### GPG Agent - -On the windows side the YubiKey is fully accessible, the GPG agent should just work. - -## In WSL2 - -### SSH Agent - -```sh -# Bash - -# Install depends -sudo apt install socat iproute2 - -# Install wsl2-ssh-pageant -destination="$HOME/.ssh/wsl2-ssh-pageant.exe" -curl -sL "https://github.com/BlackReloaded/wsl2-ssh-pageant/releases/latest/download/wsl2-ssh-pageant.exe" -o "$destination" -# wget -O "$destination" "https://github.com/BlackReloaded/wsl2-ssh-pageant/releases/latest/download/wsl2-ssh-pageant.exe" -# Set the executable bit. -chmod +x "$destination" -``` - -### GPG Agent - -The only setup needed for getting the YubiKey working in WSL2 is to source/copy-paste [gpg.sh](wsl/gpg.sh) in your shell profile. - -Along with the initialization code, I wrote a small function the resets all the related agents/sockets. If you do not attempt to access the YubiKey while it is not inserted, in my experience, GPG works great has no issues once reinserting the YubiKey. It is only (inconsistently) when you try to access a YubiKey that you have removed that puts it in a failed state. \ No newline at end of file diff --git a/git.md b/git.md new file mode 100644 index 0000000..c6ae4ac --- /dev/null +++ b/git.md @@ -0,0 +1,99 @@ +# Git + +My personal cheat sheet of commands for various tools and workflows + +- [Git](#git) + - [Split out subfolder into new repository](#split-out-subfolder-into-new-repository) + - [(Optional) Migrate original subdir to submodule](#optional-migrate-original-subdir-to-submodule) + +## Split out subfolder into new repository + +*Be sure you are inside the original repo* + +```sh +cd / +``` + +Set local variables for use + +```sh +username="$(git config user.username)" +subdir="$(git rev-parse --show-prefix)" +newrepo="$(basename $subdir)" +oldrepo="$(git rev-parse --show-toplevel)" +cd $oldrepo +``` + +Create a new branch containing only the sub-directory using `git subtree` + +```sh +git subtree split -P $subdir -b $newrepo +``` + +Create a temp git repo and pull in the newly created branch + +```sh +cd $(mktemp -d) + +git init && git pull $oldrepo $newrepo +``` + +Copy over the git artifacts from original repo's root directory + +```sh +cp -rt ./ $oldrepo/.gitignore $oldrepo/.gitattributes $oldrepo/.vscode +``` + +Commit changes + +```sh +git add -A && git commit -m "split out $newrepo into submodule" +``` + +Create a new remote repository using something like [gh](https://github.com/cli/cli) + +```sh +gh repo create $username/$newrepo +``` + +(Optional) You can also just create the new remote repository manually and set the new local repository's remote with + +```sh +git remote add origin https://github.com/$username/$newrepo +``` + +Push newly created repository to remote + +```sh +git push -u origin master +``` + +### (Optional) Migrate original subdir to submodule + +Switch back into the original repository + +```sh +cd $oldrepo +``` + +Remove the `subdir` from git and the filesystem + +```sh +git rm -rf $subdir +rm -rf $subdir +``` + +Add the newly created remote repository as a submodule at the `subdir`'s path + +```sh +git submodule add git@github.com:$username/$newrepo $subdir +git submodule update --init --recursive +``` + +Commit the changes to the original repository and push to remote + +```sh +git commit -m "split out $newrepo into submodule" +git push -u origin master +``` + diff --git a/git/.gitconfig b/git/.gitconfig new file mode 100644 index 0000000..c232be3 --- /dev/null +++ b/git/.gitconfig @@ -0,0 +1,87 @@ +[user] +email = tobyv13@gmail.com +name = Toby Vincent +username = tobyvin +signingkey = 0xA0876F29023F43AF + +[commit] +gpgsign = true + +[init] +defaultBranch = main + +[pull] +rebase = true + +[merge] +ff = no + +[fetch] +prune = true + +[advice] +detachedHead = false + +[diff] +tool = default-difftool + +[difftool "default-difftool"] +cmd = code --wait --diff $LOCAL $REMOTE + +[trailer] +separators = ":#" +[trailer "fix"] +key = "Fix #" + +[alias] +# basic +st = status -s +cl = clone +ci = commit +co = checkout +br = branch +r = reset +rv = remote -v +cp = cherry-pick +dev = checkout develop +main = checkout main + +# tweak defaults +grep = grep -Ii +diff = diff --word-diff +branch = branch -ra +ai = add --interactive +recommit = commit --amend -C HEAD +redate = rebase --committer-date-is-author-date + +# log commands +lg = log --graph --oneline --decorate --branches --remotes --tags --abbrev-commit +ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%an]" --decorate --date=relative +ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [a:%an,c:%cn]" --decorate --numstat +watch = "!f() { watch -c 'git -c color.ui=always lg | sed \"s/\\[m/\\[00m/\"'; }; f" + +# undo http://megakemp.com/2016/08/25/git-undo/ +undo = "!f() { git reset --soft $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f" +pop = git reset HEAD~ + +# rename branch +brn = "!f() { git branch -m \"$(git rev-parse --abbrev-ref HEAD)\" $1; git fetch origin; git branch -u origin/$1 $1; git remote set-head origin -a; }; f" + +# squash the last N commits, inclusivly +squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f" + +# grep on filename +f = "!git ls-files | grep -i" + +# remove submodule +smrm = "!f(){ git rm --cached \"$1\";rm -r \"$1\";git config -f .gitmodules --remove-section \"submodule.$1\";git config -f .git/config --remove-section \"submodule.$1\";git add .gitmodules; }; f" + +# generate git artifacts +ignore = "!f() { IFS=\",\"; curl -L -s \"https://www.toptal.com/developers/gitignore/api/$*\" ;}; f" +attributes = "!f() { curl -sL https://gist.githubusercontent.com/tobyvin/70f3671c76016063594ea45edbb97094/raw ;}; f" +license = "!f() { curl -sH 'Accept: application/vnd.github.v3+json' https://api.github.com/licenses/$1 | grep -oP '.*\"body\":\\s*\"\\K.*(?=\\s*\",)' | tr '\\n' '\\0' | xargs -0 printf '%b\\n' | sed \"s/\\[year\\]/$(date +'%Y')/\" | sed \"s/\\[fullname\\]/$(git config --get user.name)/\"; }; f" +[filter "lfs"] + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true diff --git a/gitconfig b/gitconfig deleted file mode 100644 index c232be3..0000000 --- a/gitconfig +++ /dev/null @@ -1,87 +0,0 @@ -[user] -email = tobyv13@gmail.com -name = Toby Vincent -username = tobyvin -signingkey = 0xA0876F29023F43AF - -[commit] -gpgsign = true - -[init] -defaultBranch = main - -[pull] -rebase = true - -[merge] -ff = no - -[fetch] -prune = true - -[advice] -detachedHead = false - -[diff] -tool = default-difftool - -[difftool "default-difftool"] -cmd = code --wait --diff $LOCAL $REMOTE - -[trailer] -separators = ":#" -[trailer "fix"] -key = "Fix #" - -[alias] -# basic -st = status -s -cl = clone -ci = commit -co = checkout -br = branch -r = reset -rv = remote -v -cp = cherry-pick -dev = checkout develop -main = checkout main - -# tweak defaults -grep = grep -Ii -diff = diff --word-diff -branch = branch -ra -ai = add --interactive -recommit = commit --amend -C HEAD -redate = rebase --committer-date-is-author-date - -# log commands -lg = log --graph --oneline --decorate --branches --remotes --tags --abbrev-commit -ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%an]" --decorate --date=relative -ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [a:%an,c:%cn]" --decorate --numstat -watch = "!f() { watch -c 'git -c color.ui=always lg | sed \"s/\\[m/\\[00m/\"'; }; f" - -# undo http://megakemp.com/2016/08/25/git-undo/ -undo = "!f() { git reset --soft $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f" -pop = git reset HEAD~ - -# rename branch -brn = "!f() { git branch -m \"$(git rev-parse --abbrev-ref HEAD)\" $1; git fetch origin; git branch -u origin/$1 $1; git remote set-head origin -a; }; f" - -# squash the last N commits, inclusivly -squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f" - -# grep on filename -f = "!git ls-files | grep -i" - -# remove submodule -smrm = "!f(){ git rm --cached \"$1\";rm -r \"$1\";git config -f .gitmodules --remove-section \"submodule.$1\";git config -f .git/config --remove-section \"submodule.$1\";git add .gitmodules; }; f" - -# generate git artifacts -ignore = "!f() { IFS=\",\"; curl -L -s \"https://www.toptal.com/developers/gitignore/api/$*\" ;}; f" -attributes = "!f() { curl -sL https://gist.githubusercontent.com/tobyvin/70f3671c76016063594ea45edbb97094/raw ;}; f" -license = "!f() { curl -sH 'Accept: application/vnd.github.v3+json' https://api.github.com/licenses/$1 | grep -oP '.*\"body\":\\s*\"\\K.*(?=\\s*\",)' | tr '\\n' '\\0' | xargs -0 printf '%b\\n' | sed \"s/\\[year\\]/$(date +'%Y')/\" | sed \"s/\\[fullname\\]/$(git config --get user.name)/\"; }; f" -[filter "lfs"] - clean = git-lfs clean -- %f - smudge = git-lfs smudge -- %f - process = git-lfs filter-process - required = true diff --git a/gnupg/.gnupg/gpg-agent.conf b/gnupg/.gnupg/gpg-agent.conf new file mode 100644 index 0000000..52034d5 --- /dev/null +++ b/gnupg/.gnupg/gpg-agent.conf @@ -0,0 +1,2 @@ +enable-ssh-support +enable-putty-support \ No newline at end of file diff --git a/gnupg/.gnupg/gpg.conf b/gnupg/.gnupg/gpg.conf new file mode 100755 index 0000000..cc4ecce --- /dev/null +++ b/gnupg/.gnupg/gpg.conf @@ -0,0 +1,64 @@ +# https://github.com/drduh/config/blob/master/gpg.conf +# https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html +# https://www.gnupg.org/documentation/manuals/gnupg/GPG-Esoteric-Options.html +# Use AES256, 192, or 128 as cipher +personal-cipher-preferences AES256 AES192 AES +# Use SHA512, 384, or 256 as digest +personal-digest-preferences SHA512 SHA384 SHA256 +# Use ZLIB, BZIP2, ZIP, or no compression +personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed +# Default preferences for new keys +default-preference-list SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed +# SHA512 as digest to sign keys +cert-digest-algo SHA512 +# SHA512 as digest for symmetric ops +s2k-digest-algo SHA512 +# AES256 as cipher for symmetric ops +s2k-cipher-algo AES256 +# UTF-8 support for compatibility +charset utf-8 +# Show Unix timestamps +fixed-list-mode +# No comments in signature +no-comments +# No version in output +no-emit-version +# Disable banner +no-greeting +# Long hexidecimal key format +keyid-format 0xlong +# Display UID validity +list-options show-uid-validity +verify-options show-uid-validity +# Display all keys and their fingerprints +with-fingerprint +# Display key origins and updates +#with-key-origin +# Cross-certify subkeys are present and valid +require-cross-certification +# Disable caching of passphrase for symmetrical ops +no-symkey-cache +# Enable smartcard +use-agent +# Disable recipient key ID in messages +throw-keyids +# Default/trusted key ID to use (helpful with throw-keyids) +default-key 0xC8F6E06F5C8E2634 +trusted-key 0xC8F6E06F5C8E2634 +# Use the default key as default recipient +default-recipient-self +# Group recipient keys (preferred ID last) +#group keygroup = 0xFF00000000000001 0xFF00000000000002 0xFF3E7D88647EBCDB +# Keyserver URL +keyserver hkps://keys.openpgp.org +#keyserver hkps://keyserver.ubuntu.com:443 +#keyserver hkps://hkps.pool.sks-keyservers.net +#keyserver hkps://pgp.ocf.berkeley.edu +# Proxy to use for keyservers +keyserver-options auto-key-retrieve +#keyserver-options http-proxy=http://127.0.0.1:8118 +#keyserver-options http-proxy=socks5-hostname://127.0.0.1:9050 +# Verbose output +#verbose +# Show expired subkeys +#list-options show-unusable-subkeys \ No newline at end of file diff --git a/gnupg/.gnupg/scdaemon.conf b/gnupg/.gnupg/scdaemon.conf new file mode 100755 index 0000000..dbdae90 --- /dev/null +++ b/gnupg/.gnupg/scdaemon.conf @@ -0,0 +1,2 @@ +reader-port Yubico YubiKey OTP+FIDO+CCID 0 +card-timeout 1 \ No newline at end of file diff --git a/gnupg/.gnupg/trustfile.txt b/gnupg/.gnupg/trustfile.txt new file mode 100644 index 0000000..969df06 --- /dev/null +++ b/gnupg/.gnupg/trustfile.txt @@ -0,0 +1,3 @@ +# List of assigned trustvalues, created Sat 08 May 2021 02:20:43 PM CDT +# (Use "gpg --import-ownertrust" to restore them) +B9520450A6280A2E7448C22EC8F6E06F5C8E2634:6: diff --git a/gnupg/gpg-agent.conf b/gnupg/gpg-agent.conf deleted file mode 100644 index 52034d5..0000000 --- a/gnupg/gpg-agent.conf +++ /dev/null @@ -1,2 +0,0 @@ -enable-ssh-support -enable-putty-support \ No newline at end of file diff --git a/gnupg/gpg.conf b/gnupg/gpg.conf deleted file mode 100755 index cc4ecce..0000000 --- a/gnupg/gpg.conf +++ /dev/null @@ -1,64 +0,0 @@ -# https://github.com/drduh/config/blob/master/gpg.conf -# https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html -# https://www.gnupg.org/documentation/manuals/gnupg/GPG-Esoteric-Options.html -# Use AES256, 192, or 128 as cipher -personal-cipher-preferences AES256 AES192 AES -# Use SHA512, 384, or 256 as digest -personal-digest-preferences SHA512 SHA384 SHA256 -# Use ZLIB, BZIP2, ZIP, or no compression -personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed -# Default preferences for new keys -default-preference-list SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed -# SHA512 as digest to sign keys -cert-digest-algo SHA512 -# SHA512 as digest for symmetric ops -s2k-digest-algo SHA512 -# AES256 as cipher for symmetric ops -s2k-cipher-algo AES256 -# UTF-8 support for compatibility -charset utf-8 -# Show Unix timestamps -fixed-list-mode -# No comments in signature -no-comments -# No version in output -no-emit-version -# Disable banner -no-greeting -# Long hexidecimal key format -keyid-format 0xlong -# Display UID validity -list-options show-uid-validity -verify-options show-uid-validity -# Display all keys and their fingerprints -with-fingerprint -# Display key origins and updates -#with-key-origin -# Cross-certify subkeys are present and valid -require-cross-certification -# Disable caching of passphrase for symmetrical ops -no-symkey-cache -# Enable smartcard -use-agent -# Disable recipient key ID in messages -throw-keyids -# Default/trusted key ID to use (helpful with throw-keyids) -default-key 0xC8F6E06F5C8E2634 -trusted-key 0xC8F6E06F5C8E2634 -# Use the default key as default recipient -default-recipient-self -# Group recipient keys (preferred ID last) -#group keygroup = 0xFF00000000000001 0xFF00000000000002 0xFF3E7D88647EBCDB -# Keyserver URL -keyserver hkps://keys.openpgp.org -#keyserver hkps://keyserver.ubuntu.com:443 -#keyserver hkps://hkps.pool.sks-keyservers.net -#keyserver hkps://pgp.ocf.berkeley.edu -# Proxy to use for keyservers -keyserver-options auto-key-retrieve -#keyserver-options http-proxy=http://127.0.0.1:8118 -#keyserver-options http-proxy=socks5-hostname://127.0.0.1:9050 -# Verbose output -#verbose -# Show expired subkeys -#list-options show-unusable-subkeys \ No newline at end of file diff --git a/gnupg/scdaemon.conf b/gnupg/scdaemon.conf deleted file mode 100755 index dbdae90..0000000 --- a/gnupg/scdaemon.conf +++ /dev/null @@ -1,2 +0,0 @@ -reader-port Yubico YubiKey OTP+FIDO+CCID 0 -card-timeout 1 \ No newline at end of file diff --git a/gnupg/trustfile.txt b/gnupg/trustfile.txt deleted file mode 100644 index 969df06..0000000 --- a/gnupg/trustfile.txt +++ /dev/null @@ -1,3 +0,0 @@ -# List of assigned trustvalues, created Sat 08 May 2021 02:20:43 PM CDT -# (Use "gpg --import-ownertrust" to restore them) -B9520450A6280A2E7448C22EC8F6E06F5C8E2634:6: diff --git a/install b/install deleted file mode 100755 index 5a7e72c..0000000 --- a/install +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -e - -CONFIG="install.conf.yaml" -DOTBOT_DIR="dotbot" - -DOTBOT_BIN="bin/dotbot" -BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -cd "${BASEDIR}" -git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive -git submodule update --init --recursive "${DOTBOT_DIR}" - -"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}" diff --git a/install.conf.yaml b/install.conf.yaml deleted file mode 100644 index 44258fe..0000000 --- a/install.conf.yaml +++ /dev/null @@ -1,185 +0,0 @@ -- defaults: - link: - create: true - relink: true - force: true - shell: - quiet: true - stdin: true - -- clean: ["~"] - -- create: - - ~/.local/share/bash-completion/completions - - ~/.local/share/zsh/site-functions - - ~/.bash - - ~/.zsh - -- shell: - - description: Installing submodules - command: git submodule update --init --recursive - - - description: Installing rust - command: - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path && ( - rustup completions bash >~/.local/share/bash-completion/completions/rustup; - rustup completions zsh >~/.local/share/zsh/site-functions/_rustup; - rustup completions bash cargo >~/.local/share/bash-completion/completions/cargo; - rustup completions zsh cargo >~/.local/share/zsh/site-functions/_cargo) - - - description: Installing Starship - command: - target=$(rustc -Vv | grep host | cut -d' ' -f2 | sed s/gnu/musl/ | sed s/armv7/arm/) && - scripts/install-crate.sh --git starship/starship --no-tag --target $target && ( - starship completions bash >~/.local/share/bash-completion/completions/starship; - starship completions zsh >~/.local/share/zsh/site-functions/_starship) - - - description: Installing fzf - command: td=$(mktemp -d) && - arch="$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/ | sed s/armv7l/armv7/)" && - tag="$(curl -sI https://github.com/junegunn/fzf/releases/latest | grep -Po 'tag\/v?\K(\S+)')" && - name="fzf-${tag}-linux_${arch}" && - url="https://github.com/junegunn/fzf/releases/latest/download/${name}.tar.gz" && - curl -sL $url | tar -C $td -xz && - test -x $td/fzf && - rm -f ~/.local/bin/fzf && - install -Dm 755 $td/fzf ~/.local/bin/fzf && - rm -rf $td && ( - curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.bash >~/.local/share/bash-completion/completions/fzf; - curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh >~/.local/share/zsh/site-functions/_fzf; - curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.bash >~/.bash/fzf-key-bindings.sh; - curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh >~/.zsh/fzf-key-bindings.zsh; - curl -sL https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236/raw/6e5d520bfc96d6b3e42571a54cb4d1ebc8e2dd84/functions.sh | tee -a ~/.zsh/fzf-key-bindings.zsh ~/.bash/fzf-key-bindings.sh; - curl -sL https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236/raw/6e5d520bfc96d6b3e42571a54cb4d1ebc8e2dd84/key-binding.bash >>~/.bash/fzf-key-bindings.sh; - curl -sL https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236/raw/6e5d520bfc96d6b3e42571a54cb4d1ebc8e2dd84/key-binding.zsh >>~/.bash/fzf-key-bindings.sh; - ) - - # Install manually with cargo see https://github.com/sharkdp/bat/issues/2106 - # - description: Installing bat - # command: - # target=$(rustc -Vv | grep host | cut -d' ' -f2 | sed s/armv7/arm/) && - # scripts/install-crate.sh --git sharkdp/bat --target $target --completion-bash --completion-zsh - - - description: Installing fd - command: - target=$(rustc -Vv | grep host | cut -d' ' -f2 | sed s/armv7/arm/) && - scripts/install-crate.sh --git sharkdp/fd --target $target --completion-bash --completion-zsh - - - description: Installing ripgrep - command: - target=$(rustc -Vv | grep host | cut -d' ' -f2 | sed s/gnu/musl/ | sed s/armv7/arm/) && - scripts/install-crate.sh --git BurntSushi/ripgrep --target $target --completion-bash --completion-zsh - - - description: Installing cheat.sh - command: curl https://cht.sh/:cht.sh >~/.local/bin/cht.sh && - chmod +x ~/.local/bin/cht.sh && ( - curl https://cht.sh/:bash_completion >~/.local/share/bash-completion/completions/cht; - curl https://cheat.sh/:zsh >~/.local/share/zsh/site-functions/_cht) - - - description: Installing gh - command: td=$(mktemp -d) && - arch="$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/ | sed s/armv7l/armv6/)" && - tag="$(curl -sI https://github.com/cli/cli/releases/latest | grep -Po 'tag\/v?\K(\S+)')" && - name="gh_${tag}_linux_${arch}" && - url="https://github.com/cli/cli/releases/latest/download/${name}.tar.gz" && - curl -sL $url | tar -C $td -xz && - test -x $td/$name/bin/gh && - install -Dm 755 $td/$name/bin/gh ~/.local/bin/gh && - rm -rf $td && ( - gh completion --shell bash >~/.local/share/bash-completion/completions/gh; - gh completion --shell zsh >~/.local/share/zsh/site-functions/_gh) - - - description: Installing git-open - command: - curl -sL "https://raw.githubusercontent.com/paulirish/git-open/master/git-open" >~/.local/bin/git-open && - chmod +x ~/.local/bin/git-open; - - - description: Installing git completions - command: \! command -v git &> /dev/null || - url=https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion && ( - curl -sL ${url}.bash >~/.local/share/bash-completion/completions/git; - curl -sL ${url}.zsh >~/.local/share/zsh/site-functions/_git) - - - description: Installing dotnet completions - command: \! command -v dotnet &> /dev/null || - url=https://raw.githubusercontent.com/dotnet/cli/master/scripts/register-completions && ( - curl -sL ${url}.bash >~/.local/share/bash-completion/completions/dotnet; - curl -sL ${url}.zsh >~/.local/share/zsh/site-functions/_dotnet) - - - description: Installing docker completions - command: \! command -v docker &> /dev/null || - url=https://raw.githubusercontent.com/docker/cli/master/contrib/completion && ( - curl -sL ${url}/bash/docker >~/.local/share/bash-completion/completions/docker; - curl -sL ${url}/zsh/_docker >~/.local/share/zsh/site-functions/_docker) - - - description: Installing pandoc completions - command: \! command -v pandoc &> /dev/null || - url=https://raw.githubusercontent.com/srijanshetty/zsh-pandoc-completion/master/_pandoc && ( - pandoc --bash-completion >~/.local/share/bash-completion/completions/docker; - curl -sL ${url} >~/.local/share/zsh/site-functions/_pandoc) - - - description: Installing zsh-autosuggestions - command: repo=https://github.com/zsh-users/zsh-autosuggestions && - target=~/.zsh/zsh-autosuggestions && - git clone $repo $target || - git -C $target pull - - - description: Installing zsh-syntax-highlighting - command: repo=https://github.com/zsh-users/zsh-syntax-highlighting - target=~/.zsh/zsh-syntax-highlighting && - git clone $repo $target || - git -C $target pull - -- link: - # shell - ~/.bashrc: - ~/.bash: - glob: true - path: bash/* - ~/.bash/: - glob: true - if: '[ -n "${WSL_DISTRO_NAME+1}" ]' - path: wsl/* - - ~/.zshrc: - ~/.zshenv: bash/env.sh - ~/.zsh/aliases.sh: bash/aliases.sh - ~/.zsh: - glob: true - path: zsh/* - ~/.zsh/: - glob: true - if: '[ -n "${WSL_DISTRO_NAME+1}" ]' - path: wsl/* - - ~/.config/starship.toml: starship.toml - ~/.config/alacritty: alacritty - ~/.config/bat/config: bat.conf - ~/.gitconfig: - ~/.ssh/config: ssh/config - ~/.tmux.conf: - path: /dev/null - if: "! ln -f tmux.conf ~/.tmux.conf" - ~/.gnupg/: - glob: true - path: gnupg/*.conf - ~/.local/bin: - glob: true - path: bin/* - -- shell: - - description: Installing gpg key - command: gpg --auto-key-locate keyserver --locate-keys tobyv13@gmail.com - - description: Importing GPG trustfile - command: gpg --import-ownertrust gnupg/trustfile.txt - # ISSUE #1 Fails to import key inside of WSL2 - # - description: Importing gpg key (WSL) - # command: \! command -v gpg.exe &> /dev/null || gpg.exe --auto-key-locate keyserver --locate-keys tobyv13@gmail.com - # - description: Importing gpg trustfile (WSL) - # command: \! command -v gpg.exe &> /dev/null || gpg.exe --import-ownertrust gnupg/trustfile.txt - -- shell: - - description: "" - command: if [ -n "${WSL_DISTRO_NAME+1}" ]; then ./wsl.install; fi - stdout: true - # stderr: true diff --git a/installers/docker-compose.sh b/installers/docker-compose.sh deleted file mode 100755 index ff8e0f6..0000000 --- a/installers/docker-compose.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -arch="$(uname -m | sed s/armv7l/armv7/)" -url="https://github.com/docker/compose/releases/latest/download/docker-compose-linux-${arch}" -td=$(mktemp -d) -curl -sL $url -o $td/docker-compose -install -Dm 755 $td/docker-compose ~/.docker/cli-plugins/docker-compose -rm -rf $td diff --git a/justfile b/justfile index fe09d19..fb6305c 100644 --- a/justfile +++ b/justfile @@ -1,22 +1,91 @@ -#!/usr/bin/env just --justfile +# set positional-arguments := true -dotfiles_path := justfile_directory() -comp_dir_zsh := "$HOME/.local/share/zsh/site-functions" -comp_dir_bash := "$HOME/.local/share/bash-completion/completions" +EMAIL := 'tobyv13@gmail.com' +ZSH_COMP_DIR := join(env_var('HOME'), '/.local/share/zsh/site-functions') +BASH_COMP_DIR := join(env_var('HOME'), '/.local/share/bash-completion/completions') -default: - @just --choose +stow: + stow --target={{ env_var('HOME') }} */ -# install completion scripts for just -completion_just: - just --completions zsh > {{comp_dir_zsh}}/_just - just --completions bash > {{comp_dir_bash}}/just - -install_rust: +unstow: + stow --target={{ env_var('HOME') }} --delete */ + +install +TARGETS: + for target in {{TARGETS}}; do just $target; done + +rustup: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path - -completion_rust: - rustup completions bash > {{comp_dir_bash}}/rustup; - rustup completions zsh > {{comp_dir_zsh}}/_rustup; - rustup completions bash cargo > {{comp_dir_bash}}/cargo; - rustup completions zsh cargo > {{comp_dir_zsh}}/_cargo \ No newline at end of file + rustup completions bash >{{ BASH_COMP_DIR }}/completions/rustup; + rustup completions zsh >{{ ZSH_COMP_DIR }}/_rustup; + rustup completions bash cargo >{{ BASH_COMP_DIR }}/completions/cargo; + rustup completions zsh cargo >{{ ZSH_COMP_DIR }}/_cargo) + +cargo: + command -v cargo || just rustup + command -v cargo-quickinstall || cargo install cargo-quickinstall + +starship: cargo + cargo quickinstall starship --locked + starship completions bash >{{ BASH_COMP_DIR }}/completions/starship; + starship completions zsh >{{ ZSH_COMP_DIR }}/_starship + +# Install manually with cargo see https://github.com/sharkdp/bat/issues/2106 +bat: + cargo quickinstall bat --target {{ arch() }}-unknown-{{ os() }}-mus + curl -sL https://raw.githubusercontent.com/sharkdp/bat/master/assets/completions/bat.bash.in >{{ BASH_COMP_DIR }}/completions/bat + curl -sL https://raw.githubusercontent.com/sharkdp/bat/master/assets/completions/bat.zsh.in >{{ ZSH_COMP_DIR }}/_bat + +fd: + cargo quickinstall fd-find + curl -sL https://raw.githubusercontent.com/sharkdp/fd/master/contrib/completion/_fd >{{ ZSH_COMP_DIR }}/_fd + +ripgrep: + cargo install ripgrep + curl -sL https://raw.githubusercontent.com/BurntSushi/ripgrep/master/complete/_rg >{{ ZSH_COMP_DIR }}/_rg + +chtsh: + curl https://cht.sh/:cht.sh >~/.local/bin/cht.sh + chmod +x ~/.local/bin/cht.sh + curl https://cht.sh/:bash_completion >{{ BASH_COMP_DIR }}/completions/cht + curl https://cheat.sh/:zsh >{{ ZSH_COMP_DIR }}/_cht + +git-open: + curl -sL "https://raw.githubusercontent.com/paulirish/git-open/master/git-open" >~/.local/bin/git-open && + chmod +x ~/.local/bin/git-open; + +gh: + #!/usr/bin/env bash + set -euxo pipefail + td=$(mktemp -d) + arch="$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/ | sed s/armv7l/armv6/)" + tag="$(curl -sI https://github.com/cli/cli/releases/latest | grep -Po 'tag\/v?\K(\S+)')" + name="gh_${tag}_linux_${arch}" + url="https://github.com/cli/cli/releases/latest/download/${name}.tar.gz" + curl -sL $url | tar -C $td -xz + test -x $td/$name/bin/gh + install -Dm 755 $td/$name/bin/gh ~/.local/bin/gh + rm -rf $td + gh completion --shell bash >{{ BASH_COMP_DIR }}/gh + gh completion --shell zsh >{{ ZSH_COMP_DIR }}/_gh + +fzf: + #!/usr/bin/env sh + set -euxo pipefail + td=$(mktemp -d) + tag="$(curl -sI https://github.com/junegunn/fzf/releases/latest | grep -Po 'tag\/v?\K(\S+)')" + alt_arch="$(echo {{arch()}} | sed s/aarch64/arm64/ | sed s/x86_64/amd64/ | sed s/armv7l/armv7/)" + name="fzf-${tag}-{{ os() }}_${alt_arch}" + url="https://github.com/junegunn/fzf/releases/latest/download/${name}.tar.gz" + curl -sL $url | tar -C $td -xz + test -x $td/fzf + rm -f ~/.local/bin/fzf + install -Dm 755 $td/fzf ~/.local/bin/fzf + rm -rf $td + curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.bash >{{ BASH_COMP_DIR }}/completions/fzf + curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh >{{ ZSH_COMP_DIR }}/_fzf + curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.bash >~/.bash/fzf-key-bindings.sh + curl -sL https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh >~/.zsh/fzf-key-bindings.zsh + +gpg: + gpg --auto-key-locate keyserver --locate-keys {{ EMAIL }} + gpg --import-ownertrust {{ join(env_var('HOME'), '.gnupg/trustfile.txt') }} diff --git a/navi.yaml b/navi.yaml deleted file mode 100644 index 89723f7..0000000 --- a/navi.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# THIS IS EXPERIMENTAL -# the config file schema may change at any time - -style: - tag: - color: cyan # text color. possible values: https://bit.ly/3gloNNI - width_percentage: 26 # column width relative to the terminal window - min_width: 20 # minimum column width as number of characters - comment: - color: blue - width_percentage: 42 - min_width: 45 - snippet: - color: white - -finder: - command: fzf # equivalent to the --finder option - # overrides: --tac # equivalent to the --fzf-overrides option - # overrides_var: --tac # equivalent to the --fzf-overrides-var option - -# cheats: - # paths: - # - /path/to/some/dir - # - /path/to/another/dir - # path: /path/to/some/dir # (DEPRECATED) equivalent to the --path option - -# search: - # tags: git,!checkout # equivalent to the --tag-rules option - -shell: - command: zsh # shell used for shell out. possible values: bash, zsh, dash, ... - diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..4671808 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,7 @@ +-- https://github.com/mikebarkmin/.dotfiles/tree/main/nvim/.config/nvim +-- https://github.com/ThePrimeagen/.dotfiles/tree/master/nvim +-- https://github.com/ChristianChiarulli/nvim +require('plugins') +require('options') +require('autocommands') +require('mappings') diff --git a/nvim/.config/nvim/lua/autocommands.lua b/nvim/.config/nvim/lua/autocommands.lua new file mode 100644 index 0000000..c87fb70 --- /dev/null +++ b/nvim/.config/nvim/lua/autocommands.lua @@ -0,0 +1,55 @@ +-- to Show whitespace, MUST be inserted BEFORE the colorscheme command +vim.cmd [[ + augroup _general_settings + autocmd! + autocmd FileType qf,help,man,lspinfo,spectre_panel nnoremap q :close + autocmd TextYankPost * silent!lua require('vim.highlight').on_yank({higroup = 'Visual', timeout = 200}) + autocmd BufWritePre * :%s/\s\+$//e + autocmd BufWinEnter * :set formatoptions-=cro + autocmd BufEnter * set fo-=c fo-=r fo-=o + autocmd FileType qf set nobuflisted + autocmd CmdWinEnter * quit + autocmd FileType xml,html,xhtml,css,scss,javascript,lua,dart setlocal shiftwidth=2 tabstop=2 + autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + augroup end + + augroup format_on_save + autocmd! + autocmd BufWritePre * lua vim.lsp.buf.formatting() + augroup end + + augroup _git + autocmd! + autocmd FileType gitcommit setlocal wrap + autocmd FileType gitcommit setlocal spell + augroup end + + augroup _markdown + autocmd! + autocmd FileType markdown setlocal wrap + autocmd FileType markdown setlocal spell + autocmd BufNewFile,BufRead *.mdx set filetype=markdown + augroup end + + augroup _latex + autocmd! + autocmd FileType latex,tex,plaintex setlocal wrap + autocmd FileType latex,tex,plaintex setlocal spell + autocmd FileType latex,tex,plaintex setlocal linebreak + augroup end + + augroup _json + autocmd! + autocmd BufEnter *.json set ai expandtab shiftwidth=2 tabstop=2 sta fo=croql + augroup end + + augroup _auto_resize + autocmd! + autocmd VimResized * tabdo wincmd = + augroup end + + augroup _alpha + autocmd! + autocmd User AlphaReady set showtabline=0 | autocmd BufUnload set showtabline=2 + augroup end +]] diff --git a/nvim/.config/nvim/lua/icons.lua b/nvim/.config/nvim/lua/icons.lua new file mode 100644 index 0000000..be868a0 --- /dev/null +++ b/nvim/.config/nvim/lua/icons.lua @@ -0,0 +1,106 @@ +-- https://github.com/microsoft/vscode/blob/main/src/vs/base/common/codicons.ts +-- go to the above and then enter u and the symbold should appear +-- or go here and upload the font file: https://mathew-kurian.github.io/CharacterMap/ +-- find more here: https://www.nerdfonts.com/cheat-sheet +--   פּ ﯟ   蘒練 some other good icons +return { + kind = { + Text = "", + -- Method = "m", + -- Function = "", + -- Constructor = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + -- Variable = "", + Variable = "", + Class = "", + Interface = "", + -- Module = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + -- Keyword = "", + Keyword = "", + -- Snippet = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + }, + type = { + Array = "", + Number = "", + String = "", + Boolean = "蘒", + Object = "", + }, + documents = { + File = "", + Files = "", + Folder = "", + OpenFolder = "", + }, + git = { + Add = "", + Mod = "", + Remove = "", + Ignore = "", + Rename = "", + Diff = "", + Repo = "", + }, + ui = { + Lock = "", + Circle = "", + BigCircle = "", + BigUnfilledCircle = "", + Close = "", + NewFile = "", + Search = "", + Lightbulb = "", + Project = "", + Dashboard = "", + History = "", + Comment = "", + Bug = "", + Code = "", + Telescope = "", + Gear = "", + Package = "", + List = "", + SignIn = "", + Check = "", + Fire = "", + Note = "", + BookMark = "", + Pencil = "", + -- ChevronRight = "", + ChevronRight = ">", + Table = "", + Calendar = "", + }, + diagnostics = { + Error = "", + Warning = "", + Information = "", + Question = "", + Hint = "", + }, + misc = { + Robot = "ﮧ", + Squirrel = "", + Tag = "", + Watch = "", + }, +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/mappings.lua b/nvim/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..3b6c7d5 --- /dev/null +++ b/nvim/.config/nvim/lua/mappings.lua @@ -0,0 +1,193 @@ +local status_ok, which_key = pcall(require, "which-key") +if not status_ok then + return +end + +local opts = { + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local mappings = { + -- Ctrl maps + [""] = { "w!", "Save" }, + [""] = { "NvimTreeToggle", "Explorer" }, +} + +local nopts = { + mode = "n", -- NORMAL mode + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local nmappings = { + -- Ctrl maps + [""] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, + + -- Prefix "" + [""] = { + a = { "Alpha", "Alpha" }, + c = { "Bdelete!", "Close Buffer" }, + q = { "q!", "Quit" }, + R = { "lua require('renamer').rename()", "Rename" }, + w = { "w!", "Save" }, + W = { ":set wrap! linebreak!", "Toggle Line Wrap" }, + z = { "ZenMode", "Zen" }, + ["/"] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, + + f = { + name = "Find", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope colorscheme", "Colorscheme" }, + C = { "Telescope commands", "Commands" }, + e = { "Telescope frecency theme=get_dropdown", "Frecency" }, + f = { "Telescope find_files theme=get_dropdown", "Find files" }, + g = { "Telescope live_grep theme=ivy", "Find Text" }, + h = { "Telescope help_tags", "Help" }, + i = { "lua require('telescope').extensions.media_files.media_files()", "Media" }, + k = { "Telescope keymaps", "Keymaps" }, + l = { "Telescope resume", "Last Search" }, + m = { "Telescope man_pages", "Man Pages" }, + p = { "lua require('telescope').extensions.projects.projects()", "Projects" }, + r = { "Telescope oldfiles", "Recent File" }, + R = { "Telescope registers", "Registers" }, + t = { "Telescope buffers show_all_buffers=true theme=get_dropdown", "Buffers" }, + }, + + g = { + name = "Git", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + d = { "Gitsigns diffthis HEAD", "Diff" }, + g = { "LazyGit", "Lazygit" }, + j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, + k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, + l = { "GitBlameToggle", "Blame" }, + o = { "Telescope git_status", "Open changed file" }, + p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, + r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, + R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, + s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, + u = { "lua require 'gitsigns'.undo_stage_hunk()", "Undo Stage Hunk" }, + w = { + name = "Worktree", + s = { [[lua require('telescope').extensions.git_worktree.git_worktrees()]], "Switch" }, + c = { [[lua require('telescope').extensions.git_worktree.create_git_worktree()]], "Create" }, + }, + }, + + l = { + name = "LSP", + a = { "lua vim.lsp.buf.code_action()", "Code Action" }, + d = { "TroubleToggle", "Diagnostics" }, + f = { "lua vim.lsp.buf.formatting()", "Format" }, + -- F = { "LspToggleAutoFormat", "Toggle Autoformat" }, + g = { + name = "Goto", + d = { "lua vim.lsp.buf.definition()", "Definition" }, + D = { "lua vim.lsp.buf.declaration()", "Declaration" }, + i = { "lua vim.lsp.buf.implementation()", "Implementation" }, + r = { "lua vim.lsp.buf.references()", "References" }, + }, + h = { "lua vim.lsp.buf.hover()", "Hover" }, + H = { "lua vim.lsp.buf.signature_help()", "Signature Help" }, + i = { "LspInfo", "Info" }, + I = { "LspInstallInfo", "Installer Info" }, + j = { "lua vim.diagnostic.goto_next({buffer=0})", "Next Diagnostic" }, + k = { "lua vim.diagnostic.goto_prev({buffer=0})", "Prev Diagnostic" }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, + o = { "SymbolsOutline", "Outline" }, + q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, + r = { "lua vim.lsp.buf.rename()", "Rename" }, + R = { "TroubleToggle lsp_references", "References" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols" }, + w = { "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics" }, + }, + + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + + r = { + name = "Replace", + f = { "lua require('spectre').open_file_search()", "Replace Buffer" }, + r = { "lua require('spectre').open()", "Replace" }, + w = { "lua require('spectre').open_visual({select_word=true})", "Replace Word" }, + }, + + s = { + name = "Surround", + ["."] = { "lua require('surround').repeat_last()", "Repeat" }, + a = { "lua require('surround').surround_add(true)", "Add" }, + b = { "lua require('surround').toggle_brackets()", "Brackets" }, + d = { "lua require('surround').surround_delete()", "Delete" }, + q = { "lua require('surround').toggle_quotes()", "Quotes" }, + r = { "lua require('surround').surround_replace()", "Replace" }, + }, + + t = { + name = "Terminal", + ["1"] = { ":1ToggleTerm", "1" }, + ["2"] = { ":2ToggleTerm", "2" }, + ["3"] = { ":3ToggleTerm", "3" }, + ["4"] = { ":4ToggleTerm", "4" }, + f = { "ToggleTerm direction=float", "Float" }, + h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, + v = { "ToggleTerm size=80 direction=vertical", "Vertical" }, + }, + + T = { + name = "Treesitter", + h = { "TSHighlightCapturesUnderCursor", "Highlight" }, + p = { "TSPlaygroundToggle", "Playground" }, + }, + }, + -- Prefix "m" + m = { + a = { "BookmarkAnnotate", "Annotate" }, + c = { "BookmarkClear", "Clear" }, + h = { 'lua require("harpoon.mark").add_file()', "Harpoon" }, + j = { "BookmarkNext", "Next" }, + k = { "BookmarkPrev", "Prev" }, + m = { "BookmarkToggle", "Toggle" }, + s = { + "lua require('telescope').extensions.vim_bookmarks.all({ hide_filename=false, prompt_title=\"bookmarks\", shorten_path=false })", + "Show", + }, + u = { 'lua require("harpoon.ui").toggle_quick_menu()', "Harpoon UI" }, + x = { "BookmarkClearAll", "Clear All" }, + }, +} + +local vopts = { + mode = "v", -- VISUAL mode + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local vmappings = { + -- Ctrl maps + [""] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, + + -- Prefix "" + [""] = { + + ["/"] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, + } +} + +which_key.register(mappings, opts) +which_key.register(nmappings, nopts) +which_key.register(vmappings, vopts) diff --git a/nvim/.config/nvim/lua/options.lua b/nvim/.config/nvim/lua/options.lua new file mode 100644 index 0000000..6fb959d --- /dev/null +++ b/nvim/.config/nvim/lua/options.lua @@ -0,0 +1,75 @@ +local g = vim.g -- global variables +local opt = vim.opt -- vim options +local exec = vim.api.nvim_exec -- execute Vimscript + +g.mapleader = ' ' + +-- set colorscheme +g.vscode_style = "dark" +g.vscode_transparent = 1 +g.vscode_italic_comment = 1 +g.vscode_disable_nvimtree_bg = true + +vim.cmd('colorscheme vscode') + +g.tex_flavor = "latex"; + +-- global options +local options = { + termguicolors = true, -- Enable GUI colors for the terminal to get truecolor + list = false, -- show whitespace + listchars = { + nbsp = '⦸', -- CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8) + extends = '»', -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB) + precedes = '«', -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB) + tab = '▷─', -- WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7) + BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL (U+2505, UTF-8: E2 94 85) + trail = '•', -- BULLET (U+2022, UTF-8: E2 80 A2) + space = ' ' + }, + fillchars = { + diff = '∙', -- BULLET OPERATOR (U+2219, UTF-8: E2 88 99) + eob = ' ', -- NO-BREAK SPACE (U+00A0, UTF-8: C2 A0) to suppress ~ at EndOfBuffer + fold = '·', -- MIDDLE DOT (U+00B7, UTF-8: C2 B7) + vert = ' ' -- remove ugly vertical lines on window division + }, + undofile = true, + undodir = vim.fn.stdpath("config") .. "/undo", + clipboard = opt.clipboard + "unnamedplus", -- copy & paste + shortmess = opt.shortmess + "c", + wrap = false, -- don't automatically wrap on load + showmatch = true, -- show the matching part of the pair for [] {} and () + cursorline = true, -- highlight current line + number = true, -- show line numbers + relativenumber = true, -- show relative line number + incsearch = true, -- incremental search + hlsearch = true, -- highlighted search results + ignorecase = true, -- ignore case sensetive while searching + smartcase = true, + scrolloff = 1, -- when scrolling, keep cursor 1 lines away from screen border + sidescrolloff = 2, -- keep 30 columns visible left and right of the cursor at all times + backspace = 'indent,start,eol', -- make backspace behave like normal again + mouse = "a", -- turn on mouse interaction + updatetime = 500, -- CursorHold interval + expandtab = true, + softtabstop = 4, + textwidth = 100, + shiftwidth = 4, -- spaces per tab (when shifting), when using the >> or << commands, shift lines by 4 spaces + tabstop = 4, -- spaces per tab + smarttab = true, -- / indent/dedent in leading whitespace + autoindent = true, -- maintain indent of current line + shiftround = true, + splitbelow = true, -- open horizontal splits below current window + splitright = true, -- open vertical splits to the right of the current window + laststatus = 2, -- always show status line + colorcolumn = "100", -- vertical word limit line + hidden = true, -- allows you to hide buffers with unsaved changes without being prompted + inccommand = 'split', -- live preview of :s results + shell = 'zsh', -- shell to use for `!`, `:!`, `system()` etc. + wildignore = opt.wildignore + '*.o,*.rej,*.so', + lazyredraw = true, + completeopt = 'menuone,noselect,noinsert', +} + +for k, v in pairs(options) do + vim.opt[k] = v +end diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..de4c47f --- /dev/null +++ b/nvim/.config/nvim/lua/plugins.lua @@ -0,0 +1,279 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system { + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + } + print "Installing packer close and reopen Neovim..." + vim.cmd [[packadd packer.nvim]] +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]] + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, +} + +-- Install your plugins here +return packer.startup(function(use) + -- My plugins here + + -- Have packer manage itself + + use "wbthomason/packer.nvim" + + use { + 'dstein64/vim-startuptime', + cmd = 'StartupTime', + config = [[vim.g.startuptime_tries = 3]] + } + + use 'lewis6991/impatient.nvim' + use 'andweeb/presence.nvim' + use 'Mofiqul/vscode.nvim' -- vscode theme + + use { + 'tpope/vim-dispatch', + cmd = { + 'Dispatch', + 'Make', + 'Focus', + 'Start' + } + } + + use { + 'neovim/nvim-lspconfig', + config = [[require('plugins/lspconfig')]] + } + + use { + "williamboman/nvim-lsp-installer", + config = [[require('plugins/lsp-installer')]] + } + + use 'nvim-lua/lsp_extensions.nvim' + use 'simrat39/rust-tools.nvim' + use 'simrat39/symbols-outline.nvim' + + use { + "folke/trouble.nvim", + cmd = "TroubleToggle" + } + + use { + 'hrsh7th/nvim-cmp', + requires = { + { "onsails/lspkind-nvim", config = [[require('plugins/lspkind')]] }, -- vscode-like pictograms for cmp + 'ray-x/lsp_signature.nvim', + 'hrsh7th/cmp-nvim-lsp', -- nvim-cmp source for neovim builtin LSP client + 'hrsh7th/cmp-nvim-lua', -- nvim-cmp source for nvim lua + 'hrsh7th/cmp-buffer', -- nvim-cmp source for buffer words. + 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths. + 'hrsh7th/cmp-calc', -- nvim-cmp source for math calculation. + 'saadparwaiz1/cmp_luasnip', -- luasnip completion source for nvim-cmp + 'hrsh7th/cmp-nvim-lsp-signature-help', -- luasnip completion source for lsp_signature + }, + config = [[require('plugins/cmp')]], + } + + use { + 'nvim-telescope/telescope.nvim', + requires = { + 'nvim-lua/plenary.nvim', + 'BurntSushi/ripgrep', + 'nvim-telescope/telescope-dap.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, + { "nvim-telescope/telescope-frecency.nvim", requires = "tami5/sqlite.lua" }, + }, + config = [[require('plugins/telescope')]], + } + + use { + "jose-elias-alvarez/null-ls.nvim", + requires = "nvim-lua/plenary.nvim", + config = [[require('plugins/null-ls')]] + } + + use { + "L3MON4D3/LuaSnip", + requires = "rafamadriz/friendly-snippets", + config = [[require('plugins/luasnip')]] + } + + use { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + requires = { + 'nvim-treesitter/nvim-treesitter-refactor', + 'RRethy/nvim-treesitter-textsubjects', + }, + config = [[require('plugins/treesitter')]] + } + + use { + "lukas-reineke/indent-blankline.nvim", + config = [[require('plugins/blankline')]] + } + + use "tpope/vim-eunuch" + + use { + "nvim-lualine/lualine.nvim", + requires = { + { "kyazdani42/nvim-web-devicons" }, + }, + config = [[require('plugins/lualine')]] + } + + use { + 'tpope/vim-fugitive', + cmd = { + 'Git', + 'Gstatus', + 'Gblame', + 'Gpush', + 'Gpull' + }, + disable = true + } + + use { + 'lewis6991/gitsigns.nvim', + requires = 'nvim-lua/plenary.nvim', + config = [[require('plugins/gitsigns')]], + } + + use { + 'TimUntersberger/neogit', + cmd = 'Neogit', + config = [[require('neogit').setup {disable_commit_confirmation = true, disable_signs = true}]] + } + + use 'kdheepak/lazygit.nvim' + + use { + "f-person/git-blame.nvim", + config = [[require('plugins/git-blame')]] + } + + use { + 'mbbill/undotree', + cmd = 'UndotreeToggle', + config = [[vim.g.undotree_SetFocusWhenToggle = 1]], + } + + use { + "ThePrimeagen/git-worktree.nvim", + config = [[require('plugins/git-worktree')]] + } + + use { + 'ThePrimeagen/refactoring.nvim', + opt = true + } + + use { + "ahmedkhalf/project.nvim", + config = [[require('plugins/project')]] + } + + use { + "folke/which-key.nvim", + config = [[require('plugins/which-key')]] + } + + use { + 'mfussenegger/nvim-dap', + requires = { + "theHamsta/nvim-dap-virtual-text", + "rcarriga/nvim-dap-ui", + "Pocco81/DAPInstall.nvim", + }, + config = [[require('plugins/dap')]], + } + + use 'rcarriga/nvim-notify' + use "antoinemadec/FixCursorHold.nvim" + use "nacro90/numb.nvim" + use "Shatur/neovim-session-manager" + use 'ThePrimeagen/harpoon' + use "b0o/SchemaStore.nvim" + use 'windwp/nvim-spectre' + + use { + 'goolord/alpha-nvim', + config = [[require('plugins/alpha')]] + } + + use { + "filipdutescu/renamer.nvim", + config = [[require('plugins/renamer')]] + } + + use { + 'numToStr/Comment.nvim', + config = [[require('Comment').setup()]] + } + + use { + 'norcalli/nvim-colorizer.lua', + ft = { + 'css', + 'javascript', + 'vim', + 'html' + }, + config = [[require('colorizer').setup {'css', 'javascript', 'vim', 'html'}]], + } + + use { + 'akinsho/nvim-bufferline.lua', + requires = 'kyazdani42/nvim-web-devicons', + config = [[require('plugins/bufferline')]], + } + + use "moll/vim-bbye" + use 'SmiteshP/nvim-gps' + + use { + "kyazdani42/nvim-tree.lua", + requires = { + { + 'yamatsum/nvim-nonicons', + requires = 'kyazdani42/nvim-web-devicons' + }, + }, + config = [[require('plugins/nvim-tree')]] + } + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/nvim/.config/nvim/lua/plugins/alpha.lua b/nvim/.config/nvim/lua/plugins/alpha.lua new file mode 100644 index 0000000..87ae48a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/alpha.lua @@ -0,0 +1,56 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local status_ok, dashboard = pcall(require, "alpha.themes.dashboard") +if not status_ok then + return +end + + +-- alpha.setup(dashboard.config) + +local icons = require "icons" + +local dashboard = require "alpha.themes.dashboard" +dashboard.section.header.val = { + [[ __ ]], + [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], + [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], + [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], +} +dashboard.section.buttons.val = { + dashboard.button("f", icons.documents.Files .. " Find file", ":Telescope find_files "), + dashboard.button("e", icons.ui.NewFile .. " New file", ":ene startinsert "), + dashboard.button( + "p", + icons.git.Repo .. " Find project", + ":lua require('telescope').extensions.projects.projects()" + ), + dashboard.button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles "), + dashboard.button("t", icons.ui.List .. " Find text", ":Telescope live_grep "), + dashboard.button("s", icons.ui.SignIn .. " Find Session", ":Telescope sessions save_current=false "), + dashboard.button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua "), + dashboard.button("q", icons.diagnostics.Error .. " Quit", ":qa"), +} +local function footer() + -- NOTE: requires the fortune-mod package to work + -- local handle = io.popen("fortune") + -- local fortune = handle:read("*a") + -- handle:close() + -- return fortune + return "tobyvin.com" +end + +dashboard.section.footer.val = footer() + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +-- vim.cmd([[autocmd User AlphaReady echo 'ready']]) +alpha.setup(dashboard.opts) \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/blankline.lua b/nvim/.config/nvim/lua/plugins/blankline.lua new file mode 100644 index 0000000..44f90c8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/blankline.lua @@ -0,0 +1,11 @@ +local status_ok, indent_blankline = pcall(require, "indent_blankline") +if not status_ok then + return +end + +indent_blankline.setup { + -- for example, context is off by default, use this to turn it on + show_current_context = true, + show_current_context_start = true, + show_end_of_line = true +} diff --git a/nvim/.config/nvim/lua/plugins/bufferline.lua b/nvim/.config/nvim/lua/plugins/bufferline.lua new file mode 100644 index 0000000..105df66 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/bufferline.lua @@ -0,0 +1,82 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +end + +-- https://github.com/Mofiqul/vscode.nvim#-usage + +local diagnostics_signs = { + ['error'] = '', + warning = '', + default = '', +} + +require('bufferline').setup{ + options = { + indicator_icon = ' ', + buffer_close_icon = '', + modified_icon = '●', + close_icon = '', + close_command = "Bdelete! %d", + right_mouse_command = "Bdelete! %d", + always_show_bufferline = false, + diagnostics = 'nvim_lsp', + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local s = ' ' + for e, n in pairs(diagnostics_dict) do + local sym = diagnostics_signs[e] or diagnostics_signs.default + s = s .. (#s > 1 and ' ' or '') .. sym .. ' ' .. n + end + return s + end, + -- separator_style = 'slant', + offsets = {{filetype = "NvimTree", text = "EXPLORER", text_align = "center"}}, + show_tab_indicators = true, + show_close_icon = false + }, + highlights = { + fill = { + guifg = {attribute = "fg", highlight = "Normal"}, + guibg = {attribute = "bg", highlight = "StatusLineNC"}, + }, + background = { + guifg = {attribute = "fg", highlight = "Normal"}, + guibg = {attribute = "bg", highlight = "StatusLine"} + }, + buffer_visible = { + gui = "", + guifg = {attribute = "fg", highlight="Normal"}, + guibg = {attribute = "bg", highlight = "Normal"} + }, + buffer_selected = { + gui = "", + guifg = {attribute = "fg", highlight="Normal"}, + guibg = {attribute = "bg", highlight = "Normal"} + }, + separator = { + guifg = {attribute = "bg", highlight = "Normal"}, + guibg = {attribute = "bg", highlight = "StatusLine"}, + }, + separator_selected = { + guifg = {attribute = "fg", highlight="Special"}, + guibg = {attribute = "bg", highlight = "Normal"} + }, + separator_visible = { + guifg = {attribute = "fg", highlight = "Normal"}, + guibg = {attribute = "bg", highlight = "StatusLineNC"}, + }, + close_button = { + guifg = {attribute = "fg", highlight = "Normal"}, + guibg = {attribute = "bg", highlight = "StatusLine"} + }, + close_button_selected = { + guifg = {attribute = "fg", highlight="normal"}, + guibg = {attribute = "bg", highlight = "normal"} + }, + close_button_visible = { + guifg = {attribute = "fg", highlight="normal"}, + guibg = {attribute = "bg", highlight = "normal"} + }, + + } +} diff --git a/nvim/.config/nvim/lua/plugins/cmp.lua b/nvim/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..1a13863 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,119 @@ +local status_ok, cmp = pcall(require, "cmp") +if not status_ok then + return +end + +-- Require function for tab to work with LUA-SNIP +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 + +cmp.setup({ + completion = { + completeopt = 'menu,menuone,noinsert', + }, + snippet = { + expand = function(args) require('luasnip').lsp_expand(args.body) end + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + -- Add tab support + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }) + }, + formatting = { + format = function(entry, vim_item) + -- fancy icons and a name of kind + vim_item.kind = require("lspkind").presets.default[vim_item.kind] + -- set a name for each source + vim_item.menu = ({ + buffer = "[Buff]", + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + nvim_lua = "[Lua]", + latex_symbols = "[Latex]" + })[entry.source.name] + return vim_item + end + }, + sources = { + {name = 'nvim_lsp'}, + {name = 'nvim_lua'}, + {name = 'path'}, + {name = 'luasnip'}, + {name = 'buffer', keyword_length = 1}, + {name = 'calc' } + }, + experimental = { + -- ghost_text = true, + } + +}) + + + +-- local luasnip = require("luasnip") + +-- local source_mapping = { +-- nvim_lsp = "[LSP]", +-- nvim_lua = "[Lua]", +-- path = "[Path]", +-- buffer = "[Buffer]", +-- luasnip = "[LuaSnip]", +-- nvim_lsp_signature_help = "[LspSignatureHelp]", +-- calc = "[Calc]", +-- } + +-- cmp.setup({ +-- snippet = { +-- expand = function(args) require('luasnip').lsp_expand(args.body) end +-- }, + +-- mapping = { +-- [''] = cmp.mapping.select_prev_item(), +-- [''] = cmp.mapping.select_next_item(), +-- -- Add tab support +-- [''] = cmp.mapping.select_prev_item(), +-- [''] = cmp.mapping.select_next_item(), +-- [''] = cmp.mapping.scroll_docs(-4), +-- [''] = cmp.mapping.scroll_docs(4), +-- [''] = cmp.mapping.complete(), +-- [''] = cmp.mapping.close(), +-- [''] = cmp.mapping.confirm({ +-- behavior = cmp.ConfirmBehavior.Replace, +-- select = true, +-- }) +-- }, + +-- formatting = { +-- format = function(entry, vim_item) +-- vim_item.kind = require("lspkind").presets.default[vim_item.kind] +-- local menu = source_mapping[entry.source.name] +-- vim_item.menu = menu +-- return vim_item +-- end, +-- }, +-- -- Installed sources +-- sources = { +-- -- { name = 'path' }, +-- { name = "nvim_lsp" }, +-- { name = "nvim_lua" }, +-- { name = 'path' }, +-- { name = "luasnip" }, +-- { name = "buffer", keyword_length = 1 }, +-- { name = 'nvim_lsp_signature_help' }, +-- { name = 'calc' }, +-- }, +-- }) diff --git a/nvim/.config/nvim/lua/plugins/dap.lua b/nvim/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..f49590e --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,89 @@ +local status_ok, dap = pcall(require, "dap") +if not status_ok then + return +end + +-- Debugpy +dap.adapters.python = { + type = 'executable', + command = 'python', + args = { '-m', 'debugpy.adapter' }, +} + +dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = 'Launch file', + program = '${file}', + pythonPath = function() + local venv_path = vim.fn.getenv 'VIRTUAL_ENVIRONMENT' + if venv_path ~= vim.NIL and venv_path ~= '' then + return venv_path .. '/bin/python' + else + return '/usr/bin/python' + end + end, + }, +} + +-- Neovim Lua +dap.adapters.nlua = function(callback, config) + callback { type = 'server', host = config.host, port = config.port } +end + +dap.configurations.lua = { + { + type = 'nlua', + request = 'attach', + name = 'Attach to running Neovim instance', + host = function() + local value = vim.fn.input 'Host [127.0.0.1]: ' + if value ~= '' then + return value + end + return '127.0.0.1' + end, + port = function() + local val = tonumber(vim.fn.input 'Port: ') + assert(val, 'Please provide a port number') + return val + end, + }, +} + +-- lldb +dap.adapters.lldb = { + type = 'executable', + command = '/usr/bin/lldb-vscode', + name = 'lldb', +} + +dap.configurations.cpp = { + { + name = 'Launch', + type = 'lldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + runInTerminal = false, + }, +} + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + +vim.cmd [[command! BreakpointToggle lua require('dap').toggle_breakpoint()]] +vim.cmd [[command! Debug lua require('dap').continue()]] +vim.cmd [[command! DapREPL lua require('dap').repl.open()]] + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('dap') \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/git-blame.lua b/nvim/.config/nvim/lua/plugins/git-blame.lua new file mode 100644 index 0000000..f0bb678 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/git-blame.lua @@ -0,0 +1,3 @@ +vim.g.gitblame_enabled = 0 +vim.g.gitblame_message_template = "" +vim.g.gitblame_highlight_group = "LineNr" \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/git-worktree.lua b/nvim/.config/nvim/lua/plugins/git-worktree.lua new file mode 100644 index 0000000..2bc8892 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/git-worktree.lua @@ -0,0 +1,14 @@ +local status_ok, git_worktree = pcall(require, "git-worktree") +if not status_ok then + return +end + +git_worktree.setup({ +}) + +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +require("telescope").load_extension("git_worktree") \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/gitsigns.lua b/nvim/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..b3c944a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,48 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + return +end + +gitsigns.setup { + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter_opts = { + relative_time = false, + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "rounded", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { + enable = false, + }, +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/lsp-installer.lua b/nvim/.config/nvim/lua/plugins/lsp-installer.lua new file mode 100644 index 0000000..199fd37 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp-installer.lua @@ -0,0 +1,124 @@ +local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok then + print("Failed to require nvim-lsp-installer") +end + +-- Provide settings first! +lsp_installer.settings { + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + } + }, + + -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further + -- servers that are requested to be installed will be put in a queue. + max_concurrent_installers = 4 +} + +--------------------------------------------------- +local enhance_server_opts = { + ["eslintls"] = function(opts) + opts.settings = { + format = { + enable = true, + }, + } + end, + ["gopls"] = function(opts) + opts.cmd = { + "gopls", + "serve", + } + opts.settings = { + gopls = { + staticcheck = true, + analyses = { + unusedparams = true, + }, + }, + } + end +} + + +local function make_server_ready(attach) + lsp_installer.on_server_ready(function(server) + -- Specify the default options which we'll use to setup all servers + local opts = { + on_attach = on_attach, + } + if server.name == "rust_analyzer" then + local rustopts = { + tools = { + autoSetHints = true, + hover_with_actions = false, + inlay_hints = { + show_parameter_hints = true, + parameter_hints_prefix = "", + other_hints_prefix = "", + }, + }, + server = vim.tbl_deep_extend("force", server:get_default_options(), opts, { + settings = { + ["rust-analyzer"] = { + completion = { + postfix = { + enable = false + } + }, + checkOnSave = { + command = "clippy" + }, + } + } + }), + } + require("rust-tools").setup(rustopts) + server:attach_buffers() + else + if enhance_server_opts[server.name] then + -- Enhance the default opts with the server-specific ones + enhance_server_opts[server.name](opts) + end + -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) + server:setup(opts) + end + + vim.cmd [[ do User LspAttachBuffers ]] + end) +end +--------------------------------------------------- + +--------------------------------------------------- +local servers = { + "rust_analyzer", + "tsserver", -- for javascript + "jsonls", -- for json + "texlab", -- for latex + "ltex", + "sqlls", -- for sql + "pylsp", -- for python + "sumneko_lua", -- for lua + "gopls", -- for go + "yamlls", + "bashls", + "dockerls" +} + +-- setup the LS +require "plugins.lspconfig" +make_server_ready(On_attach) -- LSP mappings + +-- install the LS +for _, name in pairs(servers) do + local server_is_found, server = lsp_installer.get_server(name) + if server_is_found then + if not server:is_installed() then + print("Installing " .. name) + server:install() + end + end +end \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/lsp-signature.lua b/nvim/.config/nvim/lua/plugins/lsp-signature.lua new file mode 100644 index 0000000..084913c --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp-signature.lua @@ -0,0 +1,59 @@ +local status_ok, signature = pcall(require, "lsp_signature") +if not status_ok then + return +end + +local icons = require "icons" + +local cfg = { + debug = false, -- set to true to enable debug logging + log_path = "debug_log_file_path", -- debug log path + verbose = false, -- show debug line number + + bind = true, -- This is mandatory, otherwise border config won't get registered. + -- If you want to hook lspsaga or other signature handler, pls set to false + doc_lines = 0, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated); + -- set to 0 if you DO NOT want any API comments be shown + -- This setting only take effect in insert mode, it does not affect signature help in normal + -- mode, 10 by default + + floating_window = false, -- show hint in a floating window, set to false for virtual text only mode + + floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note: + -- will set to true when fully tested, set to false will use whichever side has more space + -- this setting will be helpful if you do not want the PUM and floating win overlap + fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters + hint_enable = true, -- virtual hint enable + hint_prefix = icons.misc.Squirrel .. " ", -- Panda for parameter + hint_scheme = "Comment", + use_lspsaga = false, -- set to true if you want to use lspsaga popup + hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight + max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down + -- to view the hiding contents + max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width + handler_opts = { + border = "rounded", -- double, rounded, single, shadow, none + }, + + always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58 + + auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil. + extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} + zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom + + padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc + + transparency = nil, -- disabled by default, allow floating win transparent value 1~100 + shadow_blend = 36, -- if you using shadow as border use this set the opacity + shadow_guibg = "Black", -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' + timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency + toggle_key = nil, -- toggle signature on and off in insert mode, e.g. toggle_key = '' +} + +-- recommanded: +signature.setup(cfg) -- no need to specify bufnr if you don't use toggle_key + +-- You can also do this inside lsp on_attach +-- note: on_attach deprecated +-- require("lsp_signature").on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key +signature.on_attach(cfg) -- no need to specify bufnr if you don't use toggle_key \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/lspconfig.lua b/nvim/.config/nvim/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..0635ee8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lspconfig.lua @@ -0,0 +1,97 @@ +local status_ok, lspconfig = pcall(require, "lspconfig") +if not status_ok then + return +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + underline = true, + signs = true, + update_in_insert = true, + virtual_text = { + true, + spacing = 6, + severity_limit='Error' -- Only show virtual text on error + }, + } +) + +local function config(_config) + return vim.tbl_deep_extend("force", { + capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()), + on_attach = function() + Nnoremap("gd", ":lua vim.lsp.buf.definition()") + Nnoremap("K", ":lua vim.lsp.buf.hover()") + Nnoremap("vws", ":lua vim.lsp.buf.workspace_symbol()") + Nnoremap("vd", ":lua vim.diagnostic.open_float()") + Nnoremap("[d", ":lua vim.lsp.diagnostic.goto_next()") + Nnoremap("]d", ":lua vim.lsp.diagnostic.goto_prev()") + Nnoremap("vca", ":lua vim.lsp.buf.code_action()") + Nnoremap("vrr", ":lua vim.lsp.buf.references()") + Nnoremap("vrn", ":lua vim.lsp.buf.rename()") + Inoremap("", "lua vim.lsp.buf.signature_help()") + end, + }, _config or {}) +end + +lspconfig.tsserver.setup(config()) + +lspconfig.ccls.setup(config()) + +lspconfig.gopls.setup(config({ + cmd = { "gopls", "serve" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, +})) + +local rustopts = { + tools = { + autoSetHints = true, + hover_with_actions = true, + runnables = { + use_telescope = true + }, + inlay_hints = { + show_parameter_hints = false, + parameter_hints_prefix = "", + other_hints_prefix = "", + }, + }, + server = { + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = "true", + }, + checkOnSave = { + command = "clippy", + }, + } + } + }, +} + +require("rust-tools").setup(rustopts) + +local opts = { + -- whether to highlight the currently hovered symbol + -- disable if your cpu usage is higher than you want it + -- or you just hate the highlight + -- default: true + highlight_hovered_item = true, + + -- whether to show outline guides + -- default: true + show_guides = true, +} + +require("symbols-outline").setup(opts) diff --git a/nvim/.config/nvim/lua/plugins/lspkind.lua b/nvim/.config/nvim/lua/plugins/lspkind.lua new file mode 100644 index 0000000..b33a24a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lspkind.lua @@ -0,0 +1,34 @@ +local status_ok, lspkind = pcall(require, "lspkind") +if not status_ok then + return +end + +lspkind.init({ + -- enables text annotations (default: 'default') + -- default symbol map can be either 'default' or 'codicons' for codicon preset (requires vscode-codicons font installed) + preset = 'codicons', + + -- override preset symbols (default: {}) + symbol_map = { + Text = '', + Method = 'ƒ', + Function = '', + Constructor = '', + Variable = '', + Class = '', + Interface = 'ﰮ', + Module = '', + Property = '', + Unit = '', + Value = '', + Enum = '了', + Keyword = '', + Snippet = '﬌', + Color = '', + File = '', + Folder = '', + EnumMember = '', + Constant = '', + Struct = '' + }, +}) \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/lspstatus.lua b/nvim/.config/nvim/lua/plugins/lspstatus.lua new file mode 100644 index 0000000..923209b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lspstatus.lua @@ -0,0 +1,13 @@ +local lsp_status = require 'lsp-status' +lsp_status.status() +lsp_status.register_progress() +lsp_status.config({ + indicator_errors = "", + indicator_warnings = "", + indicator_info = "", + indicator_hint = "", + indicator_ok = "", + current_function = true, + update_interval = 100, + status_symbol = ' 🇻', +}) \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/lualine.lua b/nvim/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..74db5b8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,113 @@ +local status_ok, lualine = pcall(require, "lualine") +if not status_ok then + return +end + +local status_gps_ok, gps = pcall(require, "nvim-gps") +if not status_gps_ok then + return +end + +local hide_in_width = function() + return vim.fn.winwidth(0) > 80 +end + +local icons = require 'icons' + +local diagnostics = { + "diagnostics", + sources = { "nvim_diagnostic" }, + sections = { "error", "warn" }, + symbols = { error = icons.diagnostics.Error .. " ", warn = icons.diagnostics.Warning .. " " }, + colored = false, + update_in_insert = false, + always_visible = true, +} + +local diff = { + "diff", + colored = false, + symbols = { added = icons.git.Add .. " ", modified = icons.git.Mod .. " ", removed = icons.git.Remove .. " " }, -- changes diff symbols + cond = hide_in_width, +} + +local mode = { + "mode", + fmt = function(str) + return "-- " .. str .. " --" + end, +} + +local filetype = { + "filetype", + icons_enabled = false, + icon = nil, +} + +local branch = { + "branch", + icons_enabled = true, + icon = "", +} + +local location = { + "location", + padding = 0, +} + +-- cool function for progress +local progress = function() + local current_line = vim.fn.line "." + local total_lines = vim.fn.line "$" + local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" } + local line_ratio = current_line / total_lines + local index = math.ceil(line_ratio * #chars) + return chars[index] +end + +local spaces = function() + return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") +end + +local nvim_gps = function() + local gps_location = gps.get_location() + if gps_location == "error" then + return "" + else + return gps.get_location() + end +end + +lualine.setup { + options = { + icons_enabled = true, + theme = "vscode", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { "alpha", "dashboard", "NvimTree", "Outline", "toggleterm" }, + always_divide_middle = true, + }, + sections = { + -- lualine_a = { branch, diagnostics }, + lualine_a = { branch }, + lualine_b = { diagnostics }, + -- lualine_c = { _gps }, + lualine_c = { + { nvim_gps, cond = hide_in_width }, + }, + -- lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_x = { diff, spaces, "encoding", filetype }, + lualine_y = { location }, + lualine_z = { progress }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {}, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = {}, +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/luasnip.lua b/nvim/.config/nvim/lua/plugins/luasnip.lua new file mode 100644 index 0000000..962dc24 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/luasnip.lua @@ -0,0 +1,18 @@ +local status_ok, luasnip = pcall(require, "luasnip") +if not status_ok then + return +end + +luasnip.config.set_config({ + history = true, + updateevents = "TextChanged,TextChangedI" +}) + +luasnip.snippets = {all = {}, html = {}} + +luasnip.snippets.javascript = luasnip.snippets.html +luasnip.snippets.javascriptreact = luasnip.snippets.html +luasnip.snippets.typescriptreact = luasnip.snippets.html +require("luasnip.loaders.from_vscode").load({include = {"html"}}) + +require('luasnip.loaders.from_vscode').lazy_load() \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/neogit.lua b/nvim/.config/nvim/lua/plugins/neogit.lua new file mode 100644 index 0000000..ad1f275 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/neogit.lua @@ -0,0 +1,6 @@ +local status_ok, neogit = pcall(require, "neogit") +if not status_ok then + return +end + +neogit.setup {} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/null-ls.lua b/nvim/.config/nvim/lua/plugins/null-ls.lua new file mode 100644 index 0000000..e3aa45f --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/null-ls.lua @@ -0,0 +1,47 @@ +local status_ok, null_ls = pcall(require, "null-ls") +if not status_ok then + return +end + +local code_actions = null_ls.builtins.code_actions +local diagnostics = null_ls.builtins.diagnostics +local formatting = null_ls.builtins.formatting + +null_ls.setup({ + sources = { + -- Code Actions + code_actions.gitsigns, + -- code_actions.shellcheck, + + -- Diagnostics + -- diagnostics.codespell, + -- diagnostics.luacheck, + -- diagnostics.markdownlint, + -- diagnostics.shellcheck, + + -- Formatting + formatting.prettier, + formatting.black, + formatting.latexindent, + formatting.markdownlint, + formatting.stylua, + formatting.rustfmt.with({ + extra_args = function(params) + local Path = require("plenary.path") + local cargo_toml = Path:new(params.root .. "/" .. "Cargo.toml") + + if cargo_toml:exists() and cargo_toml:is_file() then + for _, line in ipairs(cargo_toml:readlines()) do + local edition = line:match([[^edition%s*=%s*%"(%d+)%"]]) + if edition then + return { "--edition=" .. edition } + end + end + end + -- default edition when we don't find `Cargo.toml` or the `edition` in it. + return { "--edition=2021" } + end, + }), + formatting.shfmt, + }, +}) diff --git a/nvim/.config/nvim/lua/plugins/nvim-tree.lua b/nvim/.config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..2bab234 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,111 @@ +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +vim.g.nvim_tree_respect_buf_cwd = 1 +vim.g.nvim_tree_icons = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, +} + +nvim_tree.setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { + "startify", + "dashboard", + "alpha", + }, + auto_close = true, + open_on_tab = false, + hijack_cursor = false, + update_cwd = true, + update_to_buf_dir = { + enable = true, + auto_open = true, + }, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, + system_open = { + cmd = nil, + args = {}, + }, + filters = { + dotfiles = false, + custom = {}, + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 30, + height = 30, + hide_root_folder = false, + side = "left", + auto_resize = true, + mappings = { + custom_only = false, + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + number = false, + relativenumber = false, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + quit_on_open = 0, + git_hl = 1, + disable_window_picker = 0, + root_folder_modifier = ":t", + show_icons = { + git = 1, + folders = 1, + files = 1, + folder_arrows = 1, + tree_width = 30, + }, +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/project.lua b/nvim/.config/nvim/lua/plugins/project.lua new file mode 100644 index 0000000..810d2bd --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/project.lua @@ -0,0 +1,13 @@ +local status_ok, project = pcall(require, "project_nvim") +if not status_ok then + return +end + +project.setup {} + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('projects') \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/renamer.lua b/nvim/.config/nvim/lua/plugins/renamer.lua new file mode 100644 index 0000000..2db1899 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/renamer.lua @@ -0,0 +1,46 @@ +local status_ok, renamer = pcall(require, "renamer") +if not status_ok then + return +end + +vim.api.nvim_set_keymap( + "i", + "", + 'lua require("renamer").rename({empty = true})', + { noremap = true, silent = true } +) +vim.api.nvim_set_keymap( + "n", + "", + 'lua require("renamer").rename({empty = true})', + { noremap = true, silent = true } +) +local mappings_utils = require("renamer.mappings.utils") +renamer.setup({ + -- The popup title, shown if `border` is true + title = "Rename", + -- The padding around the popup content + padding = { + top = 0, + left = 0, + bottom = 0, + right = 0, + }, + -- Whether or not to shown a border around the popup + border = true, + -- The characters which make up the border + border_chars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + -- Whether or not to highlight the current word references through LSP + show_refs = true, + -- The keymaps available while in the `renamer` buffer. The example below + -- overrides the default values, but you can add others as well. + mappings = { + [""] = mappings_utils.set_cursor_to_start, + [""] = mappings_utils.set_cursor_to_end, + [""] = mappings_utils.set_cursor_to_word_end, + [""] = mappings_utils.set_cursor_to_word_start, + [""] = mappings_utils.clear_line, + [""] = mappings_utils.undo, + [""] = mappings_utils.redo, + }, +}) \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/session_manager.lua b/nvim/.config/nvim/lua/plugins/session_manager.lua new file mode 100644 index 0000000..736e69a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/session_manager.lua @@ -0,0 +1,25 @@ +local status_ok, session_manager = pcall(require, "session_manager") +if not status_ok then + return +end + +local status_ok, config = pcall(require, "session_manager.config") +if not status_ok then + return +end + +-- local Path = require('plenary.path') +session_manager.setup({ + autoload_mode = config.AutoloadMode.CurrentDir, -- Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession + autosave_last_session = false, -- Automatically save last session on exit. +}) + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +local tele_session_status_ok, telescope = pcall(telescope.load_extension, "sessions") +if not tele_session_status_ok then + return +end \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..4376f76 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,55 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +telescope.setup { + defaults = { + file_ignore_patterns = {"node_modules", ".git", "dist"}, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--hidden", + "--iglob", + "!yarn.lock", + "--smart-case", + "-u" + }, + layout_strategy = 'flex', + scroll_strategy = 'cycle', + }, + extensions = { + project = { + base_dirs = { + {path = "~/src", max_depth = 1} + }, + hidden_files = true + }, + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + }, + pickers = { + find_files = { + find_command = {"rg", "--files", "--hidden"} + }, + lsp_references = { theme = 'dropdown' }, + lsp_code_actions = { theme = 'dropdown' }, + lsp_definitions = { theme = 'dropdown' }, + lsp_implementations = { theme = 'dropdown' }, + buffers = { + sort_lastused = true, + }, + }, +} + +-- Extensions +telescope.load_extension('frecency') +telescope.load_extension('fzf') diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..95c1aea --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +local status_ok, treesitter = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +treesitter.setup { + indent = { + enable = true + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false + } +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/which-key.lua b/nvim/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..b30fd4d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,34 @@ +local status_ok, which_key = pcall(require, "which-key") +if not status_ok then + return +end + +local setup = { + plugins = { + spelling = { + enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions + suggestions = 20, -- how many suggestions should be shown in the list? + }, + }, + window = { + border = "rounded", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0, + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + align = "center", -- align columns left, center or right + }, +} +local opts = { + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +which_key.setup(setup) \ No newline at end of file diff --git a/nvim/.config/nvim/lua/utils.lua b/nvim/.config/nvim/lua/utils.lua new file mode 100644 index 0000000..14c6e62 --- /dev/null +++ b/nvim/.config/nvim/lua/utils.lua @@ -0,0 +1,9 @@ +local M = {} + +function M.map(mode, lhs, rhs, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend("force", options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +return M \ No newline at end of file diff --git a/nvim/.config/nvim/plugin/packer_compiled.lua b/nvim/.config/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..c302f00 --- /dev/null +++ b/nvim/.config/nvim/plugin/packer_compiled.lua @@ -0,0 +1,572 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + + local time + local profile_info + local should_profile = false + if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end + else + time = function(chunk, start) end + end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + + _G._packer = _G._packer or {} + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["Comment.nvim"] = { + config = { "require('Comment').setup()" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + ["DAPInstall.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/DAPInstall.nvim", + url = "https://github.com/Pocco81/DAPInstall.nvim" + }, + ["FixCursorHold.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim", + url = "https://github.com/antoinemadec/FixCursorHold.nvim" + }, + LuaSnip = { + config = { "require('plugins/luasnip')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["SchemaStore.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/SchemaStore.nvim", + url = "https://github.com/b0o/SchemaStore.nvim" + }, + ["alpha-nvim"] = { + config = { "require('plugins/alpha')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/alpha-nvim", + url = "https://github.com/goolord/alpha-nvim" + }, + ["cmp-buffer"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-calc"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-calc", + url = "https://github.com/hrsh7th/cmp-calc" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lsp-signature-help"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help", + url = "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help" + }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["friendly-snippets"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, + ["git-blame.nvim"] = { + config = { "require('plugins/git-blame')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/git-blame.nvim", + url = "https://github.com/f-person/git-blame.nvim" + }, + ["git-worktree.nvim"] = { + config = { "require('plugins/git-worktree')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/git-worktree.nvim", + url = "https://github.com/ThePrimeagen/git-worktree.nvim" + }, + ["gitsigns.nvim"] = { + config = { "require('plugins/gitsigns')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + harpoon = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/harpoon", + url = "https://github.com/ThePrimeagen/harpoon" + }, + ["impatient.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/impatient.nvim", + url = "https://github.com/lewis6991/impatient.nvim" + }, + ["indent-blankline.nvim"] = { + config = { "require('plugins/blankline')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + ["lazygit.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lazygit.nvim", + url = "https://github.com/kdheepak/lazygit.nvim" + }, + ["lsp_extensions.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lsp_extensions.nvim", + url = "https://github.com/nvim-lua/lsp_extensions.nvim" + }, + ["lsp_signature.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim", + url = "https://github.com/ray-x/lsp_signature.nvim" + }, + ["lspkind-nvim"] = { + config = { "require('plugins/lspkind')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lspkind-nvim", + url = "https://github.com/onsails/lspkind-nvim" + }, + ["lualine.nvim"] = { + config = { "require('plugins/lualine')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lualine.nvim", + url = "https://github.com/nvim-lualine/lualine.nvim" + }, + neogit = { + commands = { "Neogit" }, + config = { "require('neogit').setup {disable_commit_confirmation = true, disable_signs = true}" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/neogit", + url = "https://github.com/TimUntersberger/neogit" + }, + ["neovim-session-manager"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/neovim-session-manager", + url = "https://github.com/Shatur/neovim-session-manager" + }, + ["null-ls.nvim"] = { + config = { "require('plugins/null-ls')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["numb.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/numb.nvim", + url = "https://github.com/nacro90/numb.nvim" + }, + ["nvim-bufferline.lua"] = { + config = { "require('plugins/bufferline')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-bufferline.lua", + url = "https://github.com/akinsho/nvim-bufferline.lua" + }, + ["nvim-cmp"] = { + config = { "require('plugins/cmp')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-colorizer.lua"] = { + config = { "require('colorizer').setup {'css', 'javascript', 'vim', 'html'}" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-colorizer.lua", + url = "https://github.com/norcalli/nvim-colorizer.lua" + }, + ["nvim-dap"] = { + config = { "require('plugins/dap')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-dap", + url = "https://github.com/mfussenegger/nvim-dap" + }, + ["nvim-dap-ui"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-dap-ui", + url = "https://github.com/rcarriga/nvim-dap-ui" + }, + ["nvim-dap-virtual-text"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-dap-virtual-text", + url = "https://github.com/theHamsta/nvim-dap-virtual-text" + }, + ["nvim-gps"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-gps", + url = "https://github.com/SmiteshP/nvim-gps" + }, + ["nvim-lsp-installer"] = { + config = { "require('plugins/lsp-installer')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer", + url = "https://github.com/williamboman/nvim-lsp-installer" + }, + ["nvim-lspconfig"] = { + config = { "require('plugins/lspconfig')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-nonicons"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-nonicons", + url = "https://github.com/yamatsum/nvim-nonicons" + }, + ["nvim-notify"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-notify", + url = "https://github.com/rcarriga/nvim-notify" + }, + ["nvim-spectre"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-spectre", + url = "https://github.com/windwp/nvim-spectre" + }, + ["nvim-tree.lua"] = { + config = { "require('plugins/nvim-tree')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + url = "https://github.com/kyazdani42/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + config = { "require('plugins/treesitter')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-treesitter-refactor"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-treesitter-refactor", + url = "https://github.com/nvim-treesitter/nvim-treesitter-refactor" + }, + ["nvim-treesitter-textsubjects"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-treesitter-textsubjects", + url = "https://github.com/RRethy/nvim-treesitter-textsubjects" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/kyazdani42/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["presence.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/presence.nvim", + url = "https://github.com/andweeb/presence.nvim" + }, + ["project.nvim"] = { + config = { "require('plugins/project')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/project.nvim", + url = "https://github.com/ahmedkhalf/project.nvim" + }, + ["refactoring.nvim"] = { + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/refactoring.nvim", + url = "https://github.com/ThePrimeagen/refactoring.nvim" + }, + ["renamer.nvim"] = { + config = { "require('plugins/renamer')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/renamer.nvim", + url = "https://github.com/filipdutescu/renamer.nvim" + }, + ripgrep = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/ripgrep", + url = "https://github.com/BurntSushi/ripgrep" + }, + ["rust-tools.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/rust-tools.nvim", + url = "https://github.com/simrat39/rust-tools.nvim" + }, + ["sqlite.lua"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/sqlite.lua", + url = "https://github.com/tami5/sqlite.lua" + }, + ["symbols-outline.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/symbols-outline.nvim", + url = "https://github.com/simrat39/symbols-outline.nvim" + }, + ["telescope-dap.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope-dap.nvim", + url = "https://github.com/nvim-telescope/telescope-dap.nvim" + }, + ["telescope-frecency.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope-frecency.nvim", + url = "https://github.com/nvim-telescope/telescope-frecency.nvim" + }, + ["telescope-fzf-native.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim", + url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + ["telescope.nvim"] = { + config = { "require('plugins/telescope')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["trouble.nvim"] = { + commands = { "TroubleToggle" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/trouble.nvim", + url = "https://github.com/folke/trouble.nvim" + }, + undotree = { + commands = { "UndotreeToggle" }, + config = { "vim.g.undotree_SetFocusWhenToggle = 1" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/undotree", + url = "https://github.com/mbbill/undotree" + }, + ["vim-bbye"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/vim-bbye", + url = "https://github.com/moll/vim-bbye" + }, + ["vim-dispatch"] = { + commands = { "Dispatch", "Make", "Focus", "Start" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/vim-dispatch", + url = "https://github.com/tpope/vim-dispatch" + }, + ["vim-eunuch"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/vim-eunuch", + url = "https://github.com/tpope/vim-eunuch" + }, + ["vim-startuptime"] = { + commands = { "StartupTime" }, + config = { "vim.g.startuptime_tries = 3" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/vim-startuptime", + url = "https://github.com/dstein64/vim-startuptime" + }, + ["vscode.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/vscode.nvim", + url = "https://github.com/Mofiqul/vscode.nvim" + }, + ["which-key.nvim"] = { + config = { "require('plugins/which-key')" }, + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/which-key.nvim", + url = "https://github.com/folke/which-key.nvim" + } +} + +time([[Defining packer_plugins]], false) +-- Config for: indent-blankline.nvim +time([[Config for indent-blankline.nvim]], true) +require('plugins/blankline') +time([[Config for indent-blankline.nvim]], false) +-- Config for: nvim-bufferline.lua +time([[Config for nvim-bufferline.lua]], true) +require('plugins/bufferline') +time([[Config for nvim-bufferline.lua]], false) +-- Config for: nvim-cmp +time([[Config for nvim-cmp]], true) +require('plugins/cmp') +time([[Config for nvim-cmp]], false) +-- Config for: nvim-tree.lua +time([[Config for nvim-tree.lua]], true) +require('plugins/nvim-tree') +time([[Config for nvim-tree.lua]], false) +-- Config for: Comment.nvim +time([[Config for Comment.nvim]], true) +require('Comment').setup() +time([[Config for Comment.nvim]], false) +-- Config for: nvim-treesitter +time([[Config for nvim-treesitter]], true) +require('plugins/treesitter') +time([[Config for nvim-treesitter]], false) +-- Config for: nvim-dap +time([[Config for nvim-dap]], true) +require('plugins/dap') +time([[Config for nvim-dap]], false) +-- Config for: renamer.nvim +time([[Config for renamer.nvim]], true) +require('plugins/renamer') +time([[Config for renamer.nvim]], false) +-- Config for: lspkind-nvim +time([[Config for lspkind-nvim]], true) +require('plugins/lspkind') +time([[Config for lspkind-nvim]], false) +-- Config for: which-key.nvim +time([[Config for which-key.nvim]], true) +require('plugins/which-key') +time([[Config for which-key.nvim]], false) +-- Config for: lualine.nvim +time([[Config for lualine.nvim]], true) +require('plugins/lualine') +time([[Config for lualine.nvim]], false) +-- Config for: LuaSnip +time([[Config for LuaSnip]], true) +require('plugins/luasnip') +time([[Config for LuaSnip]], false) +-- Config for: git-blame.nvim +time([[Config for git-blame.nvim]], true) +require('plugins/git-blame') +time([[Config for git-blame.nvim]], false) +-- Config for: git-worktree.nvim +time([[Config for git-worktree.nvim]], true) +require('plugins/git-worktree') +time([[Config for git-worktree.nvim]], false) +-- Config for: telescope.nvim +time([[Config for telescope.nvim]], true) +require('plugins/telescope') +time([[Config for telescope.nvim]], false) +-- Config for: nvim-lsp-installer +time([[Config for nvim-lsp-installer]], true) +require('plugins/lsp-installer') +time([[Config for nvim-lsp-installer]], false) +-- Config for: gitsigns.nvim +time([[Config for gitsigns.nvim]], true) +require('plugins/gitsigns') +time([[Config for gitsigns.nvim]], false) +-- Config for: nvim-lspconfig +time([[Config for nvim-lspconfig]], true) +require('plugins/lspconfig') +time([[Config for nvim-lspconfig]], false) +-- Config for: null-ls.nvim +time([[Config for null-ls.nvim]], true) +require('plugins/null-ls') +time([[Config for null-ls.nvim]], false) +-- Config for: alpha-nvim +time([[Config for alpha-nvim]], true) +require('plugins/alpha') +time([[Config for alpha-nvim]], false) +-- Config for: project.nvim +time([[Config for project.nvim]], true) +require('plugins/project') +time([[Config for project.nvim]], false) + +-- Command lazy-loads +time([[Defining lazy-load commands]], true) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Dispatch lua require("packer.load")({'vim-dispatch'}, { cmd = "Dispatch", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Make lua require("packer.load")({'vim-dispatch'}, { cmd = "Make", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file UndotreeToggle lua require("packer.load")({'undotree'}, { cmd = "UndotreeToggle", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Start lua require("packer.load")({'vim-dispatch'}, { cmd = "Start", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neogit lua require("packer.load")({'neogit'}, { cmd = "Neogit", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file StartupTime lua require("packer.load")({'vim-startuptime'}, { cmd = "StartupTime", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Focus lua require("packer.load")({'vim-dispatch'}, { cmd = "Focus", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file TroubleToggle lua require("packer.load")({'trouble.nvim'}, { cmd = "TroubleToggle", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +time([[Defining lazy-load commands]], false) + +vim.cmd [[augroup packer_load_aucmds]] +vim.cmd [[au!]] + -- Filetype lazy-loads +time([[Defining lazy-load filetype autocommands]], true) +vim.cmd [[au FileType html ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "html" }, _G.packer_plugins)]] +vim.cmd [[au FileType vim ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "vim" }, _G.packer_plugins)]] +vim.cmd [[au FileType css ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "css" }, _G.packer_plugins)]] +vim.cmd [[au FileType javascript ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "javascript" }, _G.packer_plugins)]] +time([[Defining lazy-load filetype autocommands]], false) +vim.cmd("augroup END") +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end diff --git a/nvim/init.lua b/nvim/init.lua deleted file mode 100644 index 4671808..0000000 --- a/nvim/init.lua +++ /dev/null @@ -1,7 +0,0 @@ --- https://github.com/mikebarkmin/.dotfiles/tree/main/nvim/.config/nvim --- https://github.com/ThePrimeagen/.dotfiles/tree/master/nvim --- https://github.com/ChristianChiarulli/nvim -require('plugins') -require('options') -require('autocommands') -require('mappings') diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua deleted file mode 100644 index c87fb70..0000000 --- a/nvim/lua/autocommands.lua +++ /dev/null @@ -1,55 +0,0 @@ --- to Show whitespace, MUST be inserted BEFORE the colorscheme command -vim.cmd [[ - augroup _general_settings - autocmd! - autocmd FileType qf,help,man,lspinfo,spectre_panel nnoremap q :close - autocmd TextYankPost * silent!lua require('vim.highlight').on_yank({higroup = 'Visual', timeout = 200}) - autocmd BufWritePre * :%s/\s\+$//e - autocmd BufWinEnter * :set formatoptions-=cro - autocmd BufEnter * set fo-=c fo-=r fo-=o - autocmd FileType qf set nobuflisted - autocmd CmdWinEnter * quit - autocmd FileType xml,html,xhtml,css,scss,javascript,lua,dart setlocal shiftwidth=2 tabstop=2 - autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif - augroup end - - augroup format_on_save - autocmd! - autocmd BufWritePre * lua vim.lsp.buf.formatting() - augroup end - - augroup _git - autocmd! - autocmd FileType gitcommit setlocal wrap - autocmd FileType gitcommit setlocal spell - augroup end - - augroup _markdown - autocmd! - autocmd FileType markdown setlocal wrap - autocmd FileType markdown setlocal spell - autocmd BufNewFile,BufRead *.mdx set filetype=markdown - augroup end - - augroup _latex - autocmd! - autocmd FileType latex,tex,plaintex setlocal wrap - autocmd FileType latex,tex,plaintex setlocal spell - autocmd FileType latex,tex,plaintex setlocal linebreak - augroup end - - augroup _json - autocmd! - autocmd BufEnter *.json set ai expandtab shiftwidth=2 tabstop=2 sta fo=croql - augroup end - - augroup _auto_resize - autocmd! - autocmd VimResized * tabdo wincmd = - augroup end - - augroup _alpha - autocmd! - autocmd User AlphaReady set showtabline=0 | autocmd BufUnload set showtabline=2 - augroup end -]] diff --git a/nvim/lua/icons.lua b/nvim/lua/icons.lua deleted file mode 100644 index be868a0..0000000 --- a/nvim/lua/icons.lua +++ /dev/null @@ -1,106 +0,0 @@ --- https://github.com/microsoft/vscode/blob/main/src/vs/base/common/codicons.ts --- go to the above and then enter u and the symbold should appear --- or go here and upload the font file: https://mathew-kurian.github.io/CharacterMap/ --- find more here: https://www.nerdfonts.com/cheat-sheet ---   פּ ﯟ   蘒練 some other good icons -return { - kind = { - Text = "", - -- Method = "m", - -- Function = "", - -- Constructor = "", - Method = "", - Function = "", - Constructor = "", - Field = "", - -- Variable = "", - Variable = "", - Class = "", - Interface = "", - -- Module = "", - Module = "", - Property = "", - Unit = "", - Value = "", - Enum = "", - -- Keyword = "", - Keyword = "", - -- Snippet = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", - }, - type = { - Array = "", - Number = "", - String = "", - Boolean = "蘒", - Object = "", - }, - documents = { - File = "", - Files = "", - Folder = "", - OpenFolder = "", - }, - git = { - Add = "", - Mod = "", - Remove = "", - Ignore = "", - Rename = "", - Diff = "", - Repo = "", - }, - ui = { - Lock = "", - Circle = "", - BigCircle = "", - BigUnfilledCircle = "", - Close = "", - NewFile = "", - Search = "", - Lightbulb = "", - Project = "", - Dashboard = "", - History = "", - Comment = "", - Bug = "", - Code = "", - Telescope = "", - Gear = "", - Package = "", - List = "", - SignIn = "", - Check = "", - Fire = "", - Note = "", - BookMark = "", - Pencil = "", - -- ChevronRight = "", - ChevronRight = ">", - Table = "", - Calendar = "", - }, - diagnostics = { - Error = "", - Warning = "", - Information = "", - Question = "", - Hint = "", - }, - misc = { - Robot = "ﮧ", - Squirrel = "", - Tag = "", - Watch = "", - }, -} \ No newline at end of file diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua deleted file mode 100644 index 3b6c7d5..0000000 --- a/nvim/lua/mappings.lua +++ /dev/null @@ -1,193 +0,0 @@ -local status_ok, which_key = pcall(require, "which-key") -if not status_ok then - return -end - -local opts = { - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -local mappings = { - -- Ctrl maps - [""] = { "w!", "Save" }, - [""] = { "NvimTreeToggle", "Explorer" }, -} - -local nopts = { - mode = "n", -- NORMAL mode - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -local nmappings = { - -- Ctrl maps - [""] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, - - -- Prefix "" - [""] = { - a = { "Alpha", "Alpha" }, - c = { "Bdelete!", "Close Buffer" }, - q = { "q!", "Quit" }, - R = { "lua require('renamer').rename()", "Rename" }, - w = { "w!", "Save" }, - W = { ":set wrap! linebreak!", "Toggle Line Wrap" }, - z = { "ZenMode", "Zen" }, - ["/"] = { "lua require('Comment.api').toggle_current_linewise()", "Comment" }, - - f = { - name = "Find", - b = { "Telescope git_branches", "Checkout branch" }, - c = { "Telescope colorscheme", "Colorscheme" }, - C = { "Telescope commands", "Commands" }, - e = { "Telescope frecency theme=get_dropdown", "Frecency" }, - f = { "Telescope find_files theme=get_dropdown", "Find files" }, - g = { "Telescope live_grep theme=ivy", "Find Text" }, - h = { "Telescope help_tags", "Help" }, - i = { "lua require('telescope').extensions.media_files.media_files()", "Media" }, - k = { "Telescope keymaps", "Keymaps" }, - l = { "Telescope resume", "Last Search" }, - m = { "Telescope man_pages", "Man Pages" }, - p = { "lua require('telescope').extensions.projects.projects()", "Projects" }, - r = { "Telescope oldfiles", "Recent File" }, - R = { "Telescope registers", "Registers" }, - t = { "Telescope buffers show_all_buffers=true theme=get_dropdown", "Buffers" }, - }, - - g = { - name = "Git", - b = { "Telescope git_branches", "Checkout branch" }, - c = { "Telescope git_commits", "Checkout commit" }, - d = { "Gitsigns diffthis HEAD", "Diff" }, - g = { "LazyGit", "Lazygit" }, - j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, - k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, - l = { "GitBlameToggle", "Blame" }, - o = { "Telescope git_status", "Open changed file" }, - p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, - r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, - R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, - s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, - u = { "lua require 'gitsigns'.undo_stage_hunk()", "Undo Stage Hunk" }, - w = { - name = "Worktree", - s = { [[lua require('telescope').extensions.git_worktree.git_worktrees()]], "Switch" }, - c = { [[lua require('telescope').extensions.git_worktree.create_git_worktree()]], "Create" }, - }, - }, - - l = { - name = "LSP", - a = { "lua vim.lsp.buf.code_action()", "Code Action" }, - d = { "TroubleToggle", "Diagnostics" }, - f = { "lua vim.lsp.buf.formatting()", "Format" }, - -- F = { "LspToggleAutoFormat", "Toggle Autoformat" }, - g = { - name = "Goto", - d = { "lua vim.lsp.buf.definition()", "Definition" }, - D = { "lua vim.lsp.buf.declaration()", "Declaration" }, - i = { "lua vim.lsp.buf.implementation()", "Implementation" }, - r = { "lua vim.lsp.buf.references()", "References" }, - }, - h = { "lua vim.lsp.buf.hover()", "Hover" }, - H = { "lua vim.lsp.buf.signature_help()", "Signature Help" }, - i = { "LspInfo", "Info" }, - I = { "LspInstallInfo", "Installer Info" }, - j = { "lua vim.diagnostic.goto_next({buffer=0})", "Next Diagnostic" }, - k = { "lua vim.diagnostic.goto_prev({buffer=0})", "Prev Diagnostic" }, - l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, - o = { "SymbolsOutline", "Outline" }, - q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, - r = { "lua vim.lsp.buf.rename()", "Rename" }, - R = { "TroubleToggle lsp_references", "References" }, - s = { "Telescope lsp_document_symbols", "Document Symbols" }, - S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols" }, - w = { "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics" }, - }, - - p = { - name = "Packer", - c = { "PackerCompile", "Compile" }, - i = { "PackerInstall", "Install" }, - s = { "PackerSync", "Sync" }, - S = { "PackerStatus", "Status" }, - u = { "PackerUpdate", "Update" }, - }, - - r = { - name = "Replace", - f = { "lua require('spectre').open_file_search()", "Replace Buffer" }, - r = { "lua require('spectre').open()", "Replace" }, - w = { "lua require('spectre').open_visual({select_word=true})", "Replace Word" }, - }, - - s = { - name = "Surround", - ["."] = { "lua require('surround').repeat_last()", "Repeat" }, - a = { "lua require('surround').surround_add(true)", "Add" }, - b = { "lua require('surround').toggle_brackets()", "Brackets" }, - d = { "lua require('surround').surround_delete()", "Delete" }, - q = { "lua require('surround').toggle_quotes()", "Quotes" }, - r = { "lua require('surround').surround_replace()", "Replace" }, - }, - - t = { - name = "Terminal", - ["1"] = { ":1ToggleTerm", "1" }, - ["2"] = { ":2ToggleTerm", "2" }, - ["3"] = { ":3ToggleTerm", "3" }, - ["4"] = { ":4ToggleTerm", "4" }, - f = { "ToggleTerm direction=float", "Float" }, - h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, - v = { "ToggleTerm size=80 direction=vertical", "Vertical" }, - }, - - T = { - name = "Treesitter", - h = { "TSHighlightCapturesUnderCursor", "Highlight" }, - p = { "TSPlaygroundToggle", "Playground" }, - }, - }, - -- Prefix "m" - m = { - a = { "BookmarkAnnotate", "Annotate" }, - c = { "BookmarkClear", "Clear" }, - h = { 'lua require("harpoon.mark").add_file()', "Harpoon" }, - j = { "BookmarkNext", "Next" }, - k = { "BookmarkPrev", "Prev" }, - m = { "BookmarkToggle", "Toggle" }, - s = { - "lua require('telescope').extensions.vim_bookmarks.all({ hide_filename=false, prompt_title=\"bookmarks\", shorten_path=false })", - "Show", - }, - u = { 'lua require("harpoon.ui").toggle_quick_menu()', "Harpoon UI" }, - x = { "BookmarkClearAll", "Clear All" }, - }, -} - -local vopts = { - mode = "v", -- VISUAL mode - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -local vmappings = { - -- Ctrl maps - [""] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, - - -- Prefix "" - [""] = { - - ["/"] = { "lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())", "Comment" }, - } -} - -which_key.register(mappings, opts) -which_key.register(nmappings, nopts) -which_key.register(vmappings, vopts) diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua deleted file mode 100644 index 6fb959d..0000000 --- a/nvim/lua/options.lua +++ /dev/null @@ -1,75 +0,0 @@ -local g = vim.g -- global variables -local opt = vim.opt -- vim options -local exec = vim.api.nvim_exec -- execute Vimscript - -g.mapleader = ' ' - --- set colorscheme -g.vscode_style = "dark" -g.vscode_transparent = 1 -g.vscode_italic_comment = 1 -g.vscode_disable_nvimtree_bg = true - -vim.cmd('colorscheme vscode') - -g.tex_flavor = "latex"; - --- global options -local options = { - termguicolors = true, -- Enable GUI colors for the terminal to get truecolor - list = false, -- show whitespace - listchars = { - nbsp = '⦸', -- CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8) - extends = '»', -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB) - precedes = '«', -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB) - tab = '▷─', -- WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7) + BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL (U+2505, UTF-8: E2 94 85) - trail = '•', -- BULLET (U+2022, UTF-8: E2 80 A2) - space = ' ' - }, - fillchars = { - diff = '∙', -- BULLET OPERATOR (U+2219, UTF-8: E2 88 99) - eob = ' ', -- NO-BREAK SPACE (U+00A0, UTF-8: C2 A0) to suppress ~ at EndOfBuffer - fold = '·', -- MIDDLE DOT (U+00B7, UTF-8: C2 B7) - vert = ' ' -- remove ugly vertical lines on window division - }, - undofile = true, - undodir = vim.fn.stdpath("config") .. "/undo", - clipboard = opt.clipboard + "unnamedplus", -- copy & paste - shortmess = opt.shortmess + "c", - wrap = false, -- don't automatically wrap on load - showmatch = true, -- show the matching part of the pair for [] {} and () - cursorline = true, -- highlight current line - number = true, -- show line numbers - relativenumber = true, -- show relative line number - incsearch = true, -- incremental search - hlsearch = true, -- highlighted search results - ignorecase = true, -- ignore case sensetive while searching - smartcase = true, - scrolloff = 1, -- when scrolling, keep cursor 1 lines away from screen border - sidescrolloff = 2, -- keep 30 columns visible left and right of the cursor at all times - backspace = 'indent,start,eol', -- make backspace behave like normal again - mouse = "a", -- turn on mouse interaction - updatetime = 500, -- CursorHold interval - expandtab = true, - softtabstop = 4, - textwidth = 100, - shiftwidth = 4, -- spaces per tab (when shifting), when using the >> or << commands, shift lines by 4 spaces - tabstop = 4, -- spaces per tab - smarttab = true, -- / indent/dedent in leading whitespace - autoindent = true, -- maintain indent of current line - shiftround = true, - splitbelow = true, -- open horizontal splits below current window - splitright = true, -- open vertical splits to the right of the current window - laststatus = 2, -- always show status line - colorcolumn = "100", -- vertical word limit line - hidden = true, -- allows you to hide buffers with unsaved changes without being prompted - inccommand = 'split', -- live preview of :s results - shell = 'zsh', -- shell to use for `!`, `:!`, `system()` etc. - wildignore = opt.wildignore + '*.o,*.rej,*.so', - lazyredraw = true, - completeopt = 'menuone,noselect,noinsert', -} - -for k, v in pairs(options) do - vim.opt[k] = v -end diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua deleted file mode 100644 index de4c47f..0000000 --- a/nvim/lua/plugins.lua +++ /dev/null @@ -1,279 +0,0 @@ -local fn = vim.fn - --- Automatically install packer -local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" -if fn.empty(fn.glob(install_path)) > 0 then - PACKER_BOOTSTRAP = fn.system { - "git", - "clone", - "--depth", - "1", - "https://github.com/wbthomason/packer.nvim", - install_path, - } - print "Installing packer close and reopen Neovim..." - vim.cmd [[packadd packer.nvim]] -end - --- Autocommand that reloads neovim whenever you save the plugins.lua file -vim.cmd [[ - augroup packer_user_config - autocmd! - autocmd BufWritePost plugins.lua source | PackerSync - augroup end -]] - --- Use a protected call so we don't error out on first use -local status_ok, packer = pcall(require, "packer") -if not status_ok then - return -end - --- Have packer use a popup window -packer.init { - display = { - open_fn = function() - return require("packer.util").float { border = "rounded" } - end, - }, -} - --- Install your plugins here -return packer.startup(function(use) - -- My plugins here - - -- Have packer manage itself - - use "wbthomason/packer.nvim" - - use { - 'dstein64/vim-startuptime', - cmd = 'StartupTime', - config = [[vim.g.startuptime_tries = 3]] - } - - use 'lewis6991/impatient.nvim' - use 'andweeb/presence.nvim' - use 'Mofiqul/vscode.nvim' -- vscode theme - - use { - 'tpope/vim-dispatch', - cmd = { - 'Dispatch', - 'Make', - 'Focus', - 'Start' - } - } - - use { - 'neovim/nvim-lspconfig', - config = [[require('plugins/lspconfig')]] - } - - use { - "williamboman/nvim-lsp-installer", - config = [[require('plugins/lsp-installer')]] - } - - use 'nvim-lua/lsp_extensions.nvim' - use 'simrat39/rust-tools.nvim' - use 'simrat39/symbols-outline.nvim' - - use { - "folke/trouble.nvim", - cmd = "TroubleToggle" - } - - use { - 'hrsh7th/nvim-cmp', - requires = { - { "onsails/lspkind-nvim", config = [[require('plugins/lspkind')]] }, -- vscode-like pictograms for cmp - 'ray-x/lsp_signature.nvim', - 'hrsh7th/cmp-nvim-lsp', -- nvim-cmp source for neovim builtin LSP client - 'hrsh7th/cmp-nvim-lua', -- nvim-cmp source for nvim lua - 'hrsh7th/cmp-buffer', -- nvim-cmp source for buffer words. - 'hrsh7th/cmp-path', -- nvim-cmp source for filesystem paths. - 'hrsh7th/cmp-calc', -- nvim-cmp source for math calculation. - 'saadparwaiz1/cmp_luasnip', -- luasnip completion source for nvim-cmp - 'hrsh7th/cmp-nvim-lsp-signature-help', -- luasnip completion source for lsp_signature - }, - config = [[require('plugins/cmp')]], - } - - use { - 'nvim-telescope/telescope.nvim', - requires = { - 'nvim-lua/plenary.nvim', - 'BurntSushi/ripgrep', - 'nvim-telescope/telescope-dap.nvim', - { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, - { "nvim-telescope/telescope-frecency.nvim", requires = "tami5/sqlite.lua" }, - }, - config = [[require('plugins/telescope')]], - } - - use { - "jose-elias-alvarez/null-ls.nvim", - requires = "nvim-lua/plenary.nvim", - config = [[require('plugins/null-ls')]] - } - - use { - "L3MON4D3/LuaSnip", - requires = "rafamadriz/friendly-snippets", - config = [[require('plugins/luasnip')]] - } - - use { - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - requires = { - 'nvim-treesitter/nvim-treesitter-refactor', - 'RRethy/nvim-treesitter-textsubjects', - }, - config = [[require('plugins/treesitter')]] - } - - use { - "lukas-reineke/indent-blankline.nvim", - config = [[require('plugins/blankline')]] - } - - use "tpope/vim-eunuch" - - use { - "nvim-lualine/lualine.nvim", - requires = { - { "kyazdani42/nvim-web-devicons" }, - }, - config = [[require('plugins/lualine')]] - } - - use { - 'tpope/vim-fugitive', - cmd = { - 'Git', - 'Gstatus', - 'Gblame', - 'Gpush', - 'Gpull' - }, - disable = true - } - - use { - 'lewis6991/gitsigns.nvim', - requires = 'nvim-lua/plenary.nvim', - config = [[require('plugins/gitsigns')]], - } - - use { - 'TimUntersberger/neogit', - cmd = 'Neogit', - config = [[require('neogit').setup {disable_commit_confirmation = true, disable_signs = true}]] - } - - use 'kdheepak/lazygit.nvim' - - use { - "f-person/git-blame.nvim", - config = [[require('plugins/git-blame')]] - } - - use { - 'mbbill/undotree', - cmd = 'UndotreeToggle', - config = [[vim.g.undotree_SetFocusWhenToggle = 1]], - } - - use { - "ThePrimeagen/git-worktree.nvim", - config = [[require('plugins/git-worktree')]] - } - - use { - 'ThePrimeagen/refactoring.nvim', - opt = true - } - - use { - "ahmedkhalf/project.nvim", - config = [[require('plugins/project')]] - } - - use { - "folke/which-key.nvim", - config = [[require('plugins/which-key')]] - } - - use { - 'mfussenegger/nvim-dap', - requires = { - "theHamsta/nvim-dap-virtual-text", - "rcarriga/nvim-dap-ui", - "Pocco81/DAPInstall.nvim", - }, - config = [[require('plugins/dap')]], - } - - use 'rcarriga/nvim-notify' - use "antoinemadec/FixCursorHold.nvim" - use "nacro90/numb.nvim" - use "Shatur/neovim-session-manager" - use 'ThePrimeagen/harpoon' - use "b0o/SchemaStore.nvim" - use 'windwp/nvim-spectre' - - use { - 'goolord/alpha-nvim', - config = [[require('plugins/alpha')]] - } - - use { - "filipdutescu/renamer.nvim", - config = [[require('plugins/renamer')]] - } - - use { - 'numToStr/Comment.nvim', - config = [[require('Comment').setup()]] - } - - use { - 'norcalli/nvim-colorizer.lua', - ft = { - 'css', - 'javascript', - 'vim', - 'html' - }, - config = [[require('colorizer').setup {'css', 'javascript', 'vim', 'html'}]], - } - - use { - 'akinsho/nvim-bufferline.lua', - requires = 'kyazdani42/nvim-web-devicons', - config = [[require('plugins/bufferline')]], - } - - use "moll/vim-bbye" - use 'SmiteshP/nvim-gps' - - use { - "kyazdani42/nvim-tree.lua", - requires = { - { - 'yamatsum/nvim-nonicons', - requires = 'kyazdani42/nvim-web-devicons' - }, - }, - config = [[require('plugins/nvim-tree')]] - } - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if PACKER_BOOTSTRAP then - require("packer").sync() - end -end) diff --git a/nvim/lua/plugins/alpha.lua b/nvim/lua/plugins/alpha.lua deleted file mode 100644 index 87ae48a..0000000 --- a/nvim/lua/plugins/alpha.lua +++ /dev/null @@ -1,56 +0,0 @@ -local status_ok, alpha = pcall(require, "alpha") -if not status_ok then - return -end - -local status_ok, dashboard = pcall(require, "alpha.themes.dashboard") -if not status_ok then - return -end - - --- alpha.setup(dashboard.config) - -local icons = require "icons" - -local dashboard = require "alpha.themes.dashboard" -dashboard.section.header.val = { - [[ __ ]], - [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], - [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], - [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], - [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], - [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], -} -dashboard.section.buttons.val = { - dashboard.button("f", icons.documents.Files .. " Find file", ":Telescope find_files "), - dashboard.button("e", icons.ui.NewFile .. " New file", ":ene startinsert "), - dashboard.button( - "p", - icons.git.Repo .. " Find project", - ":lua require('telescope').extensions.projects.projects()" - ), - dashboard.button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles "), - dashboard.button("t", icons.ui.List .. " Find text", ":Telescope live_grep "), - dashboard.button("s", icons.ui.SignIn .. " Find Session", ":Telescope sessions save_current=false "), - dashboard.button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua "), - dashboard.button("q", icons.diagnostics.Error .. " Quit", ":qa"), -} -local function footer() - -- NOTE: requires the fortune-mod package to work - -- local handle = io.popen("fortune") - -- local fortune = handle:read("*a") - -- handle:close() - -- return fortune - return "tobyvin.com" -end - -dashboard.section.footer.val = footer() - -dashboard.section.footer.opts.hl = "Type" -dashboard.section.header.opts.hl = "Include" -dashboard.section.buttons.opts.hl = "Keyword" - -dashboard.opts.opts.noautocmd = true --- vim.cmd([[autocmd User AlphaReady echo 'ready']]) -alpha.setup(dashboard.opts) \ No newline at end of file diff --git a/nvim/lua/plugins/blankline.lua b/nvim/lua/plugins/blankline.lua deleted file mode 100644 index 44f90c8..0000000 --- a/nvim/lua/plugins/blankline.lua +++ /dev/null @@ -1,11 +0,0 @@ -local status_ok, indent_blankline = pcall(require, "indent_blankline") -if not status_ok then - return -end - -indent_blankline.setup { - -- for example, context is off by default, use this to turn it on - show_current_context = true, - show_current_context_start = true, - show_end_of_line = true -} diff --git a/nvim/lua/plugins/bufferline.lua b/nvim/lua/plugins/bufferline.lua deleted file mode 100644 index 105df66..0000000 --- a/nvim/lua/plugins/bufferline.lua +++ /dev/null @@ -1,82 +0,0 @@ -local status_ok, bufferline = pcall(require, "bufferline") -if not status_ok then - return -end - --- https://github.com/Mofiqul/vscode.nvim#-usage - -local diagnostics_signs = { - ['error'] = '', - warning = '', - default = '', -} - -require('bufferline').setup{ - options = { - indicator_icon = ' ', - buffer_close_icon = '', - modified_icon = '●', - close_icon = '', - close_command = "Bdelete! %d", - right_mouse_command = "Bdelete! %d", - always_show_bufferline = false, - diagnostics = 'nvim_lsp', - diagnostics_indicator = function(count, level, diagnostics_dict, context) - local s = ' ' - for e, n in pairs(diagnostics_dict) do - local sym = diagnostics_signs[e] or diagnostics_signs.default - s = s .. (#s > 1 and ' ' or '') .. sym .. ' ' .. n - end - return s - end, - -- separator_style = 'slant', - offsets = {{filetype = "NvimTree", text = "EXPLORER", text_align = "center"}}, - show_tab_indicators = true, - show_close_icon = false - }, - highlights = { - fill = { - guifg = {attribute = "fg", highlight = "Normal"}, - guibg = {attribute = "bg", highlight = "StatusLineNC"}, - }, - background = { - guifg = {attribute = "fg", highlight = "Normal"}, - guibg = {attribute = "bg", highlight = "StatusLine"} - }, - buffer_visible = { - gui = "", - guifg = {attribute = "fg", highlight="Normal"}, - guibg = {attribute = "bg", highlight = "Normal"} - }, - buffer_selected = { - gui = "", - guifg = {attribute = "fg", highlight="Normal"}, - guibg = {attribute = "bg", highlight = "Normal"} - }, - separator = { - guifg = {attribute = "bg", highlight = "Normal"}, - guibg = {attribute = "bg", highlight = "StatusLine"}, - }, - separator_selected = { - guifg = {attribute = "fg", highlight="Special"}, - guibg = {attribute = "bg", highlight = "Normal"} - }, - separator_visible = { - guifg = {attribute = "fg", highlight = "Normal"}, - guibg = {attribute = "bg", highlight = "StatusLineNC"}, - }, - close_button = { - guifg = {attribute = "fg", highlight = "Normal"}, - guibg = {attribute = "bg", highlight = "StatusLine"} - }, - close_button_selected = { - guifg = {attribute = "fg", highlight="normal"}, - guibg = {attribute = "bg", highlight = "normal"} - }, - close_button_visible = { - guifg = {attribute = "fg", highlight="normal"}, - guibg = {attribute = "bg", highlight = "normal"} - }, - - } -} diff --git a/nvim/lua/plugins/cmp.lua b/nvim/lua/plugins/cmp.lua deleted file mode 100644 index 1a13863..0000000 --- a/nvim/lua/plugins/cmp.lua +++ /dev/null @@ -1,119 +0,0 @@ -local status_ok, cmp = pcall(require, "cmp") -if not status_ok then - return -end - --- Require function for tab to work with LUA-SNIP -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 - -cmp.setup({ - completion = { - completeopt = 'menu,menuone,noinsert', - }, - snippet = { - expand = function(args) require('luasnip').lsp_expand(args.body) end - }, - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - -- Add tab support - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }) - }, - formatting = { - format = function(entry, vim_item) - -- fancy icons and a name of kind - vim_item.kind = require("lspkind").presets.default[vim_item.kind] - -- set a name for each source - vim_item.menu = ({ - buffer = "[Buff]", - nvim_lsp = "[LSP]", - luasnip = "[LuaSnip]", - nvim_lua = "[Lua]", - latex_symbols = "[Latex]" - })[entry.source.name] - return vim_item - end - }, - sources = { - {name = 'nvim_lsp'}, - {name = 'nvim_lua'}, - {name = 'path'}, - {name = 'luasnip'}, - {name = 'buffer', keyword_length = 1}, - {name = 'calc' } - }, - experimental = { - -- ghost_text = true, - } - -}) - - - --- local luasnip = require("luasnip") - --- local source_mapping = { --- nvim_lsp = "[LSP]", --- nvim_lua = "[Lua]", --- path = "[Path]", --- buffer = "[Buffer]", --- luasnip = "[LuaSnip]", --- nvim_lsp_signature_help = "[LspSignatureHelp]", --- calc = "[Calc]", --- } - --- cmp.setup({ --- snippet = { --- expand = function(args) require('luasnip').lsp_expand(args.body) end --- }, - --- mapping = { --- [''] = cmp.mapping.select_prev_item(), --- [''] = cmp.mapping.select_next_item(), --- -- Add tab support --- [''] = cmp.mapping.select_prev_item(), --- [''] = cmp.mapping.select_next_item(), --- [''] = cmp.mapping.scroll_docs(-4), --- [''] = cmp.mapping.scroll_docs(4), --- [''] = cmp.mapping.complete(), --- [''] = cmp.mapping.close(), --- [''] = cmp.mapping.confirm({ --- behavior = cmp.ConfirmBehavior.Replace, --- select = true, --- }) --- }, - --- formatting = { --- format = function(entry, vim_item) --- vim_item.kind = require("lspkind").presets.default[vim_item.kind] --- local menu = source_mapping[entry.source.name] --- vim_item.menu = menu --- return vim_item --- end, --- }, --- -- Installed sources --- sources = { --- -- { name = 'path' }, --- { name = "nvim_lsp" }, --- { name = "nvim_lua" }, --- { name = 'path' }, --- { name = "luasnip" }, --- { name = "buffer", keyword_length = 1 }, --- { name = 'nvim_lsp_signature_help' }, --- { name = 'calc' }, --- }, --- }) diff --git a/nvim/lua/plugins/dap.lua b/nvim/lua/plugins/dap.lua deleted file mode 100644 index f49590e..0000000 --- a/nvim/lua/plugins/dap.lua +++ /dev/null @@ -1,89 +0,0 @@ -local status_ok, dap = pcall(require, "dap") -if not status_ok then - return -end - --- Debugpy -dap.adapters.python = { - type = 'executable', - command = 'python', - args = { '-m', 'debugpy.adapter' }, -} - -dap.configurations.python = { - { - type = 'python', - request = 'launch', - name = 'Launch file', - program = '${file}', - pythonPath = function() - local venv_path = vim.fn.getenv 'VIRTUAL_ENVIRONMENT' - if venv_path ~= vim.NIL and venv_path ~= '' then - return venv_path .. '/bin/python' - else - return '/usr/bin/python' - end - end, - }, -} - --- Neovim Lua -dap.adapters.nlua = function(callback, config) - callback { type = 'server', host = config.host, port = config.port } -end - -dap.configurations.lua = { - { - type = 'nlua', - request = 'attach', - name = 'Attach to running Neovim instance', - host = function() - local value = vim.fn.input 'Host [127.0.0.1]: ' - if value ~= '' then - return value - end - return '127.0.0.1' - end, - port = function() - local val = tonumber(vim.fn.input 'Port: ') - assert(val, 'Please provide a port number') - return val - end, - }, -} - --- lldb -dap.adapters.lldb = { - type = 'executable', - command = '/usr/bin/lldb-vscode', - name = 'lldb', -} - -dap.configurations.cpp = { - { - name = 'Launch', - type = 'lldb', - request = 'launch', - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - cwd = '${workspaceFolder}', - stopOnEntry = false, - args = {}, - runInTerminal = false, - }, -} - -dap.configurations.c = dap.configurations.cpp -dap.configurations.rust = dap.configurations.cpp - -vim.cmd [[command! BreakpointToggle lua require('dap').toggle_breakpoint()]] -vim.cmd [[command! Debug lua require('dap').continue()]] -vim.cmd [[command! DapREPL lua require('dap').repl.open()]] - -local tele_status_ok, telescope = pcall(require, "telescope") -if not tele_status_ok then - return -end - -telescope.load_extension('dap') \ No newline at end of file diff --git a/nvim/lua/plugins/git-blame.lua b/nvim/lua/plugins/git-blame.lua deleted file mode 100644 index f0bb678..0000000 --- a/nvim/lua/plugins/git-blame.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.g.gitblame_enabled = 0 -vim.g.gitblame_message_template = "" -vim.g.gitblame_highlight_group = "LineNr" \ No newline at end of file diff --git a/nvim/lua/plugins/git-worktree.lua b/nvim/lua/plugins/git-worktree.lua deleted file mode 100644 index 2bc8892..0000000 --- a/nvim/lua/plugins/git-worktree.lua +++ /dev/null @@ -1,14 +0,0 @@ -local status_ok, git_worktree = pcall(require, "git-worktree") -if not status_ok then - return -end - -git_worktree.setup({ -}) - -local status_ok, telescope = pcall(require, "telescope") -if not status_ok then - return -end - -require("telescope").load_extension("git_worktree") \ No newline at end of file diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua deleted file mode 100644 index b3c944a..0000000 --- a/nvim/lua/plugins/gitsigns.lua +++ /dev/null @@ -1,48 +0,0 @@ -local status_ok, gitsigns = pcall(require, "gitsigns") -if not status_ok then - return -end - -gitsigns.setup { - signs = { - add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, - change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, - delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, - topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, - changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, - }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - interval = 1000, - follow_files = true, - }, - attach_to_untracked = true, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - }, - current_line_blame_formatter_opts = { - relative_time = false, - }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, - preview_config = { - -- Options passed to nvim_open_win - border = "rounded", - style = "minimal", - relative = "cursor", - row = 0, - col = 1, - }, - yadm = { - enable = false, - }, -} \ No newline at end of file diff --git a/nvim/lua/plugins/lsp-installer.lua b/nvim/lua/plugins/lsp-installer.lua deleted file mode 100644 index 199fd37..0000000 --- a/nvim/lua/plugins/lsp-installer.lua +++ /dev/null @@ -1,124 +0,0 @@ -local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") -if not status_ok then - print("Failed to require nvim-lsp-installer") -end - --- Provide settings first! -lsp_installer.settings { - ui = { - icons = { - server_installed = "✓", - server_pending = "➜", - server_uninstalled = "✗" - } - }, - - -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further - -- servers that are requested to be installed will be put in a queue. - max_concurrent_installers = 4 -} - ---------------------------------------------------- -local enhance_server_opts = { - ["eslintls"] = function(opts) - opts.settings = { - format = { - enable = true, - }, - } - end, - ["gopls"] = function(opts) - opts.cmd = { - "gopls", - "serve", - } - opts.settings = { - gopls = { - staticcheck = true, - analyses = { - unusedparams = true, - }, - }, - } - end -} - - -local function make_server_ready(attach) - lsp_installer.on_server_ready(function(server) - -- Specify the default options which we'll use to setup all servers - local opts = { - on_attach = on_attach, - } - if server.name == "rust_analyzer" then - local rustopts = { - tools = { - autoSetHints = true, - hover_with_actions = false, - inlay_hints = { - show_parameter_hints = true, - parameter_hints_prefix = "", - other_hints_prefix = "", - }, - }, - server = vim.tbl_deep_extend("force", server:get_default_options(), opts, { - settings = { - ["rust-analyzer"] = { - completion = { - postfix = { - enable = false - } - }, - checkOnSave = { - command = "clippy" - }, - } - } - }), - } - require("rust-tools").setup(rustopts) - server:attach_buffers() - else - if enhance_server_opts[server.name] then - -- Enhance the default opts with the server-specific ones - enhance_server_opts[server.name](opts) - end - -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) - server:setup(opts) - end - - vim.cmd [[ do User LspAttachBuffers ]] - end) -end ---------------------------------------------------- - ---------------------------------------------------- -local servers = { - "rust_analyzer", - "tsserver", -- for javascript - "jsonls", -- for json - "texlab", -- for latex - "ltex", - "sqlls", -- for sql - "pylsp", -- for python - "sumneko_lua", -- for lua - "gopls", -- for go - "yamlls", - "bashls", - "dockerls" -} - --- setup the LS -require "plugins.lspconfig" -make_server_ready(On_attach) -- LSP mappings - --- install the LS -for _, name in pairs(servers) do - local server_is_found, server = lsp_installer.get_server(name) - if server_is_found then - if not server:is_installed() then - print("Installing " .. name) - server:install() - end - end -end \ No newline at end of file diff --git a/nvim/lua/plugins/lsp-signature.lua b/nvim/lua/plugins/lsp-signature.lua deleted file mode 100644 index 084913c..0000000 --- a/nvim/lua/plugins/lsp-signature.lua +++ /dev/null @@ -1,59 +0,0 @@ -local status_ok, signature = pcall(require, "lsp_signature") -if not status_ok then - return -end - -local icons = require "icons" - -local cfg = { - debug = false, -- set to true to enable debug logging - log_path = "debug_log_file_path", -- debug log path - verbose = false, -- show debug line number - - bind = true, -- This is mandatory, otherwise border config won't get registered. - -- If you want to hook lspsaga or other signature handler, pls set to false - doc_lines = 0, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated); - -- set to 0 if you DO NOT want any API comments be shown - -- This setting only take effect in insert mode, it does not affect signature help in normal - -- mode, 10 by default - - floating_window = false, -- show hint in a floating window, set to false for virtual text only mode - - floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note: - -- will set to true when fully tested, set to false will use whichever side has more space - -- this setting will be helpful if you do not want the PUM and floating win overlap - fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters - hint_enable = true, -- virtual hint enable - hint_prefix = icons.misc.Squirrel .. " ", -- Panda for parameter - hint_scheme = "Comment", - use_lspsaga = false, -- set to true if you want to use lspsaga popup - hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight - max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down - -- to view the hiding contents - max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width - handler_opts = { - border = "rounded", -- double, rounded, single, shadow, none - }, - - always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58 - - auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil. - extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} - zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom - - padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc - - transparency = nil, -- disabled by default, allow floating win transparent value 1~100 - shadow_blend = 36, -- if you using shadow as border use this set the opacity - shadow_guibg = "Black", -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' - timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency - toggle_key = nil, -- toggle signature on and off in insert mode, e.g. toggle_key = '' -} - --- recommanded: -signature.setup(cfg) -- no need to specify bufnr if you don't use toggle_key - --- You can also do this inside lsp on_attach --- note: on_attach deprecated --- require("lsp_signature").on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key -signature.on_attach(cfg) -- no need to specify bufnr if you don't use toggle_key \ No newline at end of file diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua deleted file mode 100644 index 0635ee8..0000000 --- a/nvim/lua/plugins/lspconfig.lua +++ /dev/null @@ -1,97 +0,0 @@ -local status_ok, lspconfig = pcall(require, "lspconfig") -if not status_ok then - return -end - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - underline = true, - signs = true, - update_in_insert = true, - virtual_text = { - true, - spacing = 6, - severity_limit='Error' -- Only show virtual text on error - }, - } -) - -local function config(_config) - return vim.tbl_deep_extend("force", { - capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()), - on_attach = function() - Nnoremap("gd", ":lua vim.lsp.buf.definition()") - Nnoremap("K", ":lua vim.lsp.buf.hover()") - Nnoremap("vws", ":lua vim.lsp.buf.workspace_symbol()") - Nnoremap("vd", ":lua vim.diagnostic.open_float()") - Nnoremap("[d", ":lua vim.lsp.diagnostic.goto_next()") - Nnoremap("]d", ":lua vim.lsp.diagnostic.goto_prev()") - Nnoremap("vca", ":lua vim.lsp.buf.code_action()") - Nnoremap("vrr", ":lua vim.lsp.buf.references()") - Nnoremap("vrn", ":lua vim.lsp.buf.rename()") - Inoremap("", "lua vim.lsp.buf.signature_help()") - end, - }, _config or {}) -end - -lspconfig.tsserver.setup(config()) - -lspconfig.ccls.setup(config()) - -lspconfig.gopls.setup(config({ - cmd = { "gopls", "serve" }, - settings = { - gopls = { - analyses = { - unusedparams = true, - }, - staticcheck = true, - }, - }, -})) - -local rustopts = { - tools = { - autoSetHints = true, - hover_with_actions = true, - runnables = { - use_telescope = true - }, - inlay_hints = { - show_parameter_hints = false, - parameter_hints_prefix = "", - other_hints_prefix = "", - }, - }, - server = { - settings = { - ["rust-analyzer"] = { - cargo = { - allFeatures = "true", - }, - checkOnSave = { - command = "clippy", - }, - } - } - }, -} - -require("rust-tools").setup(rustopts) - -local opts = { - -- whether to highlight the currently hovered symbol - -- disable if your cpu usage is higher than you want it - -- or you just hate the highlight - -- default: true - highlight_hovered_item = true, - - -- whether to show outline guides - -- default: true - show_guides = true, -} - -require("symbols-outline").setup(opts) diff --git a/nvim/lua/plugins/lspkind.lua b/nvim/lua/plugins/lspkind.lua deleted file mode 100644 index b33a24a..0000000 --- a/nvim/lua/plugins/lspkind.lua +++ /dev/null @@ -1,34 +0,0 @@ -local status_ok, lspkind = pcall(require, "lspkind") -if not status_ok then - return -end - -lspkind.init({ - -- enables text annotations (default: 'default') - -- default symbol map can be either 'default' or 'codicons' for codicon preset (requires vscode-codicons font installed) - preset = 'codicons', - - -- override preset symbols (default: {}) - symbol_map = { - Text = '', - Method = 'ƒ', - Function = '', - Constructor = '', - Variable = '', - Class = '', - Interface = 'ﰮ', - Module = '', - Property = '', - Unit = '', - Value = '', - Enum = '了', - Keyword = '', - Snippet = '﬌', - Color = '', - File = '', - Folder = '', - EnumMember = '', - Constant = '', - Struct = '' - }, -}) \ No newline at end of file diff --git a/nvim/lua/plugins/lspstatus.lua b/nvim/lua/plugins/lspstatus.lua deleted file mode 100644 index 923209b..0000000 --- a/nvim/lua/plugins/lspstatus.lua +++ /dev/null @@ -1,13 +0,0 @@ -local lsp_status = require 'lsp-status' -lsp_status.status() -lsp_status.register_progress() -lsp_status.config({ - indicator_errors = "", - indicator_warnings = "", - indicator_info = "", - indicator_hint = "", - indicator_ok = "", - current_function = true, - update_interval = 100, - status_symbol = ' 🇻', -}) \ No newline at end of file diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua deleted file mode 100644 index 74db5b8..0000000 --- a/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,113 +0,0 @@ -local status_ok, lualine = pcall(require, "lualine") -if not status_ok then - return -end - -local status_gps_ok, gps = pcall(require, "nvim-gps") -if not status_gps_ok then - return -end - -local hide_in_width = function() - return vim.fn.winwidth(0) > 80 -end - -local icons = require 'icons' - -local diagnostics = { - "diagnostics", - sources = { "nvim_diagnostic" }, - sections = { "error", "warn" }, - symbols = { error = icons.diagnostics.Error .. " ", warn = icons.diagnostics.Warning .. " " }, - colored = false, - update_in_insert = false, - always_visible = true, -} - -local diff = { - "diff", - colored = false, - symbols = { added = icons.git.Add .. " ", modified = icons.git.Mod .. " ", removed = icons.git.Remove .. " " }, -- changes diff symbols - cond = hide_in_width, -} - -local mode = { - "mode", - fmt = function(str) - return "-- " .. str .. " --" - end, -} - -local filetype = { - "filetype", - icons_enabled = false, - icon = nil, -} - -local branch = { - "branch", - icons_enabled = true, - icon = "", -} - -local location = { - "location", - padding = 0, -} - --- cool function for progress -local progress = function() - local current_line = vim.fn.line "." - local total_lines = vim.fn.line "$" - local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" } - local line_ratio = current_line / total_lines - local index = math.ceil(line_ratio * #chars) - return chars[index] -end - -local spaces = function() - return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") -end - -local nvim_gps = function() - local gps_location = gps.get_location() - if gps_location == "error" then - return "" - else - return gps.get_location() - end -end - -lualine.setup { - options = { - icons_enabled = true, - theme = "vscode", - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = { "alpha", "dashboard", "NvimTree", "Outline", "toggleterm" }, - always_divide_middle = true, - }, - sections = { - -- lualine_a = { branch, diagnostics }, - lualine_a = { branch }, - lualine_b = { diagnostics }, - -- lualine_c = { _gps }, - lualine_c = { - { nvim_gps, cond = hide_in_width }, - }, - -- lualine_x = { "encoding", "fileformat", "filetype" }, - lualine_x = { diff, spaces, "encoding", filetype }, - lualine_y = { location }, - lualine_z = { progress }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {}, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - extensions = {}, -} \ No newline at end of file diff --git a/nvim/lua/plugins/luasnip.lua b/nvim/lua/plugins/luasnip.lua deleted file mode 100644 index 962dc24..0000000 --- a/nvim/lua/plugins/luasnip.lua +++ /dev/null @@ -1,18 +0,0 @@ -local status_ok, luasnip = pcall(require, "luasnip") -if not status_ok then - return -end - -luasnip.config.set_config({ - history = true, - updateevents = "TextChanged,TextChangedI" -}) - -luasnip.snippets = {all = {}, html = {}} - -luasnip.snippets.javascript = luasnip.snippets.html -luasnip.snippets.javascriptreact = luasnip.snippets.html -luasnip.snippets.typescriptreact = luasnip.snippets.html -require("luasnip.loaders.from_vscode").load({include = {"html"}}) - -require('luasnip.loaders.from_vscode').lazy_load() \ No newline at end of file diff --git a/nvim/lua/plugins/neogit.lua b/nvim/lua/plugins/neogit.lua deleted file mode 100644 index ad1f275..0000000 --- a/nvim/lua/plugins/neogit.lua +++ /dev/null @@ -1,6 +0,0 @@ -local status_ok, neogit = pcall(require, "neogit") -if not status_ok then - return -end - -neogit.setup {} \ No newline at end of file diff --git a/nvim/lua/plugins/null-ls.lua b/nvim/lua/plugins/null-ls.lua deleted file mode 100644 index e3aa45f..0000000 --- a/nvim/lua/plugins/null-ls.lua +++ /dev/null @@ -1,47 +0,0 @@ -local status_ok, null_ls = pcall(require, "null-ls") -if not status_ok then - return -end - -local code_actions = null_ls.builtins.code_actions -local diagnostics = null_ls.builtins.diagnostics -local formatting = null_ls.builtins.formatting - -null_ls.setup({ - sources = { - -- Code Actions - code_actions.gitsigns, - -- code_actions.shellcheck, - - -- Diagnostics - -- diagnostics.codespell, - -- diagnostics.luacheck, - -- diagnostics.markdownlint, - -- diagnostics.shellcheck, - - -- Formatting - formatting.prettier, - formatting.black, - formatting.latexindent, - formatting.markdownlint, - formatting.stylua, - formatting.rustfmt.with({ - extra_args = function(params) - local Path = require("plenary.path") - local cargo_toml = Path:new(params.root .. "/" .. "Cargo.toml") - - if cargo_toml:exists() and cargo_toml:is_file() then - for _, line in ipairs(cargo_toml:readlines()) do - local edition = line:match([[^edition%s*=%s*%"(%d+)%"]]) - if edition then - return { "--edition=" .. edition } - end - end - end - -- default edition when we don't find `Cargo.toml` or the `edition` in it. - return { "--edition=2021" } - end, - }), - formatting.shfmt, - }, -}) diff --git a/nvim/lua/plugins/nvim-tree.lua b/nvim/lua/plugins/nvim-tree.lua deleted file mode 100644 index 2bab234..0000000 --- a/nvim/lua/plugins/nvim-tree.lua +++ /dev/null @@ -1,111 +0,0 @@ -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then - return -end - -local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not config_status_ok then - return -end - -local tree_cb = nvim_tree_config.nvim_tree_callback - -vim.g.nvim_tree_respect_buf_cwd = 1 -vim.g.nvim_tree_icons = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - }, -} - -nvim_tree.setup { - disable_netrw = true, - hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = { - "startify", - "dashboard", - "alpha", - }, - auto_close = true, - open_on_tab = false, - hijack_cursor = false, - update_cwd = true, - update_to_buf_dir = { - enable = true, - auto_open = true, - }, - diagnostics = { - enable = true, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - update_focused_file = { - enable = true, - update_cwd = true, - ignore_list = {}, - }, - system_open = { - cmd = nil, - args = {}, - }, - filters = { - dotfiles = false, - custom = {}, - }, - git = { - enable = true, - ignore = true, - timeout = 500, - }, - view = { - width = 30, - height = 30, - hide_root_folder = false, - side = "left", - auto_resize = true, - mappings = { - custom_only = false, - list = { - { key = { "l", "", "o" }, cb = tree_cb "edit" }, - { key = "h", cb = tree_cb "close_node" }, - { key = "v", cb = tree_cb "vsplit" }, - }, - }, - number = false, - relativenumber = false, - }, - trash = { - cmd = "trash", - require_confirm = true, - }, - quit_on_open = 0, - git_hl = 1, - disable_window_picker = 0, - root_folder_modifier = ":t", - show_icons = { - git = 1, - folders = 1, - files = 1, - folder_arrows = 1, - tree_width = 30, - }, -} \ No newline at end of file diff --git a/nvim/lua/plugins/project.lua b/nvim/lua/plugins/project.lua deleted file mode 100644 index 810d2bd..0000000 --- a/nvim/lua/plugins/project.lua +++ /dev/null @@ -1,13 +0,0 @@ -local status_ok, project = pcall(require, "project_nvim") -if not status_ok then - return -end - -project.setup {} - -local tele_status_ok, telescope = pcall(require, "telescope") -if not tele_status_ok then - return -end - -telescope.load_extension('projects') \ No newline at end of file diff --git a/nvim/lua/plugins/renamer.lua b/nvim/lua/plugins/renamer.lua deleted file mode 100644 index 2db1899..0000000 --- a/nvim/lua/plugins/renamer.lua +++ /dev/null @@ -1,46 +0,0 @@ -local status_ok, renamer = pcall(require, "renamer") -if not status_ok then - return -end - -vim.api.nvim_set_keymap( - "i", - "", - 'lua require("renamer").rename({empty = true})', - { noremap = true, silent = true } -) -vim.api.nvim_set_keymap( - "n", - "", - 'lua require("renamer").rename({empty = true})', - { noremap = true, silent = true } -) -local mappings_utils = require("renamer.mappings.utils") -renamer.setup({ - -- The popup title, shown if `border` is true - title = "Rename", - -- The padding around the popup content - padding = { - top = 0, - left = 0, - bottom = 0, - right = 0, - }, - -- Whether or not to shown a border around the popup - border = true, - -- The characters which make up the border - border_chars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - -- Whether or not to highlight the current word references through LSP - show_refs = true, - -- The keymaps available while in the `renamer` buffer. The example below - -- overrides the default values, but you can add others as well. - mappings = { - [""] = mappings_utils.set_cursor_to_start, - [""] = mappings_utils.set_cursor_to_end, - [""] = mappings_utils.set_cursor_to_word_end, - [""] = mappings_utils.set_cursor_to_word_start, - [""] = mappings_utils.clear_line, - [""] = mappings_utils.undo, - [""] = mappings_utils.redo, - }, -}) \ No newline at end of file diff --git a/nvim/lua/plugins/session_manager.lua b/nvim/lua/plugins/session_manager.lua deleted file mode 100644 index 736e69a..0000000 --- a/nvim/lua/plugins/session_manager.lua +++ /dev/null @@ -1,25 +0,0 @@ -local status_ok, session_manager = pcall(require, "session_manager") -if not status_ok then - return -end - -local status_ok, config = pcall(require, "session_manager.config") -if not status_ok then - return -end - --- local Path = require('plenary.path') -session_manager.setup({ - autoload_mode = config.AutoloadMode.CurrentDir, -- Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession - autosave_last_session = false, -- Automatically save last session on exit. -}) - -local tele_status_ok, telescope = pcall(require, "telescope") -if not tele_status_ok then - return -end - -local tele_session_status_ok, telescope = pcall(telescope.load_extension, "sessions") -if not tele_session_status_ok then - return -end \ No newline at end of file diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua deleted file mode 100644 index 4376f76..0000000 --- a/nvim/lua/plugins/telescope.lua +++ /dev/null @@ -1,55 +0,0 @@ -local status_ok, telescope = pcall(require, "telescope") -if not status_ok then - return -end - -telescope.setup { - defaults = { - file_ignore_patterns = {"node_modules", ".git", "dist"}, - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--hidden", - "--iglob", - "!yarn.lock", - "--smart-case", - "-u" - }, - layout_strategy = 'flex', - scroll_strategy = 'cycle', - }, - extensions = { - project = { - base_dirs = { - {path = "~/src", max_depth = 1} - }, - hidden_files = true - }, - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case', - }, - }, - pickers = { - find_files = { - find_command = {"rg", "--files", "--hidden"} - }, - lsp_references = { theme = 'dropdown' }, - lsp_code_actions = { theme = 'dropdown' }, - lsp_definitions = { theme = 'dropdown' }, - lsp_implementations = { theme = 'dropdown' }, - buffers = { - sort_lastused = true, - }, - }, -} - --- Extensions -telescope.load_extension('frecency') -telescope.load_extension('fzf') diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index 95c1aea..0000000 --- a/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,14 +0,0 @@ -local status_ok, treesitter = pcall(require, "nvim-treesitter.configs") -if not status_ok then - return -end - -treesitter.setup { - indent = { - enable = true - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false - } -} \ No newline at end of file diff --git a/nvim/lua/plugins/which-key.lua b/nvim/lua/plugins/which-key.lua deleted file mode 100644 index b30fd4d..0000000 --- a/nvim/lua/plugins/which-key.lua +++ /dev/null @@ -1,34 +0,0 @@ -local status_ok, which_key = pcall(require, "which-key") -if not status_ok then - return -end - -local setup = { - plugins = { - spelling = { - enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions - suggestions = 20, -- how many suggestions should be shown in the list? - }, - }, - window = { - border = "rounded", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0, - }, - layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns - align = "center", -- align columns left, center or right - }, -} -local opts = { - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -which_key.setup(setup) \ No newline at end of file diff --git a/nvim/lua/utils.lua b/nvim/lua/utils.lua deleted file mode 100644 index 14c6e62..0000000 --- a/nvim/lua/utils.lua +++ /dev/null @@ -1,9 +0,0 @@ -local M = {} - -function M.map(mode, lhs, rhs, opts) - local options = {noremap = true} - if opts then options = vim.tbl_extend("force", options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end - -return M \ No newline at end of file diff --git a/nvim/plugin/packer_compiled.lua b/nvim/plugin/packer_compiled.lua deleted file mode 100644 index c302f00..0000000 --- a/nvim/plugin/packer_compiled.lua +++ /dev/null @@ -1,572 +0,0 @@ --- Automatically generated packer.nvim plugin loader code - -if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then - vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') - return -end - -vim.api.nvim_command('packadd packer.nvim') - -local no_errors, error_msg = pcall(function() - - local time - local profile_info - local should_profile = false - if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end - end - else - time = function(chunk, start) end - end - -local function save_profiles(threshold) - local sorted_times = {} - for chunk_name, time_taken in pairs(profile_info) do - sorted_times[#sorted_times + 1] = {chunk_name, time_taken} - end - table.sort(sorted_times, function(a, b) return a[2] > b[2] end) - local results = {} - for i, elem in ipairs(sorted_times) do - if not threshold or threshold and elem[2] > threshold then - results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' - end - end - - _G._packer = _G._packer or {} - _G._packer.profile_output = results -end - -time([[Luarocks path setup]], true) -local package_path_str = "/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" -local install_cpath_pattern = "/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" -if not string.find(package.path, package_path_str, 1, true) then - package.path = package.path .. ';' .. package_path_str -end - -if not string.find(package.cpath, install_cpath_pattern, 1, true) then - package.cpath = package.cpath .. ';' .. install_cpath_pattern -end - -time([[Luarocks path setup]], false) -time([[try_loadstring definition]], true) -local function try_loadstring(s, component, name) - local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) - if not success then - vim.schedule(function() - vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) - end) - end - return result -end - -time([[try_loadstring definition]], false) -time([[Defining packer_plugins]], true) -_G.packer_plugins = { - ["Comment.nvim"] = { - config = { "require('Comment').setup()" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/Comment.nvim", - url = "https://github.com/numToStr/Comment.nvim" - }, - ["DAPInstall.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/DAPInstall.nvim", - url = "https://github.com/Pocco81/DAPInstall.nvim" - }, - ["FixCursorHold.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim", - url = "https://github.com/antoinemadec/FixCursorHold.nvim" - }, - LuaSnip = { - config = { "require('plugins/luasnip')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/LuaSnip", - url = "https://github.com/L3MON4D3/LuaSnip" - }, - ["SchemaStore.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/SchemaStore.nvim", - url = "https://github.com/b0o/SchemaStore.nvim" - }, - ["alpha-nvim"] = { - config = { "require('plugins/alpha')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/alpha-nvim", - url = "https://github.com/goolord/alpha-nvim" - }, - ["cmp-buffer"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-buffer", - url = "https://github.com/hrsh7th/cmp-buffer" - }, - ["cmp-calc"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-calc", - url = "https://github.com/hrsh7th/cmp-calc" - }, - ["cmp-nvim-lsp"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", - url = "https://github.com/hrsh7th/cmp-nvim-lsp" - }, - ["cmp-nvim-lsp-signature-help"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help", - url = "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help" - }, - ["cmp-nvim-lua"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", - url = "https://github.com/hrsh7th/cmp-nvim-lua" - }, - ["cmp-path"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp-path", - url = "https://github.com/hrsh7th/cmp-path" - }, - cmp_luasnip = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/cmp_luasnip", - url = "https://github.com/saadparwaiz1/cmp_luasnip" - }, - ["friendly-snippets"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/friendly-snippets", - url = "https://github.com/rafamadriz/friendly-snippets" - }, - ["git-blame.nvim"] = { - config = { "require('plugins/git-blame')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/git-blame.nvim", - url = "https://github.com/f-person/git-blame.nvim" - }, - ["git-worktree.nvim"] = { - config = { "require('plugins/git-worktree')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/git-worktree.nvim", - url = "https://github.com/ThePrimeagen/git-worktree.nvim" - }, - ["gitsigns.nvim"] = { - config = { "require('plugins/gitsigns')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", - url = "https://github.com/lewis6991/gitsigns.nvim" - }, - harpoon = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/harpoon", - url = "https://github.com/ThePrimeagen/harpoon" - }, - ["impatient.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/impatient.nvim", - url = "https://github.com/lewis6991/impatient.nvim" - }, - ["indent-blankline.nvim"] = { - config = { "require('plugins/blankline')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", - url = "https://github.com/lukas-reineke/indent-blankline.nvim" - }, - ["lazygit.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lazygit.nvim", - url = "https://github.com/kdheepak/lazygit.nvim" - }, - ["lsp_extensions.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lsp_extensions.nvim", - url = "https://github.com/nvim-lua/lsp_extensions.nvim" - }, - ["lsp_signature.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim", - url = "https://github.com/ray-x/lsp_signature.nvim" - }, - ["lspkind-nvim"] = { - config = { "require('plugins/lspkind')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lspkind-nvim", - url = "https://github.com/onsails/lspkind-nvim" - }, - ["lualine.nvim"] = { - config = { "require('plugins/lualine')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/lualine.nvim", - url = "https://github.com/nvim-lualine/lualine.nvim" - }, - neogit = { - commands = { "Neogit" }, - config = { "require('neogit').setup {disable_commit_confirmation = true, disable_signs = true}" }, - loaded = false, - needs_bufread = true, - only_cond = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/neogit", - url = "https://github.com/TimUntersberger/neogit" - }, - ["neovim-session-manager"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/neovim-session-manager", - url = "https://github.com/Shatur/neovim-session-manager" - }, - ["null-ls.nvim"] = { - config = { "require('plugins/null-ls')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/null-ls.nvim", - url = "https://github.com/jose-elias-alvarez/null-ls.nvim" - }, - ["numb.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/numb.nvim", - url = "https://github.com/nacro90/numb.nvim" - }, - ["nvim-bufferline.lua"] = { - config = { "require('plugins/bufferline')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-bufferline.lua", - url = "https://github.com/akinsho/nvim-bufferline.lua" - }, - ["nvim-cmp"] = { - config = { "require('plugins/cmp')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-cmp", - url = "https://github.com/hrsh7th/nvim-cmp" - }, - ["nvim-colorizer.lua"] = { - config = { "require('colorizer').setup {'css', 'javascript', 'vim', 'html'}" }, - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-colorizer.lua", - url = "https://github.com/norcalli/nvim-colorizer.lua" - }, - ["nvim-dap"] = { - config = { "require('plugins/dap')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-dap", - url = "https://github.com/mfussenegger/nvim-dap" - }, - ["nvim-dap-ui"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-dap-ui", - url = "https://github.com/rcarriga/nvim-dap-ui" - }, - ["nvim-dap-virtual-text"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-dap-virtual-text", - url = "https://github.com/theHamsta/nvim-dap-virtual-text" - }, - ["nvim-gps"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-gps", - url = "https://github.com/SmiteshP/nvim-gps" - }, - ["nvim-lsp-installer"] = { - config = { "require('plugins/lsp-installer')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer", - url = "https://github.com/williamboman/nvim-lsp-installer" - }, - ["nvim-lspconfig"] = { - config = { "require('plugins/lspconfig')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", - url = "https://github.com/neovim/nvim-lspconfig" - }, - ["nvim-nonicons"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-nonicons", - url = "https://github.com/yamatsum/nvim-nonicons" - }, - ["nvim-notify"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-notify", - url = "https://github.com/rcarriga/nvim-notify" - }, - ["nvim-spectre"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-spectre", - url = "https://github.com/windwp/nvim-spectre" - }, - ["nvim-tree.lua"] = { - config = { "require('plugins/nvim-tree')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", - url = "https://github.com/kyazdani42/nvim-tree.lua" - }, - ["nvim-treesitter"] = { - config = { "require('plugins/treesitter')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-treesitter", - url = "https://github.com/nvim-treesitter/nvim-treesitter" - }, - ["nvim-treesitter-refactor"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-treesitter-refactor", - url = "https://github.com/nvim-treesitter/nvim-treesitter-refactor" - }, - ["nvim-treesitter-textsubjects"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-treesitter-textsubjects", - url = "https://github.com/RRethy/nvim-treesitter-textsubjects" - }, - ["nvim-web-devicons"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", - url = "https://github.com/kyazdani42/nvim-web-devicons" - }, - ["packer.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/packer.nvim", - url = "https://github.com/wbthomason/packer.nvim" - }, - ["plenary.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/plenary.nvim", - url = "https://github.com/nvim-lua/plenary.nvim" - }, - ["presence.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/presence.nvim", - url = "https://github.com/andweeb/presence.nvim" - }, - ["project.nvim"] = { - config = { "require('plugins/project')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/project.nvim", - url = "https://github.com/ahmedkhalf/project.nvim" - }, - ["refactoring.nvim"] = { - loaded = false, - needs_bufread = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/refactoring.nvim", - url = "https://github.com/ThePrimeagen/refactoring.nvim" - }, - ["renamer.nvim"] = { - config = { "require('plugins/renamer')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/renamer.nvim", - url = "https://github.com/filipdutescu/renamer.nvim" - }, - ripgrep = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/ripgrep", - url = "https://github.com/BurntSushi/ripgrep" - }, - ["rust-tools.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/rust-tools.nvim", - url = "https://github.com/simrat39/rust-tools.nvim" - }, - ["sqlite.lua"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/sqlite.lua", - url = "https://github.com/tami5/sqlite.lua" - }, - ["symbols-outline.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/symbols-outline.nvim", - url = "https://github.com/simrat39/symbols-outline.nvim" - }, - ["telescope-dap.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope-dap.nvim", - url = "https://github.com/nvim-telescope/telescope-dap.nvim" - }, - ["telescope-frecency.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope-frecency.nvim", - url = "https://github.com/nvim-telescope/telescope-frecency.nvim" - }, - ["telescope-fzf-native.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim", - url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" - }, - ["telescope.nvim"] = { - config = { "require('plugins/telescope')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/telescope.nvim", - url = "https://github.com/nvim-telescope/telescope.nvim" - }, - ["trouble.nvim"] = { - commands = { "TroubleToggle" }, - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/trouble.nvim", - url = "https://github.com/folke/trouble.nvim" - }, - undotree = { - commands = { "UndotreeToggle" }, - config = { "vim.g.undotree_SetFocusWhenToggle = 1" }, - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/undotree", - url = "https://github.com/mbbill/undotree" - }, - ["vim-bbye"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/vim-bbye", - url = "https://github.com/moll/vim-bbye" - }, - ["vim-dispatch"] = { - commands = { "Dispatch", "Make", "Focus", "Start" }, - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/vim-dispatch", - url = "https://github.com/tpope/vim-dispatch" - }, - ["vim-eunuch"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/vim-eunuch", - url = "https://github.com/tpope/vim-eunuch" - }, - ["vim-startuptime"] = { - commands = { "StartupTime" }, - config = { "vim.g.startuptime_tries = 3" }, - loaded = false, - needs_bufread = false, - only_cond = false, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/vim-startuptime", - url = "https://github.com/dstein64/vim-startuptime" - }, - ["vscode.nvim"] = { - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/vscode.nvim", - url = "https://github.com/Mofiqul/vscode.nvim" - }, - ["which-key.nvim"] = { - config = { "require('plugins/which-key')" }, - loaded = true, - path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/which-key.nvim", - url = "https://github.com/folke/which-key.nvim" - } -} - -time([[Defining packer_plugins]], false) --- Config for: indent-blankline.nvim -time([[Config for indent-blankline.nvim]], true) -require('plugins/blankline') -time([[Config for indent-blankline.nvim]], false) --- Config for: nvim-bufferline.lua -time([[Config for nvim-bufferline.lua]], true) -require('plugins/bufferline') -time([[Config for nvim-bufferline.lua]], false) --- Config for: nvim-cmp -time([[Config for nvim-cmp]], true) -require('plugins/cmp') -time([[Config for nvim-cmp]], false) --- Config for: nvim-tree.lua -time([[Config for nvim-tree.lua]], true) -require('plugins/nvim-tree') -time([[Config for nvim-tree.lua]], false) --- Config for: Comment.nvim -time([[Config for Comment.nvim]], true) -require('Comment').setup() -time([[Config for Comment.nvim]], false) --- Config for: nvim-treesitter -time([[Config for nvim-treesitter]], true) -require('plugins/treesitter') -time([[Config for nvim-treesitter]], false) --- Config for: nvim-dap -time([[Config for nvim-dap]], true) -require('plugins/dap') -time([[Config for nvim-dap]], false) --- Config for: renamer.nvim -time([[Config for renamer.nvim]], true) -require('plugins/renamer') -time([[Config for renamer.nvim]], false) --- Config for: lspkind-nvim -time([[Config for lspkind-nvim]], true) -require('plugins/lspkind') -time([[Config for lspkind-nvim]], false) --- Config for: which-key.nvim -time([[Config for which-key.nvim]], true) -require('plugins/which-key') -time([[Config for which-key.nvim]], false) --- Config for: lualine.nvim -time([[Config for lualine.nvim]], true) -require('plugins/lualine') -time([[Config for lualine.nvim]], false) --- Config for: LuaSnip -time([[Config for LuaSnip]], true) -require('plugins/luasnip') -time([[Config for LuaSnip]], false) --- Config for: git-blame.nvim -time([[Config for git-blame.nvim]], true) -require('plugins/git-blame') -time([[Config for git-blame.nvim]], false) --- Config for: git-worktree.nvim -time([[Config for git-worktree.nvim]], true) -require('plugins/git-worktree') -time([[Config for git-worktree.nvim]], false) --- Config for: telescope.nvim -time([[Config for telescope.nvim]], true) -require('plugins/telescope') -time([[Config for telescope.nvim]], false) --- Config for: nvim-lsp-installer -time([[Config for nvim-lsp-installer]], true) -require('plugins/lsp-installer') -time([[Config for nvim-lsp-installer]], false) --- Config for: gitsigns.nvim -time([[Config for gitsigns.nvim]], true) -require('plugins/gitsigns') -time([[Config for gitsigns.nvim]], false) --- Config for: nvim-lspconfig -time([[Config for nvim-lspconfig]], true) -require('plugins/lspconfig') -time([[Config for nvim-lspconfig]], false) --- Config for: null-ls.nvim -time([[Config for null-ls.nvim]], true) -require('plugins/null-ls') -time([[Config for null-ls.nvim]], false) --- Config for: alpha-nvim -time([[Config for alpha-nvim]], true) -require('plugins/alpha') -time([[Config for alpha-nvim]], false) --- Config for: project.nvim -time([[Config for project.nvim]], true) -require('plugins/project') -time([[Config for project.nvim]], false) - --- Command lazy-loads -time([[Defining lazy-load commands]], true) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Dispatch lua require("packer.load")({'vim-dispatch'}, { cmd = "Dispatch", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Make lua require("packer.load")({'vim-dispatch'}, { cmd = "Make", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file UndotreeToggle lua require("packer.load")({'undotree'}, { cmd = "UndotreeToggle", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Start lua require("packer.load")({'vim-dispatch'}, { cmd = "Start", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neogit lua require("packer.load")({'neogit'}, { cmd = "Neogit", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file StartupTime lua require("packer.load")({'vim-startuptime'}, { cmd = "StartupTime", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Focus lua require("packer.load")({'vim-dispatch'}, { cmd = "Focus", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file TroubleToggle lua require("packer.load")({'trouble.nvim'}, { cmd = "TroubleToggle", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) -time([[Defining lazy-load commands]], false) - -vim.cmd [[augroup packer_load_aucmds]] -vim.cmd [[au!]] - -- Filetype lazy-loads -time([[Defining lazy-load filetype autocommands]], true) -vim.cmd [[au FileType html ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "html" }, _G.packer_plugins)]] -vim.cmd [[au FileType vim ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "vim" }, _G.packer_plugins)]] -vim.cmd [[au FileType css ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "css" }, _G.packer_plugins)]] -vim.cmd [[au FileType javascript ++once lua require("packer.load")({'nvim-colorizer.lua'}, { ft = "javascript" }, _G.packer_plugins)]] -time([[Defining lazy-load filetype autocommands]], false) -vim.cmd("augroup END") -if should_profile then save_profiles() end - -end) - -if not no_errors then - error_msg = error_msg:gsub('"', '\\"') - vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') -end diff --git a/scripts/.scripts/discord-relay.sh b/scripts/.scripts/discord-relay.sh new file mode 100755 index 0000000..3932908 --- /dev/null +++ b/scripts/.scripts/discord-relay.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec socat UNIX-LISTEN:/var/run/discord-ipc-0,fork,group=discord,umask=007 EXEC:"npiperelay.exe -ep -s //./pipe/discord-ipc-0",nofork >/dev/null 2>&1 diff --git a/scripts/.scripts/git-split.sh b/scripts/.scripts/git-split.sh new file mode 100755 index 0000000..ecb2b3a --- /dev/null +++ b/scripts/.scripts/git-split.sh @@ -0,0 +1,208 @@ +#!/usr/bin/env bash + +TEMP=$(getopt -o hvdymu:r: --long help,verbose,debug,submodule,remote:,username:,visibility: \ + -n 'javawrap' -- "$@") + +if [ $? != 0 ]; then + echo "Terminating..." >&2 + exit 1 +fi + +if ! git rev-parse --is-inside-work-tree &>/dev/null; then + echo "Must be run inside a git repository" >&2 + exit 1 +fi + +eval set -- "$TEMP" + +SCRIPT="$(basename $0)" +ARTIFACTS=(".gitignore" ".gitattributes" ".vscode" "LICENSE") +VERBOSE=false +DEBUG=false +CONFIRMED=false +SUBMODULE=false +REPO=$(git rev-parse --show-toplevel) +USERNAME="$(git config user.username)" +REMOTE= +VISIBILITY="--public" + +read -r -d '' USAGE <<-EOF +USAGE: $SCRIPT [OPTIONS] + +OPTIONS: + -h, --help Show this message + -v, --verbose Show more output + -d, --debug NOT IMPLEMENTED + -y, --confirm Do not prompt for confirmation + -m, --submodule + Migrate directory in original repository to submodule + + -u, --username= + Github username. Can be used instead of remote to dynamically name + the repositories. If --username and --remote are both ommited, defaults + to $(git config user.username) + + -r, --remote= + Github remote, defaults to ${username}/${directory} + + --private + Create the new remote repository as private. It is created + as public if ommited + +ARGS: + ... Directory to split out of original repository, + defaults to current directory +EOF + +while true; do + case "$1" in + -h | --help) + echo "$USAGE" + exit 0 + ;; + -v | --verbose) + VERBOSE=true + shift + ;; + -d | --debug) + DEBUG=true + shift + ;; + -y) + CONFIRMED=true + shift + ;; + -m | --submodule) + SUBMODULE=true + shift + ;; + -u | --username) + USERNAME="$2" + shift 2 + ;; + -r | --remote) + REMOTE="$(basename $(dirname ${2#"git@github.com:"}))/$(basename ${2#"git@github.com:"})" + shift 2 + ;; + --public | --private) + VISIBILITY="$1" + shift + ;; + --) + shift + break + ;; + *) + break + ;; + esac +done + +DIRECTORY="${1:-$(realpath --relative-to="$REPO" .)}" + +if [ ! -d "${REPO}/${DIRECTORY}" ]; then + echo "ERROR: Directory does not exist." >&2 + echo "$USAGE" + exit 1 +fi + +if [ -z "$REMOTE" ]; then + if [ -z "$USERNAME" ]; then + echo "ERROR: No remote provided and user.username was not set." >&2 + echo "$USAGE" + exit 1 + else + REMOTE="${USERNAME}/${DIRECTORY}" + fi +fi + +set -e + +cd $REPO + +git subtree split -P $DIRECTORY -b $DIRECTORY + +cd "$(mktemp -d)" + +git init && git pull $REPO $DIRECTORY && git branch -M main + +for f in "${ARTIFACTS[@]}"; do + if [[ ! -e "./${f}" && -e "${REPO}/${f}" ]]; then + printf '%s\n' "Copying ${f} to new repository..." + cp -r "${REPO}/${f}" ./ + fi +done + +git add -A && git commit -m "split out $DIRECTORY into submodule" + +# TODO check if remote already exists +if command -v gh &>/dev/null; then + yes "n" | gh repo create --confirm "${REMOTE}" "${VISIBILITY}" +else + printf '%s\n' 'gh cli tool could not be found. Explicitly adding git remote to your local repository.' + + git remote add origin https://github.com/${REMOTE} +fi + +set +e + +git push -u origin main + +if [ $? -ne 0 ]; then + printf '\n%s\n' 'Verify/create the remote repository and push to it with the following command: ' + printf '\n\t%s%s%s\n\n' '`cd ' "$(pwd)" ' && git push -u origin main`' + + printf '\t%s\n' \ + '*********************************************************************************' \ + '* The new repository was created in a temp directory! *' \ + '* If the local repository is not pushed to remote, it will be lost on reboot. *' \ + '*********************************************************************************' +else + tempdir="$(pwd)" + cd "$REPO" + rm -rf "$tempdir" +fi + +# Migrate to submodule + +if [ "$SUBMODULE" != true ]; then + exit 0 +fi + +# TODO fix and remove warning + +printf 'Migrating the original subdirectory to submodule.\n' + +if [ "$QUIET" != true ]; then + printf '\t%s\n' \ + '*************************************************************************************' \ + '* THIS IS NOT TESTED AND HAS A POSSIBLY OF DATA LOSS! *' \ + '* *' \ + '* This runs `git rm -rf` and `rm -rf` on the original subdirectory. *' \ + '* Double check you succesfully migrated the subdirectory to the new repository. *' \ + '*************************************************************************************' +fi + +if [ "$CONFIRMED" != true ]; then + read -p "Proceed? (Y/n) " -n 1 -r + printf '\n' + if [[ $REPLY =~ ^[Yy]$ ]]; then + CONFIRMED=true + else + [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 + fi +fi + +cd $REPO + +git rm -rf $DIRECTORY +rm -rf $DIRECTORY + +git submodule add git@github.com:$REMOTE $DIRECTORY +git submodule update --init --recursive + +git commit -m "split out $DIRECTORY into submodule" + +if [ $? -ne 0 ]; then + printf '%s\n' 'Submodule succesfully added. Be sure to `git push -u origin main` after verifing the migration.' +fi diff --git a/scripts/.scripts/gpg-test.sh b/scripts/.scripts/gpg-test.sh new file mode 100644 index 0000000..f23b83d --- /dev/null +++ b/scripts/.scripts/gpg-test.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +TEMP=$(getopt -o hvdsea: --long help,verbose,debug,signature,encryption,authentication \ + -n 'javawrap' -- "$@") + +if [ $? != 0 ]; then + echo "Terminating..." >&2 + exit 1 +fi + +eval set -- "$TEMP" + +usage() { + cat <$temp/test.txt + + result="$(gpg --output $temp/test.gpg -e $temp/test.txt 2>&1 && gpg --output $temp/test.out -d $temp/test.txt.gpg 2>&1)" + grep '42' $temp/test.out 2>&1 + print_result result +fi + +if [[ $ALL -eq "true" || $AUTHENTICATION -eq "true" ]]; then + echo "Testing authentication key..." + result="$(ssh-add -l)" + print_result result +fi diff --git a/scripts/.scripts/init-git.sh b/scripts/.scripts/init-git.sh new file mode 100755 index 0000000..0a45b90 --- /dev/null +++ b/scripts/.scripts/init-git.sh @@ -0,0 +1,193 @@ +#!/usr/bin/env bash + +# Global +SCRIPT="$(basename $0)" +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +GITATTRIBUTES_URL="https://gist.githubusercontent.com/tobyvin/70f3671c76016063594ea45edbb97094/raw" + +# Defaults +VERBOSE=0 +QUIET=0 +INTERACTIVE=0 +TEMPLATE="visualstudiocode" +LICENSE="mit" + +# Usage output +read -r -d '' USAGE < + +OPTIONS: + -h, --help Show this message + -v, --verbose Show more output + -q, --quiet Suppress all output + -i, --interactive Run command interactivly + + -l, --license [LICENSE_ID] + Specify which license to generate. Defaults to '$LICENSE' + + -t, --template [IGNORE_TEMPLATE,...] + Project template(s) used when generating the .gitignore file. It + can also be a comma seperated list or templates. Use '-t list' to + see available templates. Defaults to '$TEMPLATE' +USAGE + +# Options +SHORT=hvqil:t: +LONG=help,verbose,quiet,interactive,license:,template: + +# Test getopt +getopt --test 2>/dev/null +if [[ $? -ne 4 ]]; then + read -r -d '' message <&2 + exit 1 +fi + +# Parse options +TEMP=$(getopt \ + --options ${SHORT} \ + --longoptions ${LONG} \ + --name ${SCRIPT} \ + -- "$@") + +# Exit on failed getopt +if [ $? != 0 ]; then + echo "Error in getopt. Terminating..." >&2 + exit 1 +fi + +eval set -- "${TEMP}" +unset TEMP + +while [[ $# -gt 0 ]]; do + case "$1" in + -h | --help) + echo "$USAGE" + exit 0 + ;; + -v | --verbose) + VERBOSE=1 + shift + ;; + -q | --quiet) + QUIET=1 + shift + ;; + -i | --interactive) + INTERACTIVE=1 + shift + ;; + -l | --license) + LICENSE="$2" + shift 2 + ;; + -t | --template) + TEMPLATE="$2" + shift 2 + ;; + --) + shift + break + ;; + *) break ;; + esac +done + +VALID_TEMPLATES=$(curl -L -s "https://www.toptal.com/developers/gitignore/api/list") + +validate-template() { + local template="$1" + local templates="$2" + if [[ ",$2," == *",$template,"* ]]; then + [ "$QUIET" != 1 ] && printf "'%s' is already added.\n" "$template" >&2 + return 1 + elif ! [[ $VALID_TEMPLATES =~ "$template" ]]; then + [ "$QUIET" != 1 ] && printf "'%s' is not a valid template.\n" "$template" >&2 + return 1 + else + [ "$VERBOSE" == 1 ] && printf "Added template: %s\n" "$template" >&2 + return 0 + fi +} + +get-gitignore() { + local templates='' + IFS=',' read -ra input <<<"$1" + + for template in "${input[@]}"; do + if validate-template "$template" "$templates"; then + templates+="${template}," + fi + done + + echo ${templates%?} +} + +get-gitignore-interactive() { + local templates='' + + while true; do + read -p 'Input gitignore template(s): ' -i "$1" readInput + echo "" + + IFS=', ' input=$readInput + [ -z "$input" ] && break + if [[ "$input" == "list" ]]; then + echo "$VALID_TEMPLATES" >&2 + else + for template in $input; do + if validate-template "$template" "$templates"; then + templates+="${template}," + fi + done + fi + [ "$QUIET" != 1 ] && printf "\nTemplates: %s\n" "${templates%?}" >&2 + done + + echo "${templates%?}" +} + +get-license() { + licenseJson="$(curl -sH 'Accept: application/vnd.github.v3+json' https://api.github.com/licenses/$1)" + # not_found='"message": "Not Found"' + if [[ $licenseJson =~ '"message": "Not Found"' ]]; then + [ "$QUIET" != 1 ] && printf "'%s' is not a valid license identifier.\n" "$LICENSE" >&2 + else + echo $licenseJson | grep -oP '.*"body":\s*"\K.*(?=\s*",)' | + tr '\n' '\0' | xargs -0 printf '%b\n' | + sed "s/\\[year\\]/$(date +'%Y')/" | + sed "s/\\[fullname\\]/$(git config --get user.name)/" + fi +} + +if [[ "$TEMPLATE" == "list" ]]; then + echo "$VALID_TEMPLATES" + exit 0 +fi + +if [ $INTERACTIVE -eq 0 ]; then + gitignore_cmd=get-gitignore +else + gitignore_cmd=get-gitignore-interactive +fi + +TEMPLATES=$($gitignore_cmd $TEMPLATE) + +# .gitignore +[ "$VERBOSE" == 1 ] && printf "Creating .gitignore using: %s\n" "$TEMPLATES" >&1 +curl -L -s "https://www.toptal.com/developers/gitignore/api/${TEMPLATES}" >.gitignore + +# .gitattributes +[ "$VERBOSE" == 1 ] && printf "Creating .gitattributes\n" >&1 +curl -sL "$GITATTRIBUTES_URL" >.gitattributes + +# LICENSE +[ "$VERBOSE" == 1 ] && printf "Creating LICENSE using: %s\n" "$LICENSE" >&1 +get-license $LICENSE >LICENSE + +echo "$PWD" diff --git a/scripts/.scripts/init-latex.sh b/scripts/.scripts/init-latex.sh new file mode 100755 index 0000000..7b8125e --- /dev/null +++ b/scripts/.scripts/init-latex.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +USER="tobyvin" +GIST_ID="c94716d1106256e4ab0e27aed398a0a2" + +curl -Ls "https://gist.github.com/${USER}/${GIST_ID}/download" -o tempFile +unzip -q tempFile +rm -rf tempFile +mv "${GIST_ID}-master" styles +mv styles/template.tex "$(basename "$(pwd)").tex" +mv styles/table.tex . diff --git a/scripts/.scripts/install-crate.sh b/scripts/.scripts/install-crate.sh new file mode 100755 index 0000000..1c1578a --- /dev/null +++ b/scripts/.scripts/install-crate.sh @@ -0,0 +1,235 @@ +#!/bin/sh + +# modified from https://github.com/japaric/trust/blob/gh-pages/install.sh. + +set -e + +help() { + cat <<'EOF' +Install a binary release of a Rust crate hosted on GitHub + +Usage: + install-crate.sh [options] + +Options: + -h, --help Display this message + -q, --quiet Silence all output + --git SLUG Get the crate from "https://github/$SLUG" + -f, --force Force overwriting an existing binary + --crate NAME Name of the crate to install (default ) + --tag TAG Tag (version) of the crate to install (default ) + --no-tag Do not tag between the crate and the target in the url + --target TARGET Install the release compiled for $TARGET (default <`rustc` host>) + --to LOCATION Where to install the binary (default ~/.cargo/bin) + --completion + Install all the completions + + --completion-bash DIR + Install the bash completion scripts in DIR (default ~/.local/share/bash_completion.d) + + --completion-zsh DIR + Install the zsh completion scripts in DIR (default ~/.local/share/zsh/site-functions) + + --completion-fish DIR + Install the fish completion scripts in DIR (default ~/.config/fish/completions) +EOF +} + +say() { + if [ ! $quiet ]; then + echo "install-crate.sh: $1" + fi +} + +say_err() { + say "$1" >&2 +} + +err() { + if [ ! -z $td ]; then + rm -rf $td + fi + + say_err "ERROR $1" + exit 1 +} + +need() { + if ! command -v $1 >/dev/null 2>&1; then + err "need $1 (command not found)" + fi +} + +is_opt() { case $1 in "--"*) true ;; *) false ;; esac } +is_arg() { if [ "$1" ] && ! is_opt $1; then true; else false; fi; } + +quiet=false +force=false +no_tag=false +completion_bash=false +completion_zsh=false +completion_fish=false +comp_dir_bash="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" +comp_dir_zsh="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" +comp_dir_fish="${XDG_CONFIG_HOME:-$HOME/.config}/fish/completions" +while test $# -gt 0; do + case $1 in + --quiet | -q) + quiet=true + ;; + --crate) + crate=$2 + shift + ;; + --force | -f) + force=true + ;; + --git) + git=$2 + shift + ;; + --help | -h) + help + exit 0 + ;; + --tag) + tag=$2 + shift + ;; + --no-tag) + no_tag=true + ;; + --target) + target=$2 + shift + ;; + --to) + dest=$2 + shift + ;; + --completion) + completion_bash=true + completion_zsh=true + completion_fish=true + ;; + --completion-bash) + completion_bash=true + if is_arg $2; then + comp_dir_bash=$2 + shift + fi + ;; + --completion-zsh) + completion_zsh=true + if is_arg $2; then + echo "$2" + comp_dir_zsh=$2 + shift + fi + ;; + --completion-fish) + completion_fish=true + if is_arg $2; then + comp_dir_fish=$2 + shift + fi + ;; + *) ;; + + esac + shift +done + +# Dependencies +need basename +need curl +need install +need mkdir +need mktemp +need tar + +# Optional dependencies +if [ -z $crate ] || [ -z $tag ] || [ -z $target ]; then + need cut +fi + +if [ -z $tag ]; then + need rev +fi + +if [ -z $target ]; then + need grep + need rustc +fi + +if [ -z $git ]; then + err 'must specify a git repository using `--git`. Example: `install.sh --git japaric/cross`' +fi + +url="https://github.com/$git" +say_err "GitHub repository: $url" + +if [ -z $crate ]; then + crate=$(echo $git | cut -d'/' -f2) +fi + +say_err "Crate: $crate" + +url="$url/releases" + +if [ -z $tag ]; then + tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev) + say_err "Tag: latest ($tag)" +else + say_err "Tag: $tag" +fi + +if [ -z $target ]; then + target=$(rustc -Vv | grep host | cut -d' ' -f2) +fi + +say_err "Target: $target" + +if [ -z $dest ]; then + dest="$HOME/.cargo/bin" +fi + +if [ $no_tag = true ]; then + crate_tag="$crate" +elif case $tag in "$crate"*) true ;; *) false ;; esac then + crate_tag="$tag" +else + crate_tag="$crate-$tag" +fi + +say_err "Installing to: $dest" +url="$url/download/$tag/${crate_tag}-$target.tar.gz" + +say_err "Downloading: $url" + +td=$(mktemp -d || mktemp -d -t tmp) +curl -sL $url | tar -C $td -xz + +for f in $(find "$td" -type f); do + case $f in + *".bash") + [ $completion_bash ] && install -D $f "$comp_dir_bash/$crate" + ;; + *".zsh" | *"_$crate") + [ $completion_zsh ] && install -D $f "$comp_dir_zsh/_$crate" + ;; + *".fish") + [ $completion_fish ] && install -D $f "$comp_dir_fish/$crate.fish" + ;; + *) ;; + esac + + test -x $f || continue + if [ -e "$dest/$f" ] && [ $force = false ]; then + err "$(dirname $f) already exists in $dest" + else + install -Dm 755 $f $dest + fi +done + +rm -rf $td diff --git a/scripts/.scripts/mega-dl.sh b/scripts/.scripts/mega-dl.sh new file mode 100755 index 0000000..b19be68 --- /dev/null +++ b/scripts/.scripts/mega-dl.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +# Source: https://gist.github.com/zanculmarktum/170b94764bd9a3da31078580ccea8d7e + +# Copyright 2018, 2019, 2020 Azure Zanculmarktum +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Dependencies: +# openssl + +# Usage: +# $ ./megafetch.sh https://mega.nz/#!abcdefgh!1234567890abcdefghijklmnopqrstuvwxyzABCDEFG +# http://gfs208n103.userstorage.mega.co.nz/dl/-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A +# file.name +# abcefghijklmnopqrstuvwxyz0123456 +# 1234567890abcdef0000000000000000 +# $ wget -O file.name http://gfs208n103.userstorage.mega.co.nz/dl/-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A +# $ cat file.name | openssl enc -d -aes-128-ctr -K abcefghijklmnopqrstuvwxyz0123456 -iv 1234567890abcdef0000000000000000 > file.name.new +# $ mv -f file.name.new file.name + +URL="" +OUTPATH="$PWD" +USAGE="Usage: ${0##*/} " + +if [[ $1 =~ ^https?:\/\/mega(\.co)?\.nz ]]; then + URL="$1" +fi + +if [[ ! $URL ]]; then + echo $USAGE >&2 + exit 1 +fi + +if [[ ! -z "$2" ]]; then + OUTPATH="$2" +fi + +if [[ ! -d "$OUTPATH" ]]; then + echo $USAGE >&2 + exit 1 +fi + +CURL="curl -Y 1 -y 10" + +missing=false +for cmd in openssl; do + if [[ ! $(command -v "$cmd" 2>&1) ]]; then + missing=true + echo "${0##*/}: $cmd: command not found" >&2 + fi +done +if $missing; then + exit 1 +fi + +if [[ $URL =~ .*/file/[^#]*#[^#]* ]]; then + id="${URL#*file/}" + id="${id%%#*}" + key="${URL##*file/}" + key="${key##*#}" +else + id="${URL#*!}" + id="${id%%!*}" + key="${URL##*!}" +fi + +raw_hex=$(echo "${key}=" | tr '\-_' '+/' | tr -d ',' | base64 -d -i 2>/dev/null | od -v -An -t x1 | tr -d '\n ') +hex=$( + printf "%016x" \ + $((0x${raw_hex:0:16} ^ 0x${raw_hex:32:16})) \ + $((0x${raw_hex:16:16} ^ 0x${raw_hex:48:16})) +) + +json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "g":"1", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1 +json="${json#"[{"}" +json="${json%"}]"}" +file_url="${json##*'"g":'}" +file_url="${file_url%%,*}" +file_url="${file_url//'"'/}" + +json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1 +at="${json##*'"at":'}" +at="${at%%,*}" +at="${at//'"'/}" + +json=$(echo "${at}==" | tr '\-_' '+/' | tr -d ',' | openssl enc -a -A -d -aes-128-cbc -K "$hex" -iv "00000000000000000000000000000000" -nopad | tr -d '\0') +json="${json#"MEGA{"}" +json="${json%"}"}" +file_name="${json##*'"n":'}" +if [[ $file_name == *,* ]]; then + file_name="${file_name%%,*}" +fi +file_name="${file_name//'"'/}" + +outfile="$OUTPATH/$file_name" + +$CURL -s "$file_url" | openssl enc -d -aes-128-ctr -K "$hex" -iv "${raw_hex:32:16}0000000000000000" >"$outfile" + +echo "$outfile" + +# echo "$file_url" +# echo "$file_name" +# echo "$hex" +# echo "${raw_hex:32:16}0000000000000000" diff --git a/scripts/.scripts/mkln.sh b/scripts/.scripts/mkln.sh new file mode 100755 index 0000000..ef174c2 --- /dev/null +++ b/scripts/.scripts/mkln.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +TEMP=$(getopt -o hvqdf --long help,verbose,quiet,debug,force \ + -n 'javawrap' -- "$@") + +if [ $? != 0 ]; then + echo "Terminating..." >&2 + exit 1 +fi + +eval set -- "$TEMP" + +SCRIPT="$(basename $0)" +VERBOSE=false +QUIET=false +DEBUG=false +FORCE=false + +read -r -d '' USAGE <<-EOF +USAGE: $SCRIPT [OPTIONS] + +OPTIONS: + -h, --help Show this message + -v, --verbose Show more output + -q, --quiet Suppress all output + -d, --debug NOT IMPLEMENTED + -f, --force Overwrite items + +ARGS: + ... File to link. +EOF + +while true; do + case "$1" in + -h | --help) + echo "$USAGE" + exit 0 + ;; + -v | --verbose) + VERBOSE=true + shift + ;; + -q | --quiet) + QUIET=true + shift + ;; + -d | --debug) + DEBUG=true + shift + ;; + -f | --force) + FORCE=true + shift + ;; + --) + shift + break + ;; + *) + break + ;; + esac +done + +if ! command -v powershell.exe &>/dev/null; then + [ "$QUIET" != true ] && echo "Powershell not found in path." >&2 + exit 1 +fi + +if [ -z "$2" ]; then + 2="$(pwd)" +fi + +[ "$VERBOSE" == true ] && echo "linking $2 -> $1" + +if [ -d "$1" ]; then + [ "$VERBOSE" == true ] && echo "$1 is a directory. Creating symbolic link." + args='/D' +fi + +mkdir -p $(dirname $2) + +source=$(wslpath -w $1) +target=$(wslpath -w $(dirname $2))\\$(basename $2) + +if ls -la "$(dirname $2)/" 2>/dev/null | grep -q "$(basename $2)"; then + + current_path=$(powershell.exe -c "(Get-Item $target).Target" 2>/dev/null) + + if [[ "${current_path/*wsl$/}" == *"${source/*wsl$/}"* ]]; then + [ "$VERBOSE" == true ] && echo "$(basename $2) is set correctly. Skipping." + exit 0 + fi + + if [ "$FORCE" == true ]; then + [ "$VERBOSE" == true ] && echo "$(basename $2) exists. Overwriting." + rm -rf "$2" + else + [ "$QUIET" != true ] && echo "$(basename $target) already exists. Use -f to overwrite." >&2 + exit 1 + fi +fi + +mkdir -p "$(dirname $2)" +cmd="cd ~; cmd /c mklink ${args} ${target} ${source}" + +if [ "$DEBUG" == true ]; then + [ "$QUIET" != true ] && printf '\nCommand: \n%s\n\n' "powershell.exe -c ${cmd} &>/dev/null" +else + if $QUIET; then + powershell.exe -c "${cmd}" &>/dev/null + else + powershell.exe -c "${cmd}" + fi +fi diff --git a/scripts/.scripts/socket-relay.sh b/scripts/.scripts/socket-relay.sh new file mode 100755 index 0000000..436fa54 --- /dev/null +++ b/scripts/.scripts/socket-relay.sh @@ -0,0 +1,217 @@ +#!/usr/bin/env bash +set -euo pipefail + +OPTS=$(getopt -o hds:x: --long help,debug,sock:,exec:,ssh,gpg,gpg-extra,discord -n 'javawrap' -- "$@") + +eval set -- "$OPTS" + +PAGEANT="$HOME/.ssh/wsl2-ssh-pageant.exe" +NPIPE="$(command -v npiperelay.exe)" +SCRIPT="$(basename "$0")" + +help() { + cat <<-EOF +$SCRIPT +Toby Vincent + +$SCRIPT description + +USAGE: + $SCRIPT [OPTIONS] + $SCRIPT [OPTIONS] + +OPTIONS: + -h, --help Display this message + -s, --sock Path to the linux socket + -x, --exec Command to run for socat's EXEC: arg + --ssh Relay the ssh agent's socket + --gpg Relay the gpg agent's socket + --gpg-extra Relay the gpg agent's extra socket + +ARGS: + start (default) + Start the socat process + + stop + Kill the socat process +EOF +} + +say() { + if ! $quiet; then + echo "$SCRIPT: $1" + fi +} + +say_err() { + say "$1" >&2 +} + +err() { + say_err "ERROR: $1" + exit 1 +} + +need() { + for cmd in $@; do + if ! command -v $cmd >/dev/null 2>&1; then + err "need $cmd (command not found)" + fi + done +} + +start() { + if ! ss -a | grep -q "$sock"; then + if test -x "$relay"; then + rm -rf "$sock" + (setsid nohup socat UNIX-LISTEN:"${sock},${listen_args}" EXEC:"$cmd" >/dev/null 2>&1 &) + + else + echo >&2 "WARNING: $relay is not executable." + fi + fi + + if $gpg; then + gpg-connect-agent.exe /bye &>/dev/null + fi +} + +stop() { + if $gpg; then + gpg-connect-agent.exe KILLAGENT /bye &>/dev/null + fi + + if pgrep -f "socat.*$sock.*$relay" &>/dev/null; then + pkill -f "socat.*$sock.*$relay" + fi +} + +check() { + pgrep -fa "socat.*$sock.*$relay" +} + +quiet=false +debug=false +sock="" +cmd="" +gpg=false +ssh=false +extra=false +discord=false +while test $# -gt 0; do + case $1 in + -h | --help) + help + return 0 + ;; + -q | --quiet) + quiet=true + shift + ;; + -d | --debug) + debug=true + shift + ;; + -s | --sock) + sock=$2 + shift + shift + ;; + -x | --exec) + cmd=$2 + shift + shift + ;; + --ssh) + ssh=true + shift + ;; + --gpg) + gpg=true + shift + ;; + --gpg-extra) + gpg=true + extra=true + shift + ;; + --discord) + discord=true + shift + ;; + --) + shift + break + ;; + *) + help + exit 1 + ;; + esac +done + +need ss +need socat + +listen_args="fork" + +case true in +$ssh) + need $PAGEANT + + sock="${SSH_AUTH_SOCK:-$HOME/.ssh/agent.sock}" + cmd="$PAGEANT" + ;; +$gpg) + need $PAGEANT + need "gpg-connect-agent.exe" + + sock="${GPG_AGENT_SOCK:-$HOME/.gnupg/S.gpg-agent}" + if $extra; then + sock+=".extra" + fi + + cmd="$PAGEANT --gpg $(basename $sock)" + ;; +$discord) + need $NPIPE + + sock="${DISCORD_IPC_SOCK:-/var/run/discord-ipc-0}" + cmd="$NPIPE -ep -s //./pipe/$(basename $sock)" + + listen_args="fork,group=discord,umask=007" + ;; +$(test -z "${cmd}")) + err "No EXEC provided. Must supply either --ssh, --gpg, --gpg-extra, --pipe, or --exec" + ;; +esac + +if test -z "${sock}"; then + err "No socket provided." +fi + +relay="$(echo $cmd | head -n1 | awk '{print $1;}')" + +case ${1:-'start'} in +check) + shift + check + ;; +start) + shift + start + ;; +stop) + shift + stop + ;; +restart) + shift + stop + start + ;; +*) + help + exit 1 + ;; +esac diff --git a/scripts/.scripts/td.sh b/scripts/.scripts/td.sh new file mode 100755 index 0000000..968c98b --- /dev/null +++ b/scripts/.scripts/td.sh @@ -0,0 +1,151 @@ +#!/bin/sh +TEMP=$(getopt -o hf --long help,force \ + -n 'javawrap' -- "$@") + +if [ $? != 0 ]; then + echo "Terminating..." >&2 + exit 1 +fi + +eval set -- "$TEMP" + +SCRIPT="$(basename $0)" +ENV_CACHE="${HOME}/.cache/td/.env" + +help() { + cat <<-EOF +$SCRIPT +Toby Vincent + +$SCRIPT is a script for managing and navigating a persistent temp directory. In +order to function properly, this script must be sourced in the currently shell. +Consider setting an alias such as + + alias td=". $SCRIPT" + +USAGE: + $SCRIPT [OPTIONS] + $SCRIPT [OPTIONS] + +OPTIONS: + -h, --help Display this message + -f, --force Use the --force argument when removing TD + +ARGS: + toggle (default) + Switch between TD_ORIGIN and TD. This will create TD if it does not + exist. This is the default if no command is provided. + + new | create + Creates a new temp directory and cds into it it stores the path + to the temp directory in TD, and the path to the previous directory in + TD_ORIGIN. + + rm | remove + Removes the directory stored in TD unsets TD and TD_ORIGIN. + + ls | list | show + Shows the current values for TD and TD_ORIGIN +EOF +} + +echo_err() { + echo >&2 "$SCRIPT: $@" +} + +show() { + if [ ! -n "$TD" ]; then + echo_err "Not set" + return 1 + fi + echo "TD=$TD" + echo "TD_ORIGIN=$TD_ORIGIN" +} + +remove() { + if [ ! -n "$TD" ]; then + echo_err "Not set" + return 1 + fi + + rm "$rm_args" "$TD" + + echo "removed $TD" + + if [ "$PWD" = "$TD" ]; then + cd "$TD_ORIGIN" + fi + + rm "$ENV_CACHE" -rf + unset TD + unset TD_ORIGIN +} + +create() { + remove 2>/dev/null + + td=$(mktemp -d) + + export TD="$td" + update-origin + + echo "created $TD" + cd "$TD" +} + +update-origin() { + export TD_ORIGIN="$PWD" + cat >$ENV_CACHE <<-EOF +TD=$TD +TD_ORIGIN=$TD_ORIGIN +EOF +} + +toggle() { + if [ "$PWD" = "$TD" ]; then + cd "$TD_ORIGIN" + elif [ -n "$TD" ]; then + update-origin + cd "$TD" + else + create + fi +} + +if [ -f "$ENV_CACHE" ]; then + export $(cat "$ENV_CACHE" | xargs) +fi + +rm_args="-r" +while test $# -gt 0; do + case $1 in + --help | -h) + help + return 0 + ;; + --force | -f) + rm_args="-rf" + shift + ;; + --) + shift + break + ;; + *) break ;; + esac +done + +case $1 in +ls | list | show) + show + ;; +rm | remove) + remove + ;; +new | create) + create + ;; +* | toggle) + toggle + ;; +esac diff --git a/scripts/discord-relay.sh b/scripts/discord-relay.sh deleted file mode 100755 index 3932908..0000000 --- a/scripts/discord-relay.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec socat UNIX-LISTEN:/var/run/discord-ipc-0,fork,group=discord,umask=007 EXEC:"npiperelay.exe -ep -s //./pipe/discord-ipc-0",nofork >/dev/null 2>&1 diff --git a/scripts/git-split.sh b/scripts/git-split.sh deleted file mode 100755 index ecb2b3a..0000000 --- a/scripts/git-split.sh +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env bash - -TEMP=$(getopt -o hvdymu:r: --long help,verbose,debug,submodule,remote:,username:,visibility: \ - -n 'javawrap' -- "$@") - -if [ $? != 0 ]; then - echo "Terminating..." >&2 - exit 1 -fi - -if ! git rev-parse --is-inside-work-tree &>/dev/null; then - echo "Must be run inside a git repository" >&2 - exit 1 -fi - -eval set -- "$TEMP" - -SCRIPT="$(basename $0)" -ARTIFACTS=(".gitignore" ".gitattributes" ".vscode" "LICENSE") -VERBOSE=false -DEBUG=false -CONFIRMED=false -SUBMODULE=false -REPO=$(git rev-parse --show-toplevel) -USERNAME="$(git config user.username)" -REMOTE= -VISIBILITY="--public" - -read -r -d '' USAGE <<-EOF -USAGE: $SCRIPT [OPTIONS] - -OPTIONS: - -h, --help Show this message - -v, --verbose Show more output - -d, --debug NOT IMPLEMENTED - -y, --confirm Do not prompt for confirmation - -m, --submodule - Migrate directory in original repository to submodule - - -u, --username= - Github username. Can be used instead of remote to dynamically name - the repositories. If --username and --remote are both ommited, defaults - to $(git config user.username) - - -r, --remote= - Github remote, defaults to ${username}/${directory} - - --private - Create the new remote repository as private. It is created - as public if ommited - -ARGS: - ... Directory to split out of original repository, - defaults to current directory -EOF - -while true; do - case "$1" in - -h | --help) - echo "$USAGE" - exit 0 - ;; - -v | --verbose) - VERBOSE=true - shift - ;; - -d | --debug) - DEBUG=true - shift - ;; - -y) - CONFIRMED=true - shift - ;; - -m | --submodule) - SUBMODULE=true - shift - ;; - -u | --username) - USERNAME="$2" - shift 2 - ;; - -r | --remote) - REMOTE="$(basename $(dirname ${2#"git@github.com:"}))/$(basename ${2#"git@github.com:"})" - shift 2 - ;; - --public | --private) - VISIBILITY="$1" - shift - ;; - --) - shift - break - ;; - *) - break - ;; - esac -done - -DIRECTORY="${1:-$(realpath --relative-to="$REPO" .)}" - -if [ ! -d "${REPO}/${DIRECTORY}" ]; then - echo "ERROR: Directory does not exist." >&2 - echo "$USAGE" - exit 1 -fi - -if [ -z "$REMOTE" ]; then - if [ -z "$USERNAME" ]; then - echo "ERROR: No remote provided and user.username was not set." >&2 - echo "$USAGE" - exit 1 - else - REMOTE="${USERNAME}/${DIRECTORY}" - fi -fi - -set -e - -cd $REPO - -git subtree split -P $DIRECTORY -b $DIRECTORY - -cd "$(mktemp -d)" - -git init && git pull $REPO $DIRECTORY && git branch -M main - -for f in "${ARTIFACTS[@]}"; do - if [[ ! -e "./${f}" && -e "${REPO}/${f}" ]]; then - printf '%s\n' "Copying ${f} to new repository..." - cp -r "${REPO}/${f}" ./ - fi -done - -git add -A && git commit -m "split out $DIRECTORY into submodule" - -# TODO check if remote already exists -if command -v gh &>/dev/null; then - yes "n" | gh repo create --confirm "${REMOTE}" "${VISIBILITY}" -else - printf '%s\n' 'gh cli tool could not be found. Explicitly adding git remote to your local repository.' - - git remote add origin https://github.com/${REMOTE} -fi - -set +e - -git push -u origin main - -if [ $? -ne 0 ]; then - printf '\n%s\n' 'Verify/create the remote repository and push to it with the following command: ' - printf '\n\t%s%s%s\n\n' '`cd ' "$(pwd)" ' && git push -u origin main`' - - printf '\t%s\n' \ - '*********************************************************************************' \ - '* The new repository was created in a temp directory! *' \ - '* If the local repository is not pushed to remote, it will be lost on reboot. *' \ - '*********************************************************************************' -else - tempdir="$(pwd)" - cd "$REPO" - rm -rf "$tempdir" -fi - -# Migrate to submodule - -if [ "$SUBMODULE" != true ]; then - exit 0 -fi - -# TODO fix and remove warning - -printf 'Migrating the original subdirectory to submodule.\n' - -if [ "$QUIET" != true ]; then - printf '\t%s\n' \ - '*************************************************************************************' \ - '* THIS IS NOT TESTED AND HAS A POSSIBLY OF DATA LOSS! *' \ - '* *' \ - '* This runs `git rm -rf` and `rm -rf` on the original subdirectory. *' \ - '* Double check you succesfully migrated the subdirectory to the new repository. *' \ - '*************************************************************************************' -fi - -if [ "$CONFIRMED" != true ]; then - read -p "Proceed? (Y/n) " -n 1 -r - printf '\n' - if [[ $REPLY =~ ^[Yy]$ ]]; then - CONFIRMED=true - else - [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 - fi -fi - -cd $REPO - -git rm -rf $DIRECTORY -rm -rf $DIRECTORY - -git submodule add git@github.com:$REMOTE $DIRECTORY -git submodule update --init --recursive - -git commit -m "split out $DIRECTORY into submodule" - -if [ $? -ne 0 ]; then - printf '%s\n' 'Submodule succesfully added. Be sure to `git push -u origin main` after verifing the migration.' -fi diff --git a/scripts/gpg-test.sh b/scripts/gpg-test.sh deleted file mode 100644 index f23b83d..0000000 --- a/scripts/gpg-test.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bash - -TEMP=$(getopt -o hvdsea: --long help,verbose,debug,signature,encryption,authentication \ - -n 'javawrap' -- "$@") - -if [ $? != 0 ]; then - echo "Terminating..." >&2 - exit 1 -fi - -eval set -- "$TEMP" - -usage() { - cat <$temp/test.txt - - result="$(gpg --output $temp/test.gpg -e $temp/test.txt 2>&1 && gpg --output $temp/test.out -d $temp/test.txt.gpg 2>&1)" - grep '42' $temp/test.out 2>&1 - print_result result -fi - -if [[ $ALL -eq "true" || $AUTHENTICATION -eq "true" ]]; then - echo "Testing authentication key..." - result="$(ssh-add -l)" - print_result result -fi diff --git a/scripts/init-git.sh b/scripts/init-git.sh deleted file mode 100755 index 0a45b90..0000000 --- a/scripts/init-git.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env bash - -# Global -SCRIPT="$(basename $0)" -SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" -GITATTRIBUTES_URL="https://gist.githubusercontent.com/tobyvin/70f3671c76016063594ea45edbb97094/raw" - -# Defaults -VERBOSE=0 -QUIET=0 -INTERACTIVE=0 -TEMPLATE="visualstudiocode" -LICENSE="mit" - -# Usage output -read -r -d '' USAGE < - -OPTIONS: - -h, --help Show this message - -v, --verbose Show more output - -q, --quiet Suppress all output - -i, --interactive Run command interactivly - - -l, --license [LICENSE_ID] - Specify which license to generate. Defaults to '$LICENSE' - - -t, --template [IGNORE_TEMPLATE,...] - Project template(s) used when generating the .gitignore file. It - can also be a comma seperated list or templates. Use '-t list' to - see available templates. Defaults to '$TEMPLATE' -USAGE - -# Options -SHORT=hvqil:t: -LONG=help,verbose,quiet,interactive,license:,template: - -# Test getopt -getopt --test 2>/dev/null -if [[ $? -ne 4 ]]; then - read -r -d '' message <&2 - exit 1 -fi - -# Parse options -TEMP=$(getopt \ - --options ${SHORT} \ - --longoptions ${LONG} \ - --name ${SCRIPT} \ - -- "$@") - -# Exit on failed getopt -if [ $? != 0 ]; then - echo "Error in getopt. Terminating..." >&2 - exit 1 -fi - -eval set -- "${TEMP}" -unset TEMP - -while [[ $# -gt 0 ]]; do - case "$1" in - -h | --help) - echo "$USAGE" - exit 0 - ;; - -v | --verbose) - VERBOSE=1 - shift - ;; - -q | --quiet) - QUIET=1 - shift - ;; - -i | --interactive) - INTERACTIVE=1 - shift - ;; - -l | --license) - LICENSE="$2" - shift 2 - ;; - -t | --template) - TEMPLATE="$2" - shift 2 - ;; - --) - shift - break - ;; - *) break ;; - esac -done - -VALID_TEMPLATES=$(curl -L -s "https://www.toptal.com/developers/gitignore/api/list") - -validate-template() { - local template="$1" - local templates="$2" - if [[ ",$2," == *",$template,"* ]]; then - [ "$QUIET" != 1 ] && printf "'%s' is already added.\n" "$template" >&2 - return 1 - elif ! [[ $VALID_TEMPLATES =~ "$template" ]]; then - [ "$QUIET" != 1 ] && printf "'%s' is not a valid template.\n" "$template" >&2 - return 1 - else - [ "$VERBOSE" == 1 ] && printf "Added template: %s\n" "$template" >&2 - return 0 - fi -} - -get-gitignore() { - local templates='' - IFS=',' read -ra input <<<"$1" - - for template in "${input[@]}"; do - if validate-template "$template" "$templates"; then - templates+="${template}," - fi - done - - echo ${templates%?} -} - -get-gitignore-interactive() { - local templates='' - - while true; do - read -p 'Input gitignore template(s): ' -i "$1" readInput - echo "" - - IFS=', ' input=$readInput - [ -z "$input" ] && break - if [[ "$input" == "list" ]]; then - echo "$VALID_TEMPLATES" >&2 - else - for template in $input; do - if validate-template "$template" "$templates"; then - templates+="${template}," - fi - done - fi - [ "$QUIET" != 1 ] && printf "\nTemplates: %s\n" "${templates%?}" >&2 - done - - echo "${templates%?}" -} - -get-license() { - licenseJson="$(curl -sH 'Accept: application/vnd.github.v3+json' https://api.github.com/licenses/$1)" - # not_found='"message": "Not Found"' - if [[ $licenseJson =~ '"message": "Not Found"' ]]; then - [ "$QUIET" != 1 ] && printf "'%s' is not a valid license identifier.\n" "$LICENSE" >&2 - else - echo $licenseJson | grep -oP '.*"body":\s*"\K.*(?=\s*",)' | - tr '\n' '\0' | xargs -0 printf '%b\n' | - sed "s/\\[year\\]/$(date +'%Y')/" | - sed "s/\\[fullname\\]/$(git config --get user.name)/" - fi -} - -if [[ "$TEMPLATE" == "list" ]]; then - echo "$VALID_TEMPLATES" - exit 0 -fi - -if [ $INTERACTIVE -eq 0 ]; then - gitignore_cmd=get-gitignore -else - gitignore_cmd=get-gitignore-interactive -fi - -TEMPLATES=$($gitignore_cmd $TEMPLATE) - -# .gitignore -[ "$VERBOSE" == 1 ] && printf "Creating .gitignore using: %s\n" "$TEMPLATES" >&1 -curl -L -s "https://www.toptal.com/developers/gitignore/api/${TEMPLATES}" >.gitignore - -# .gitattributes -[ "$VERBOSE" == 1 ] && printf "Creating .gitattributes\n" >&1 -curl -sL "$GITATTRIBUTES_URL" >.gitattributes - -# LICENSE -[ "$VERBOSE" == 1 ] && printf "Creating LICENSE using: %s\n" "$LICENSE" >&1 -get-license $LICENSE >LICENSE - -echo "$PWD" diff --git a/scripts/init-latex.sh b/scripts/init-latex.sh deleted file mode 100755 index 7b8125e..0000000 --- a/scripts/init-latex.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -USER="tobyvin" -GIST_ID="c94716d1106256e4ab0e27aed398a0a2" - -curl -Ls "https://gist.github.com/${USER}/${GIST_ID}/download" -o tempFile -unzip -q tempFile -rm -rf tempFile -mv "${GIST_ID}-master" styles -mv styles/template.tex "$(basename "$(pwd)").tex" -mv styles/table.tex . diff --git a/scripts/install-crate.sh b/scripts/install-crate.sh deleted file mode 100755 index 1c1578a..0000000 --- a/scripts/install-crate.sh +++ /dev/null @@ -1,235 +0,0 @@ -#!/bin/sh - -# modified from https://github.com/japaric/trust/blob/gh-pages/install.sh. - -set -e - -help() { - cat <<'EOF' -Install a binary release of a Rust crate hosted on GitHub - -Usage: - install-crate.sh [options] - -Options: - -h, --help Display this message - -q, --quiet Silence all output - --git SLUG Get the crate from "https://github/$SLUG" - -f, --force Force overwriting an existing binary - --crate NAME Name of the crate to install (default ) - --tag TAG Tag (version) of the crate to install (default ) - --no-tag Do not tag between the crate and the target in the url - --target TARGET Install the release compiled for $TARGET (default <`rustc` host>) - --to LOCATION Where to install the binary (default ~/.cargo/bin) - --completion - Install all the completions - - --completion-bash DIR - Install the bash completion scripts in DIR (default ~/.local/share/bash_completion.d) - - --completion-zsh DIR - Install the zsh completion scripts in DIR (default ~/.local/share/zsh/site-functions) - - --completion-fish DIR - Install the fish completion scripts in DIR (default ~/.config/fish/completions) -EOF -} - -say() { - if [ ! $quiet ]; then - echo "install-crate.sh: $1" - fi -} - -say_err() { - say "$1" >&2 -} - -err() { - if [ ! -z $td ]; then - rm -rf $td - fi - - say_err "ERROR $1" - exit 1 -} - -need() { - if ! command -v $1 >/dev/null 2>&1; then - err "need $1 (command not found)" - fi -} - -is_opt() { case $1 in "--"*) true ;; *) false ;; esac } -is_arg() { if [ "$1" ] && ! is_opt $1; then true; else false; fi; } - -quiet=false -force=false -no_tag=false -completion_bash=false -completion_zsh=false -completion_fish=false -comp_dir_bash="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" -comp_dir_zsh="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" -comp_dir_fish="${XDG_CONFIG_HOME:-$HOME/.config}/fish/completions" -while test $# -gt 0; do - case $1 in - --quiet | -q) - quiet=true - ;; - --crate) - crate=$2 - shift - ;; - --force | -f) - force=true - ;; - --git) - git=$2 - shift - ;; - --help | -h) - help - exit 0 - ;; - --tag) - tag=$2 - shift - ;; - --no-tag) - no_tag=true - ;; - --target) - target=$2 - shift - ;; - --to) - dest=$2 - shift - ;; - --completion) - completion_bash=true - completion_zsh=true - completion_fish=true - ;; - --completion-bash) - completion_bash=true - if is_arg $2; then - comp_dir_bash=$2 - shift - fi - ;; - --completion-zsh) - completion_zsh=true - if is_arg $2; then - echo "$2" - comp_dir_zsh=$2 - shift - fi - ;; - --completion-fish) - completion_fish=true - if is_arg $2; then - comp_dir_fish=$2 - shift - fi - ;; - *) ;; - - esac - shift -done - -# Dependencies -need basename -need curl -need install -need mkdir -need mktemp -need tar - -# Optional dependencies -if [ -z $crate ] || [ -z $tag ] || [ -z $target ]; then - need cut -fi - -if [ -z $tag ]; then - need rev -fi - -if [ -z $target ]; then - need grep - need rustc -fi - -if [ -z $git ]; then - err 'must specify a git repository using `--git`. Example: `install.sh --git japaric/cross`' -fi - -url="https://github.com/$git" -say_err "GitHub repository: $url" - -if [ -z $crate ]; then - crate=$(echo $git | cut -d'/' -f2) -fi - -say_err "Crate: $crate" - -url="$url/releases" - -if [ -z $tag ]; then - tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev) - say_err "Tag: latest ($tag)" -else - say_err "Tag: $tag" -fi - -if [ -z $target ]; then - target=$(rustc -Vv | grep host | cut -d' ' -f2) -fi - -say_err "Target: $target" - -if [ -z $dest ]; then - dest="$HOME/.cargo/bin" -fi - -if [ $no_tag = true ]; then - crate_tag="$crate" -elif case $tag in "$crate"*) true ;; *) false ;; esac then - crate_tag="$tag" -else - crate_tag="$crate-$tag" -fi - -say_err "Installing to: $dest" -url="$url/download/$tag/${crate_tag}-$target.tar.gz" - -say_err "Downloading: $url" - -td=$(mktemp -d || mktemp -d -t tmp) -curl -sL $url | tar -C $td -xz - -for f in $(find "$td" -type f); do - case $f in - *".bash") - [ $completion_bash ] && install -D $f "$comp_dir_bash/$crate" - ;; - *".zsh" | *"_$crate") - [ $completion_zsh ] && install -D $f "$comp_dir_zsh/_$crate" - ;; - *".fish") - [ $completion_fish ] && install -D $f "$comp_dir_fish/$crate.fish" - ;; - *) ;; - esac - - test -x $f || continue - if [ -e "$dest/$f" ] && [ $force = false ]; then - err "$(dirname $f) already exists in $dest" - else - install -Dm 755 $f $dest - fi -done - -rm -rf $td diff --git a/scripts/mega-dl.sh b/scripts/mega-dl.sh deleted file mode 100755 index b19be68..0000000 --- a/scripts/mega-dl.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash - -# Source: https://gist.github.com/zanculmarktum/170b94764bd9a3da31078580ccea8d7e - -# Copyright 2018, 2019, 2020 Azure Zanculmarktum -# All rights reserved. -# -# Redistribution and use of this script, with or without modification, is -# permitted provided that the following conditions are met: -# -# 1. Redistributions of this script must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Dependencies: -# openssl - -# Usage: -# $ ./megafetch.sh https://mega.nz/#!abcdefgh!1234567890abcdefghijklmnopqrstuvwxyzABCDEFG -# http://gfs208n103.userstorage.mega.co.nz/dl/-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A -# file.name -# abcefghijklmnopqrstuvwxyz0123456 -# 1234567890abcdef0000000000000000 -# $ wget -O file.name http://gfs208n103.userstorage.mega.co.nz/dl/-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A -# $ cat file.name | openssl enc -d -aes-128-ctr -K abcefghijklmnopqrstuvwxyz0123456 -iv 1234567890abcdef0000000000000000 > file.name.new -# $ mv -f file.name.new file.name - -URL="" -OUTPATH="$PWD" -USAGE="Usage: ${0##*/} " - -if [[ $1 =~ ^https?:\/\/mega(\.co)?\.nz ]]; then - URL="$1" -fi - -if [[ ! $URL ]]; then - echo $USAGE >&2 - exit 1 -fi - -if [[ ! -z "$2" ]]; then - OUTPATH="$2" -fi - -if [[ ! -d "$OUTPATH" ]]; then - echo $USAGE >&2 - exit 1 -fi - -CURL="curl -Y 1 -y 10" - -missing=false -for cmd in openssl; do - if [[ ! $(command -v "$cmd" 2>&1) ]]; then - missing=true - echo "${0##*/}: $cmd: command not found" >&2 - fi -done -if $missing; then - exit 1 -fi - -if [[ $URL =~ .*/file/[^#]*#[^#]* ]]; then - id="${URL#*file/}" - id="${id%%#*}" - key="${URL##*file/}" - key="${key##*#}" -else - id="${URL#*!}" - id="${id%%!*}" - key="${URL##*!}" -fi - -raw_hex=$(echo "${key}=" | tr '\-_' '+/' | tr -d ',' | base64 -d -i 2>/dev/null | od -v -An -t x1 | tr -d '\n ') -hex=$( - printf "%016x" \ - $((0x${raw_hex:0:16} ^ 0x${raw_hex:32:16})) \ - $((0x${raw_hex:16:16} ^ 0x${raw_hex:48:16})) -) - -json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "g":"1", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1 -json="${json#"[{"}" -json="${json%"}]"}" -file_url="${json##*'"g":'}" -file_url="${file_url%%,*}" -file_url="${file_url//'"'/}" - -json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1 -at="${json##*'"at":'}" -at="${at%%,*}" -at="${at//'"'/}" - -json=$(echo "${at}==" | tr '\-_' '+/' | tr -d ',' | openssl enc -a -A -d -aes-128-cbc -K "$hex" -iv "00000000000000000000000000000000" -nopad | tr -d '\0') -json="${json#"MEGA{"}" -json="${json%"}"}" -file_name="${json##*'"n":'}" -if [[ $file_name == *,* ]]; then - file_name="${file_name%%,*}" -fi -file_name="${file_name//'"'/}" - -outfile="$OUTPATH/$file_name" - -$CURL -s "$file_url" | openssl enc -d -aes-128-ctr -K "$hex" -iv "${raw_hex:32:16}0000000000000000" >"$outfile" - -echo "$outfile" - -# echo "$file_url" -# echo "$file_name" -# echo "$hex" -# echo "${raw_hex:32:16}0000000000000000" diff --git a/scripts/mkln.sh b/scripts/mkln.sh deleted file mode 100755 index ef174c2..0000000 --- a/scripts/mkln.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash - -TEMP=$(getopt -o hvqdf --long help,verbose,quiet,debug,force \ - -n 'javawrap' -- "$@") - -if [ $? != 0 ]; then - echo "Terminating..." >&2 - exit 1 -fi - -eval set -- "$TEMP" - -SCRIPT="$(basename $0)" -VERBOSE=false -QUIET=false -DEBUG=false -FORCE=false - -read -r -d '' USAGE <<-EOF -USAGE: $SCRIPT [OPTIONS] - -OPTIONS: - -h, --help Show this message - -v, --verbose Show more output - -q, --quiet Suppress all output - -d, --debug NOT IMPLEMENTED - -f, --force Overwrite items - -ARGS: - ... File to link. -EOF - -while true; do - case "$1" in - -h | --help) - echo "$USAGE" - exit 0 - ;; - -v | --verbose) - VERBOSE=true - shift - ;; - -q | --quiet) - QUIET=true - shift - ;; - -d | --debug) - DEBUG=true - shift - ;; - -f | --force) - FORCE=true - shift - ;; - --) - shift - break - ;; - *) - break - ;; - esac -done - -if ! command -v powershell.exe &>/dev/null; then - [ "$QUIET" != true ] && echo "Powershell not found in path." >&2 - exit 1 -fi - -if [ -z "$2" ]; then - 2="$(pwd)" -fi - -[ "$VERBOSE" == true ] && echo "linking $2 -> $1" - -if [ -d "$1" ]; then - [ "$VERBOSE" == true ] && echo "$1 is a directory. Creating symbolic link." - args='/D' -fi - -mkdir -p $(dirname $2) - -source=$(wslpath -w $1) -target=$(wslpath -w $(dirname $2))\\$(basename $2) - -if ls -la "$(dirname $2)/" 2>/dev/null | grep -q "$(basename $2)"; then - - current_path=$(powershell.exe -c "(Get-Item $target).Target" 2>/dev/null) - - if [[ "${current_path/*wsl$/}" == *"${source/*wsl$/}"* ]]; then - [ "$VERBOSE" == true ] && echo "$(basename $2) is set correctly. Skipping." - exit 0 - fi - - if [ "$FORCE" == true ]; then - [ "$VERBOSE" == true ] && echo "$(basename $2) exists. Overwriting." - rm -rf "$2" - else - [ "$QUIET" != true ] && echo "$(basename $target) already exists. Use -f to overwrite." >&2 - exit 1 - fi -fi - -mkdir -p "$(dirname $2)" -cmd="cd ~; cmd /c mklink ${args} ${target} ${source}" - -if [ "$DEBUG" == true ]; then - [ "$QUIET" != true ] && printf '\nCommand: \n%s\n\n' "powershell.exe -c ${cmd} &>/dev/null" -else - if $QUIET; then - powershell.exe -c "${cmd}" &>/dev/null - else - powershell.exe -c "${cmd}" - fi -fi diff --git a/scripts/socket-relay.sh b/scripts/socket-relay.sh deleted file mode 100755 index 436fa54..0000000 --- a/scripts/socket-relay.sh +++ /dev/null @@ -1,217 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -OPTS=$(getopt -o hds:x: --long help,debug,sock:,exec:,ssh,gpg,gpg-extra,discord -n 'javawrap' -- "$@") - -eval set -- "$OPTS" - -PAGEANT="$HOME/.ssh/wsl2-ssh-pageant.exe" -NPIPE="$(command -v npiperelay.exe)" -SCRIPT="$(basename "$0")" - -help() { - cat <<-EOF -$SCRIPT -Toby Vincent - -$SCRIPT description - -USAGE: - $SCRIPT [OPTIONS] - $SCRIPT [OPTIONS] - -OPTIONS: - -h, --help Display this message - -s, --sock Path to the linux socket - -x, --exec Command to run for socat's EXEC: arg - --ssh Relay the ssh agent's socket - --gpg Relay the gpg agent's socket - --gpg-extra Relay the gpg agent's extra socket - -ARGS: - start (default) - Start the socat process - - stop - Kill the socat process -EOF -} - -say() { - if ! $quiet; then - echo "$SCRIPT: $1" - fi -} - -say_err() { - say "$1" >&2 -} - -err() { - say_err "ERROR: $1" - exit 1 -} - -need() { - for cmd in $@; do - if ! command -v $cmd >/dev/null 2>&1; then - err "need $cmd (command not found)" - fi - done -} - -start() { - if ! ss -a | grep -q "$sock"; then - if test -x "$relay"; then - rm -rf "$sock" - (setsid nohup socat UNIX-LISTEN:"${sock},${listen_args}" EXEC:"$cmd" >/dev/null 2>&1 &) - - else - echo >&2 "WARNING: $relay is not executable." - fi - fi - - if $gpg; then - gpg-connect-agent.exe /bye &>/dev/null - fi -} - -stop() { - if $gpg; then - gpg-connect-agent.exe KILLAGENT /bye &>/dev/null - fi - - if pgrep -f "socat.*$sock.*$relay" &>/dev/null; then - pkill -f "socat.*$sock.*$relay" - fi -} - -check() { - pgrep -fa "socat.*$sock.*$relay" -} - -quiet=false -debug=false -sock="" -cmd="" -gpg=false -ssh=false -extra=false -discord=false -while test $# -gt 0; do - case $1 in - -h | --help) - help - return 0 - ;; - -q | --quiet) - quiet=true - shift - ;; - -d | --debug) - debug=true - shift - ;; - -s | --sock) - sock=$2 - shift - shift - ;; - -x | --exec) - cmd=$2 - shift - shift - ;; - --ssh) - ssh=true - shift - ;; - --gpg) - gpg=true - shift - ;; - --gpg-extra) - gpg=true - extra=true - shift - ;; - --discord) - discord=true - shift - ;; - --) - shift - break - ;; - *) - help - exit 1 - ;; - esac -done - -need ss -need socat - -listen_args="fork" - -case true in -$ssh) - need $PAGEANT - - sock="${SSH_AUTH_SOCK:-$HOME/.ssh/agent.sock}" - cmd="$PAGEANT" - ;; -$gpg) - need $PAGEANT - need "gpg-connect-agent.exe" - - sock="${GPG_AGENT_SOCK:-$HOME/.gnupg/S.gpg-agent}" - if $extra; then - sock+=".extra" - fi - - cmd="$PAGEANT --gpg $(basename $sock)" - ;; -$discord) - need $NPIPE - - sock="${DISCORD_IPC_SOCK:-/var/run/discord-ipc-0}" - cmd="$NPIPE -ep -s //./pipe/$(basename $sock)" - - listen_args="fork,group=discord,umask=007" - ;; -$(test -z "${cmd}")) - err "No EXEC provided. Must supply either --ssh, --gpg, --gpg-extra, --pipe, or --exec" - ;; -esac - -if test -z "${sock}"; then - err "No socket provided." -fi - -relay="$(echo $cmd | head -n1 | awk '{print $1;}')" - -case ${1:-'start'} in -check) - shift - check - ;; -start) - shift - start - ;; -stop) - shift - stop - ;; -restart) - shift - stop - start - ;; -*) - help - exit 1 - ;; -esac diff --git a/scripts/td.sh b/scripts/td.sh deleted file mode 100755 index 968c98b..0000000 --- a/scripts/td.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/sh -TEMP=$(getopt -o hf --long help,force \ - -n 'javawrap' -- "$@") - -if [ $? != 0 ]; then - echo "Terminating..." >&2 - exit 1 -fi - -eval set -- "$TEMP" - -SCRIPT="$(basename $0)" -ENV_CACHE="${HOME}/.cache/td/.env" - -help() { - cat <<-EOF -$SCRIPT -Toby Vincent - -$SCRIPT is a script for managing and navigating a persistent temp directory. In -order to function properly, this script must be sourced in the currently shell. -Consider setting an alias such as - - alias td=". $SCRIPT" - -USAGE: - $SCRIPT [OPTIONS] - $SCRIPT [OPTIONS] - -OPTIONS: - -h, --help Display this message - -f, --force Use the --force argument when removing TD - -ARGS: - toggle (default) - Switch between TD_ORIGIN and TD. This will create TD if it does not - exist. This is the default if no command is provided. - - new | create - Creates a new temp directory and cds into it it stores the path - to the temp directory in TD, and the path to the previous directory in - TD_ORIGIN. - - rm | remove - Removes the directory stored in TD unsets TD and TD_ORIGIN. - - ls | list | show - Shows the current values for TD and TD_ORIGIN -EOF -} - -echo_err() { - echo >&2 "$SCRIPT: $@" -} - -show() { - if [ ! -n "$TD" ]; then - echo_err "Not set" - return 1 - fi - echo "TD=$TD" - echo "TD_ORIGIN=$TD_ORIGIN" -} - -remove() { - if [ ! -n "$TD" ]; then - echo_err "Not set" - return 1 - fi - - rm "$rm_args" "$TD" - - echo "removed $TD" - - if [ "$PWD" = "$TD" ]; then - cd "$TD_ORIGIN" - fi - - rm "$ENV_CACHE" -rf - unset TD - unset TD_ORIGIN -} - -create() { - remove 2>/dev/null - - td=$(mktemp -d) - - export TD="$td" - update-origin - - echo "created $TD" - cd "$TD" -} - -update-origin() { - export TD_ORIGIN="$PWD" - cat >$ENV_CACHE <<-EOF -TD=$TD -TD_ORIGIN=$TD_ORIGIN -EOF -} - -toggle() { - if [ "$PWD" = "$TD" ]; then - cd "$TD_ORIGIN" - elif [ -n "$TD" ]; then - update-origin - cd "$TD" - else - create - fi -} - -if [ -f "$ENV_CACHE" ]; then - export $(cat "$ENV_CACHE" | xargs) -fi - -rm_args="-r" -while test $# -gt 0; do - case $1 in - --help | -h) - help - return 0 - ;; - --force | -f) - rm_args="-rf" - shift - ;; - --) - shift - break - ;; - *) break ;; - esac -done - -case $1 in -ls | list | show) - show - ;; -rm | remove) - remove - ;; -new | create) - create - ;; -* | toggle) - toggle - ;; -esac diff --git a/scripts/yt.sh b/scripts/yt.sh deleted file mode 100755 index e39d6f6..0000000 --- a/scripts/yt.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# originally by Kris Occhipinti -# https://www.youtube.com/watch?v=FsQuGplQvrw - -mpv.exe --ytdl-format=bestvideo+bestaudio/best --fs "$(powershell.exe -c "Get-Clipboard")" diff --git a/ssh/.ssh/config b/ssh/.ssh/config new file mode 100644 index 0000000..69c94b8 --- /dev/null +++ b/ssh/.ssh/config @@ -0,0 +1,66 @@ +# Read more about SSH config files: https://linux.die.net/man/5/ssh_config + +Host * + StrictHostKeyChecking no + ServerAliveInterval 300 + ServerAliveCountMax 2 + +Host heimdall loki + User pi + ForwardAgent yes + StreamLocalBindUnlink yes + RemoteForward /run/user/1000/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra + ControlMaster auto + ControlPath ~/.ssh/controlmasters/%r@%h:%p + ControlPersist 30m + +Host odin thor + User tobyv + Port 2222 + ForwardAgent yes + StreamLocalBindUnlink yes + RemoteForward /run/user/1000/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra + ControlMaster auto + ControlPath ~/.ssh/controlmasters/%r@%h:%p + ControlPersist 30m + +host bifrost + User tobyv + ControlMaster auto + ControlPath ~/.ssh/controlmasters/%r@%h:%p + ControlPersist 30m + +Host aegir + User root + HostName foundry.tobyvin.com + ForwardAgent yes + StreamLocalBindUnlink yes + +Host door + User tovince + HostName door.cs.siue.edu + ForwardAgent yes + StreamLocalBindUnlink yes + RemoteForward /run/user/1000/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra + ControlMaster auto + ControlPath ~/.ssh/controlmasters/%r@%h:%p + ControlPersist 30m + +Host siue + User tovince + HostName home.cs.siue.edu + ForwardAgent yes + StreamLocalBindUnlink yes + RemoteForward /run/user/1400158178/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra + RemoteCommand rm -f /run/user/1400158178/gnupg/S.gpg-agent && zsh -l + RequestTTY force + +Host zone zone1 zone2 + User tovince + HostName zone.cs.siue.edu + +Host zone1 + SetEnv INSTANCE=1 + +Host zone2 + SetEnv INSTANCE=2 diff --git a/ssh/config b/ssh/config deleted file mode 100644 index 69c94b8..0000000 --- a/ssh/config +++ /dev/null @@ -1,66 +0,0 @@ -# Read more about SSH config files: https://linux.die.net/man/5/ssh_config - -Host * - StrictHostKeyChecking no - ServerAliveInterval 300 - ServerAliveCountMax 2 - -Host heimdall loki - User pi - ForwardAgent yes - StreamLocalBindUnlink yes - RemoteForward /run/user/1000/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra - ControlMaster auto - ControlPath ~/.ssh/controlmasters/%r@%h:%p - ControlPersist 30m - -Host odin thor - User tobyv - Port 2222 - ForwardAgent yes - StreamLocalBindUnlink yes - RemoteForward /run/user/1000/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra - ControlMaster auto - ControlPath ~/.ssh/controlmasters/%r@%h:%p - ControlPersist 30m - -host bifrost - User tobyv - ControlMaster auto - ControlPath ~/.ssh/controlmasters/%r@%h:%p - ControlPersist 30m - -Host aegir - User root - HostName foundry.tobyvin.com - ForwardAgent yes - StreamLocalBindUnlink yes - -Host door - User tovince - HostName door.cs.siue.edu - ForwardAgent yes - StreamLocalBindUnlink yes - RemoteForward /run/user/1000/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra - ControlMaster auto - ControlPath ~/.ssh/controlmasters/%r@%h:%p - ControlPersist 30m - -Host siue - User tovince - HostName home.cs.siue.edu - ForwardAgent yes - StreamLocalBindUnlink yes - RemoteForward /run/user/1400158178/gnupg/S.gpg-agent /home/tobyv/.gnupg/S.gpg-agent.extra - RemoteCommand rm -f /run/user/1400158178/gnupg/S.gpg-agent && zsh -l - RequestTTY force - -Host zone zone1 zone2 - User tovince - HostName zone.cs.siue.edu - -Host zone1 - SetEnv INSTANCE=1 - -Host zone2 - SetEnv INSTANCE=2 diff --git a/ssh/wsl2-ssh-pageant.exe b/ssh/wsl2-ssh-pageant.exe deleted file mode 100755 index 7852088..0000000 Binary files a/ssh/wsl2-ssh-pageant.exe and /dev/null differ diff --git a/starship.toml b/starship.toml deleted file mode 100644 index 8868f01..0000000 --- a/starship.toml +++ /dev/null @@ -1,123 +0,0 @@ -format = """ -$all\ -""" - -add_newline = false - -[fill] -disabled = true -symbol = "" - -[character] -success_symbol = "[❯](green)" -error_symbol = "[❯](red)" - -[aws] -symbol = " " - -[conda] -symbol = " " - -[cmd_duration] -disabled = true -format = "[$duration](bold yellow)" -show_notifications = true -min_time_to_notify = 1_000 - -[dart] -symbol = " " - -[directory] -read_only = " " -# truncation_length = 2 -fish_style_pwd_dir_length = 1 -truncate_to_repo = false -repo_root_style = "bold purple" - -[directory.substitutions] -"~/win" = " ~" -"/mnt/c/Users/tobyv" = " ~" -"/mnt/c" = ' C:' -"/mnt/d" = ' D:' -"/mnt/e" = ' E:' - -[docker_context] -symbol = " " - -[elixir] -symbol = " " - -[elm] -symbol = " " - -[git_branch] -symbol = " " - -[git_status] -format = '([\[$conflicted$deleted$renamed$modified$staged$untracked$ahead_behind\]]($style) )' - -[golang] -symbol = " " - -[hg_branch] -symbol = " " - -[java] -symbol = " " - -[julia] -symbol = " " - -[memory_usage] -symbol = " " - -[nim] -symbol = " " - -[nix_shell] -symbol = " " - -[package] -symbol = " " - -[perl] -symbol = " " - -[php] -symbol = " " - -[python] -symbol = " " - -[ruby] -symbol = " " - -[rust] -symbol = " " - -[scala] -symbol = " " - -[shlvl] -symbol = " " - -[status] -disabled = true -format = "[$symbol$maybe_int]($style)" -pipestatus_format = "\\[$pipestatus\\]" -pipestatus = true -map_symbol = true -style = "red" -symbol = "☓" -recognize_signal_code = true -success_symbol = "[✓](bright-green)" -signal_symbol = "[⚡](bright-yellow)" -not_executable_symbol = "!" -not_found_symbol = "?" -sigint_symbol = "" - -# pipestatus_format = "\\[$pipestatus\\]=>[$symbol$common_meaning$signal_name$maybe_int]($style)" - - -[swift] -symbol = "ﯣ " diff --git a/starship/.config/starship.toml b/starship/.config/starship.toml new file mode 100644 index 0000000..8868f01 --- /dev/null +++ b/starship/.config/starship.toml @@ -0,0 +1,123 @@ +format = """ +$all\ +""" + +add_newline = false + +[fill] +disabled = true +symbol = "" + +[character] +success_symbol = "[❯](green)" +error_symbol = "[❯](red)" + +[aws] +symbol = " " + +[conda] +symbol = " " + +[cmd_duration] +disabled = true +format = "[$duration](bold yellow)" +show_notifications = true +min_time_to_notify = 1_000 + +[dart] +symbol = " " + +[directory] +read_only = " " +# truncation_length = 2 +fish_style_pwd_dir_length = 1 +truncate_to_repo = false +repo_root_style = "bold purple" + +[directory.substitutions] +"~/win" = " ~" +"/mnt/c/Users/tobyv" = " ~" +"/mnt/c" = ' C:' +"/mnt/d" = ' D:' +"/mnt/e" = ' E:' + +[docker_context] +symbol = " " + +[elixir] +symbol = " " + +[elm] +symbol = " " + +[git_branch] +symbol = " " + +[git_status] +format = '([\[$conflicted$deleted$renamed$modified$staged$untracked$ahead_behind\]]($style) )' + +[golang] +symbol = " " + +[hg_branch] +symbol = " " + +[java] +symbol = " " + +[julia] +symbol = " " + +[memory_usage] +symbol = " " + +[nim] +symbol = " " + +[nix_shell] +symbol = " " + +[package] +symbol = " " + +[perl] +symbol = " " + +[php] +symbol = " " + +[python] +symbol = " " + +[ruby] +symbol = " " + +[rust] +symbol = " " + +[scala] +symbol = " " + +[shlvl] +symbol = " " + +[status] +disabled = true +format = "[$symbol$maybe_int]($style)" +pipestatus_format = "\\[$pipestatus\\]" +pipestatus = true +map_symbol = true +style = "red" +symbol = "☓" +recognize_signal_code = true +success_symbol = "[✓](bright-green)" +signal_symbol = "[⚡](bright-yellow)" +not_executable_symbol = "!" +not_found_symbol = "?" +sigint_symbol = "" + +# pipestatus_format = "\\[$pipestatus\\]=>[$symbol$common_meaning$signal_name$maybe_int]($style)" + + +[swift] +symbol = "ﯣ " diff --git a/tmux.conf b/tmux.conf deleted file mode 100644 index 7af5105..0000000 --- a/tmux.conf +++ /dev/null @@ -1,18 +0,0 @@ -set -g mouse on -set -g base-index 1 -set -g default-terminal "tmux-256color" -set -ga terminal-overrides ",alacritty:Tc" -set -g detach-on-destroy off -set -g prefix C-a - -bind-key f run-shell "tmux neww -n sessionizer ~/.local/bin/tmux-sessionizer" - -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-sensible' -set -g @plugin 'tmux-plugins/tmux-yank' -set -g @plugin 'tmux-plugins/tmux-pain-control' - -if "test ! -d ~/.tmux/plugins/tpm" \ - "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'" - -run '~/.tmux/plugins/tpm/tpm' diff --git a/tmux/.local/bin/tm b/tmux/.local/bin/tm new file mode 100755 index 0000000..5c976d3 --- /dev/null +++ b/tmux/.local/bin/tm @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" +session=$( + tmux list-sessions -F "#{session_name}" 2>/dev/null | + sed "/^$(tmux display-message -p '#S' 2>/dev/null)$/d" | + fzf --query="$1" --select-1 --exit-0 +) && + tmux $change -t "$session" || + ( + tmux new-session -d -s $session && + tmux $change -t "$session" + ) diff --git a/tmux/.local/bin/tmux-sessionizer b/tmux/.local/bin/tmux-sessionizer new file mode 100755 index 0000000..f43cea3 --- /dev/null +++ b/tmux/.local/bin/tmux-sessionizer @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(cat <(fd . ~/src ~/dkr --exact-depth 1 -td) <(echo $HOME/.dotfiles) | sort | + fzf -d/ --with-nth 3.. --preview="tree -a -C -L 1 {}") +fi + +if [[ -z $selected ]]; then + exit 0 +fi + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then + tmux new-session -s $selected_name -c $selected + exit 0 +fi + +if ! tmux has-session -t=$selected_name 2>/dev/null; then + tmux new-session -ds $selected_name -c $selected +fi + +tmux switch-client -t $selected_name diff --git a/tmux/.local/bin/tmux-windowizer b/tmux/.local/bin/tmux-windowizer new file mode 100755 index 0000000..6cee8b0 --- /dev/null +++ b/tmux/.local/bin/tmux-windowizer @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +branch_name=$(basename $1) +session_name=$(tmux display-message -p "#S") +clean_name=$(echo $branch_name | tr "./" "__") +target="$session_name:$clean_name" + +if ! tmux has-session -t $target 2>/dev/null; then + tmux neww -dn $clean_name +fi + +shift +tmux send-keys -t $target "$* +" diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..7af5105 --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,18 @@ +set -g mouse on +set -g base-index 1 +set -g default-terminal "tmux-256color" +set -ga terminal-overrides ",alacritty:Tc" +set -g detach-on-destroy off +set -g prefix C-a + +bind-key f run-shell "tmux neww -n sessionizer ~/.local/bin/tmux-sessionizer" + +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-yank' +set -g @plugin 'tmux-plugins/tmux-pain-control' + +if "test ! -d ~/.tmux/plugins/tpm" \ + "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'" + +run '~/.tmux/plugins/tpm/tpm' diff --git a/update b/update deleted file mode 100755 index 7aa09fc..0000000 --- a/update +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -cd "$(cd $(dirname "$(readlink -fm "$0")") && git rev-parse --show-toplevel)" - -git pull diff --git a/winget.json b/winget.json deleted file mode 100755 index b583c03..0000000 --- a/winget.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "https://aka.ms/winget-settings.schema.json", - "source": { - "autoUpdateIntervalInMinutes": 5 - }, - "visual": { - "progressBar": "accent" - }, - "installBehavior": { - "preferences": { - "scope": "user", - "locale": [ - "en-US" - ] - } - }, - "network": { - "downloader": "do", - "doProgressTimeoutInSeconds": 60 - }, - "telemetry": { - "disable": true - }, - "experimentalFeatures": { - "dependencies": true, - "directMSI": true - } -} \ No newline at end of file diff --git a/wsl.install b/wsl.install deleted file mode 100755 index 7c199f3..0000000 --- a/wsl.install +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -cd "${BASEDIR:-${HOME}/dotfiles}" - -WINHOME="$(wslpath c:\\Users\\${USER})" - -RESET='\033[0m' -RED='\033[91m' -GREEN='\033[92m' -YELLOW='\033[93m' -BLUE='\033[94m' -MAGENTA='\033[95m' - -mkln="scripts/mkln.sh -f" - -function show-warning() { - gpgpath=$(wslpath -w "$(command -v gpg.exe)") - gitgpg=$(git.exe config --system --get gpg.program) - if [ "$gitgpg" = "$gpgpath" ]; then - return - fi - echo - echo -e "${BLUE}In order to use gpg with git for windows" - echo -e "${BLUE}(and still share gitconfigs), you need to run" - echo -e "${BLUE}the following command from an admin terminal:" - echo - echo "git.exe config --system gpg.program '$(wslpath -w "$(command -v gpg.exe)")'" - echo -} - -echo -e "${BLUE}Setting up WSL" - -# link WINHOME -ln -sfn $WINHOME ~/win - -# ssh-config -sed -r 's|(RemoteForward\s+.+\s+)\/home\/tobyv\/\.gnupg\/S\.gpg-agent\.extra|\1127.0.0.1:4321|' ssh/config | - sed '/Control/d' >"${WINHOME}/.ssh/config" - -# Create windows symlinks to dotfiles -$mkln $@ "gitconfig" "${WINHOME}/.gitconfig" -$mkln $@ "gnupg/gpg.conf" "${WINHOME}/AppData/Roaming/gnupg/gpg.conf" -$mkln $@ "alacritty" "${WINHOME}/AppData/Roaming/alacritty" -$mkln $@ "gnupg/gpg-agent.conf" "${WINHOME}/AppData/Roaming/gnupg/gpg-agent.conf" -$mkln $@ "gnupg/scdaemon.conf" "${WINHOME}/AppData/Roaming/gnupg/scdaemon.conf" -$mkln $@ "wt.json" "${WINHOME}/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json" -$mkln $@ "winget.json" "${WINHOME}/AppData/Local/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/LocalState/settings.json" - -# install xclip/xsel -curl -sL "https://raw.githubusercontent.com/Konfekt/win-bash-xclip-xsel/master/clip.sh" >"${HOME}/.local/bin/xclip" -curl -sL "https://raw.githubusercontent.com/Konfekt/win-bash-xclip-xsel/master/clip.sh" >"${HOME}/.local/bin/xsel" -chmod +x "${HOME}/.local/bin/xclip" -chmod +x "${HOME}/.local/bin/xsel" - -# install hotkeys.exe -install_dir="${WINHOME}/AppData/Local/Programs/hotkeys" -mkdir -p "${install_dir}" -rm -f "${install_dir}/hotkeys.exe" -curl -sL "https://github.com/tobyvin/hotkeys/releases/latest/download/hotkeys.exe" >"${install_dir}/hotkeys.exe" - -# https://github.com/wslutilities/wslu -if ! command -v wslview &>/dev/null; then - echo "wslu is not installed." - echo "wslu (wslview) is needed to open browser windows from linux commands." - echo "install instructions: https://github.com/wslutilities/wslu#installation" -fi - -echo -e "${GREEN}WSL has been set up" diff --git a/wsl/.config/zsh/gpg.sh b/wsl/.config/zsh/gpg.sh new file mode 100755 index 0000000..ac0bb4c --- /dev/null +++ b/wsl/.config/zsh/gpg.sh @@ -0,0 +1,66 @@ +export SSH_AUTH_SOCK="$HOME/.ssh/agent.sock" +export GPG_AGENT_SOCK="$HOME/.gnupg/S.gpg-agent" + +gpg-init() ( + if ! ss -a | grep -q "$SSH_AUTH_SOCK"; then + rm -f "$SSH_AUTH_SOCK" + wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" + if test -x "$wsl2_ssh_pageant_bin"; then + (setsid nohup socat UNIX-LISTEN:"$SSH_AUTH_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin" >/dev/null 2>&1 &) + else + echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." + fi + unset wsl2_ssh_pageant_bin + fi + + if ! ss -a | grep -q "$GPG_AGENT_SOCK"; then + rm -rf "$GPG_AGENT_SOCK" + wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" + if test -x "$wsl2_ssh_pageant_bin"; then + (setsid nohup socat UNIX-LISTEN:"$GPG_AGENT_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent" >/dev/null 2>&1 &) + else + echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." + fi + unset wsl2_ssh_pageant_bin + fi + + if ! ss -a | grep -q "${GPG_AGENT_SOCK}.extra"; then + rm -rf "${GPG_AGENT_SOCK}.extra" + wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" + if test -x "$wsl2_ssh_pageant_bin"; then + (setsid nohup socat UNIX-LISTEN:"${GPG_AGENT_SOCK}.extra,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent.extra" >/dev/null 2>&1 &) + else + echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." + fi + unset wsl2_ssh_pageant_bin + fi +) + +start-pageant() { + # TODO: WIP + if ! ss -a | grep -q "${GPG_AGENT_SOCK}.extra"; then + rm -rf "${GPG_AGENT_SOCK}.extra" + wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" + if test -x "$wsl2_ssh_pageant_bin"; then + (setsid nohup socat UNIX-LISTEN:"${GPG_AGENT_SOCK}.extra,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent.extra" >/dev/null 2>&1 &) + else + echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." + fi + unset wsl2_ssh_pageant_bin + fi +} + +# Reload +gpg-reset() { + gpg-connect-agent.exe KILLAGENT /bye &>/dev/null + pkill -f 'socat.*wsl2-ssh-pageant.exe' + gpg-connect-agent.exe /bye &>/dev/null + gpg-init +} + +# Relearn card serial number +gpg-learn() { + gpg-connect-agent.exe "scd serialno" "learn --force" /bye +} + +gpg-init diff --git a/wsl/.config/zsh/wsl.sh b/wsl/.config/zsh/wsl.sh new file mode 100644 index 0000000..80d93af --- /dev/null +++ b/wsl/.config/zsh/wsl.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +WINHOME="/mnt/c/Users/$USER" +[ "$PWD" = "$WINHOME" ] && cd + +mkdir -p /tmp/xdg + +export BROWSER=wslview +export EDITOR="code --wait" +export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0 +export XDG_RUNTIME_DIR=/tmp/xdg + +alias wsl=wsl.exe +alias ykman='/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe' +# python +alias pip2="DISPLAY= pip2" +alias pip3="DISPLAY= pip3" +alias pip3.7="DISPLAY= pip3.7" +alias pip3.10="DISPLAY= pip3.10" +alias pip="DISPLAY= pip3" + +wt() { + powershell.exe -NoProfile -c "wt $@" +} + +wsl_cmd_proxy() { + exe="$1" + shift # past exe + + cmd=" ${1}" + shift # past cmd + + args="" + while [[ $# -gt 0 ]]; do + case "$1" in + -*) + args+="${1} '${2}' " + shift + shift + ;; + *) + args+="'${1}'" + shift + ;; + esac + args+=" " + done + + powershell.exe -NoProfile -c 'cd $HOME;' "$exe" "$cmd" "$args" +} + +winget() { wsl_cmd_proxy "winget.exe" "$@"; } +scoop() { wsl_cmd_proxy "scoop" "$@"; } +alacritty() { wsl_cmd_proxy "alacritty.exe" "$@"; } + +# https://github.com/validatedev/drop-cache-if-idle +[ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null diff --git a/wsl/.ssh/wsl2-ssh-pageant.exe b/wsl/.ssh/wsl2-ssh-pageant.exe new file mode 100755 index 0000000..7852088 Binary files /dev/null and b/wsl/.ssh/wsl2-ssh-pageant.exe differ diff --git a/wsl/gpg.sh b/wsl/gpg.sh deleted file mode 100755 index ac0bb4c..0000000 --- a/wsl/gpg.sh +++ /dev/null @@ -1,66 +0,0 @@ -export SSH_AUTH_SOCK="$HOME/.ssh/agent.sock" -export GPG_AGENT_SOCK="$HOME/.gnupg/S.gpg-agent" - -gpg-init() ( - if ! ss -a | grep -q "$SSH_AUTH_SOCK"; then - rm -f "$SSH_AUTH_SOCK" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"$SSH_AUTH_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi - - if ! ss -a | grep -q "$GPG_AGENT_SOCK"; then - rm -rf "$GPG_AGENT_SOCK" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"$GPG_AGENT_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi - - if ! ss -a | grep -q "${GPG_AGENT_SOCK}.extra"; then - rm -rf "${GPG_AGENT_SOCK}.extra" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"${GPG_AGENT_SOCK}.extra,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent.extra" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi -) - -start-pageant() { - # TODO: WIP - if ! ss -a | grep -q "${GPG_AGENT_SOCK}.extra"; then - rm -rf "${GPG_AGENT_SOCK}.extra" - wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant.exe" - if test -x "$wsl2_ssh_pageant_bin"; then - (setsid nohup socat UNIX-LISTEN:"${GPG_AGENT_SOCK}.extra,fork" EXEC:"$wsl2_ssh_pageant_bin --gpg S.gpg-agent.extra" >/dev/null 2>&1 &) - else - echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable." - fi - unset wsl2_ssh_pageant_bin - fi -} - -# Reload -gpg-reset() { - gpg-connect-agent.exe KILLAGENT /bye &>/dev/null - pkill -f 'socat.*wsl2-ssh-pageant.exe' - gpg-connect-agent.exe /bye &>/dev/null - gpg-init -} - -# Relearn card serial number -gpg-learn() { - gpg-connect-agent.exe "scd serialno" "learn --force" /bye -} - -gpg-init diff --git a/wsl/install.sh b/wsl/install.sh new file mode 100755 index 0000000..be920ee --- /dev/null +++ b/wsl/install.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +cd "${BASEDIR:-${HOME}/.dotfiles}" + +WINHOME="$(wslpath c:\\Users\\${USER})" + +RESET='\033[0m' +RED='\033[91m' +GREEN='\033[92m' +YELLOW='\033[93m' +BLUE='\033[94m' +MAGENTA='\033[95m' + +mkln="scripts/mkln.sh -f" + +function show-warning() { + gpgpath=$(wslpath -w "$(command -v gpg.exe)") + gitgpg=$(git.exe config --system --get gpg.program) + if [ "$gitgpg" = "$gpgpath" ]; then + return + fi + echo + echo -e "${BLUE}In order to use gpg with git for windows" + echo -e "${BLUE}(and still share gitconfigs), you need to run" + echo -e "${BLUE}the following command from an admin terminal:" + echo + echo "git.exe config --system gpg.program '$(wslpath -w "$(command -v gpg.exe)")'" + echo +} + +echo -e "${BLUE}Setting up WSL" + +# link WINHOME +ln -sfn $WINHOME ~/win + +# ssh-config +sed -r 's|(RemoteForward\s+.+\s+)\/home\/tobyv\/\.gnupg\/S\.gpg-agent\.extra|\1127.0.0.1:4321|' ssh/config | + sed '/Control/d' >"${WINHOME}/.ssh/config" + +# Create windows symlinks to dotfiles +$mkln $@ "gitconfig" "${WINHOME}/.gitconfig" +$mkln $@ "gnupg/gpg.conf" "${WINHOME}/AppData/Roaming/gnupg/gpg.conf" +$mkln $@ "alacritty" "${WINHOME}/AppData/Roaming/alacritty" +$mkln $@ "gnupg/gpg-agent.conf" "${WINHOME}/AppData/Roaming/gnupg/gpg-agent.conf" +$mkln $@ "gnupg/scdaemon.conf" "${WINHOME}/AppData/Roaming/gnupg/scdaemon.conf" +$mkln $@ "wt.json" "${WINHOME}/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json" +$mkln $@ "winget.json" "${WINHOME}/AppData/Local/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/LocalState/settings.json" + +# install xclip/xsel +curl -sL "https://raw.githubusercontent.com/Konfekt/win-bash-xclip-xsel/master/clip.sh" >"${HOME}/.local/bin/xclip" +curl -sL "https://raw.githubusercontent.com/Konfekt/win-bash-xclip-xsel/master/clip.sh" >"${HOME}/.local/bin/xsel" +chmod +x "${HOME}/.local/bin/xclip" +chmod +x "${HOME}/.local/bin/xsel" + +# install hotkeys.exe +install_dir="${WINHOME}/AppData/Local/Programs/hotkeys" +mkdir -p "${install_dir}" +rm -f "${install_dir}/hotkeys.exe" +curl -sL "https://github.com/tobyvin/hotkeys/releases/latest/download/hotkeys.exe" >"${install_dir}/hotkeys.exe" + +# https://github.com/wslutilities/wslu +if ! command -v wslview &>/dev/null; then + echo "wslu is not installed." + echo "wslu (wslview) is needed to open browser windows from linux commands." + echo "install instructions: https://github.com/wslutilities/wslu#installation" +fi + +echo -e "${GREEN}WSL has been set up" diff --git a/wsl/install/winget.json b/wsl/install/winget.json new file mode 100755 index 0000000..b583c03 --- /dev/null +++ b/wsl/install/winget.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://aka.ms/winget-settings.schema.json", + "source": { + "autoUpdateIntervalInMinutes": 5 + }, + "visual": { + "progressBar": "accent" + }, + "installBehavior": { + "preferences": { + "scope": "user", + "locale": [ + "en-US" + ] + } + }, + "network": { + "downloader": "do", + "doProgressTimeoutInSeconds": 60 + }, + "telemetry": { + "disable": true + }, + "experimentalFeatures": { + "dependencies": true, + "directMSI": true + } +} \ No newline at end of file diff --git a/wsl/install/wt.json b/wsl/install/wt.json new file mode 100644 index 0000000..ff53422 --- /dev/null +++ b/wsl/install/wt.json @@ -0,0 +1,389 @@ +{ + "$help": "https://aka.ms/terminal-documentation", + "$schema": "https://aka.ms/terminal-profiles-schema", + "actions": + [ + { + "command": + { + "action": "closeTab" + }, + "keys": "ctrl+w" + }, + { + "command": + { + "action": "openSettings", + "target": "settingsUI" + }, + "keys": "ctrl+comma" + }, + { + "command": + { + "action": "openSettings" + }, + "keys": "ctrl+shift+comma" + }, + { + "command": "paste", + "keys": "ctrl+v" + }, + { + "command": + { + "action": "openSettings", + "target": "defaultsFile" + }, + "keys": "ctrl+alt+comma" + }, + { + "command": + { + "action": "newTab", + "profile": "btm" + }, + "keys": "alt+`" + }, + { + "command": "unbound", + "keys": "ctrl+f" + }, + { + "command": "unbound", + "keys": "ctrl+t" + }, + { + "command": + { + "action": "commandPalette" + }, + "keys": "f1" + } + ], + "alwaysShowNotificationIcon": true, + "confirmCloseAllTabs": false, + "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", + "disabledProfileSources": + [ + "Windows.Terminal.Azure" + ], + "experimental.rendering.forceFullRepaint": true, + "initialCols": 100, + "initialRows": 30, + "multiLinePasteWarning": false, + "profiles": + { + "defaults": + { + "bellStyle": + [ + "window", + "taskbar" + ], + "closeOnExit": "always", + "colorScheme": "vscode-dark", + "cursorColor": "#D4D4D4", + "cursorShape": "filledBox", + "font": + { + "face": "FiraCode NF", + "size": 11 + }, + "padding": "8", + "useAcrylic": true + }, + "list": + [ + { + "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}", + "hidden": false, + "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", + "name": "Debian", + "source": "Windows.Terminal.Wsl" + }, + { + "commandline": "ssh heimdall", + "guid": "{a66d99ed-52b1-4302-9aac-b1b95d81a051}", + "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", + "name": "Heimdall" + }, + { + "commandline": "ssh loki", + "guid": "{1dd1a300-37b9-4aff-b7e3-8b029ca796a9}", + "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", + "name": "Loki" + }, + { + "commandline": "C:\\Users\\tobyv\\.ssh\\wsl-ssh.bat door", + "guid": "{2d87a771-a5dd-44d5-b32d-ce8688b41f7c}", + "hidden": false, + "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", + "name": "Door" + }, + { + "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", + "hidden": false, + "name": "PowerShell", + "source": "Windows.Terminal.PowershellCore" + }, + { + "commandline": "btm", + "guid": "{1a3bcafa-ff3b-46ba-bdf4-582e99ec9dfc}", + "hidden": false, + "name": "btm" + }, + { + "guid": "{b154058b-47bb-56d5-a1b0-06d98908dfa2}", + "hidden": false, + "name": "Developer Command Prompt for VS 2019 (2)", + "source": "Windows.Terminal.VisualStudio" + }, + { + "guid": "{f1a99e78-5690-5e40-b3ff-55031ae2cce5}", + "hidden": false, + "name": "Developer PowerShell for VS 2019 (2)", + "source": "Windows.Terminal.VisualStudio" + } + ] + }, + "schemes": + [ + { + "background": "#0C0C0C", + "black": "#0C0C0C", + "blue": "#0037DA", + "brightBlack": "#767676", + "brightBlue": "#3B78FF", + "brightCyan": "#61D6D6", + "brightGreen": "#16C60C", + "brightPurple": "#B4009E", + "brightRed": "#E74856", + "brightWhite": "#F2F2F2", + "brightYellow": "#F9F1A5", + "cursorColor": "#FFFFFF", + "cyan": "#3A96DD", + "foreground": "#CCCCCC", + "green": "#13A10E", + "name": "Campbell", + "purple": "#881798", + "red": "#C50F1F", + "selectionBackground": "#FFFFFF", + "white": "#CCCCCC", + "yellow": "#C19C00" + }, + { + "background": "#012456", + "black": "#0C0C0C", + "blue": "#0037DA", + "brightBlack": "#767676", + "brightBlue": "#3B78FF", + "brightCyan": "#61D6D6", + "brightGreen": "#16C60C", + "brightPurple": "#B4009E", + "brightRed": "#E74856", + "brightWhite": "#F2F2F2", + "brightYellow": "#F9F1A5", + "cursorColor": "#FFFFFF", + "cyan": "#3A96DD", + "foreground": "#CCCCCC", + "green": "#13A10E", + "name": "Campbell Powershell", + "purple": "#881798", + "red": "#C50F1F", + "selectionBackground": "#FFFFFF", + "white": "#CCCCCC", + "yellow": "#C19C00" + }, + { + "background": "#282C34", + "black": "#282C34", + "blue": "#61AFEF", + "brightBlack": "#5A6374", + "brightBlue": "#61AFEF", + "brightCyan": "#56B6C2", + "brightGreen": "#98C379", + "brightPurple": "#C678DD", + "brightRed": "#E06C75", + "brightWhite": "#DCDFE4", + "brightYellow": "#E5C07B", + "cursorColor": "#FFFFFF", + "cyan": "#56B6C2", + "foreground": "#DCDFE4", + "green": "#98C379", + "name": "One Half Dark", + "purple": "#C678DD", + "red": "#E06C75", + "selectionBackground": "#FFFFFF", + "white": "#DCDFE4", + "yellow": "#E5C07B" + }, + { + "background": "#FAFAFA", + "black": "#383A42", + "blue": "#0184BC", + "brightBlack": "#4F525D", + "brightBlue": "#61AFEF", + "brightCyan": "#56B5C1", + "brightGreen": "#98C379", + "brightPurple": "#C577DD", + "brightRed": "#DF6C75", + "brightWhite": "#FFFFFF", + "brightYellow": "#E4C07A", + "cursorColor": "#4F525D", + "cyan": "#0997B3", + "foreground": "#383A42", + "green": "#50A14F", + "name": "One Half Light", + "purple": "#A626A4", + "red": "#E45649", + "selectionBackground": "#FFFFFF", + "white": "#FAFAFA", + "yellow": "#C18301" + }, + { + "background": "#002B36", + "black": "#002B36", + "blue": "#268BD2", + "brightBlack": "#073642", + "brightBlue": "#839496", + "brightCyan": "#93A1A1", + "brightGreen": "#586E75", + "brightPurple": "#6C71C4", + "brightRed": "#CB4B16", + "brightWhite": "#FDF6E3", + "brightYellow": "#657B83", + "cursorColor": "#FFFFFF", + "cyan": "#2AA198", + "foreground": "#839496", + "green": "#859900", + "name": "Solarized Dark", + "purple": "#D33682", + "red": "#DC322F", + "selectionBackground": "#FFFFFF", + "white": "#EEE8D5", + "yellow": "#B58900" + }, + { + "background": "#FDF6E3", + "black": "#002B36", + "blue": "#268BD2", + "brightBlack": "#073642", + "brightBlue": "#839496", + "brightCyan": "#93A1A1", + "brightGreen": "#586E75", + "brightPurple": "#6C71C4", + "brightRed": "#CB4B16", + "brightWhite": "#FDF6E3", + "brightYellow": "#657B83", + "cursorColor": "#002B36", + "cyan": "#2AA198", + "foreground": "#657B83", + "green": "#859900", + "name": "Solarized Light", + "purple": "#D33682", + "red": "#DC322F", + "selectionBackground": "#FFFFFF", + "white": "#EEE8D5", + "yellow": "#B58900" + }, + { + "background": "#000000", + "black": "#000000", + "blue": "#3465A4", + "brightBlack": "#555753", + "brightBlue": "#729FCF", + "brightCyan": "#34E2E2", + "brightGreen": "#8AE234", + "brightPurple": "#AD7FA8", + "brightRed": "#EF2929", + "brightWhite": "#EEEEEC", + "brightYellow": "#FCE94F", + "cursorColor": "#FFFFFF", + "cyan": "#06989A", + "foreground": "#D3D7CF", + "green": "#4E9A06", + "name": "Tango Dark", + "purple": "#75507B", + "red": "#CC0000", + "selectionBackground": "#FFFFFF", + "white": "#D3D7CF", + "yellow": "#C4A000" + }, + { + "background": "#FFFFFF", + "black": "#000000", + "blue": "#3465A4", + "brightBlack": "#555753", + "brightBlue": "#729FCF", + "brightCyan": "#34E2E2", + "brightGreen": "#8AE234", + "brightPurple": "#AD7FA8", + "brightRed": "#EF2929", + "brightWhite": "#EEEEEC", + "brightYellow": "#FCE94F", + "cursorColor": "#000000", + "cyan": "#06989A", + "foreground": "#555753", + "green": "#4E9A06", + "name": "Tango Light", + "purple": "#75507B", + "red": "#CC0000", + "selectionBackground": "#FFFFFF", + "white": "#D3D7CF", + "yellow": "#C4A000" + }, + { + "background": "#000000", + "black": "#000000", + "blue": "#000080", + "brightBlack": "#808080", + "brightBlue": "#0000FF", + "brightCyan": "#00FFFF", + "brightGreen": "#00FF00", + "brightPurple": "#FF00FF", + "brightRed": "#FF0000", + "brightWhite": "#FFFFFF", + "brightYellow": "#FFFF00", + "cursorColor": "#FFFFFF", + "cyan": "#008080", + "foreground": "#C0C0C0", + "green": "#008000", + "name": "Vintage", + "purple": "#800080", + "red": "#800000", + "selectionBackground": "#FFFFFF", + "white": "#C0C0C0", + "yellow": "#808000" + }, + { + "background": "#1E1E1E", + "black": "#000000", + "blue": "#2472C8", + "brightBlack": "#666666", + "brightBlue": "#3B8EEA", + "brightCyan": "#29B8DB", + "brightGreen": "#23D18B", + "brightPurple": "#D670D6", + "brightRed": "#F14C4C", + "brightWhite": "#E5E5E5", + "brightYellow": "#F5F543", + "cursorColor": "#FFFFFF", + "cyan": "#11A8CD", + "foreground": "#CCCCCC", + "green": "#0DBC79", + "name": "vscode-dark", + "purple": "#BC3FBC", + "red": "#CD3131", + "selectionBackground": "#FFFFFF", + "white": "#E5E5E5", + "yellow": "#E5E510" + } + ], + "startOnUserLogin": false, + "tabSwitcherMode": "mru", + "tabWidthMode": "equal", + "trimBlockSelection": true, + "useAcrylicInTabRow": true, + "windowingBehavior": "useExisting" +} \ No newline at end of file diff --git a/wsl/wsl.sh b/wsl/wsl.sh deleted file mode 100644 index 80d93af..0000000 --- a/wsl/wsl.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -WINHOME="/mnt/c/Users/$USER" -[ "$PWD" = "$WINHOME" ] && cd - -mkdir -p /tmp/xdg - -export BROWSER=wslview -export EDITOR="code --wait" -export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0 -export XDG_RUNTIME_DIR=/tmp/xdg - -alias wsl=wsl.exe -alias ykman='/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe' -# python -alias pip2="DISPLAY= pip2" -alias pip3="DISPLAY= pip3" -alias pip3.7="DISPLAY= pip3.7" -alias pip3.10="DISPLAY= pip3.10" -alias pip="DISPLAY= pip3" - -wt() { - powershell.exe -NoProfile -c "wt $@" -} - -wsl_cmd_proxy() { - exe="$1" - shift # past exe - - cmd=" ${1}" - shift # past cmd - - args="" - while [[ $# -gt 0 ]]; do - case "$1" in - -*) - args+="${1} '${2}' " - shift - shift - ;; - *) - args+="'${1}'" - shift - ;; - esac - args+=" " - done - - powershell.exe -NoProfile -c 'cd $HOME;' "$exe" "$cmd" "$args" -} - -winget() { wsl_cmd_proxy "winget.exe" "$@"; } -scoop() { wsl_cmd_proxy "scoop" "$@"; } -alacritty() { wsl_cmd_proxy "alacritty.exe" "$@"; } - -# https://github.com/validatedev/drop-cache-if-idle -[ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null diff --git a/wt.json b/wt.json deleted file mode 100644 index ff53422..0000000 --- a/wt.json +++ /dev/null @@ -1,389 +0,0 @@ -{ - "$help": "https://aka.ms/terminal-documentation", - "$schema": "https://aka.ms/terminal-profiles-schema", - "actions": - [ - { - "command": - { - "action": "closeTab" - }, - "keys": "ctrl+w" - }, - { - "command": - { - "action": "openSettings", - "target": "settingsUI" - }, - "keys": "ctrl+comma" - }, - { - "command": - { - "action": "openSettings" - }, - "keys": "ctrl+shift+comma" - }, - { - "command": "paste", - "keys": "ctrl+v" - }, - { - "command": - { - "action": "openSettings", - "target": "defaultsFile" - }, - "keys": "ctrl+alt+comma" - }, - { - "command": - { - "action": "newTab", - "profile": "btm" - }, - "keys": "alt+`" - }, - { - "command": "unbound", - "keys": "ctrl+f" - }, - { - "command": "unbound", - "keys": "ctrl+t" - }, - { - "command": - { - "action": "commandPalette" - }, - "keys": "f1" - } - ], - "alwaysShowNotificationIcon": true, - "confirmCloseAllTabs": false, - "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", - "disabledProfileSources": - [ - "Windows.Terminal.Azure" - ], - "experimental.rendering.forceFullRepaint": true, - "initialCols": 100, - "initialRows": 30, - "multiLinePasteWarning": false, - "profiles": - { - "defaults": - { - "bellStyle": - [ - "window", - "taskbar" - ], - "closeOnExit": "always", - "colorScheme": "vscode-dark", - "cursorColor": "#D4D4D4", - "cursorShape": "filledBox", - "font": - { - "face": "FiraCode NF", - "size": 11 - }, - "padding": "8", - "useAcrylic": true - }, - "list": - [ - { - "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}", - "hidden": false, - "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", - "name": "Debian", - "source": "Windows.Terminal.Wsl" - }, - { - "commandline": "ssh heimdall", - "guid": "{a66d99ed-52b1-4302-9aac-b1b95d81a051}", - "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", - "name": "Heimdall" - }, - { - "commandline": "ssh loki", - "guid": "{1dd1a300-37b9-4aff-b7e3-8b029ca796a9}", - "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", - "name": "Loki" - }, - { - "commandline": "C:\\Users\\tobyv\\.ssh\\wsl-ssh.bat door", - "guid": "{2d87a771-a5dd-44d5-b32d-ce8688b41f7c}", - "hidden": false, - "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", - "name": "Door" - }, - { - "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", - "hidden": false, - "name": "PowerShell", - "source": "Windows.Terminal.PowershellCore" - }, - { - "commandline": "btm", - "guid": "{1a3bcafa-ff3b-46ba-bdf4-582e99ec9dfc}", - "hidden": false, - "name": "btm" - }, - { - "guid": "{b154058b-47bb-56d5-a1b0-06d98908dfa2}", - "hidden": false, - "name": "Developer Command Prompt for VS 2019 (2)", - "source": "Windows.Terminal.VisualStudio" - }, - { - "guid": "{f1a99e78-5690-5e40-b3ff-55031ae2cce5}", - "hidden": false, - "name": "Developer PowerShell for VS 2019 (2)", - "source": "Windows.Terminal.VisualStudio" - } - ] - }, - "schemes": - [ - { - "background": "#0C0C0C", - "black": "#0C0C0C", - "blue": "#0037DA", - "brightBlack": "#767676", - "brightBlue": "#3B78FF", - "brightCyan": "#61D6D6", - "brightGreen": "#16C60C", - "brightPurple": "#B4009E", - "brightRed": "#E74856", - "brightWhite": "#F2F2F2", - "brightYellow": "#F9F1A5", - "cursorColor": "#FFFFFF", - "cyan": "#3A96DD", - "foreground": "#CCCCCC", - "green": "#13A10E", - "name": "Campbell", - "purple": "#881798", - "red": "#C50F1F", - "selectionBackground": "#FFFFFF", - "white": "#CCCCCC", - "yellow": "#C19C00" - }, - { - "background": "#012456", - "black": "#0C0C0C", - "blue": "#0037DA", - "brightBlack": "#767676", - "brightBlue": "#3B78FF", - "brightCyan": "#61D6D6", - "brightGreen": "#16C60C", - "brightPurple": "#B4009E", - "brightRed": "#E74856", - "brightWhite": "#F2F2F2", - "brightYellow": "#F9F1A5", - "cursorColor": "#FFFFFF", - "cyan": "#3A96DD", - "foreground": "#CCCCCC", - "green": "#13A10E", - "name": "Campbell Powershell", - "purple": "#881798", - "red": "#C50F1F", - "selectionBackground": "#FFFFFF", - "white": "#CCCCCC", - "yellow": "#C19C00" - }, - { - "background": "#282C34", - "black": "#282C34", - "blue": "#61AFEF", - "brightBlack": "#5A6374", - "brightBlue": "#61AFEF", - "brightCyan": "#56B6C2", - "brightGreen": "#98C379", - "brightPurple": "#C678DD", - "brightRed": "#E06C75", - "brightWhite": "#DCDFE4", - "brightYellow": "#E5C07B", - "cursorColor": "#FFFFFF", - "cyan": "#56B6C2", - "foreground": "#DCDFE4", - "green": "#98C379", - "name": "One Half Dark", - "purple": "#C678DD", - "red": "#E06C75", - "selectionBackground": "#FFFFFF", - "white": "#DCDFE4", - "yellow": "#E5C07B" - }, - { - "background": "#FAFAFA", - "black": "#383A42", - "blue": "#0184BC", - "brightBlack": "#4F525D", - "brightBlue": "#61AFEF", - "brightCyan": "#56B5C1", - "brightGreen": "#98C379", - "brightPurple": "#C577DD", - "brightRed": "#DF6C75", - "brightWhite": "#FFFFFF", - "brightYellow": "#E4C07A", - "cursorColor": "#4F525D", - "cyan": "#0997B3", - "foreground": "#383A42", - "green": "#50A14F", - "name": "One Half Light", - "purple": "#A626A4", - "red": "#E45649", - "selectionBackground": "#FFFFFF", - "white": "#FAFAFA", - "yellow": "#C18301" - }, - { - "background": "#002B36", - "black": "#002B36", - "blue": "#268BD2", - "brightBlack": "#073642", - "brightBlue": "#839496", - "brightCyan": "#93A1A1", - "brightGreen": "#586E75", - "brightPurple": "#6C71C4", - "brightRed": "#CB4B16", - "brightWhite": "#FDF6E3", - "brightYellow": "#657B83", - "cursorColor": "#FFFFFF", - "cyan": "#2AA198", - "foreground": "#839496", - "green": "#859900", - "name": "Solarized Dark", - "purple": "#D33682", - "red": "#DC322F", - "selectionBackground": "#FFFFFF", - "white": "#EEE8D5", - "yellow": "#B58900" - }, - { - "background": "#FDF6E3", - "black": "#002B36", - "blue": "#268BD2", - "brightBlack": "#073642", - "brightBlue": "#839496", - "brightCyan": "#93A1A1", - "brightGreen": "#586E75", - "brightPurple": "#6C71C4", - "brightRed": "#CB4B16", - "brightWhite": "#FDF6E3", - "brightYellow": "#657B83", - "cursorColor": "#002B36", - "cyan": "#2AA198", - "foreground": "#657B83", - "green": "#859900", - "name": "Solarized Light", - "purple": "#D33682", - "red": "#DC322F", - "selectionBackground": "#FFFFFF", - "white": "#EEE8D5", - "yellow": "#B58900" - }, - { - "background": "#000000", - "black": "#000000", - "blue": "#3465A4", - "brightBlack": "#555753", - "brightBlue": "#729FCF", - "brightCyan": "#34E2E2", - "brightGreen": "#8AE234", - "brightPurple": "#AD7FA8", - "brightRed": "#EF2929", - "brightWhite": "#EEEEEC", - "brightYellow": "#FCE94F", - "cursorColor": "#FFFFFF", - "cyan": "#06989A", - "foreground": "#D3D7CF", - "green": "#4E9A06", - "name": "Tango Dark", - "purple": "#75507B", - "red": "#CC0000", - "selectionBackground": "#FFFFFF", - "white": "#D3D7CF", - "yellow": "#C4A000" - }, - { - "background": "#FFFFFF", - "black": "#000000", - "blue": "#3465A4", - "brightBlack": "#555753", - "brightBlue": "#729FCF", - "brightCyan": "#34E2E2", - "brightGreen": "#8AE234", - "brightPurple": "#AD7FA8", - "brightRed": "#EF2929", - "brightWhite": "#EEEEEC", - "brightYellow": "#FCE94F", - "cursorColor": "#000000", - "cyan": "#06989A", - "foreground": "#555753", - "green": "#4E9A06", - "name": "Tango Light", - "purple": "#75507B", - "red": "#CC0000", - "selectionBackground": "#FFFFFF", - "white": "#D3D7CF", - "yellow": "#C4A000" - }, - { - "background": "#000000", - "black": "#000000", - "blue": "#000080", - "brightBlack": "#808080", - "brightBlue": "#0000FF", - "brightCyan": "#00FFFF", - "brightGreen": "#00FF00", - "brightPurple": "#FF00FF", - "brightRed": "#FF0000", - "brightWhite": "#FFFFFF", - "brightYellow": "#FFFF00", - "cursorColor": "#FFFFFF", - "cyan": "#008080", - "foreground": "#C0C0C0", - "green": "#008000", - "name": "Vintage", - "purple": "#800080", - "red": "#800000", - "selectionBackground": "#FFFFFF", - "white": "#C0C0C0", - "yellow": "#808000" - }, - { - "background": "#1E1E1E", - "black": "#000000", - "blue": "#2472C8", - "brightBlack": "#666666", - "brightBlue": "#3B8EEA", - "brightCyan": "#29B8DB", - "brightGreen": "#23D18B", - "brightPurple": "#D670D6", - "brightRed": "#F14C4C", - "brightWhite": "#E5E5E5", - "brightYellow": "#F5F543", - "cursorColor": "#FFFFFF", - "cyan": "#11A8CD", - "foreground": "#CCCCCC", - "green": "#0DBC79", - "name": "vscode-dark", - "purple": "#BC3FBC", - "red": "#CD3131", - "selectionBackground": "#FFFFFF", - "white": "#E5E5E5", - "yellow": "#E5E510" - } - ], - "startOnUserLogin": false, - "tabSwitcherMode": "mru", - "tabWidthMode": "equal", - "trimBlockSelection": true, - "useAcrylicInTabRow": true, - "windowingBehavior": "useExisting" -} \ No newline at end of file diff --git a/yubikey.md b/yubikey.md new file mode 100644 index 0000000..a6adfb4 --- /dev/null +++ b/yubikey.md @@ -0,0 +1,88 @@ +# WSL2 YubiKey Setup + +- [WSL2 YubiKey Setup](#wsl2-yubikey-setup) + - [Intro](#Intro) + - [SSH Agent](#ssh-agent) + - [In Windows](#in-windows) + - [VS Code](#vs-code) + - [In WSL2](#in-wsl2) + +## Intro + +The following two sections are the result of a painstaking amount of google searches and GitHub issues followed by troubleshooting, tears, and tea breaks. Well, more accurately, the 20% came from the aforementioned alliteration. The 80% came from the following two guides. + + - [drduh/YubiKey-Guide](https://github.com/drduh/YubiKey-Guide) + - [The ultimate guide to YubiKey on WSL2](https://dev.to/dzerycz/series/11353) + - [Forwarding gpg-agent to a remote system over SSH](https://wiki.gnupg.org/AgentForwarding) + +The former is an incredibly detailed guide to setting up GPG keys using YubiKey as a smart card. The amount of information drduh has organized in that repository in immense, so I urge you to go star it if you find anything in this section helpful, as he deserves at least that much. + +The second guide was used more as a reference/verification source for the first guide but none-the-less I found it to be helpful, so I figured I would include it here. + +While I went down this rock filled rabbit hole for the purpose of getting my YubiKey working (seamlessly) in WSL2, the majority of this should be helpful even if you don't use a security key, as its specificity deals with getting the respective agents/sockets communicating between WSL2 and Windows. + + + + + +## Windows + +### SSH Agent + +Install [gpg-bridge](https://github.com/BusyJay/gpg-bridge) using cargo + +```powershell +# Powershell +cargo install -f --git https://github.com/busyjay/gpg-bridge +``` + +Set gpg-bridge to run on startup + +```powershell +# Powershell +$cmdl = "$HOME\.cargo\bin\gpg-bridge.exe gpg-bridge-ssh --extra 127.0.0.1:4321 --ssh \\.\pipe\gpg-bridge-ssh --detach" +$key = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -Force +New-ItemProperty -Path $key.PSPath -Name "gpg-bridge" -Value "$cmdl" +``` + +Set SSH_AUTH_SOCK to have ssh use the translated pipe + +```powershell +# Powershell +[System.Environment]::SetEnvironmentVariable('SSH_AUTH_SOCK',"\\.\pipe\gpg-bridge-ssh") +``` + +One-off to run gpg-bridge.exe without restarting + +```powershell +# Powershell +Invoke-Expression "& $cmdl" +``` + +### GPG Agent + +On the windows side the YubiKey is fully accessible, the GPG agent should just work. + +## In WSL2 + +### SSH Agent + +```sh +# Bash + +# Install depends +sudo apt install socat iproute2 + +# Install wsl2-ssh-pageant +destination="$HOME/.ssh/wsl2-ssh-pageant.exe" +curl -sL "https://github.com/BlackReloaded/wsl2-ssh-pageant/releases/latest/download/wsl2-ssh-pageant.exe" -o "$destination" +# wget -O "$destination" "https://github.com/BlackReloaded/wsl2-ssh-pageant/releases/latest/download/wsl2-ssh-pageant.exe" +# Set the executable bit. +chmod +x "$destination" +``` + +### GPG Agent + +The only setup needed for getting the YubiKey working in WSL2 is to source/copy-paste [gpg.sh](wsl/gpg.sh) in your shell profile. + +Along with the initialization code, I wrote a small function the resets all the related agents/sockets. If you do not attempt to access the YubiKey while it is not inserted, in my experience, GPG works great has no issues once reinserting the YubiKey. It is only (inconsistently) when you try to access a YubiKey that you have removed that puts it in a failed state. \ No newline at end of file diff --git a/zsh/.config/zsh/aliases.sh b/zsh/.config/zsh/aliases.sh new file mode 100644 index 0000000..3e87862 --- /dev/null +++ b/zsh/.config/zsh/aliases.sh @@ -0,0 +1,30 @@ +alias ls='ls --color=tty' +alias l='ls -lah' +alias la='ls -lAh' +alias ll='ls -lh' +alias lla='ls -lA' +alias lsa='ls -lah' +alias grep='grep --color' +alias ipa="ip -s -c -h a" +alias untar="tar -zxvf" +alias td=". td.sh" +alias vim=nvim +#python +alias pip=pip3 +alias python=python3 +# docker +alias dexec="docker exec -it" +alias dps="docker ps" +# docker compose +alias dc="docker compose" +alias dce="docker compose exec" +alias dcps="docker compose ps" +alias dcls="docker compose ls" +alias dcdn="docker compose down" +alias dcup="docker compose up" +alias dcupd="docker compose up -d" +alias dcl="docker compose logs" +alias dclf="docker compose logs -f" +# docker context +alias dct="docker context" +alias dcu="docker context use" diff --git a/zsh/.config/zsh/env.sh b/zsh/.config/zsh/env.sh new file mode 100644 index 0000000..2429dd6 --- /dev/null +++ b/zsh/.config/zsh/env.sh @@ -0,0 +1,24 @@ +# XDG +export XDG_CONFIG_HOME=~/.config +export XDG_CACHE_HOME=~/.cache +export XDG_DATA_HOME=~/.local/share +export XDG_RUNTIME_DIR=~/.xdg + +# Path +export PATH=$PATH:$HOME/.local/bin +export PATH=$PATH:$HOME/.scripts +export PATH=$PATH:$HOME/.go/bin +export PATH=$PATH:$HOME/.dotnet/tools +export PATH=$PATH:$HOME/.cargo/bin +export PATH=$PATH:/usr/local/texlive/2021/bin/x86_64-linux + +# Misc +export EDITOR="$(command -v vim 2>/dev/null || command -v vi)" +export VISUAL="code --wait" +export GPG_TTY=$(tty) +export MANPAGER="sh -c 'col -bx | bat -l man -p'" +export MANROFFOPT="-c" +export GOPATH=$HOME/.go +export STARSHIP_LOG="error" +export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || tree -C {}" +export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_COMMAND) 2> /dev/null'" diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..6df7443 --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,132 @@ +# Opts +HYPHEN_INSENSITIVE="true" +DISABLE_UPDATE_PROMPT="true" +DISABLE_AUTO_TITLE="true" +HISTFILE=~/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 + +setopt NO_BEEP +setopt MENU_COMPLETE +setopt auto_pushd # auto push to the directory stack on cd +setopt extended_history # record timestamp of command in HISTFILE +setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_ignore_dups # ignore duplicated commands history list +setopt hist_ignore_space # ignore commands that start with space +setopt hist_verify # show command with history expansion to user before running it +setopt share_history # share command history data + +# Exports +export ZDOTDIR=${XDG_CONFIG_HOME:-$HOME/.config}/zsh +export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || tree -C {}" +export FZF_DEFAULT_COMMAND="fd --type f || git ls-tree -r --name-only HEAD || rg --files || find ." +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_COMMAND) 2> /dev/null'" +export GOPATH=$HOME/.go +typeset -A ZSH_HIGHLIGHT_STYLES +export ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' +export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern line) +export ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion) + +# Load ZDOTDIR +for f in $ZDOTDIR/*.*sh; do source $f; done + +# Misc +command -v fd &>/dev/null && _fzf_compgen_path() { + fd --hidden --follow --exclude ".git" . "$1" +} + +command -v fd &>/dev/null && _fzf_compgen_dir() { + fd --type d --hidden --follow --exclude ".git" . "$1" +} + +eval "$(starship init zsh 2>/dev/null)" + +set_win_title() { + local prefix + + if [ "$USER" != "tobyv" ]; then + prefix="${USER} in " + fi + + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + prefix="${prefix/in/on}${HOST} in " + fi + + echo -ne "\033]0;${prefix}${PWD/$HOME/~}\007" +} + +precmd_functions+=(set_win_title) + +bindkey '^ ' autosuggest-accept +bindkey '^[[Z' reverse-menu-complete + +# Plugins +function plugin-load { + local repo plugin_name plugin_dir initfile initfiles + export ZPLUGINDIR=${ZPLUGINDIR:-${ZDOTDIR:-$HOME/.config/zsh}/plugins} + for repo in $@; do + plugin_name=${repo:t} + plugin_dir=$ZPLUGINDIR/$plugin_name + initfile=$plugin_dir/$plugin_name.plugin.zsh + + if [[ ! -d $plugin_dir ]]; then + echo "Cloning $repo" + git clone -q --depth 1 --recursive --shallow-submodules https://github.com/$repo $plugin_dir + fi + + if [[ ! -e $initfile ]]; then + initfiles=($plugin_dir/*.plugin.{z,}sh(N) $plugin_dir/*.{z,}sh{-theme,}(N)) + [[ ${#initfiles[@]} -gt 0 ]] || { echo "Plugin has no init file '$repo'." >&2 && continue } + ln -sf "${initfiles[1]}" "$initfile" + fi + + fpath+=$plugin_dir + (( $+functions[zsh-defer] )) && zsh-defer . $initfile || . $initfile + done +} + +repos=( + romkatv/zsh-defer + jirutka/zsh-shift-select + zsh-users/zsh-completions + Aloxaf/fzf-tab + joshskidmore/zsh-fzf-history-search + srijanshetty/zsh-pandoc-completion + zsh-users/zsh-syntax-highlighting + zsh-users/zsh-autosuggestions +) + +plugin-load $repos + +function comp-load { + local comp src name comp_file + export ZCOMPDIR=${ZCOMPDIR:-${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions} + mkdir -p $ZCOMPDIR + for comp in $@; do + src="$(echo $comp | sed 's/[:][^:]*$//')" + name="$(echo $comp | sed 's/.*[:]//' | sed 's/^[^_]/_&/')" + + if [[ -n $name ]]; then + name="$(basename $src | sed 's/^[^_]/_&/')" + fi + + comp_file=$ZCOMPDIR/$name + + if [[ ! -f $comp_file ]]; then + curl -sL https://raw.githubusercontent.com/$src >$comp_file + fi + done + + fpath+=$ZCOMPDIR + + autoload -U compinit + compinit -i + + zstyle ':completion:*' menu select +} + +comps=( + dotnet/cli/master/scripts/register-completions.zsh:_dotnet + docker/cli/master/contrib/completion/zsh/_docker +) diff --git a/zsh/keybindings.zsh b/zsh/keybindings.zsh deleted file mode 100644 index 31b17fd..0000000 --- a/zsh/keybindings.zsh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env zsh - -r-delregion() { - if ((REGION_ACTIVE)) then - zle kill-region - else - local widget_name=$1 - shift - zle $widget_name -- $@ - fi -} - -r-deselect() { - ((REGION_ACTIVE = 0)) - local widget_name=$1 - shift - zle $widget_name -- $@ -} - -r-select() { - ((REGION_ACTIVE)) || zle set-mark-command - local widget_name=$1 - shift - zle $widget_name -- $@ -} - -r-select-a() { - r-deselect beginning-of-line - r-select end-of-line -} - -r-undo() { - zle undo -} - -r-copy() { - if ((REGION_ACTIVE)) then - zle copy-region-as-kill - printf "$CUTBUFFER" | xclip -i - else - zle kill-whole-line - fi -} - -r-cut() { - if ((REGION_ACTIVE)) then - zle kill-region - else - zle kill-whole-line - fi - printf "$CUTBUFFER" | xclip -i -} - -for key kcap seq mode widget ( - sleft kLFT $'\e[1;2D' select backward-char - sright kRIT $'\e[1;2C' select forward-char - sup kri $'\e[1;2A' select up-line-or-history - sdown kind $'\e[1;2B' select down-line-or-history - - send kEND $'\E[1;2F' select end-of-line - send2 x $'\E[4;2~' select end-of-line - - shome kHOM $'\E[1;2H' select beginning-of-line - shome2 x $'\E[1;2~' select beginning-of-line - - left kcub1 $'\EOD' deselect backward-char - right kcuf1 $'\EOC' deselect forward-char - - end kend $'\EOF' deselect end-of-line - end2 x $'\E4~' deselect end-of-line - - home khome $'\EOH' deselect beginning-of-line - home2 x $'\E1~' deselect beginning-of-line - - csleft x $'\E[1;6D' select backward-word - csright x $'\E[1;6C' select forward-word - csend x $'\E[1;6F' select end-of-line - cshome x $'\E[1;6H' select beginning-of-line - - cleft x $'\E[1;5D' deselect backward-word - cright x $'\E[1;5C' deselect forward-word - - del kdch1 $'\E[3~' delregion delete-char - bs x $'^?' delregion backward-delete-char - - cz x "^Z" undo "" - cc x "^C" copy "" - cx x "^X" cut "" - ca x "^A" select-a "" - ) { - eval "key-$key() { - r-$mode $widget \$@ - }" - zle -N key-$key - bindkey ${terminfo[$kcap]-$seq} key-$key -} - -bindkey '^ ' autosuggest-accept -bindkey '^[[Z' reverse-menu-complete - -# register ctrl+c as interupt -function ctrl_c_intr() { - stty intr \^C <$TTY >$TTY -} - -# register ctrl+y as interupt -function ctrl_y_intr() { - stty intr \^Y <$TTY >$TTY -} - -# make sure we can register hooks -autoload -Uz add-zsh-hook || return - -# register the functions as hooks -add-zsh-hook preexec ctrl_c_intr -add-zsh-hook precmd ctrl_y_intr diff --git a/zshrc b/zshrc deleted file mode 100644 index 2148dcc..0000000 --- a/zshrc +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env zsh - -HYPHEN_INSENSITIVE="true" -DISABLE_UPDATE_PROMPT="true" -DISABLE_AUTO_TITLE="true" -HISTFILE=~/.zsh_history -HISTSIZE=10000 -SAVEHIST=10000 - -setopt NO_BEEP -setopt MENU_COMPLETE -setopt auto_pushd # auto push to the directory stack on cd -setopt extended_history # record timestamp of command in HISTFILE -setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE -setopt hist_ignore_dups # ignore duplicated commands history list -setopt hist_ignore_space # ignore commands that start with space -setopt hist_verify # show command with history expansion to user before running it -setopt share_history # share command history data - -typeset -A ZSH_HIGHLIGHT_STYLES -ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' -ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern line) -ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion) - -fpath=(~/.local/share/zsh/site-functions "${fpath[@]}") - -source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh -for f in ~/.zsh/*.*sh; do source $f; done - -# fzf settings -export FZF_DEFAULT_COMMAND="fd --type f || git ls-tree -r --name-only HEAD || rg --files || find ." -export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" - -command -v fd &>/dev/null && _fzf_compgen_path() { - fd --hidden --follow --exclude ".git" . "$1" -} - -command -v fd &>/dev/null && _fzf_compgen_dir() { - fd --type d --hidden --follow --exclude ".git" . "$1" -} - -eval "$(starship init zsh 2>/dev/null)" -eval "$(navi widget zsh 2>/dev/null)" - -set_win_title() { - local prefix - - if [ "$USER" != "tobyv" ]; then - prefix="${USER} in " - fi - - if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - prefix="${prefix/in/on}${HOST} in " - fi - - echo -ne "\033]0;${prefix}${PWD/$HOME/~}\007" -} - -precmd_functions+=(set_win_title) - -autoload -U compinit -compinit -i - -zstyle ':completion:*' menu select -source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -- cgit v1.2.3-70-g09d2