" My pentadactylrc uses folds
"
" zR    open all folds
" zM    close all folds
" za    toggle fold at cursor position
" zj    move down to start of next fold
" zk    move up to end of previous fold

" My pentadactylrc command and mapping quick reference         {{{1
" -----------------------------------------------------------------
"
"  Keyboard mappings
"
" Change Option:
"    coh      -- toggles the highlight search
"    cog      -- Toggle the gui on or off
"    cob      -- shows the bookmark toolbar
"    cot      -- Toggle the tab bar on or off
" Bookmark:
"    bd       -- Bookmark in Delicious
"    bdm      -- Start the dev meeting
"    bp       -- Add video to Plex
"    br       -- Read later in Pocket
"    bx       -- Kick ass!
" Movement:
"    w        -- Horizontal scroll left
"    e        -- Horizontal scroll right
"    J        -- Alternative to <C-f>
"    K        -- Alternative to <C-b>
"    <C-h>    -- Switch to next tab to the left
"    <C-l>    -- Switch to next tab to the right
"    H        -- Move current tab to the left
"    L        -- Move current tab to the right
"    <C-;>    -- Go to the next tab group
"    <C-'>    -- Go to the previous tab group
" Other Stuff:
"    f        -- Remapped to ;; to only focus hint
"    <C-e>    -- Open textarea in external editor
"    <M-S-E>  -- Map the group tab shortcut to start pass through first
"
" Keyboard mappings that have been disabled
"
"    d        -- Turned off delete current tab
"    <bs>     -- Turned off backspace as "back"
"    <C-a>    -- Turned off auto increment because it is annoying

" General settings                                             {{{1
" -----------------------------------------------------------------
set novisualbell
"
" turn off the freakin' bell
hi Bell display: none;
"
" Only show the command line and status bar
set guioptions=Csr

" set wild mode to show completions as you type
set wildmode="list:full"

" fix completion list so search engines don't kill tabbing
set complete=lS

" show up to 35 items in the completion list
set maxitems=35

" use a different color scheme
colorscheme solarized-light


" set a stupid title
set titlestring="oh hai!"

" only show the tab bar if there are more than 1 tabs
set showtabline='multitab'

" load plugins that are css as well
set loadplugins='\.(css|js|penta)$'

" Open diverted links automatically
set activate+=diverted

" Toggle dark mode
map -builtin i :exttoggle Advanced Night Mode<CR>

" Searching                                                    {{{1
" -----------------------------------------------------------------

" Use home row letters for hints instead of numbers
set hintkeys=asdfgr;lkhiu

" find as you type
set incfind
" highlight the terms
set hlfind
" unless they contain upper-case letters
set findcase=smart
" a toggle for search highlight
map <silent> coh :set hlfind!<CR>
" Set up google as the default search engine
" set defsearch=google

" Mappings                                                     {{{1
" leader is space !
map " " <Leader>

" Space does nothing by itself
map -builtin " " <nop>

" bring back/hide portions of the GUI
map -builtin cog :set guioptions!=mBT<CR>
map -builtin cob :toolbartoggle Bookmarks Toolbar<CR>
map -builtin cot :set showtabline!=never,always<CR>

map -builtin <Leader> :tabs<space>

" temporary workaround for copy paste in text boxes
" https://code.google.com/p/dactyl/issues/detail?id=517
imap -builtin <M-z> <pass>
imap -builtin <M-a> <pass>
imap -builtin <M-x> <pass>


" Also assign ctrl + e as that is easier to type, and what I have
" set up in thunderbird :)
imap -builtin <C-e> <C-i>
imap -builtin jk <Esc>

" Clearly doesn't invoke anymore, this forces it
map -builtin <Leader>md :emenu Tools.Downloads<CR>
map -builtin <Leader>ma :emenu Tools.Add-ons<CR>
map -builtin <Leader>mp :emenu Tools.Preferences<CR>


" Never wanted to go back when I hit delete, now it won't
nmap -builtin <bs> <nop>

" The auto number incremeting is kind of annoying
nmap -builtin <C-a> <nop>

" Go into pass through mode when invoking group tabs
"nmap -builtin <M-S-E> <C-z><M-S-E>
" Text/Typing                                                       {{{1
" -----------------------------------------------------------------

" set editor to nvim on a floating alacritty terminal
set editor='alacritty --class=Floating,Floating -e nvim -c "set filetype=markdown"'

set insertmode

" tmap -builtin  jk <Esc><Esc>
" imap jk <C-T>

" tmap -builtin  jk <Esc><Esc>
imap -builtin jk <Esc>
" map -builtin gi gi
cmap -builtin jk <Esc>

" tell the bell to go beep itself!
" Navigation {{{1
" ----------------------------------------------------------------
"
" smooth scroll setting
set scrollsteps=5
set scrolltime=100

" Scroll settings
map -builtin h 10h
map -builtin l 10l
map -builtin j 10j
map -builtin k 10k
nmap -builtin d  50j
nmap -builtin u  50k
" go forward and back
" map -builtin J <C-f> TODO: RIP
" map -builtin K <C-b>

" Dont want that
nmap -builtin D <nop>

" Go to the next/previous tab
map -builtin J <Esc>:tabprevious <CR>
map -builtin K <Esc>:tabnext <CR>

" Go back and forward in history of the current page
map -builtin H :back<CR>
map -builtin L :forward<CR>

"" Go to the next / previous tab group
"map -builtin <C-;> <C-S-~>
"map -builtin <C-''> <C-`>

" Move the current tab
map -builtin <C-S-J> <Esc>:tabmove! -1<CR>
map -builtin <C-S-K> <Esc>:tabmove! +1<CR>

" Don't follow a hint immediately
map -builtin f ;;

" Bookmarklets                                                 {{{2
" -----------------------------------------------------------------

" NOTE: These are bookmarks in Firefox with keywords. You'll have
"       to add the bookmarks if they don't exist.

" Bookmark with org protocol
map -builtin <silent> <leader>bo :javascript 'javascript:location.href="org-protocol:///capture?url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title||"[untitled page]")'<CR>

" Start up the dev meeting
map -builtin <silent> bd :tabopen bkm-dev-meeting<CR>

" Shortcuts for GitHub Pull Requests
map -builtin <silent> bpr :tabopen bkm-prs-review<CR>
map -builtin <silent> bpq :tabopen bkm-prs-qa<CR>


" Add video on the page to Plex
map -builtin <silent> bp :open bkm-plex<CR>

" Ignore Rules                                             {{{1
" -----------------------------------------------------------------

" pass keys in the folowing websites
:autocmd LocationChange 'https://ozencb.github.io/tilde-enhanced/*' :normal! <C-z>
" :autocmd LocationChange 'https://www.youtube.com/watch*' :normal! <C-z>
:autocmd LocationChange 'https://www.wanikani.com/lesson*' :normal! <C-z>


" Interface Tweaks                                             {{{1
" -----------------------------------------------------------------

" Get rid of the tab group / tab selector arrow at the top of the
" vertical tab bar when using Tree Style Tab. This can't be done
" through the interface customization for some reason.
javascript <<EOF
(function() {
    var alltabs = document.getElementById('alltabs-button');
    if (alltabs !== null) {
    alltabs.parentNode.removeChild(alltabs);
    };
})();
EOF


" Overrides for local machine                                  {{{1
" -----------------------------------------------------------------
source! ~/.pentadactylrc.local

" turn on folds
" vim: fdm=marker