diff --git a/env/.config/nvim/init.lua b/env/.config/nvim/init.lua index 09d4654..150c811 100644 --- a/env/.config/nvim/init.lua +++ b/env/.config/nvim/init.lua @@ -22,11 +22,15 @@ vim.pack.add({ { src = "https://github.com/neovim/nvim-lspconfig" }, { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" }, { src = "https://github.com/mason-org/mason.nvim" }, + { src = "https://github.com/nvim-lua/plenary.nvim" }, + { src = "https://github.com/ThePrimeagen/harpoon", version = "harpoon2" }, + { src = "https://github.com/christoomey/vim-tmux-navigator" }, }) require("mason").setup() require("mini.pick").setup() require("oil").setup() +require("harpoon").setup({ settings = { save_on_toggle = true, sync_on_ui_close = true } }) -- Set color scheme vim.cmd([[colorscheme catppuccin-mocha]]) @@ -58,14 +62,42 @@ vim.lsp.config("lua_ls", { -- Keymaps local map = vim.keymap.set +local harpoon = require("harpoon") -map('n', 'e', ':Oil') -map('n', 'f', ':Pick files tool="git"') -map('n', 'h', ':Pick help') -map('n', 'lf', vim.lsp.buf.format) -map('n', 'o', ':update :source') -map('n', 'q', ':quit') -map('n', 'w', ':write') +map('i', 'jk', '') + +map('n', 'a', function() harpoon:list():add() end, { desc = "[A]dd file to harpoon" }) +map('n', 'bb', ':bprevious', { desc = "[B]uffer [b]ack" }) +map('n', 'bn', ':bnext', { desc = "[B]uffer [n]ext" }) +map('n', 'cf', vim.lsp.buf.format, { desc = "[F]ormat" }) +map('n', '', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, { desc = "Open harpoon menu" }) +map('n', 'e', ':Oil', { desc = "[E]xplore files" }) +map('n', 'ff', ':Pick files tool="git"', { desc = "[F]ind file" }) +map('n', 'fh', ':Pick help', { desc = "[H]elp search" }) +map('n', 'hb', function() harpoon:list():prev() end, { desc = "[H]arpoon [b]ack" }) +map('n', 'hn', function() harpoon:list():next() end, { desc = "[H]arpoon [n]ext" }) +map('n', 'o', ':update :source', { desc = "Source current file" }) + +-- Tmux / pane navigation +map('n', "", "TmuxNavigateLeft") +map('n', "", "TmuxNavigateDown") +map('n', "", "TmuxNavigateUp") +map('n', "", "TmuxNavigateRight") + +-- Move line(s) up or down. +map('n', "J", ":move .+1==", { desc = "Move line down" }) +map('n', "K", ":move .-2==", { desc = "Move line up" }) +map("v", "K", ":move '<-2gv=gv", { desc = "Move selected block up.", silent = true, noremap = true }) +map("v", "J", ":move '>+1gv=gv", { desc = "Move selected block up.", silent = true, noremap = true }) + +-- Harpoon extensions +harpoon:extend({ + UI_CREATE = function(cx) + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ vsplit = true }) + end, { buffer = cx.buffer, desc = "Open in [V]ertical split" }) + end, +}) -- Auto commands. local defaultopts = { clear = true } @@ -77,7 +109,8 @@ vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { callback = function(args) local first_line = vim.api.nvim_buf_get_lines(args.buf, 0, 1, false)[1] or "" if first_line:match("^#!.*zsh") then - vim.bo[args.buf].filetype = "bash" + -- vim.bo[args.buf].filetype = "bash" + vim.cmd.setlocal("filetype=bash") end end, }) @@ -141,3 +174,31 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, { } end }) + +-- Highlight when yanking. +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking text.", + group = vim.api.nvim_create_augroup("my.highlight-yank", defaultopts), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- Add '-' to be part of words. +vim.api.nvim_create_autocmd("BufEnter", { + desc = "Add '-' to be part of word.", + group = vim.api.nvim_create_augroup('my.iskeyword', defaultopts), + pattern = "*", + callback = function() + vim.cmd.setlocal("iskeyword+=-") + end +}) + +vim.api.nvim_create_autocmd("BufWritePre", { + desc = "Format on write.", + group = vim.api.nvim_create_augroup('my.format-on-write', defaultopts), + pattern = "*", + callback = function() + vim.lsp.buf.format() + end +}) diff --git a/env/.config/zsh/.zshrc b/env/.config/zsh/.zshrc index 7b11318..afd6542 100755 --- a/env/.config/zsh/.zshrc +++ b/env/.config/zsh/.zshrc @@ -19,17 +19,6 @@ zle -N down-line-or-beginning-search # Colors autoload -Uz colors && colors -#------------------------------ pager ------------------------------ -#eval "$(batman --export-env)" -# export LESS_TERMCAP_mb="" # magenta -# export LESS_TERMCAP_md="" # yellow -# export LESS_TERMCAP_me="" -# export LESS_TERMCAP_se="" -# export LESS_TERMCAP_so="" # blue -# export LESS_TERMCAP_ue="" -# export LESS_TERMCAP_so="" # underline -# export LESSHISTFILE="-" - #------------------------------ path ------------------------------ # Helper function to prepend to the $PATH @@ -97,8 +86,6 @@ export HISTFILESIZE=5000 export SAVEHIST=5000 export HISTFILE="$XDG_CONFIG_HOME/zsh/history" -#set -o vi - #------------------------------ cdpath ------------------------------ setopt autocd @@ -132,7 +119,6 @@ zsh_add_plugin "Aloxaf/fzf-tab" #------------------------------ completions ------------------------------ # case insensitive path-completion
 -#zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
 zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # partial completion suggestions @@ -154,10 +140,8 @@ _source_if "$ZDOTDIR/plugins/fzf-tab/fzf-tab.plugin.zsh" #------------------------------ prompt ------------------------------ -# Prompt / managed by brew. (`brew install starship`) autoload -Uz promptinit; promptinit eval "$(starship init zsh)" -#prompt pure #------------------------------ aliases ------------------------------ @@ -203,11 +187,6 @@ alias temp='cd $(mktemp -d)' # create a temporary directory and move alias vi='nvim' # set vi to open neovim alias newf='"$SCRIPTS"/newx --function' # generate a new shell function alias n='nvim' -# alias nlnv='nvim "$LOCAL_ENV"' # open local environment overrides file in neovime -# alias nvim='unset VIMINIT && unset MYVIMRC && nvim' # alias nvim to unset vimrc, useful when using both vim & neovim -# alias nvim-mhoush='NVIM_APPNAME=m-housh && nvim' # set neovim to use my config. -# alias nvim-kickstart='NVIM_APPNAME=kickstart nvim' # set neovim to use kickstart config. -# alias nvim-lazy='NVIM_APPNAME=lazy nvim' # set neovim to use lazy config. alias wget="wget --hsts-file=$XDG_DATA_HOME/wget-hsts" # set wget history location. # GPG Yubikey restart relearn when switching keys and stubbed. alias yubikeyrestart='gpg-connect-agent killagent /bye && gpg-connect-agent "scd serialno" "learn --force" /bye && gpg --card-status' @@ -237,12 +216,9 @@ esac # pnpm end # The following lines have been added by Docker Desktop to enable Docker CLI completions. -# fpath=(/Users/michael/.docker/completions $fpath) autoload -Uz compinit compinit -#eval "$(ssh-agent -s)" 1>/dev/null - ######################################## # Set things up for using gpg-agent diff --git a/env/.zshenv b/env/.zshenv index 44bf2ab..a60e6ba 100755 --- a/env/.zshenv +++ b/env/.zshenv @@ -19,9 +19,6 @@ export VISUAL=nvim export EDITOR_PREFIX=nvim export MANPAGER="bat" export BROWSER="brave" -#export VIMINIT='source $MYVIMRC' -#export MYVIMRC="$HOME/.vim/vimrc" -#export NVIM_APPNAME="m-housh" # Git export GITUSER="m-housh" @@ -36,6 +33,8 @@ export LOCAL_ENV="$XDG_DATA_HOME/zsh/env.zsh" export MYZSHRC="$ZDOTDIR/.zshrc" export SCRIPTS="$HOME/.local/scripts" export SKELETONDIR="$DOTFILES/skeleton" +export REPOS="$HOME/dev" +export WORK="$HOME/work" # NPM export NPM_CONFIG_CACHE="$XDG_DATA_HOME/npm" @@ -68,10 +67,9 @@ export VAULT_ADDR="https://vault.housh.dev" export CARGO_HOME="$XDG_DATA_HOME/cargo" # Tmux-Sessionator path. -export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS:$HOME/.config:$HOME/.config/personal:$HOME/dev:$HOME/dev/homelab/utils:$HOME/dev/homelab/services:$HOME/work/consults:$HOME/work" +export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS:$HOME/.config:$HOME/.config/personal:$REPOS:$REPOS/homelab/utils:$REPOS/homelab/services:$WORK/consults:$WORK" # Password-store -# export PASSWORD_STORE_DIR="$XDG_DATA_HOME/gopass/stores/root" export PASSWORD_STORE_GENERATED_LENGTH=40 export PASSWORD_STORE_ENABLE_EXTENSIONS=true