Merge branch 'experimental'

This commit is contained in:
Noah Masur 2021-11-08 23:48:45 -05:00
commit c71ffe0ea2
14 changed files with 339 additions and 152 deletions

View File

@ -99,7 +99,8 @@ font:
# - (Windows) Consolas # - (Windows) Consolas
#family: Fira Code #family: Fira Code
#family: Noto Sans Mono #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. # The `style` can be specified to pick a specific face.
#style: Regular #style: Regular
@ -138,7 +139,7 @@ font:
#style: Bold Italic #style: Bold Italic
# Point size # Point size
size: 18.0 size: 17.0
# Offset is the extra space around each character. `offset.y` can be thought of # 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. # as modifying the line spacing, and `offset.x` as modifying the letter spacing.

View File

@ -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)"

5
bin/url-decode Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
urldecode "$@"

View File

@ -30,7 +30,7 @@ function abbrs --description 'All abbreviations'
abbr -a gca 'git commit --amend' abbr -a gca 'git commit --amend'
abbr -a gu 'git pull' abbr -a gu 'git pull'
abbr -a gp 'git push' 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 gl 'git log --graph --decorate --oneline -20'
abbr -a gll 'git log --graph --decorate --oneline' abbr -a gll 'git log --graph --decorate --oneline'
abbr -a gco 'git checkout' abbr -a gco 'git checkout'
@ -48,9 +48,11 @@ function abbrs --description 'All abbreviations'
# GitHub # GitHub
abbr -a ghr 'gh repo view -w' 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 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 grf 'gh run view --log-failed'
abbr -a grl 'gh run view --log' 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 # Vim
if command -v nvim > /dev/null if command -v nvim > /dev/null
@ -62,7 +64,8 @@ function abbrs --description 'All abbreviations'
end end
abbr -a v 'vim' abbr -a v 'vim'
abbr -a vl 'vim -c "normal! `0"' 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 # Notes
abbr -a qn 'quicknote' abbr -a qn 'quicknote'
@ -73,6 +76,7 @@ function abbrs --description 'All abbreviations'
# Improved CLI Tools # Improved CLI Tools
abbr -a cat 'bat' # Swap cat with bat abbr -a cat 'bat' # Swap cat with bat
abbr -a h 'http -Fh --all' # Curl site for headers abbr -a h 'http -Fh --all' # Curl site for headers
abbr -a j 'just'
# Fun CLI Tools # Fun CLI Tools
abbr goo 'googler' abbr goo 'googler'

View File

@ -2,9 +2,12 @@
function fish_user_key_bindings function fish_user_key_bindings
bind -M insert \co 'edit' bind -M insert \co 'edit'
bind -M insert \ca 'cd; and edit; cd -'
bind -M insert \ce 'recent' bind -M insert \ce 'recent'
bind -M insert \cg 'commandline-git-commits' bind -M insert \cg 'commandline-git-commits'
bind -M insert \cf 'fcd' bind -M insert \cf 'fcd'
bind -M insert \cp 'prj'
bind -M default \cp 'prj'
bind -M insert \x1F accept-autosuggestion bind -M insert \x1F accept-autosuggestion
bind -M default \x1F accept-autosuggestion bind -M default \x1F accept-autosuggestion
end end

View File

@ -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

View File

@ -1,4 +1,5 @@
function prj --description "cd to a project" function prj --description "cd to a project"
set projdir (ls $PROJ | fzf) set projdir (ls $PROJ | fzf)
and cd $PROJ/$projdir and cd $PROJ/$projdir
and commandline -f execute
end end

View File

@ -39,15 +39,20 @@ function obj:init()
-- Control was not down but is now -- Control was not down but is now
if not self.lastModifiers['ctrl'] then if not self.lastModifiers['ctrl'] then
-- Only prepare to send escape if no other modifier keys are in use
self.lastModifiers = newModifiers self.lastModifiers = newModifiers
if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then
self.sendEscape = true self.sendEscape = true
self.movements = 0 self.movements = 0
end end
-- Control was down and is up, hasn't been blocked by another key, and -- Control was down and is up, hasn't been blocked by another key, and
-- isn't above the movement threshold -- 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 self.lastModifiers = newModifiers
-- Allow for shift-escape -- Allow for shift-escape
if newModifiers['shift'] then if newModifiers['shift'] then
hs.eventtap.keyStroke({'shift'}, 'escape', 0) hs.eventtap.keyStroke({'shift'}, 'escape', 0)
@ -56,8 +61,12 @@ function obj:init()
end end
self.sendEscape = false self.sendEscape = false
self.movements = 0 self.movements = 0
self.numberOfCharacters = 0
-- Control was down and is up, but isn't ready to send escape
else else
self.lastModifiers = newModifiers self.lastModifiers = newModifiers
end end
end end
) )
@ -65,7 +74,7 @@ function obj:init()
-- If any other key is pressed, don't send escape -- If any other key is pressed, don't send escape
self.asModifier = hs.eventtap.new({hs.eventtap.event.types.keyDown}, self.asModifier = hs.eventtap.new({hs.eventtap.event.types.keyDown},
function(event) function(event)
self.sendEscape = false self.sendEscape = false
end end
) )

View File

@ -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

View File

@ -1 +1,2 @@
hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon
hs.loadSpoon('Launcher'):init()

View File

@ -24,6 +24,7 @@ cask "hammerspoon"
# Fonts # Fonts
tap "homebrew/cask-fonts" tap "homebrew/cask-fonts"
cask "font-fira-mono-for-powerline" cask "font-fira-mono-for-powerline"
cask "font-fira-mono-nerd-font"
# Personal # Personal
cask "authy" # Authentication cask "authy" # Authentication

View File

@ -1,6 +1,7 @@
# DevOps Packages # DevOps Packages
tap "nmasur/repo" tap "nmasur/repo"
tap "hashicorp/tap"
brew "ansible" # Deploy to local server brew "ansible" # Deploy to local server
brew "terraform" # Deploy cloud infra brew "terraform" # Deploy cloud infra
@ -9,3 +10,5 @@ brew "awscli" # AWS API tools
brew "kubectl" # Kubernetes CLI brew "kubectl" # Kubernetes CLI
brew "k9s" # Kubernetes TUI brew "k9s" # Kubernetes TUI
brew "nmasur/repo/drips" # Retrieve AWS IPs brew "nmasur/repo/drips" # Retrieve AWS IPs
brew "hashicorp/tap/terraform-ls"
brew "tflint"

View File

@ -10,72 +10,144 @@ end
-- Packer plugin installations -- Packer plugin installations
local use = require('packer').use local use = require('packer').use
require('packer').startup(function() require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Maintain plugin manager use 'wbthomason/packer.nvim' -- Maintain plugin manager
use 'tpope/vim-eunuch' -- File manipulation in Vim use 'lewis6991/impatient.nvim' -- Startup speed hacks
use 'tpope/vim-vinegar' -- Fixes netrw file explorer use 'tpope/vim-eunuch' -- File manipulation in Vim
use 'tpope/vim-fugitive' -- Git commands use 'tpope/vim-vinegar' -- Fixes netrw file explorer
use 'tpope/vim-surround' -- Manipulate parentheses use 'tpope/vim-fugitive' -- Git commands and syntax
use 'tpope/vim-commentary' -- Use gc or gcc to add comments use 'tpope/vim-surround' -- Manipulate parentheses
use 'tpope/vim-repeat' -- Actually repeat using . use 'tpope/vim-commentary' -- Use gc or gcc to add comments
use 'christoomey/vim-tmux-navigator' -- Hotkeys for tmux panes use 'tpope/vim-repeat' -- Actually repeat using .
use 'morhetz/gruvbox' -- Colorscheme use 'christoomey/vim-tmux-navigator' -- Hotkeys for tmux panes
use 'phaazon/hop.nvim' -- Quick jump around the buffer use 'morhetz/gruvbox' -- Colorscheme
use 'neovim/nvim-lspconfig' -- Language server linting use 'L3MON4D3/LuaSnip' -- Snippet engine
use 'folke/lsp-colors.nvim' -- Pretty LSP highlights use 'neovim/nvim-lspconfig' -- Language server linting
use 'rafamadriz/friendly-snippets' use 'folke/lsp-colors.nvim' -- Pretty LSP highlights
use 'hrsh7th/vim-vsnip' use 'hrsh7th/cmp-nvim-lsp' -- Language server completion
use 'hrsh7th/vim-vsnip-integ' use 'hrsh7th/cmp-buffer' -- Generic text completion
use 'hrsh7th/nvim-compe' -- Auto-complete use 'hrsh7th/cmp-path' -- Local file completion
use 'godlygeek/tabular' -- Spacing and alignment use 'hrsh7th/cmp-cmdline' -- Command line completion
use 'vimwiki/vimwiki' -- Wiki Markdown System use 'hrsh7th/cmp-nvim-lua' -- Nvim lua api completion
use 'airblade/vim-rooter' -- Change directory to git route use 'saadparwaiz1/cmp_luasnip' -- Luasnip completion
use { -- Status bar 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', 'hoob3rt/lualine.nvim',
requires = { requires = {
'kyazdani42/nvim-web-devicons', 'kyazdani42/nvim-web-devicons',
opt = true opt = true
} }
} }
use { -- Syntax highlighting for most languages use 'nathom/filetype.nvim' -- Faster startup
use { -- Syntax highlighting processor
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate' run = ':TSUpdate'
} }
use 'bfontaine/Brewfile.vim' -- Brewfile syntax use 'bfontaine/Brewfile.vim' -- Brewfile syntax
use 'blankname/vim-fish' -- Fish syntax use 'chr4/nginx.vim' -- Nginx syntax
use 'chr4/nginx.vim' -- Nginx syntax use 'hashivim/vim-terraform' -- Terraform formatting
use 'hashivim/vim-terraform' -- Terraform syntax use 'towolf/vim-helm' -- Helm syntax
use 'cespare/vim-toml' -- TOML syntax use 'rodjek/vim-puppet' -- Puppet syntax
use 'towolf/vim-helm' -- Helm syntax use { -- Git next to line numbers
use 'LnL7/vim-nix' -- Nix syntax
use { -- Git next to line numbers
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
branch = 'main',
requires = {'nvim-lua/plenary.nvim'}, requires = {'nvim-lua/plenary.nvim'},
config = function() config = function()
require('gitsigns').setup() require('gitsigns').setup()
end end
} }
use { -- Fuzzy finder use {
'junegunn/fzf.vim', 'nvim-telescope/telescope.nvim',
requires = {'/usr/local/opt/fzf'} 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) 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 = {
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<Esc>'] = function(fallback)
cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
})
vim.cmd('stopinsert') -- Abort and leave insert mode
end,
-- ['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
-- ['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }),
['<CR>'] = 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 -- 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{ 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 if require('lspconfig/util').has_bins('diagnostic-languageserver') then
require('lspconfig').diagnosticls.setup{ require('lspconfig').diagnosticls.setup{
cmd = { "diagnostic-languageserver", "--stdio" }, cmd = { "diagnostic-languageserver", "--stdio" },
@ -113,52 +185,6 @@ if require('lspconfig/util').has_bins('diagnostic-languageserver') then
} }
end 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 "<C-n>"
elseif vim.fn.call("vsnip#available", {1}) == 1 then
return t "<Plug>(vsnip-expand-or-jump)"
elseif check_back_space() then
return t "<Tab>"
else
return vim.fn['compe#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<Plug>(vsnip-jump-prev)"
else
return t "<S-Tab>"
end
end
-- Auto-complete keybinds
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
-- Settings -- Settings
-- ======== -- ========
@ -187,47 +213,65 @@ vim.o.updatetime = 300 -- Faster diagnostics
vim.o.mouse = "nv" -- Mouse interaction / scrolling vim.o.mouse = "nv" -- Mouse interaction / scrolling
-- Neovim features -- Neovim features
vim.o.inccommand = "split" -- Live preview search and replace vim.o.inccommand = "split" -- Live preview search and replace
vim.o.completeopt = "menuone,noselect" -- Required for nvim-compe completion 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 -- Remember last position when reopening file
vim.api.nvim_exec([[ vim.api.nvim_exec([[
if has("autocmd") au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif
]], false) ]], false)
-- Better backup, swap and undo storage -- Better backup, swap and undo storage
vim.o.backup = true -- Easier to recover and more secure vim.o.backup = true -- Easier to recover and more secure
vim.bo.swapfile = false -- Instead of swaps, create backups vim.bo.swapfile = false -- Instead of swaps, create backups
vim.bo.undofile = true -- Keeps undos after quit vim.bo.undofile = true -- Keeps undos after quit
-- Create backup directories if they don't exist -- 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([[ vim.api.nvim_exec([[
set backupdir=~/.local/share/nvim/backup
set undodir=~/.local/share/nvim/undo
if !isdirectory(&backupdir) if !isdirectory(&backupdir)
call mkdir(&backupdir, "p") call mkdir(&backupdir, "p")
endif endif
if !isdirectory(&undodir)
call mkdir(&undodir, "p")
endif
]], false) ]], false)
-- Keep selection when tabbing -- Filetype for .env files
vim.api.nvim_set_keymap("v", "<", "<gv", {noremap=true}) local envfiletype = function()
vim.api.nvim_set_keymap("v", ">", ">gv", {noremap=true}) vim.bo.filetype = 'text'
vim.bo.syntax = 'sh'
end
-- Force filetype patterns that Vim doesn't know about -- Force filetype patterns that Vim doesn't know about
vim.api.nvim_exec([[ require('filetype').setup({
au BufRead,BufNewFile *.Brewfile setfiletype brewfile overrides = {
au BufRead,BufNewFile tmux.conf* setfiletype tmux extensions = {
au BufRead,BufNewFile *ignore.*link setfiletype gitignore Brewfile = 'brewfile',
au BufRead,BufNewFile gitconfig.*link setfiletype gitconfig muttrc = 'muttrc',
au BufRead,BufNewFile *.toml.*link setfiletype toml hcl = 'terraform',
au BufRead,BufNewFile *.muttrc setfiletype muttrc },
au BufRead,BufNewFile .env* set ft=text | set syntax=sh literal = {
]], false) 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 -- LaTeX options
vim.api.nvim_exec([[ vim.api.nvim_exec([[
@ -240,11 +284,6 @@ vim.api.nvim_exec([[
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
]], false) ]], false)
-- Rust stuff
-- vim.api.nvim_exec([[
-- au BufWritePost *.rs silent! execute "%! rustfmt"
-- ]], false)
-- Auto-pairs -- Auto-pairs
vim.g.AutoPairsFlyMode = 0 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_browse_split = 4 -- Open in previous window
vim.g.netrw_altv = 1 -- Always split left vim.g.netrw_altv = 1 -- Always split left
-- Polyglot -- Formatting
vim.g.terraform_fmt_on_save = 1 -- Formats with terraform plugin vim.g.terraform_fmt_on_save = 1 -- Formats with terraform plugin
vim.g.rustfmt_autosave = 1 -- Formats with rust 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 -- VimWiki
vim.g.vimwiki_list = { vim.g.vimwiki_list = {
{ {
@ -289,14 +334,48 @@ vim.api.nvim_exec([[
-- Status bar -- Status bar
require('lualine').setup({ 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 = { ["<esc>"] = 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 -- Remap space as leader key
vim.api.nvim_set_keymap("", "<Space>", "<Nop>", {noremap=true, silent=true}) vim.api.nvim_set_keymap("", "<Space>", "<Nop>", {noremap=true, silent=true})
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
-- Keep selection when changing indentation
vim.api.nvim_set_keymap("v", "<", "<gv", {noremap=true})
vim.api.nvim_set_keymap("v", ">", ">gv", {noremap=true})
-- Unset search pattern register -- Unset search pattern register
vim.api.nvim_set_keymap("n", "<CR>", ":noh<CR><CR>", {noremap=true, silent=true}) vim.api.nvim_set_keymap("n", "<CR>", ":noh<CR><CR>", {noremap=true, silent=true})
@ -308,12 +387,33 @@ vim.api.nvim_set_keymap("i", "<A-k>", "<Esc>:m .-2<CR>==gi", {noremap=true})
vim.api.nvim_set_keymap("v", "<A-j>", ":m '>+1<CR>gv=gv", {noremap=true}) vim.api.nvim_set_keymap("v", "<A-j>", ":m '>+1<CR>gv=gv", {noremap=true})
vim.api.nvim_set_keymap("v", "<A-k>", ":m '<-2<CR>gv=gv", {noremap=true}) vim.api.nvim_set_keymap("v", "<A-k>", ":m '<-2<CR>gv=gv", {noremap=true})
-- Fzf (fuzzy finder) -- Telescope (fuzzy finder)
vim.api.nvim_set_keymap("n", "<Leader>/", ":Rg<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>/", ":Telescope live_grep<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>ff", ":Files<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>ff", ":Telescope find_files<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>fr", ":History<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>fa", ":Telescope file_browser<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>b", ":Buffers<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>wt", ":Telescope tmux sessions<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>s", ":BLines<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>ww", ":Telescope tmux windows<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>w/", ":Telescope tmux pane_contents<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>fz", ":Telescope zoxide list<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>b", ":Telescope buffers<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>hh", ":Telescope help_tags<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>fr", ":Telescope oldfiles<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>cc", ":Telescope commands<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>cr", ":Telescope command_history<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>y", ":Telescope neoclip<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>s", ":Telescope current_buffer_fuzzy_find<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>gc", ":Telescope git_commits<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>gf", ":Telescope git_bcommits<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>gb", ":Telescope git_branches<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>gs", ":Telescope git_status<CR>", {noremap=true})
-- LSP
vim.api.nvim_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "gh", "<Cmd>lua vim.lsp.buf.hover()<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "]e", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "[e", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>e", "<Cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", {silent=true, noremap=true})
-- File commands -- File commands
vim.api.nvim_set_keymap("n", "<Leader>q", ":quit<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>q", ":quit<CR>", {noremap=true})
@ -325,7 +425,9 @@ vim.api.nvim_set_keymap("n", "<Leader>fd", ":lcd %:p:h<CR>", {silent=true, norem
vim.api.nvim_set_keymap("n", "<Leader>fu", ":lcd ..<CR>", {silent=true, noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>fu", ":lcd ..<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "<Leader><Tab>", ":b#<CR>", {silent=true, noremap=true}) vim.api.nvim_set_keymap("n", "<Leader><Tab>", ":b#<CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", {silent=true, noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", {silent=true, noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>tt", [[<Cmd>exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]], {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>tt",
[[<Cmd>exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]], {noremap=true}
)
-- Window commands -- Window commands
vim.api.nvim_set_keymap("n", "<Leader>wv", ":vsplit<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>wv", ":vsplit<CR>", {noremap=true})
@ -336,13 +438,25 @@ vim.api.nvim_set_keymap("n", "<Leader>wm", ":only<CR>", {noremap=true})
vim.api.nvim_set_keymap("", "<Leader>ta", ":Tabularize /", {noremap=true}) vim.api.nvim_set_keymap("", "<Leader>ta", ":Tabularize /", {noremap=true})
vim.api.nvim_set_keymap("", "<Leader>t#", ":Tabularize /#<CR>", {noremap=true}) vim.api.nvim_set_keymap("", "<Leader>t#", ":Tabularize /#<CR>", {noremap=true})
vim.api.nvim_set_keymap("", "<Leader>t\"", ":Tabularize /\"<CR>", {noremap=true}) vim.api.nvim_set_keymap("", "<Leader>t\"", ":Tabularize /\"<CR>", {noremap=true})
vim.api.nvim_set_keymap("", "<Leader>tl", ":Tabularize /--<CR>", {noremap=true})
-- Vimrc -- Vimrc editing
vim.api.nvim_set_keymap("n", "<Leader>fv", ":edit $MYVIMRC<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>fv", ":edit $MYVIMRC<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>rr", ":luafile $MYVIMRC<CR>", {noremap=true}) vim.api.nvim_set_keymap("n", "<Leader>rr", ":luafile $MYVIMRC<CR>", {noremap=true})
vim.api.nvim_set_keymap("n", "<Leader>rp", ":luafile $MYVIMRC<CR>:PackerInstall<CR>:PackerCompile<CR>", {noremap=true})
-- Other -- Other
vim.api.nvim_set_keymap("n", "<Leader><Space>", ":HopWord<CR>", {noremap=true}) vim.api.nvim_set_keymap("t", "<A-CR>", "<C-\\><C-n>", {noremap=true}) -- Exit terminal mode
vim.api.nvim_set_keymap("t", "<A-CR>", "<C-\\><C-n>", {noremap=true}) -- Exit terminal mode vim.api.nvim_set_keymap("n", "<A-CR>", ":noh<CR>", {noremap=true, silent=true}) -- Clear search
vim.api.nvim_set_keymap("n", "<A-CR>", ":noh<CR>", {noremap=true, silent=true}) vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true}) -- Copy to end of line
vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true})
-- 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", ',', ",<C-g>u", {noremap=true})
vim.api.nvim_set_keymap("i", '.', ".<C-g>u", {noremap=true})
vim.api.nvim_set_keymap("i", '!', "!<C-g>u", {noremap=true})
vim.api.nvim_set_keymap("i", '?', "?<C-g>u", {noremap=true})

View File

@ -7,6 +7,7 @@ set -Ux EDITOR nvim # Preferred text editor
set -U PROJ $HOME/dev/work # Projects directory set -U PROJ $HOME/dev/work # Projects directory
set -Ux NOTES_PATH $HOME/notes # Notes directory set -Ux NOTES_PATH $HOME/notes # Notes directory
set -Ux MANPAGER "nvim +Man!" # Used for reading man pages set -Ux MANPAGER "nvim +Man!" # Used for reading man pages
set -Ux DIRENV_LOG_FORMAT "" # Disable direnv output
# Load abbreviations # Load abbreviations
abbrs abbrs