" -*- vimrc-generic -*-
"
" Base on
" https://raw.githubusercontent.com/tridactyl/tridactyl/master/.tridactylrc
" See that for more advanced examples.

" Installing Tridactyl:
"
" * Put this config in ~/.tridactylrc (or $XDG_CONFIG_DIR/tridactyl/tridactylrc).
"
" * Install the native messenger by running :installnative in Tridactyl
"   and then running the shell command it copies to clipboard.
"
" * Run :source in the browser or just restart.

" NB: If you want "vim-like" behaviour where removing a line from
" here makes the setting disappear, uncomment the line below.
"
"sanitise tridactyllocal tridactylsync

" Use this to see current config in the browser
" :viewconfig --user

" WARNING: THERE IS A BUG WHEREBY SOMETIMES SOME LINES IN THE CONFIG GET IGNORED :/
" https://github.com/tridactyl/tridactyl/issues/1409

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Search Urls
"
" These work in the 'o' -> ':open ' dialog, but not in the regular
" address bar.
"
" In addition to using %s for a single query param, you can use %1,
" %2, etc, for multiple query params.

"set searchurls.hackage http://hackage.haskell.org/package/%s
"set searchurls.hayoo http://hayoo.fh-wedel.de/?query=%s
"set searchurls.h4 https://www.haskell.org/hoogle/?hoogle=%s
"set searchurls.h5 https://hoogle.haskell.org/?hoogle=%s&scope=set%3Astackage

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Quickmarks
"
" Use go<key>/gn<key>/gw<key> to open quickmark for <key> in
" current/new tab/new window

quickmark g https://mail.google.com/mail/u/0/#inbox
quickmark G https://mail.google.com/mail/u/1/#inbox

""""""""""""""""
"
" Disable on some sites
"

"blacklistadd youtube.com
blacklistadd calendar.google.com
blacklistadd docs.google.com
blacklistadd drive.google.com
blacklistadd keep.google.com
blacklistadd mail.google.com
blacklistadd monkeytype.com
blacklistadd typeracer.com
blacklistadd codepen.io
blacklistadd codesandbox.io
"blacklistadd github.dev

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Binds
"
" Some defaults:
" - :help
" - :tutor
" - b : buffers/tabs navigation
" - yy : yank url
" - gg : top of page
" - G : bottom of page
" - insert, shift+insert, ctrl+alt+`, shift+escape : toggle pass thru
" - d/D : close current tab and move focus right/left
" - p/P : open url in clipboard or search for clipboard content in current/new tab
" - zi/zo/zz : zoom in/out/reset
" - \[\[ / \]\] : guess previous/next page (seems smart, e.g. works when
"   url does not end in a number, but "next" occurs in link text)
" - ;; : focus an element. Useful if you want to scroll something non-default with up/down or j/k
" - ;p : copy element (e.g. link, paragraph) to clipboard
" - ;k : kill element (e.g. a big "please disable your ad blocker" banner)
" - :viewconfig nmaps : see all key bindings (but how to delete?)
" - f/;t/F: follow hint in current tab/new foreground tab (switch focus)/new background tab (don't switch focus)
" - C-o : run a single command (in normal mode) when in ignore mode, then switch back to ignore mode

" Make 'd' switch to previous active tab after close
bind d composite tabclose | buffer #

" Don't bind paste to ignore mode. Can use 'S-Esc' or 'C-A-Esc' instead.
unbind <S-Insert>

" Don't bind 'f' in youtube
unbindurl youtube\.com/watch\?v=.* f

" Bind <Insert> to toggle normal/ignore mode. I use <Insert> to toggle
" Ctrl-lock in Emacs, so hopefully this will be memorable. We leave
" insert mode, but don't enter it. The insert mode bind doesn't work,
" but <C-,> still allows escape.
bind --mode=normal <Insert> mode ignore
bind --mode=ignore <Insert> mode normal
"bind --mode=insert <Insert> mode normal

" Bind <C-o> to toggle normal/ignore mode for one command. Already
" bound to C-o in normal mode, make it work everywhere. I'm rebinding
" the existing normal mode bind for completeness/clairity. We leave
" insert mode, but don't enter. The insert mode bind doesn't work, but
" <C-,> still allows escape.
bind --mode=normal <C-o> nmode normal 1 mode ignore
bind --mode=ignore <C-o> nmode ignore 1 mode normal
"bind --mode=insert <C-o> nmode insert 1 mode normal

bind / fillcmdline find
bind n findnext 1
bind N findnext -1
"bind <Space>/ nohlsearch
set findcase smart

" Workaround bug on web.whatsapp.com that prevents focus from leaving
" message entry
"" box. https://github.com/tridactyl/tridactyl/issues/3070
"bindurl web.whatsapp.com  --mode=normal         <Escape> composite hint -f m2 ; fillcmdline ; ex.hide_and_clear
"bindurl web.whatsapp.com  --mode=insert         <Escape> composite hint -f m2 ; fillcmdline ; ex.hide_and_clear
"bindurl web.whatsapp.com  --mode=input          <Escape> composite hint -f m2 ; fillcmdline ; ex.hide_and_clear

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Misc settings
"

" but make sure i can always get into the console"
bind : fillcmdline_notrail

" newtab
set newtab about:blank

" I’m a smooth operator
set smoothscroll true

" Vimperator-style hinting, using numbers to select and letters to
" narrow, instead of just letters to select.
set hintfiltermode vimperator-reflow
set hintnames numeric
" " I use Programmer Dvorak
" set hintchars dhtnaoeuifgcrl',.pybm;qjkx

" Defaults to 300ms
set hintdelay 100

" Don't autofocus!
autocmd TabEnter .* unfocus
autocmd DocLoad .* unfocus


" Include numbers in tab names, to make 'b' and '<A-<number>>'
" switching easier.
guiset tabs numbers

" Make Tridactyl work on more sites at the expense of some security
" set csp clobber
" fixamo_quiet

" This will have to do until someone writes us a nice syntax file :)
" vim: set filetype=vim:
