mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 08:45:39 +00:00
Merge branch 'experimental'
This commit is contained in:
commit
06a2c5eb3d
@ -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" }
|
||||
|
138
fish.configlink/conf.d/nix-env.fish
Normal file
138
fish.configlink/conf.d/nix-env.fish
Normal file
@ -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
|
@ -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
|
||||
|
@ -43,10 +43,15 @@ function abbrs --description 'All abbreviations'
|
||||
abbr -a grh 'git reset --hard'
|
||||
abbr -a gm 'git merge'
|
||||
abbr -a gcp 'git cherry-pick'
|
||||
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)'
|
||||
|
||||
# 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 grf 'gh run view --log-failed'
|
||||
abbr -a grl 'gh run view --log'
|
||||
|
||||
# Vim
|
||||
if command -v nvim > /dev/null
|
||||
alias --save vim='nvim'
|
||||
@ -62,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
|
||||
|
@ -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
|
||||
|
@ -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 = {}
|
||||
|
||||
@ -27,16 +28,59 @@ 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'] 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 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.
|
||||
if self.lastModifiers['ctrl'] == newModifiers['ctrl'] then
|
||||
return false
|
||||
end
|
||||
|
||||
-- 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
|
||||
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
|
||||
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
|
||||
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
|
||||
)
|
||||
|
||||
-- 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
|
||||
-- Increment the movement counter
|
||||
self.movements = self.movements + 1
|
||||
end
|
||||
i, v = next(touches, i) -- get next index
|
||||
end
|
||||
self.lastModifiers = newModifiers
|
||||
end
|
||||
)
|
||||
end
|
||||
@ -46,6 +90,8 @@ end
|
||||
--- Start sending `escape` when `control` is pressed and released in isolation
|
||||
function obj:start()
|
||||
self.controlTap:start()
|
||||
self.asModifier:start()
|
||||
self.scrolling:start()
|
||||
end
|
||||
|
||||
--- ControlEscape:stop()
|
||||
@ -54,6 +100,8 @@ end
|
||||
function obj:stop()
|
||||
-- Stop monitoring keystrokes
|
||||
self.controlTap:stop()
|
||||
self.asModifier:stop()
|
||||
self.scrolling:stop()
|
||||
|
||||
-- Reset state
|
||||
self.sendEscape = false
|
||||
|
@ -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
|
||||
|
@ -16,3 +16,4 @@ brew "googler" # Search Google
|
||||
brew "gh" # GitHub commands
|
||||
brew "pandoc" # Document converter
|
||||
brew "visidata" # Spreadsheet manipulation
|
||||
brew "mdp" # Terminal slideshows
|
||||
|
@ -10,43 +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 '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 '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 { -- 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 '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' -- Good for autogen tags
|
||||
-- use 'ludovicchabant/vim-gutentags'
|
||||
end)
|
||||
|
||||
-- LSP Plugins
|
||||
-- LSP Settings
|
||||
-- ============
|
||||
|
||||
require('lspconfig').rust_analyzer.setup{}
|
||||
require('lspconfig').pyright.setup{
|
||||
cmd = { "poetry", "run", "pyright-langserver", "--stdio" }
|
||||
@ -223,8 +240,13 @@ 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 = 1
|
||||
vim.g.AutoPairsFlyMode = 0
|
||||
|
||||
-- Netrw
|
||||
vim.g.netrw_liststyle = 3 -- Change style to 'tree' view
|
||||
@ -262,25 +284,13 @@ 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
|
||||
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("", "<Space>", "<Nop>", {noremap=true, silent=true})
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user