From 2334f33cdb5efaee6578d141a9c0fc6c89fddb6a Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 7 Nov 2024 21:44:00 -0500 Subject: [PATCH] feat: Cleanup some nvim config --- nvim/m-housh/init.lua | 3 +- nvim/m-housh/lua/user/keymaps.lua | 107 ++++++++++++++++++++++++ nvim/m-housh/lua/user/mappings.lua | 126 ----------------------------- zsh/config/.zshenv | 40 ++++----- 4 files changed, 125 insertions(+), 151 deletions(-) create mode 100755 nvim/m-housh/lua/user/keymaps.lua delete mode 100755 nvim/m-housh/lua/user/mappings.lua diff --git a/nvim/m-housh/init.lua b/nvim/m-housh/init.lua index 9cc011d..6f50e0c 100755 --- a/nvim/m-housh/init.lua +++ b/nvim/m-housh/init.lua @@ -9,7 +9,7 @@ require('user.autocmd') require('user.plugins') -- Key maps -require('user.mappings') +require('user.keymaps') -- Theme (must stay after plugins are loaded) require('user.theme') @@ -18,4 +18,3 @@ require('user.theme') require('user.settings') vim.o.shiftwidth = 2 - diff --git a/nvim/m-housh/lua/user/keymaps.lua b/nvim/m-housh/lua/user/keymaps.lua new file mode 100755 index 0000000..c6d34d6 --- /dev/null +++ b/nvim/m-housh/lua/user/keymaps.lua @@ -0,0 +1,107 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local keymap = vim.keymap.set +local default_options = {noremap = true, silent = true} +local telescope = require('telescope.builtin') +local wk = require("which-key") + +local wk_add = function(mode, keymaps) + wk.add(keymaps, { mode = mode, noremap = true, silent = true }) +end + +local find_files = function(dir) + return function() + telescope.find_files({ cwd = dir, hidden = true, no_ignore = true }) + end +end + +-------------------------------------------------------------------------------- +-- Insert Mode +-------------------------------------------------------------------------------- +-- easier escape key mapping +keymap('i', 'jk', '', default_options) +wk_add("i", { + { "", ":writea", desc = "[S]ave" } +}) + +-------------------------------------------------------------------------------- +-- Normal Mode +-------------------------------------------------------------------------------- +wk_add("n", { + { "", ":vertical resize +1", desc = "Resize Pane Left" }, + { "", ":vertical resize -1", desc = "Resize Pane Right" }, + { "", "resize -1", desc = "Resize Pane Up" }, + { "", "resize +1", desc = "Resize Pane Down" }, + + { "n", ":noh", desc = "[N]o highlighting" }, + { "s", ":set spell!", desc = "[S]pell check toggle" }, + { "", ":Neotree toggle", desc = "Toggle Neotree" }, + { "", ":write", desc = "[S]ave" }, + + -- Git + { "gg", ":LazyGit", desc = "Open [G]it" }, + { "gf", ":Telescope git_files", desc = "Find [G]it [F]ile" }, + { "t", ":ToggleTerm", desc = "Open [T]erminal" }, + + -- Telescope keymaps + { "ff", telescope.find_files, desc = "[F]ind [F]iles" }, + { "fg", telescope.live_grep, desc = "[F]ind [G]rep" }, + { "fb", telescope.buffers, desc = "[F]ind [B]uffers" }, + { "fh", telescope.help_tags, desc = "[F]ind [H]elp" }, + { "fd", find_files('$DOTFILES'), desc = "[F]ind [D]otfiles" }, + { "fn", find_files('$DOTFILES/nvim/m-housh'), desc = "[F]ind [N]vim file" }, + { "fs", find_files('$DOTFILES/scripts/scripts'), desc = "[F]ind [S]cript" }, + { "fz", find_files('$DOTFILES/zsh/config'), desc = "[F]ind [Z]sh config file" }, + { "z", ":ZenMode", desc = "[Z]en Mode" }, +}) + +-------------------------------------------------------------------------------- +-- Visual Mode +-------------------------------------------------------------------------------- +wk_add("v", { + { "p", "\"_dP", desc = "[P]aste" }, +}) + +wk_add("x", { + { "K", ":move '<-2gv-gv", desc = "Move selected block up" }, + { "J", ":move '>+1gv-gv", desc = "Move selected block down" }, +}) + +-- Toggle term key maps, that get attached when terminal is opened. +function _G.set_terminal_keymaps() + local opts = { buffer = 0 } + keymap('t', '', [[]], opts) +end +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +-- LuaSnip Keymaps +--local ls = require('luasnip') + +-- to expand snippets. +-- This will expand the snippet or jump to the next item within the snippet. +-- vim.keymap.set({ "i", "s" }, "", function() +-- if ls.expand_or_jumpable() then +-- ls.expand_or_jump() +-- end +-- end, { silent = true }) + + +-- +-- This will jump backwards in the snippet. +-- vim.keymap.set({ "i", "s" }, "", function() +-- if ls.jumpable(-1) then +-- ls.jump(-1) +-- end +-- end, { silent = true }) + +-- +-- This is for selecting withing a list of options. +-- vim.keymap.set("i", "", function() +-- if ls.choice_active() then +-- ls.change_choice(1) +-- end +-- end, { silent = true }) + +-- Reload the snippets. +--vim.keymap.set("n", "s", "source ~/.config/m-housh/lua/snippets/init.lua") diff --git a/nvim/m-housh/lua/user/mappings.lua b/nvim/m-housh/lua/user/mappings.lua deleted file mode 100755 index dc571a0..0000000 --- a/nvim/m-housh/lua/user/mappings.lua +++ /dev/null @@ -1,126 +0,0 @@ -local keymap = vim.keymap.set -local default_options = {noremap = true, silent = true} -local telescope = require('telescope.builtin') --- local expr_options = {noremap = true, expr = true, silent = true} -vim.g.mapleader = " " -vim.g.maplocalleader = " " - --- easier escape key mapping -keymap('i', 'jk', '', default_options) - -keymap('n', '', ':w', default_options) -keymap('i', '', ':wa', default_options) - --- paste over currently selected text without yanking it -keymap("v", "p", "\"_dP", default_options) - --- buffer focus --- keymap('n', '', 'j', default_options) --- keymap('n', '', 'h', default_options) --- keymap('n', '', 'k', default_options) --- keymap('n', '', 'l', default_options) - --- Resizing panes -keymap("n", "", ":vertical resize +1", default_options) -keymap("n", "", ":vertical resize -1", default_options) -keymap("n", "", ":resize -1", default_options) -keymap("n", "", ":resize +1", default_options) - --- Move selected line / block of text in visual mode -keymap("x", "K", ":move '<-2gv-gv", default_options) -keymap("x", "J", ":move '>+1gv-gv", default_options) - --- Toggle neo-tree open or closed -keymap("n", "", ":Neotree toggle", default_options) - --- Toggle Lazy Git -keymap("n", 'gg', ':LazyGit', default_options) -keymap("n", "gf", ":Telescope git_files", default_options) -keymap("n", "t", ":ToggleTerm", default_options) - --- Zen Mode Toggle -keymap('n', 'z', ":ZenMode", default_options) - --- Toggle term key maps, that get attached when terminal is opened. -function _G.set_terminal_keymaps() - local opts = { buffer = 0 } - vim.keymap.set('t', '', [[]], opts) -end - -vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') - --- Formatting -keymap('n', 'f', ':Format', default_options) -keymap('n', 'F', ':FormatWrite', default_options) - --- Telescope keymaps -vim.keymap.set('n', 'ff', telescope.find_files, {}) -vim.keymap.set('n', 'fg', telescope.live_grep, {}) -vim.keymap.set('n', 'fb', telescope.buffers, {}) -vim.keymap.set('n', 'fh', telescope.help_tags, {}) - --- Find espanso config files. -keymap('n', 'fe', function() - telescope.find_files({ - cwd='$HOME/.dotfiles/espanso/espanso' - }) -end, default_options) - --- Find nvim config files. -keymap('n', 'fn', function() - telescope.find_files({ - cwd='$HOME/.dotfiles/nvim/m-housh' - }) -end, default_options) - --- Find script files. -keymap('n', 'fs', function() - telescope.find_files({ - cwd='$HOME/.dotfiles/scripts/scripts' - }) -end, default_options) - --- Find zsh config files. -keymap('n', 'fz', function() - telescope.find_files({ - cwd = '$HOME/.dotfiles/zsh/config', - hidden = true - }) -end, default_options) - --- Turn off highlighting after search. -keymap('n', 'n', ':noh', default_options) - --- Toggle Spell Checking. -keymap('n', 's', ':set spell!', default_options) - --- LuaSnip Keymaps ---local ls = require('luasnip') - --- to expand snippets. --- This will expand the snippet or jump to the next item within the snippet. --- vim.keymap.set({ "i", "s" }, "", function() --- if ls.expand_or_jumpable() then --- ls.expand_or_jump() --- end --- end, { silent = true }) - - --- --- This will jump backwards in the snippet. --- vim.keymap.set({ "i", "s" }, "", function() --- if ls.jumpable(-1) then --- ls.jump(-1) --- end --- end, { silent = true }) - --- --- This is for selecting withing a list of options. --- vim.keymap.set("i", "", function() --- if ls.choice_active() then --- ls.change_choice(1) --- end --- end, { silent = true }) - --- Reload the snippets. ---vim.keymap.set("n", "s", "source ~/.config/m-housh/lua/snippets/init.lua") diff --git a/zsh/config/.zshenv b/zsh/config/.zshenv index defb517..9fddc19 100755 --- a/zsh/config/.zshenv +++ b/zsh/config/.zshenv @@ -3,7 +3,7 @@ # This includes general default environment variables, local overrides may be stored # in `$XDG_DATA_HOME/zsh/env.zsh`. -# XDG +# XDG Directories export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$HOME/.local/share" export XDG_STATE_HOME="$HOME/.local/state" @@ -12,7 +12,7 @@ export XDG_CACHE_HOME="$HOME/.cache" # Config export ZDOTDIR="$HOME/.config/zsh" export ZFUNCDIR="$ZDOTDIR/functions" -export SHELL="$(which zsh)" +export SHELL="$(command -v zsh)" export TERM=xterm-256color export EDITOR=nvim export VISUAL=nvim @@ -26,33 +26,28 @@ export GITUSER="m-housh" export GIT_DISCOVERY_ACROSS_FILESYSTEM=1 # Directories +export ANSIBLE_GEN_DIR="$GHREPOS/ansible/ansible-gen-playbook" +export ANSIBLE_LOCAL="$GHREPOS/ansible" +export ANSIBLE_MACOS_PLAYBOOK_DIR="$HOME/ansible-macos-playbook" export ARCHIVE="/Volumes/Archive" export BUCKET="/Volumes/Bucket" -export REPOS="/Volumes/Bucket/Repos" -export GHREPOS="$REPOS/github.com" -#export HHEREPOS="$REPOS/github.com/hhe-dev" -#export HVACIOTREPOS="$REPOS/github.com/hvac-iot" -export LOCAL_REPOS="$REPOS/local" -export LOCAL_ENV="$XDG_DATA_HOME/zsh/env.zsh" -#export HCP_NOTES="$HHEREPOS/hcp-notes" -#export HXZET="$BUCKET/Repos/github.com/hvac-hx/hx-zets" -#export HAAS="$BUCKET/Repos/github.com/haas" -#export HAASZET="$HAAS/zets" +export DOTFILES="$HOME/.dotfiles" export DOCUMENTS="$HOME/Documents" export DOWNLOADS="$HOME/Downloads" -export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents" -export PROPOSALS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals" -export SCREENSHOTS="$BUCKET/Pictures/Screenshots" -export DOTFILES="$HOME/.dotfiles" -export SCRIPTS="$XDG_DATA_HOME/scripts" -export WORK="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work" -export ZETDIR="$GHREPOS/zets" +export GHREPOS="$REPOS/github.com" +export LOCAL_REPOS="$REPOS/local" +export LOCAL_ENV="$XDG_DATA_HOME/zsh/env.zsh" export MYZSHRC="$ZDOTDIR/.zshrc" export NAP_CONFIG="$HOME/.config/nap/config.yaml" -export SKELETONDIR="$DOTFILES/skeleton" -export ANSIBLE_GEN_DIR="$GHREPOS/ansible/ansible-gen-playbook" -export ANSIBLE_MACOS_PLAYBOOK_DIR="$GHREPOS/ansible/ansible-macos-playbook" +export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents" +export PROPOSALS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals" +export REPOS="/Volumes/Bucket/Repos" +export SCREENSHOTS="$BUCKET/Pictures/Screenshots" +export SCRIPTS="$XDG_DATA_HOME/scripts" export SITES="$GHREPOS/sites" +export SKELETONDIR="$DOTFILES/skeleton" +export WORK="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work" +export ZETDIR="$GHREPOS/zets" # NPM export NPM_CONFIG_CACHE="$XDG_DATA_HOME/npm" @@ -82,7 +77,6 @@ export PSQL_HISTORY="$XDG_DATA_HOME/psql_history" export VAULT_ADDR="https://vault.housh.dev" # Ansible -export ANSIBLE_LOCAL="$GHREPOS/ansible" export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible" export ANSIBLE_VAULT_PASSWORD_FILE="$XDG_DATA_HOME/ansible/.vaultpwd" export DEFAULT_VAULT_PASSWORD_FILE="$XDG_DATA_HOME/ansible/.vaultpwd"