···11-# Normal git completion
22-complete -c yadm --wraps git
11+# Derived from https://github.com/TheLocehiliosan/yadm/pull/224
3244-if ! functions -q __fish_git_using_command
55- source $__fish_data_dir/completions/git.fish
33+function __fish_yadm_universal_optspecs
44+ string join \n 'a-yadm-dir=' 'b-yadm-repo=' 'c-yadm-config=' \
55+ 'd-yadm-encrypt=' 'e-yadm-archive=' 'f-yadm-bootstrap='
66end
7788-function gitconfig_completions
99- # gitconfig options, copied from /usr/local/share/fish/completions/git.fish
1010- # Complete both options and possible parameters to `git config`
1111- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l global -d 'Get/set global configuration'
1212- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l system -d 'Get/set system configuration'
1313- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l local -d 'Get/set local repo configuration'
1414- complete -f -c yadm -n '__fish_git_using_command gitconfig' -s f -l file -d 'Read config from file'
1515- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l blob -d 'Read config from blob' -ra '(__fish_complete_suffix '')'
1616-1717- # If no argument is specified, it's as if --get was used
1818- complete -c yadm -n '__fish_git_using_command gitconfig; and __fish_is_token_n 3' -fa '(__fish_git_config_keys)'
1919- complete -f -c yadm -n '__fish_git_using_command gitconfig; and __fish_is_first_arg' -l get -d 'Get config with name' -ra '(__fish_git_config_keys)'
2020- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l get -d 'Get config with name' -ra '(__fish_git_config_keys)'
2121- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l get-all -d 'Get all values matching key' -a '(__fish_git_config_keys)'
2222- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l get-urlmatch -d 'Get value specific for the section url' -r
2323- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l replace-all -d 'Replace all matching variables' -ra '(__fish_git_config_keys)'
2424- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l add -d 'Add a new variable' -r
2525- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l unset -d 'Remove a variable' -a '(__fish_git_config_keys)'
2626- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l unset-all -d 'Remove matching variables' -a '(__fish_git_config_keys)'
2727- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l rename-section -d 'Rename section' -r
2828- complete -f -c yadm -n '__fish_git_using_command gitconfig' -s l -l list -d 'List all variables'
2929- complete -f -c yadm -n '__fish_git_using_command gitconfig' -s e -l edit -d 'Open configuration in an editor'
3030-3131- complete -f -c yadm -n '__fish_git_using_command gitconfig' -s t -l type -d 'Value is of given type'
3232- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l bool -d 'Value is \'true\' or \'false\''
3333- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l int -d 'Value is a decimal number'
3434- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l bool-or-int -d 'Value is --bool or --int'
3535- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l path -d 'Value is a path'
3636- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l expiry-date -d 'Value is an expiry date'
88+function __fish_yadm_needs_command
99+ # Figure out if the current invocation already has a command.
1010+ set -l cmd (commandline -opc)
1111+ set -e cmd[1]
1212+ argparse -s (__fish_yadm_universal_optspecs) -- $cmd 2>/dev/null
1313+ or return 0
1414+ if set -q argv[1]
1515+ echo $argv[1]
1616+ return 1
1717+ end
1818+ return 0
1919+end
37203838- complete -f -c yadm -n '__fish_git_using_command gitconfig' -s z -l null -d 'Terminate values with NUL byte'
3939- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l name-only -d 'Show variable names only'
4040- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l includes -d 'Respect include directives'
4141- complete -f -c yadm -n '__fish_git_using_command gitconfig' -l show-origin -d 'Show origin of configuration'
4242- complete -f -c yadm -n '__fish_git_using_command gitconfig; and __fish_seen_argument get' -l default -d 'Use default value when missing entry'
2121+function __fish_yadm_using_command
2222+ set -l cmd (__fish_yadm_needs_command)
2323+ test -z "$cmd"
2424+ and return 1
2525+ contains -- $cmd $argv
2626+ and return 0
4327end
44284545-# In general, piggyback off git helper functions for subcommands
2929+# yadm's specific autocomplete
3030+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'clone' -d 'Clone an existing repository'
3131+complete -F -c yadm -n '__fish_yadm_using_command clone' -s w -d 'work-tree to use (default: $HOME)'
3232+complete -f -c yadm -n '__fish_yadm_using_command clone' -s b -d 'branch to clone'
3333+complete -x -c yadm -n '__fish_yadm_using_command clone' -s f -d 'force to overwrite'
3434+complete -x -c yadm -n '__fish_yadm_using_command clone' -l bootstrap -d 'force bootstrap to run'
3535+complete -x -c yadm -n '__fish_yadm_using_command clone' -l no-bootstrap -d 'prevent bootstrap from beingrun'
46364747-# TODO: `yadm add` does not complete paths the same way as `git add`.
4848-# May be easier to just overwrite the default completion completely
3737+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'alt' -d 'Create links for alternates'
3838+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'bootstrap' -d 'Execute $HOME/.config/yadm/bootstrap'
3939+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'perms' -d 'Fix perms for private files'
4040+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'enter' -d 'Run sub-shell with GIT variables set'
4141+complete -c yadm -n '__fish_yadm_needs_command' -a 'git-crypt' -d 'Run git-crypt commands for the yadm repo'
4242+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'help' -d 'Print a summary of yadm commands'
4343+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'upgrade' -d 'Upgrade to version 2 of yadm directory structure'
4444+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'version' -d 'Print the version of yadm'
49455050-# Based on output of `yadm introspect switches`:
5151-complete -f -c yadm -n '__fish_git_needs_command' \
5252- -l yadm-archive -d 'yadm: Override the location of the yadm encrypted files archive'
5353-complete -f -c yadm -n '__fish_git_needs_command' \
5454- -l yadm-bootstrap -d 'yadm: Override the location of the yadm bootstrap program'
5555-complete -f -c yadm -n '__fish_git_needs_command' \
5656- -l yadm-config -d 'yadm: Override the location of the yadm configuration file'
5757-complete -f -c yadm -n '__fish_git_needs_command' \
5858- -s Y -l yadm-dir -d 'yadm: Override the yadm directory.'
5959-complete -f -c yadm -n '__fish_git_needs_command' \
6060- -l yadm-encrypt -d 'yadm: Override the location of the yadm encryption configuration'
6161-complete -f -c yadm -n '__fish_git_needs_command' \
6262- -l yadm-repo -d 'yadm: Override the location of the yadm repository'
4646+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'init' -d 'Initialize an empty repository'
4747+complete -x -c yadm -n '__fish_yadm_using_command init' -s f -d 'force to overwrite'
4848+complete -F -c yadm -n '__fish_yadm_using_command init' -s w -d 'set work-tree (default: $HOME)'
63496464-# Descriptions taken from yadm man pages
6565-complete -f -c yadm -n '__fish_git_needs_command' \
6666- -a alt -d 'yadm: Create symlinks for managed files matching alt naming rules'
5050+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'list' -d 'List tracked files at current directory'
5151+complete -x -c yadm -n '__fish_yadm_using_command list' -s a -d 'list all managed files instead'
67526868-complete -f -c yadm -n '__fish_git_needs_command' \
6969- -a bootstrap -d 'yadm: Execute $HOME/.config/yadm/bootstrap if it exists.'
5353+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'encrypt' -d 'Encrypt files'
5454+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'decrypt' -d 'Decrypt files'
5555+complete -x -c yadm -n '__fish_yadm_using_command decrypt' -s l -d 'list the files stored without extracting'
70567171-complete -x -c yadm -n '__fish_git_using_command clone' \
7272- --long-option bootstrap -d 'yadm: Automatically run bootstrap on successful clone' \
7373- --long-option no-bootstrap -d 'yadm: Prevent bootstrap from running on successful clone'
5757+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'introspect' -d 'Report internal yadm data'
5858+complete -x -c yadm -n '__fish_yadm_using_command introspect' -a (printf -- '%s\n' 'commands configs repo switches') -d 'category'
74597575-complete -f -c yadm -n '__fish_git_needs_command' \
7676- -a decrypt -d 'yadm: decrypt files stored in ~/.config/yadm/files.gpg'
7777-complete -f -c yadm -n '__fish_git_using_command decrypt' \
7878- --short-option l -d 'yadm: List files without decrypting them'
6060+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'gitconfig' -d 'Pass options to the git config command'
6161+complete -x -c yadm -n '__fish_yadm_needs_command' -a 'config' -d 'Configure a setting'
6262+for name in (yadm introspect configs)
6363+ complete -x -c yadm -n '__fish_yadm_using_command config' -a "$name" -d 'yadm config'
6464+end
79658080-complete -f -c yadm -n '__fish_git_needs_command' \
8181- -a encrypt -d 'yadm: Encrypt all files matching the patterns in ~/.config/yadm/encrypt'
8282-8383-complete -f -c yadm -n '__fish_git_needs_command' \
8484- -a enter -d 'yadm: Run a sub-shell with all Git variables set'
8585-8686-complete -f -c yadm -n '__fish_git_needs_command' \
8787- -a gitconfig -d 'yadm: Pass options to the "git config" command'
6666+# yadm universal options
6767+complete --force-files -c yadm -s Y -l yadm-dir -d 'Override location of yadm directory'
6868+complete --force-files -c yadm -l yadm-repo -d 'Override location of yadm repository'
6969+complete --force-files -c yadm -l yadm-config -d 'Override location of yadm configuration file'
7070+complete --force-files -c yadm -l yadm-encrypt -d 'Override location of yadm encryption configuration'
7171+complete --force-files -c yadm -l yadm-archive -d 'Override location of yadm encrypted files archive'
7272+complete --force-files -c yadm -l yadm-bootstrap -d 'Override location of yadm bootstrap program'
88738989-gitconfig_completions
7474+set -l GIT_DIR (yadm introspect repo)
7575+set -l GIT_WORK_TREE (yadm enter 'printf -- "%s" $GIT_WORK_TREE')
90769191-complete -f -c yadm -n '__fish_git_needs_command' \
9292- -a help -d 'yadm: Print a summary of yadm commands'
9393-9494-complete -f -c yadm -n '__fish_git_needs_command' \
9595- -a list -d 'yadm: print a List of files managed by yadm'
9696-complete -f -c yadm -n '__fish_git_using_command list' \
9797- --short-option a -d 'yadm: List all managed files, instead of current dir or below'
9898-9999-complete -f -c yadm -n '__fish_git_needs_command' \
100100- -a introspect -d 'yadm: Report internal yadm data'
101101-complete -f -c yadm -n '__fish_git_using_command introspect' \
102102- -a 'commands configs repo switches'
103103-104104-complete -f -c yadm -n '__fish_git_needs_command' \
105105- -a perms -d 'yadm: Update permissions as described in the PERMISSIONS section'
106106-107107-complete -f -c yadm -n '__fish_git_needs_command' \
108108- -a upgrade -d 'yadm: Upgrade from version 1 configuration to version 2 configuration'
109109-110110-complete -f -c yadm -n '__fish_git_needs_command' \
111111- -a version -d 'yadm: Print the version of yadm'
7777+# setup variables for git completion using `yadm enter`
7878+complete -c yadm -w "git --git-dir='$GIT_DIR' --work-tree='$GIT_WORK_TREE'"
+1-1
.config/fish/conf.d/50-config.fish
···44# Run nvm to update fish_user_paths for npm installs. Allow failure if running
55# outside home directory (no .nvmrc found), and run in background to avoid
66# blocking the shell from starting
77-# nvm &>/dev/null & || true
77+nvm &>/dev/null & || true
8899if not set -q DOCKER_NAME; and test -f /etc/profile.d/docker_name.sh
1010 set -gx DOCKER_NAME (sed -E 's/.*DOCKER_NAME=(.+)/\1/' /etc/profile.d/docker_name.sh)
···3434 fi
35353636 # Install fishfile packages
3737- fish -c fisher
3737+ fish -lc fisher
38383939 echo "macOS setup is complete!"
4040}
···5252 setup_macos
5353 elif [[ "$OS_NAME" == "Linux" ]]; then
5454 setup_linux
5555+ fi
5656+5757+ if confirm "Update fish auto-generated completions?"; then
5858+ fish -c 'fish_update_completions'
5559 fi
56605761 if confirm "Decrypt encrypted files?"; then
···2424 ;; If you edit it by hand, you could mess it up, so be careful.
2525 ;; Your init file should contain only one such instance.
2626 ;; If there is more than one, they won't work right.
2727+ '(browse-url-browser-function (quote browse-url-default-browser))
2828+ '(evil-vsplit-window-right t)
2729 '(fill-column 88)
2828- '(evil-vsplit-window-right t)
2930 '(hl-todo-color-background t)
3031 '(hl-todo-keyword-faces
3132 (quote
···4243 ("w" "Weekend Agenda and TODOs" agenda ""
4344 ((org-agenda-overriding-header "WEEKEND")
4445 (org-agenda-span
4545- (quote 2))
4646+ (quote 2))
4647 (org-agenda-start-day "saturday")
4748 (org-read-date-prefer-future nil)))
4849 ("3" "3-day Agenda and TODOs" agenda ""
4950 ((org-agenda-overriding-header "3 DAY VIEW")
5051 (org-agenda-span
5151- (quote 3))
5252+ (quote 3))
5253 (org-agenda-start-day "today"))))))
5354 '(org-agenda-files (quote ("~/Documents/notes/")))
5455 '(org-agenda-restore-windows-after-quit t)
···101102(global-hl-todo-mode)
102103103104;; ----------------------------------------------------------------------
104104-;; Custom functions
105105+;; Custom functions and evil-mode commands
105106;; ----------------------------------------------------------------------
106106-(defun quit-window-and-buffer ()
107107- "Quit the window, killing its buffer if it was the last window
108108- displaying that buffer."
109109- (interactive)
107107+(evil-define-command evil-quit-buffer-or-window (&optional force)
108108+ "Close the current buffer, displaying that buffer. If it is the last
109109+ open buffer, "
110110+ :repeat nil
111111+ (interactive "<!>")
110112 (setq curbuf (current-buffer))
111113 (setq curwindow (get-buffer-window curbuf))
112114115115+ ;; TODO rework this a bit
113116 (if (eq curwindow (next-window nil nil "visible"))
114114- (kill-buffer)
117117+ (bury-buffer)
115118 (delete-window)
116116- (unless (get-buffer-window curbuf) (kill-buffer curbuf)))
117117-)
119119+ (unless (get-buffer-window curbuf) (bury-buffer curbuf))))
120120+121121+(evil-define-command evil-save-and-quit-buffer-or-window (file &optional force)
122122+ "Save the current buffer and close it, closing the window if that was the
123123+ last buffer in the window."
124124+ ;; parts taken from evil-commands.el: 'evil-save-and-close
125125+ :repeat nil
126126+ (interactive "<f><!>")
127127+ (evil-write nil nil nil file force)
128128+ (evil-quit-buffer-or-window))
118129119130(defun minibuffer-keyboard-quit ()
120131 "Abort recursive edit.
···126137 (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
127138 (abort-recursive-edit)))
128139140140+(defun go-to-definition-or-open-link (event)
141141+ "Find the definition of the identifier at point, or attempt to open a file
142142+ or hyperlink if no definitions were found."
143143+ (interactive "e")
144144+ ;; move point like normal mouse click
145145+ (save-mark-and-excursion
146146+ (mouse-set-point event)
147147+ (let* ((url-str (thing-at-point 'url t))
148148+ (parsed-url (url-generic-parse-url url-str)))
149149+ (if (and
150150+ (url-type parsed-url)
151151+ (url-host parsed-url))
152152+ (browse-url url-str)
153153+ ;; If not a valid URL (no proto+hostname), then try to find definitions
154154+ ;; taken from xref--read-identifier
155155+ (let* ((xref-backend (xref-find-backend))
156156+ (identifier (xref-backend-identifier-at-point xref-backend)))
157157+ (xref-find-definitions identifier))))))
158158+129159;; ----------------------------------------------------------------------
130160;; Key bindings
131161;; ----------------------------------------------------------------------
···141171(global-set-key (kbd "s-\\") 'evil-window-vsplit)
142172(global-set-key (kbd "s-|") 'evil-window-split)
143173144144-(global-set-key (kbd "<s-mouse-1>") (kbd "<mouse-1>"))
174174+(global-set-key (kbd "<s-mouse-1>") 'go-to-definition-or-open-link)
145175146176;; window movement
147177(global-set-key (kbd "<M-s-right>") 'windmove-right)
···159189160190(global-display-line-numbers-mode)
161191162162-;; Should no longer be needed due to desktop-save-mode
163163-;; (add-to-list 'default-frame-alist '(width . 0.5))
164164-;; (add-to-list 'default-frame-alist '(height . 1.0))
192192+;; Allow using mouse to resize split windows
193193+(window-divider-mode)
194194+195195+;; TODO: handle "qa" better than currently (basically, it should kill
196196+;; all buffers and open the scratch buffer)
165197166198;; Make `:q` not kill the entire process
167167-(evil-ex-define-cmd "q" 'quit-window-and-buffer)
199199+(evil-ex-define-cmd "q" 'evil-quit-buffer-or-window)
200200+201201+;; Make `:wq` not kill the entire process
202202+(evil-ex-define-cmd "wq" 'evil-save-and-quit-buffer-or-window)
168203169204;; Typing out `:quit` will still quit emacs
170205(evil-ex-define-cmd "quit" 'evil-quit)
171206172207;; Make <esc> quit from minibuffer, etc.
173208(define-key evil-normal-state-map [escape] 'keyboard-quit)
209209+174210(define-key evil-visual-state-map [escape] 'keyboard-quit)
175211(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
176212(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)