diff --git a/alacritty.configlink/alacritty.yml b/alacritty.configlink/alacritty.yml index 8495635..d6e9988 100644 --- a/alacritty.configlink/alacritty.yml +++ b/alacritty.configlink/alacritty.yml @@ -99,7 +99,8 @@ font: # - (Windows) Consolas #family: Fira Code #family: Noto Sans Mono - family: Fira Mono for Powerline + # family: Fira Mono for Powerline + family: FiraMono Nerd Font # The `style` can be specified to pick a specific face. #style: Regular @@ -138,7 +139,7 @@ font: #style: Bold Italic # Point size - size: 18.0 + size: 17.0 # Offset is the extra space around each character. `offset.y` can be thought of # as modifying the line spacing, and `offset.x` as modifying the letter spacing. diff --git a/bin/git_set_upstream b/bin/git_set_upstream deleted file mode 100755 index 553f3c8..0000000 --- a/bin/git_set_upstream +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Copied from David Pedersen: https://github.com/davidpdrsn/dotfiles/blob/master/bin/git-pp - -set -e - -git_branch_name() { - val=$( git branch 2>/dev/null | grep '^\*' | colrm 1 2 ) - echo "$val" -} - -git push --set-upstream origin "$(git_branch_name)" diff --git a/bin/url-decode b/bin/url-decode new file mode 100755 index 0000000..10a20ae --- /dev/null +++ b/bin/url-decode @@ -0,0 +1,5 @@ +#!/bin/bash + +function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } + +urldecode "$@" diff --git a/fish.configlink/functions/abbrs.fish b/fish.configlink/functions/abbrs.fish index c2c3276..07dc025 100644 --- a/fish.configlink/functions/abbrs.fish +++ b/fish.configlink/functions/abbrs.fish @@ -30,7 +30,7 @@ function abbrs --description 'All abbreviations' abbr -a gca 'git commit --amend' abbr -a gu 'git pull' abbr -a gp 'git push' - abbr -a gpp 'git_set_upstream' + abbr -a gpp 'git-push-upstream' abbr -a gl 'git log --graph --decorate --oneline -20' abbr -a gll 'git log --graph --decorate --oneline' abbr -a gco 'git checkout' @@ -48,9 +48,11 @@ function abbrs --description 'All abbreviations' # GitHub abbr -a ghr 'gh repo view -w' abbr -a gha 'gh run list | head -1 | awk \'{ print $(NF-2) }\' | xargs gh run view' - abbr -a grw 'gh run watch' + abbr -a grw 'noti gh run watch' abbr -a grf 'gh run view --log-failed' abbr -a grl 'gh run view --log' + abbr -a ghpr 'gh pr create && sleep 3 && noti gh run watch' + abbr -a ghm 'gh pr merge -s -d && git pull' # Vim if command -v nvim > /dev/null @@ -62,7 +64,8 @@ function abbrs --description 'All abbreviations' end abbr -a v 'vim' abbr -a vl 'vim -c "normal! `0"' - abbr -a vll 'vim -c "Hist"' + abbr -a vll 'vim -c "Telescope oldfiles"' + abbr -a vh 'vim -c "Telescope oldfiles"' # Notes abbr -a qn 'quicknote' @@ -73,6 +76,7 @@ function abbrs --description 'All abbreviations' # Improved CLI Tools abbr -a cat 'bat' # Swap cat with bat abbr -a h 'http -Fh --all' # Curl site for headers + abbr -a j 'just' # Fun CLI Tools abbr goo 'googler' diff --git a/fish.configlink/functions/fish_user_key_bindings.fish b/fish.configlink/functions/fish_user_key_bindings.fish index e9443e4..a843758 100644 --- a/fish.configlink/functions/fish_user_key_bindings.fish +++ b/fish.configlink/functions/fish_user_key_bindings.fish @@ -2,9 +2,12 @@ function fish_user_key_bindings bind -M insert \co 'edit' + bind -M insert \ca 'cd; and edit; cd -' bind -M insert \ce 'recent' bind -M insert \cg 'commandline-git-commits' bind -M insert \cf 'fcd' + bind -M insert \cp 'prj' + bind -M default \cp 'prj' bind -M insert \x1F accept-autosuggestion bind -M default \x1F accept-autosuggestion end diff --git a/fish.configlink/functions/git-push-upstream.fish b/fish.configlink/functions/git-push-upstream.fish new file mode 100644 index 0000000..06c8250 --- /dev/null +++ b/fish.configlink/functions/git-push-upstream.fish @@ -0,0 +1,6 @@ +function git-push-upstream --description "Create upstream branch" + set -l branch (git branch 2>/dev/null | grep '^\*' | colrm 1 2) + set -l command "git push --set-upstream origin $branch" + commandline -r $command + commandline -f execute +end diff --git a/fish.configlink/functions/prj.fish b/fish.configlink/functions/prj.fish index 6efcf72..a19bb37 100644 --- a/fish.configlink/functions/prj.fish +++ b/fish.configlink/functions/prj.fish @@ -1,4 +1,5 @@ function prj --description "cd to a project" set projdir (ls $PROJ | fzf) and cd $PROJ/$projdir + and commandline -f execute end diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index 44da407..09f6506 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -39,15 +39,20 @@ function obj:init() -- Control was not down but is now if not self.lastModifiers['ctrl'] then + + -- Only prepare to send escape if no other modifier keys are in use self.lastModifiers = newModifiers if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then self.sendEscape = true self.movements = 0 end + -- Control was down and is up, hasn't been blocked by another key, and -- isn't above the movement threshold - elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 20) then + elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 30) then + self.lastModifiers = newModifiers + -- Allow for shift-escape if newModifiers['shift'] then hs.eventtap.keyStroke({'shift'}, 'escape', 0) @@ -56,8 +61,12 @@ function obj:init() end self.sendEscape = false self.movements = 0 + self.numberOfCharacters = 0 + + -- Control was down and is up, but isn't ready to send escape else self.lastModifiers = newModifiers + end end ) @@ -65,7 +74,7 @@ function obj:init() -- If any other key is pressed, don't send escape self.asModifier = hs.eventtap.new({hs.eventtap.event.types.keyDown}, function(event) - self.sendEscape = false + self.sendEscape = false end ) diff --git a/hammerspoon.symlink/Spoons/Launcher.spoon/init.lua b/hammerspoon.symlink/Spoons/Launcher.spoon/init.lua new file mode 100644 index 0000000..3c19ba0 --- /dev/null +++ b/hammerspoon.symlink/Spoons/Launcher.spoon/init.lua @@ -0,0 +1,50 @@ +--- === Launcher === + +local obj={} +obj.__index = obj + +-- Metadata +obj.name = 'Launcher' +obj.version = '0.1' +obj.license = 'MIT - https://opensource.org/licenses/MIT' + +function obj:init() + + -- Begin launcher mode + self.launcher = hs.hotkey.modal.new('ctrl', 'space') + + -- Behaviors on enter + function self.launcher:entered() + -- hs.alert'Entered mode' + end + -- Behaviors on exit + function self.launcher:exited() + -- hs.alert'Exited mode' + end + + -- Use escape to exit launcher mode + self.launcher:bind('', 'escape', function() self.launcher:exit() end) + + -- Launcher shortcuts + self.launcher:bind('', 'space', function() hs.hints.windowHints(); self.launcher:exit() end) + self.launcher:bind('', 'return', function() self:switch('Alacritty.app') end) + self.launcher:bind('', 'D', function() self:switch('Discord.app') end) + self.launcher:bind('', 'E', function() self:switch('Microsoft Outlook.app') end) + self.launcher:bind('', 'F', function() self:switch('Firefox.app') end) + self.launcher:bind('', 'G', function() self:switch('Mimestream.app') end) + self.launcher:bind('', 'M', function() self:switch('Messages.app') end) + self.launcher:bind('', 'O', function() self:switch('Obsidian.app') end) + self.launcher:bind('', 'P', function() self:switch('System Preferences.app') end) + self.launcher:bind('', 'R', function() hs.reload() end) + self.launcher:bind('', 'S', function() self:switch('Slack.app') end) + self.launcher:bind('', 'Z', function() self:switch('zoom.us.app') end) + +end + +function obj:switch(app) + hs.application.launchOrFocus(app) + self.launcher:exit() +end + +return obj + diff --git a/hammerspoon.symlink/init.lua b/hammerspoon.symlink/init.lua index ec04d67..7306367 100644 --- a/hammerspoon.symlink/init.lua +++ b/hammerspoon.symlink/init.lua @@ -1 +1,2 @@ hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon +hs.loadSpoon('Launcher'):init() diff --git a/homebrew/Caskfile b/homebrew/Caskfile index a065ccc..a613f1b 100644 --- a/homebrew/Caskfile +++ b/homebrew/Caskfile @@ -24,6 +24,7 @@ cask "hammerspoon" # Fonts tap "homebrew/cask-fonts" cask "font-fira-mono-for-powerline" +cask "font-fira-mono-nerd-font" # Personal cask "authy" # Authentication diff --git a/homebrew/devops.Brewfile b/homebrew/devops.Brewfile index 4e5df2f..34005b0 100644 --- a/homebrew/devops.Brewfile +++ b/homebrew/devops.Brewfile @@ -1,6 +1,7 @@ # DevOps Packages tap "nmasur/repo" +tap "hashicorp/tap" brew "ansible" # Deploy to local server brew "terraform" # Deploy cloud infra @@ -9,3 +10,5 @@ brew "awscli" # AWS API tools brew "kubectl" # Kubernetes CLI brew "k9s" # Kubernetes TUI brew "nmasur/repo/drips" # Retrieve AWS IPs +brew "hashicorp/tap/terraform-ls" +brew "tflint" diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index a3026fb..9b80662 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -10,72 +10,144 @@ end -- Packer plugin installations local use = require('packer').use require('packer').startup(function() - use 'wbthomason/packer.nvim' -- Maintain plugin manager - use 'tpope/vim-eunuch' -- File manipulation in Vim - use 'tpope/vim-vinegar' -- Fixes netrw file explorer - use 'tpope/vim-fugitive' -- Git commands - use 'tpope/vim-surround' -- Manipulate parentheses - use 'tpope/vim-commentary' -- Use gc or gcc to add comments - use 'tpope/vim-repeat' -- Actually repeat using . - use 'christoomey/vim-tmux-navigator' -- Hotkeys for tmux panes - use 'morhetz/gruvbox' -- Colorscheme - use 'phaazon/hop.nvim' -- Quick jump around the buffer - use 'neovim/nvim-lspconfig' -- Language server linting - use 'folke/lsp-colors.nvim' -- Pretty LSP highlights - use 'rafamadriz/friendly-snippets' - use 'hrsh7th/vim-vsnip' - use 'hrsh7th/vim-vsnip-integ' - use 'hrsh7th/nvim-compe' -- Auto-complete - use 'godlygeek/tabular' -- Spacing and alignment - use 'vimwiki/vimwiki' -- Wiki Markdown System - use 'airblade/vim-rooter' -- Change directory to git route - use { -- Status bar + use 'wbthomason/packer.nvim' -- Maintain plugin manager + use 'lewis6991/impatient.nvim' -- Startup speed hacks + use 'tpope/vim-eunuch' -- File manipulation in Vim + use 'tpope/vim-vinegar' -- Fixes netrw file explorer + use 'tpope/vim-fugitive' -- Git commands and syntax + use 'tpope/vim-surround' -- Manipulate parentheses + use 'tpope/vim-commentary' -- Use gc or gcc to add comments + use 'tpope/vim-repeat' -- Actually repeat using . + use 'christoomey/vim-tmux-navigator' -- Hotkeys for tmux panes + use 'morhetz/gruvbox' -- Colorscheme + use 'L3MON4D3/LuaSnip' -- Snippet engine + use 'neovim/nvim-lspconfig' -- Language server linting + use 'folke/lsp-colors.nvim' -- Pretty LSP highlights + use 'hrsh7th/cmp-nvim-lsp' -- Language server completion + use 'hrsh7th/cmp-buffer' -- Generic text completion + use 'hrsh7th/cmp-path' -- Local file completion + use 'hrsh7th/cmp-cmdline' -- Command line completion + use 'hrsh7th/cmp-nvim-lua' -- Nvim lua api completion + use 'saadparwaiz1/cmp_luasnip' -- Luasnip completion + use 'hrsh7th/nvim-cmp' -- Completion system + use 'godlygeek/tabular' -- Spacing and alignment + use 'vimwiki/vimwiki' -- Wiki Markdown System + use 'airblade/vim-rooter' -- Change directory to git route + use { -- Status bar 'hoob3rt/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true } } - use { -- Syntax highlighting for most languages + use 'nathom/filetype.nvim' -- Faster startup + use { -- Syntax highlighting processor 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use 'bfontaine/Brewfile.vim' -- Brewfile syntax - use 'blankname/vim-fish' -- Fish syntax - use 'chr4/nginx.vim' -- Nginx syntax - use 'hashivim/vim-terraform' -- Terraform syntax - use 'cespare/vim-toml' -- TOML syntax - use 'towolf/vim-helm' -- Helm syntax - use 'LnL7/vim-nix' -- Nix syntax - use { -- Git next to line numbers + use 'bfontaine/Brewfile.vim' -- Brewfile syntax + use 'chr4/nginx.vim' -- Nginx syntax + use 'hashivim/vim-terraform' -- Terraform formatting + use 'towolf/vim-helm' -- Helm syntax + use 'rodjek/vim-puppet' -- Puppet syntax + use { -- Git next to line numbers 'lewis6991/gitsigns.nvim', + branch = 'main', requires = {'nvim-lua/plenary.nvim'}, config = function() require('gitsigns').setup() end } - use { -- Fuzzy finder - 'junegunn/fzf.vim', - requires = {'/usr/local/opt/fzf'} + use { + 'nvim-telescope/telescope.nvim', + requires = { {'nvim-lua/plenary.nvim'} } } - -- use 'ludovicchabant/vim-gutentags' + use 'nvim-telescope/telescope-fzy-native.nvim' + use 'camgraff/telescope-tmux.nvim' + use { + 'jvgrootveld/telescope-zoxide', + requires = {'nvim-lua/popup.nvim'}, + } + use { + "AckslD/nvim-neoclip.lua", + branch = 'main', + requires = {'tami5/sqlite.lua', module = 'sqlite'}, + } + -- use 'ludovicchabant/vim-gutentags' end) +require('impatient') -- Faster startup + +-- Completion Settings +-- =================== + +local cmp = require'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = function(fallback) + cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }) + vim.cmd('stopinsert') -- Abort and leave insert mode + end, + -- [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }), + -- [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + sources = { + { name = 'nvim_lua' }, + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'luasnip' }, + { name = 'buffer', keyword_length = 5, max_item_count = 10 }, + }, + experimental = { + native_menu = false, -- Use cmp menu instead of Vim menu + ghost_text = true, -- Show preview auto-completion + }, +}) + +-- Use buffer source for `/` +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer', keyword_length = 5 } + } +}) + +-- Use cmdline & path source for ':' +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + + -- LSP Settings -- ============ -require('lspconfig').rust_analyzer.setup{} +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) + +require('lspconfig').rust_analyzer.setup{ capabilities = capabilities } +require('lspconfig').tflint.setup{ capabilities = capabilities } +require('lspconfig').terraformls.setup{ capabilities = capabilities } require('lspconfig').pyright.setup{ - cmd = { "poetry", "run", "pyright-langserver", "--stdio" } + cmd = { "poetry", "run", "pyright-langserver", "--stdio" }, + capabilities = capabilities, } -require'compe'.setup({ - enabled = true, - source = { - path = true, - buffer = true, - nvim_lsp = true, - }, -}) if require('lspconfig/util').has_bins('diagnostic-languageserver') then require('lspconfig').diagnosticls.setup{ cmd = { "diagnostic-languageserver", "--stdio" }, @@ -113,52 +185,6 @@ if require('lspconfig/util').has_bins('diagnostic-languageserver') then } end --- Auto-complete --- ==================== - --- Auto-complete mapping -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - -local check_back_space = function() - local col = vim.fn.col('.') - 1 - if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false - end -end --- Use (s-)tab to: ---- move to prev/next item in completion menuone ---- jump to prev/next snippet's placeholder -_G.tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#available", {1}) == 1 then - return t "(vsnip-expand-or-jump)" - elseif check_back_space() then - return t "" - else - return vim.fn['compe#complete']() - end -end -_G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then - return t "(vsnip-jump-prev)" - else - return t "" - end -end - --- Auto-complete keybinds -vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) - -- Settings -- ======== @@ -187,47 +213,65 @@ vim.o.updatetime = 300 -- Faster diagnostics vim.o.mouse = "nv" -- Mouse interaction / scrolling -- Neovim features -vim.o.inccommand = "split" -- Live preview search and replace -vim.o.completeopt = "menuone,noselect" -- Required for nvim-compe completion +vim.o.inccommand = "split" -- Live preview search and replace +vim.o.completeopt = "menu,menuone,noselect" -- Required for nvim-cmp completion +-- Required until 0.6.0: do not source the default filetype.vim +vim.g.did_load_filetypes = 1 -- Remember last position when reopening file vim.api.nvim_exec([[ - if has("autocmd") - au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif - endif + au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif ]], false) -- Better backup, swap and undo storage -vim.o.backup = true -- Easier to recover and more secure -vim.bo.swapfile = false -- Instead of swaps, create backups -vim.bo.undofile = true -- Keeps undos after quit +vim.o.backup = true -- Easier to recover and more secure +vim.bo.swapfile = false -- Instead of swaps, create backups +vim.bo.undofile = true -- Keeps undos after quit -- Create backup directories if they don't exist +-- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433 +vim.o.backupdir = vim.fn.stdpath('cache') .. '/backup' vim.api.nvim_exec([[ - set backupdir=~/.local/share/nvim/backup - set undodir=~/.local/share/nvim/undo if !isdirectory(&backupdir) call mkdir(&backupdir, "p") endif - if !isdirectory(&undodir) - call mkdir(&undodir, "p") - endif ]], false) --- Keep selection when tabbing -vim.api.nvim_set_keymap("v", "<", "", ">gv", {noremap=true}) +-- Filetype for .env files +local envfiletype = function() + vim.bo.filetype = 'text' + vim.bo.syntax = 'sh' +end -- Force filetype patterns that Vim doesn't know about -vim.api.nvim_exec([[ - au BufRead,BufNewFile *.Brewfile setfiletype brewfile - au BufRead,BufNewFile tmux.conf* setfiletype tmux - au BufRead,BufNewFile *ignore.*link setfiletype gitignore - au BufRead,BufNewFile gitconfig.*link setfiletype gitconfig - au BufRead,BufNewFile *.toml.*link setfiletype toml - au BufRead,BufNewFile *.muttrc setfiletype muttrc - au BufRead,BufNewFile .env* set ft=text | set syntax=sh -]], false) +require('filetype').setup({ + overrides = { + extensions = { + Brewfile = 'brewfile', + muttrc = 'muttrc', + hcl = 'terraform', + }, + literal = { + Caskfile = 'brewfile', + [".gitignore"] = 'gitignore', + }, + complex = { + [".*git/config"] = "gitconfig", + ["tmux.conf%..*link"] = "tmux", + ["gitconfig%..*link"] = "gitconfig", + [".*ignore%..*link"] = "gitignore", + [".*%.toml%..*link"] = "toml", + }, + function_extensions = {}, + function_literal = { + [".envrc"] = envfiletype, + [".env"] = envfiletype, + [".env.dev"] = envfiletype, + [".env.prod"] = envfiletype, + [".env.example"] = envfiletype, + }, + } +}) -- LaTeX options vim.api.nvim_exec([[ @@ -240,11 +284,6 @@ vim.api.nvim_exec([[ au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } ]], false) --- Rust stuff --- vim.api.nvim_exec([[ --- au BufWritePost *.rs silent! execute "%! rustfmt" --- ]], false) - -- Auto-pairs vim.g.AutoPairsFlyMode = 0 @@ -255,10 +294,16 @@ vim.g.netrw_winsize = 15 -- Explore window takes % of page vim.g.netrw_browse_split = 4 -- Open in previous window vim.g.netrw_altv = 1 -- Always split left --- Polyglot +-- Formatting vim.g.terraform_fmt_on_save = 1 -- Formats with terraform plugin vim.g.rustfmt_autosave = 1 -- Formats with rust plugin +-- Tree-Sitter Syntax Processing +require('nvim-treesitter.configs').setup { + highlight = { enable = true }, + indent = { enable = true }, +} + -- VimWiki vim.g.vimwiki_list = { { @@ -289,14 +334,48 @@ vim.api.nvim_exec([[ -- Status bar require('lualine').setup({ - options = { theme = 'gruvbox' } + options = { + theme = 'gruvbox', + icons_enabled = true + } }) +-- Clipboard history +require('neoclip').setup({ + enable_persistant_history = true, +}) + +-- Telescope: quit instantly with escape +local actions = require("telescope.actions") +require("telescope").setup({ + defaults = { + mappings = { + i = { [""] = actions.close, }, + }, + }, + pickers = { + find_files = { theme = "dropdown" }, + oldfiles = { theme = "dropdown" }, + buffers = { theme = "dropdown" }, + }, + extensions = { + fzy_native = {}, + tmux = {}, + zoxide = {}, + neoclip = {}, + }, +}) +require('telescope').load_extension('neoclip') + -- Remap space as leader key vim.api.nvim_set_keymap("", "", "", {noremap=true, silent=true}) vim.g.mapleader = " " vim.g.maplocalleader = " " +-- Keep selection when changing indentation +vim.api.nvim_set_keymap("v", "<", "", ">gv", {noremap=true}) + -- Unset search pattern register vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) @@ -308,12 +387,33 @@ vim.api.nvim_set_keymap("i", "", ":m .-2==gi", {noremap=true}) vim.api.nvim_set_keymap("v", "", ":m '>+1gv=gv", {noremap=true}) vim.api.nvim_set_keymap("v", "", ":m '<-2gv=gv", {noremap=true}) --- Fzf (fuzzy finder) -vim.api.nvim_set_keymap("n", "/", ":Rg", {noremap=true}) -vim.api.nvim_set_keymap("n", "ff", ":Files", {noremap=true}) -vim.api.nvim_set_keymap("n", "fr", ":History", {noremap=true}) -vim.api.nvim_set_keymap("n", "b", ":Buffers", {noremap=true}) -vim.api.nvim_set_keymap("n", "s", ":BLines", {noremap=true}) +-- Telescope (fuzzy finder) +vim.api.nvim_set_keymap("n", "/", ":Telescope live_grep", {noremap=true}) +vim.api.nvim_set_keymap("n", "ff", ":Telescope find_files", {noremap=true}) +vim.api.nvim_set_keymap("n", "fa", ":Telescope file_browser", {noremap=true}) +vim.api.nvim_set_keymap("n", "wt", ":Telescope tmux sessions", {noremap=true}) +vim.api.nvim_set_keymap("n", "ww", ":Telescope tmux windows", {noremap=true}) +vim.api.nvim_set_keymap("n", "w/", ":Telescope tmux pane_contents", {noremap=true}) +vim.api.nvim_set_keymap("n", "fz", ":Telescope zoxide list", {noremap=true}) +vim.api.nvim_set_keymap("n", "b", ":Telescope buffers", {noremap=true}) +vim.api.nvim_set_keymap("n", "hh", ":Telescope help_tags", {noremap=true}) +vim.api.nvim_set_keymap("n", "fr", ":Telescope oldfiles", {noremap=true}) +vim.api.nvim_set_keymap("n", "cc", ":Telescope commands", {noremap=true}) +vim.api.nvim_set_keymap("n", "cr", ":Telescope command_history", {noremap=true}) +vim.api.nvim_set_keymap("n", "y", ":Telescope neoclip", {noremap=true}) +vim.api.nvim_set_keymap("n", "s", ":Telescope current_buffer_fuzzy_find", {noremap=true}) +vim.api.nvim_set_keymap("n", "gc", ":Telescope git_commits", {noremap=true}) +vim.api.nvim_set_keymap("n", "gf", ":Telescope git_bcommits", {noremap=true}) +vim.api.nvim_set_keymap("n", "gb", ":Telescope git_branches", {noremap=true}) +vim.api.nvim_set_keymap("n", "gs", ":Telescope git_status", {noremap=true}) + +-- LSP +vim.api.nvim_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "gh", "lua vim.lsp.buf.hover()", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "]e", "lua vim.lsp.diagnostic.goto_next()", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "[e", "lua vim.lsp.diagnostic.goto_prev()", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", {silent=true, noremap=true}) -- File commands vim.api.nvim_set_keymap("n", "q", ":quit", {noremap=true}) @@ -325,7 +425,9 @@ vim.api.nvim_set_keymap("n", "fd", ":lcd %:p:h", {silent=true, norem vim.api.nvim_set_keymap("n", "fu", ":lcd ..", {silent=true, noremap=true}) vim.api.nvim_set_keymap("n", "", ":b#", {silent=true, noremap=true}) vim.api.nvim_set_keymap("n", "gr", ":!gh repo view -w", {silent=true, noremap=true}) -vim.api.nvim_set_keymap("n", "tt", [[exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md']], {noremap=true}) +vim.api.nvim_set_keymap("n", "tt", + [[exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md']], {noremap=true} +) -- Window commands vim.api.nvim_set_keymap("n", "wv", ":vsplit", {noremap=true}) @@ -336,13 +438,25 @@ vim.api.nvim_set_keymap("n", "wm", ":only", {noremap=true}) vim.api.nvim_set_keymap("", "ta", ":Tabularize /", {noremap=true}) vim.api.nvim_set_keymap("", "t#", ":Tabularize /#", {noremap=true}) vim.api.nvim_set_keymap("", "t\"", ":Tabularize /\"", {noremap=true}) +vim.api.nvim_set_keymap("", "tl", ":Tabularize /--", {noremap=true}) --- Vimrc +-- Vimrc editing vim.api.nvim_set_keymap("n", "fv", ":edit $MYVIMRC", {noremap=true}) vim.api.nvim_set_keymap("n", "rr", ":luafile $MYVIMRC", {noremap=true}) +vim.api.nvim_set_keymap("n", "rp", ":luafile $MYVIMRC:PackerInstall:PackerCompile", {noremap=true}) -- Other -vim.api.nvim_set_keymap("n", "", ":HopWord", {noremap=true}) -vim.api.nvim_set_keymap("t", "", "", {noremap=true}) -- Exit terminal mode -vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true}) +vim.api.nvim_set_keymap("t", "", "", {noremap=true}) -- Exit terminal mode +vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) -- Clear search +vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true}) -- Copy to end of line + +-- Keep cursor in place +vim.api.nvim_set_keymap("n", 'n', "nzz", {noremap=true}) +vim.api.nvim_set_keymap("n", 'N', "Nzz", {noremap=true}) +vim.api.nvim_set_keymap("n", 'J', "mzJ`z", {noremap=true}) -- Mark and jump back to it + +-- Add undo breakpoints +vim.api.nvim_set_keymap("i", ',', ",u", {noremap=true}) +vim.api.nvim_set_keymap("i", '.', ".u", {noremap=true}) +vim.api.nvim_set_keymap("i", '!', "!u", {noremap=true}) +vim.api.nvim_set_keymap("i", '?', "?u", {noremap=true}) diff --git a/scripts/setup_fish b/scripts/setup_fish index 987677a..35b1035 100755 --- a/scripts/setup_fish +++ b/scripts/setup_fish @@ -7,6 +7,7 @@ set -Ux EDITOR nvim # Preferred text editor set -U PROJ $HOME/dev/work # Projects directory set -Ux NOTES_PATH $HOME/notes # Notes directory set -Ux MANPAGER "nvim +Man!" # Used for reading man pages +set -Ux DIRENV_LOG_FORMAT "" # Disable direnv output # Load abbreviations abbrs