From 0489401afd1233492982c6b4b7458f704e9c5cbf Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 May 2021 20:38:34 -0400 Subject: [PATCH 01/12] more comfort on keys --- hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua | 4 +++- nvim.configlink/init.lua | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index 3e1471c..b412c58 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -29,7 +29,9 @@ function obj:init() local newModifiers = event:getFlags() if not self.lastModifiers['ctrl'] then if newModifiers['ctrl'] then - if newModifiers['shift'] then + if (newModifiers['shift'] and newModifiers['cmd']) then + ; + elseif newModifiers['shift'] then hs.eventtap.keyStroke({'shift'}, 'escape', 0) else hs.eventtap.keyStroke(newModifiers, 'escape', 0) diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index d184a6e..2bfd0bd 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -224,7 +224,7 @@ vim.api.nvim_exec([[ ]], false) -- Auto-pairs -vim.g.AutoPairsFlyMode = 1 +vim.g.AutoPairsFlyMode = 0 -- Netrw vim.g.netrw_liststyle = 3 -- Change style to 'tree' view From 269e7a122524a7f641cc5b8662fc60913a0c27d6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 May 2021 20:58:54 -0400 Subject: [PATCH 02/12] remove p bindings from tmux --- tmux/tmux.conf.symlink | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink index 190d5e7..6be27b2 100644 --- a/tmux/tmux.conf.symlink +++ b/tmux/tmux.conf.symlink @@ -17,9 +17,6 @@ bind j select-pane -D bind K select-pane -U bind l select-pane -R -# Another option for previous -bind P previous-window - # Split out pane bind b break-pane @@ -27,7 +24,6 @@ bind b break-pane bind Escape copy-mode bind k copy-mode bind C-[ copy-mode -bind p paste-buffer # Vi-style scrollback with prefix + C-[ set-window-option -g mode-keys vi From 4348c52b1fadc03addd3b1f791639c52d95f1d4a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 May 2021 09:10:37 -0400 Subject: [PATCH 03/12] isolate escape from control key --- .../Spoons/ControlEscape.spoon/init.lua | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index b412c58..c8e6713 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -27,18 +27,40 @@ function obj:init() self.controlTap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(event) local newModifiers = event:getFlags() - if not self.lastModifiers['ctrl'] then - if newModifiers['ctrl'] then - if (newModifiers['shift'] and newModifiers['cmd']) then - ; - elseif newModifiers['shift'] then - hs.eventtap.keyStroke({'shift'}, 'escape', 0) - else - hs.eventtap.keyStroke(newModifiers, 'escape', 0) - end - end + + -- If this change to the modifier keys does not invole a *change* to the + -- up/down state of the `control` key (i.e., it was up before and it's + -- still up, or it was down before and it's still down), then don't take + -- any action. + if self.lastModifiers['ctrl'] == newModifiers['ctrl'] then + return false end - self.lastModifiers = newModifiers + + -- Control was not down but is now + if not self.lastModifiers['ctrl'] then + self.lastModifiers = newModifiers + if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then + self.sendEscape = true + end + -- Control was down and is up + elseif (self.sendEscape == true and not newModifiers['ctrl']) then + self.lastModifiers = newModifiers + if newModifiers['shift'] then + hs.eventtap.keyStroke({'shift'}, 'escape', 0) + else + hs.eventtap.keyStroke(newModifiers, 'escape', 0) + end + self.sendEscape = false + else + self.lastModifiers = newModifiers + end + end + ) + + -- 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 end ) end @@ -48,6 +70,7 @@ end --- Start sending `escape` when `control` is pressed and released in isolation function obj:start() self.controlTap:start() + self.asModifier:start() end --- ControlEscape:stop() @@ -56,6 +79,7 @@ end function obj:stop() -- Stop monitoring keystrokes self.controlTap:stop() + self.asModifier:stop() -- Reset state self.sendEscape = false From b4536a7dcc3017d53eb60f350d19b0d88a61c25b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 May 2021 10:35:17 -0400 Subject: [PATCH 04/12] isolate escape from trackpad --- .../Spoons/ControlEscape.spoon/init.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index c8e6713..a10ed86 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -63,6 +63,20 @@ function obj:init() self.sendEscape = false end ) + + -- If mouse is moving, don't send escape + self.scrolling = hs.eventtap.new({hs.eventtap.event.types.gesture}, + function(event) + local touches = event:getTouches() + local i, v = next(touches, nil) + while i do + if v["phase"] == "moved" then + self.sendEscape = false + end + i, v = next(touches, i) -- get next index + end + end + ) end --- ControlEscape:start() @@ -71,6 +85,7 @@ end function obj:start() self.controlTap:start() self.asModifier:start() + self.scrolling:start() end --- ControlEscape:stop() @@ -80,6 +95,7 @@ function obj:stop() -- Stop monitoring keystrokes self.controlTap:stop() self.asModifier:stop() + self.scrolling:stop() -- Reset state self.sendEscape = false From f135378d65a55db3ca31f4e7bd599af708b8faec Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 May 2021 20:27:21 -0400 Subject: [PATCH 05/12] add trackpad movement threshold --- .../Spoons/ControlEscape.spoon/init.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index a10ed86..ae7be7c 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -19,6 +19,7 @@ obj.homepage = 'https://github.com/jasonrudolph/ControlEscape.spoon' obj.license = 'MIT - https://opensource.org/licenses/MIT' function obj:init() + self.movements = 0 self.sendEscape = false self.lastModifiers = {} @@ -28,7 +29,7 @@ function obj:init() function(event) local newModifiers = event:getFlags() - -- If this change to the modifier keys does not invole a *change* to the + -- If this change to the modifier keys does not involve a *change* to the -- up/down state of the `control` key (i.e., it was up before and it's -- still up, or it was down before and it's still down), then don't take -- any action. @@ -41,16 +42,20 @@ function obj:init() 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 - elseif (self.sendEscape == true and not newModifiers['ctrl']) then + -- 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 < 12) then self.lastModifiers = newModifiers + -- Allow for shift-escape if newModifiers['shift'] then hs.eventtap.keyStroke({'shift'}, 'escape', 0) else hs.eventtap.keyStroke(newModifiers, 'escape', 0) end self.sendEscape = false + self.movements = 0 else self.lastModifiers = newModifiers end @@ -64,14 +69,15 @@ function obj:init() end ) - -- If mouse is moving, don't send escape + -- If mouse is moving significantly, don't send escape self.scrolling = hs.eventtap.new({hs.eventtap.event.types.gesture}, function(event) local touches = event:getTouches() local i, v = next(touches, nil) while i do if v["phase"] == "moved" then - self.sendEscape = false + -- Increment the movement counter + self.movements = self.movements + 1 end i, v = next(touches, i) -- get next index end From 99a65576fffaab0fc4215be3d7d2206825de353b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 May 2021 20:27:40 -0400 Subject: [PATCH 06/12] signal and slides brews --- homebrew/Caskfile | 1 + homebrew/utils.Brewfile | 1 + 2 files changed, 2 insertions(+) diff --git a/homebrew/Caskfile b/homebrew/Caskfile index 75b636a..a065ccc 100644 --- a/homebrew/Caskfile +++ b/homebrew/Caskfile @@ -32,6 +32,7 @@ cask "discord" # Chat cask "steam" # Games cask "epic-games" # Games cask "calibre" # E-Books +cask "signal" # Messaging # Maybe cask "jira-client" # Project Management diff --git a/homebrew/utils.Brewfile b/homebrew/utils.Brewfile index 379f75c..2a19cb3 100644 --- a/homebrew/utils.Brewfile +++ b/homebrew/utils.Brewfile @@ -16,3 +16,4 @@ brew "googler" # Search Google brew "gh" # GitHub commands brew "pandoc" # Document converter brew "visidata" # Spreadsheet manipulation +brew "mdp" # Terminal slideshows From 3a1f71b40f9910af98ae27798d3f987fd440864e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 May 2021 12:34:30 -0400 Subject: [PATCH 07/12] bump ctrl scroll movements --- hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua index ae7be7c..44da407 100644 --- a/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua +++ b/hammerspoon.symlink/Spoons/ControlEscape.spoon/init.lua @@ -46,7 +46,7 @@ function obj:init() 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 < 12) then + elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 20) then self.lastModifiers = newModifiers -- Allow for shift-escape if newModifiers['shift'] then From 21179deb49c08b013650d05397e98981b1bc3e14 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 May 2021 12:34:46 -0400 Subject: [PATCH 08/12] remove alacritty super shortcuts --- alacritty.configlink/alacritty.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/alacritty.configlink/alacritty.yml b/alacritty.configlink/alacritty.yml index ed40eb2..8495635 100644 --- a/alacritty.configlink/alacritty.yml +++ b/alacritty.configlink/alacritty.yml @@ -593,13 +593,8 @@ key_bindings: # Reference for escape codes: https://www.gaijin.at/en/infos/ascii-ansi-character-table - - { key: A, mods : Super, chars: "\x02" } # CMD-A sends CTRL-B for tmux - - { key: D, mods : Super, chars: "\x14" } # CMD-D sends CTRL-T for fzf - - { key: O, mods : Super, chars: "\x0f" } # CMD-O sends CTRL-O for fish/vim - - { key: R, mods : Super, chars: "\x05" } # CMD-R sends CTRL-E for fish/vim - - { key: G, mods : Super, chars: "\x07" } # CMD-G sends CTRL-G for fish/vim - { key: L, mods : Super, chars: "\x1F" } # CMD-L sends null key for fish - - { key: H, mods : Super|Shift, chars: "\x02P" } # CMD-SHIFT-H previous tmux window + - { key: H, mods : Super|Shift, chars: "\x02p" } # CMD-SHIFT-H previous tmux window - { key: L, mods : Super|Shift, chars: "\x02n" } # CMD-SHIFT-L next tmux window - { key: Return, mods : Shift, chars: "\x1b[13;2u" } From 3ef3c924c3cd0d16002b2347e94b2a685a1200de Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 May 2021 12:35:13 -0400 Subject: [PATCH 09/12] github action watching --- fish.configlink/functions/abbrs.fish | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fish.configlink/functions/abbrs.fish b/fish.configlink/functions/abbrs.fish index 49035b1..0fbaf92 100644 --- a/fish.configlink/functions/abbrs.fish +++ b/fish.configlink/functions/abbrs.fish @@ -43,9 +43,14 @@ function abbrs --description 'All abbreviations' abbr -a grh 'git reset --hard' abbr -a gm 'git merge' abbr -a gcp 'git cherry-pick' + abbr -a cdg 'cd (git rev-parse --show-toplevel)' + + # GitHub abbr -a ghr 'gh repo view -w' abbr -a gha 'gh run list | head -1 | awk \'{ print $NF }\' | xargs gh run view' - abbr -a cdg 'cd (git rev-parse --show-toplevel)' + abbr -a grw 'gh run watch' + abbr -a grf 'gh run view --log-failed' + abbr -a grl 'gh run view --log' # Vim if command -v nvim > /dev/null From 245dc6212e76e1891a544a2df483c061d5746088 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 May 2021 12:35:33 -0400 Subject: [PATCH 10/12] switch from polyglot to treesitter --- nvim.configlink/init.lua | 60 +++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index 2bfd0bd..4aefbaf 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -10,40 +10,49 @@ 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 'sheerun/vim-polyglot' -- Syntax for every language - 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 'jiangmiao/auto-pairs' -- Parentheses + 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 'jiangmiao/auto-pairs' -- Parentheses 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 'itchyny/lightline.vim' -- Status bar - use { -- Git next to line numbers + 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 'itchyny/lightline.vim' -- Status bar + use { -- Syntax highlighting for most languages + '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 { -- Git next to line numbers 'lewis6991/gitsigns.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function() require('gitsigns').setup() end } - use { -- Fuzzy finder + use { -- Fuzzy finder 'junegunn/fzf.vim', requires = {'/usr/local/opt/fzf'} } - -- use 'ludovicchabant/vim-gutentags' -- Good for autogen tags + -- use 'ludovicchabant/vim-gutentags' end) -- LSP Plugins @@ -223,6 +232,11 @@ 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 @@ -262,7 +276,7 @@ vim.api.nvim_exec([[ norm "zpx endfunction - command! AddTag call fzf#run({'source': 'rg "#[\w/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) + command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) ]], false) -- Lightline status bar From 5e928ab3af7fb36585790c6722f917a875cabf2c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 May 2021 12:37:00 -0400 Subject: [PATCH 11/12] nix fish loader --- fish.configlink/conf.d/nix-env.fish | 138 ++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 fish.configlink/conf.d/nix-env.fish diff --git a/fish.configlink/conf.d/nix-env.fish b/fish.configlink/conf.d/nix-env.fish new file mode 100644 index 0000000..9b9826e --- /dev/null +++ b/fish.configlink/conf.d/nix-env.fish @@ -0,0 +1,138 @@ +# Setup Nix + +# We need to distinguish between single-user and multi-user installs. +# This is difficult because there's no official way to do this. +# We could look for the presence of /nix/var/nix/daemon-socket/socket but this will fail if the +# daemon hasn't started yet. /nix/var/nix/daemon-socket will exist if the daemon has ever run, but +# I don't think there's any protection against accidentally running `nix-daemon` as a user. +# We also can't just look for /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh because +# older single-user installs used the default profile instead of a per-user profile. +# We can still check for it first, because all multi-user installs should have it, and so if it's +# not present that's a pretty big indicator that this is a single-user install. If it does exist, +# we still need to verify the install type. To that end we'll look for a root owner and sticky bit +# on /nix/store. Multi-user installs set both, single-user installs don't. It's certainly possible +# someone could do a single-user install as root and then manually set the sticky bit but that +# would be extremely unusual. + +set -l nix_profile_path /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh +set -l single_user_profile_path ~/.nix-profile/etc/profile.d/nix.sh +if test -e $nix_profile_path + # The path exists. Double-check that this is a multi-user install. + # We can't just check for ~/.nix-profile/… because this may be a single-user install running as + # the wrong user. + + # stat is not portable. Splitting the output of ls -nd is reliable on most platforms. + set -l owner (string split -n ' ' (ls -nd /nix/store 2>/dev/null))[3] + if not test -k /nix/store -a $owner -eq 0 + # /nix/store is either not owned by root or not sticky. Assume single-user. + set nix_profile_path $single_user_profile_path + end +else + # The path doesn't exist. Assume single-user + set nix_profile_path $single_user_profile_path +end + +if test -e $nix_profile_path + # Source the nix setup script + # We're going to run the regular Nix profile under bash and then print out a few variables + for line in (env -u BASH_ENV bash -c '. "$0"; for name in PATH "${!NIX_@}"; do printf "%s=%s\0" "$name" "${!name}"; done' $nix_profile_path | string split0) + set -xg (string split -m 1 = $line) + end + + # Insert Nix's fish share directories into fish's special variables. + # nixpkgs-installed fish tries to set these up already if NIX_PROFILES is defined, which won't + # be the case when sourcing $__fish_data_dir/share/config.fish normally, but might be for a + # recursive invocation. To guard against that, we'll only insert paths that don't already exit. + # Furthermore, for the vendor_conf.d sourcing, we'll use the pre-existing presence of a path in + # $fish_function_path to determine whether we want to source the relevant vendor_conf.d folder. + + # To start, let's locally define NIX_PROFILES if it doesn't already exist. + set -al NIX_PROFILES + if test (count $NIX_PROFILES) -eq 0 + set -a NIX_PROFILES $HOME/.nix-profile + end + # Replicate the logic from nixpkgs version of $__fish_data_dir/__fish_build_paths.fish. + set -l __nix_profile_paths (string split ' ' -- $NIX_PROFILES)[-1..1] + set -l __extra_completionsdir \ + $__nix_profile_paths/etc/fish/completions \ + $__nix_profile_paths/share/fish/vendor_completions.d + set -l __extra_functionsdir \ + $__nix_profile_paths/etc/fish/functions \ + $__nix_profile_paths/share/fish/vendor_functions.d + set -l __extra_confdir \ + $__nix_profile_paths/etc/fish/conf.d \ + $__nix_profile_paths/share/fish/vendor_conf.d \ + + ### Configure fish_function_path ### + # Remove any of our extra paths that may already exist. + # Record the equivalent __extra_confdir path for any function path that exists. + set -l existing_conf_paths + for path in $__extra_functionsdir + if set -l idx (contains --index -- $path $fish_function_path) + set -e fish_function_path[$idx] + set -a existing_conf_paths $__extra_confdir[(contains --index -- $path $__extra_functionsdir)] + end + end + # Insert the paths before $__fish_data_dir. + if set -l idx (contains --index -- $__fish_data_dir/functions $fish_function_path) + # Fish has no way to simply insert into the middle of an array. + set -l new_path $fish_function_path[1..$idx] + set -e new_path[$idx] + set -a new_path $__extra_functionsdir + set fish_function_path $new_path $fish_function_path[$idx..-1] + else + set -a fish_function_path $__extra_functionsdir + end + + ### Configure fish_complete_path ### + # Remove any of our extra paths that may already exist. + for path in $__extra_completionsdir + if set -l idx (contains --index -- $path $fish_complete_path) + set -e fish_complete_path[$idx] + end + end + # Insert the paths before $__fish_data_dir. + if set -l idx (contains --index -- $__fish_data_dir/completions $fish_complete_path) + set -l new_path $fish_complete_path[1..$idx] + set -e new_path[$idx] + set -a new_path $__extra_completionsdir + set fish_complete_path $new_path $fish_complete_path[$idx..-1] + else + set -a fish_complete_path $__extra_completionsdir + end + + ### Source conf directories ### + # The built-in directories were already sourced during shell initialization. + # Any __extra_confdir that came from $__fish_data_dir/__fish_build_paths.fish was also sourced. + # As explained above, we're using the presence of pre-existing paths in $fish_function_path as a + # signal that the corresponding conf dir has also already been sourced. + # In order to simulate this, we'll run through the same algorithm as found in + # $__fish_data_dir/config.fish except we'll avoid sourcing the file if it comes from an + # already-sourced location. + # Caveats: + # * Files will be sourced in a different order than we'd ideally do (because we're coming in + # after the fact to source them). + # * If there are existing extra conf paths, files in them may have been sourced that should have + # been suppressed by paths we're inserting in front. + # * Similarly any files in $__fish_data_dir/vendor_conf.d that should have been suppressed won't + # have been. + set -l sourcelist + for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish + # We know these paths were sourced already. Just record them. + set -l basename (string replace -r '^.*/' '' -- $file) + contains -- $basename $sourcelist + or set -a sourcelist $basename + end + for root in $__extra_confdir + for file in $root/*.fish + set -l basename (string replace -r '^.*/' '' -- $file) + contains -- $basename $sourcelist + and continue + set -a sourcelist $basename + contains -- $root $existing_conf_paths + and continue # this is a pre-existing path, it will have been sourced already + [ -f $file -a -r $file ] + and source $file + end + end +end From 3a27c37f3e3b34dba0d4d60d374e8a67afff20b2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 6 Jul 2021 22:18:30 -0400 Subject: [PATCH 12/12] direnv and neovim updates --- fish.configlink/config.fish | 5 ++ fish.configlink/functions/abbrs.fish | 3 +- .../functions/fish_user_key_bindings.fish | 1 + nvim.configlink/init.lua | 86 +++++++++---------- 4 files changed, 49 insertions(+), 46 deletions(-) diff --git a/fish.configlink/config.fish b/fish.configlink/config.fish index a8637c2..0830a37 100644 --- a/fish.configlink/config.fish +++ b/fish.configlink/config.fish @@ -36,6 +36,11 @@ if status --is-interactive set -g FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND" set -g FZF_DEFAULT_OPTS '-m --height 50% --border' + source $DOTS/fish.configlink/conf.d/nix-env.fish + # Use `starship` prompt starship init fish | source + + # Hook into direnv + direnv hook fish | source end diff --git a/fish.configlink/functions/abbrs.fish b/fish.configlink/functions/abbrs.fish index 0fbaf92..c2c3276 100644 --- a/fish.configlink/functions/abbrs.fish +++ b/fish.configlink/functions/abbrs.fish @@ -47,7 +47,7 @@ function abbrs --description 'All abbreviations' # GitHub abbr -a ghr 'gh repo view -w' - abbr -a gha 'gh run list | head -1 | awk \'{ print $NF }\' | 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 grf 'gh run view --log-failed' abbr -a grl 'gh run view --log' @@ -67,6 +67,7 @@ function abbrs --description 'All abbreviations' # Notes abbr -a qn 'quicknote' abbr -a sn 'syncnotes' + abbr -a to 'today' abbr -a work 'vim $NOTES_PATH/work.md' # Improved CLI Tools diff --git a/fish.configlink/functions/fish_user_key_bindings.fish b/fish.configlink/functions/fish_user_key_bindings.fish index 2d5afcd..e9443e4 100644 --- a/fish.configlink/functions/fish_user_key_bindings.fish +++ b/fish.configlink/functions/fish_user_key_bindings.fish @@ -4,6 +4,7 @@ function fish_user_key_bindings bind -M insert \co 'edit' bind -M insert \ce 'recent' bind -M insert \cg 'commandline-git-commits' + bind -M insert \cf 'fcd' bind -M insert \x1F accept-autosuggestion bind -M default \x1F accept-autosuggestion end diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index 4aefbaf..a3026fb 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -10,52 +10,60 @@ 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 'jiangmiao/auto-pairs' -- Parentheses + 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 'itchyny/lightline.vim' -- Status bar - use { -- Syntax highlighting for most languages + 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 + 'hoob3rt/lualine.nvim', + requires = { + 'kyazdani42/nvim-web-devicons', + opt = true + } + } + use { -- Syntax highlighting for most languages '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 { -- Git next to line numbers + 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 'lewis6991/gitsigns.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function() require('gitsigns').setup() end } - use { -- Fuzzy finder + use { -- Fuzzy finder 'junegunn/fzf.vim', requires = {'/usr/local/opt/fzf'} } - -- use 'ludovicchabant/vim-gutentags' + -- use 'ludovicchabant/vim-gutentags' end) --- LSP Plugins +-- LSP Settings +-- ============ + require('lspconfig').rust_analyzer.setup{} require('lspconfig').pyright.setup{ cmd = { "poetry", "run", "pyright-langserver", "--stdio" } @@ -279,22 +287,10 @@ vim.api.nvim_exec([[ command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) ]], false) --- Lightline status bar -vim.g.lightline = { - ["colorscheme"] = "jellybeans", - ["active"] = { - ["right"] = { - { "lineinfo" } - }, - ["left"] = { - { "mode", "paste" }, - { "readonly", "relativepath", "gitbranch", "modified" } - } - }, - ["component_function"] = { - ["gitbranch"] = "fugitive#head" - }, -} +-- Status bar +require('lualine').setup({ + options = { theme = 'gruvbox' } +}) -- Remap space as leader key vim.api.nvim_set_keymap("", "", "", {noremap=true, silent=true})