" plugin/markx.vim " " MarkX - Richard Bentley-Green, 22/03/2023 " " Auto-placement of signs in the left margin, in response to creation and " deletion of marks, plus some extra mark-placement functions " if exists('g:Markx_loaded') finish endif const g:Markx_loaded = 1 " ---------------------------------- " This is a non-standard colour highlight default link StatusMsg Normal " ---------------------------------- " Set a specific mark nnoremap (MarkXAdd) :call markx#Add(nr2char(getchar()), 0) vnoremap (MarkXAdd) :call markx#Addv('', nr2char(getchar())) " Auto-select and set mark nnoremap (MarkXAdda) :call markx#Adda() vnoremap (MarkXAdda) :call markx#Addv('l', '') nnoremap (MarkXAddA) :call markx#AddA() vnoremap (MarkXAddA) :call markx#Addv('u', '') " Delete a mark nnoremap (MarkXDel) :call markx#Del(nr2char(getchar())) " Delete all marks nnoremap (MarkXDelAllL) :call markx#DelAll('l') nnoremap (MarkXDelAllU) :call markx#DelAll('u') nnoremap (MarkXDelAllP) :call markx#DelAll('p') " Delete all auto-place marks nnoremap (MarkXDelAllAutoL) :call markx#DelAll('l', 1) nnoremap (MarkXDelAllAutoU) :call markx#DelAll('u', 1) " Refresh all marks/signs nnoremap (MarkXRefresh) :call markx#Refresh() nnoremap (MarkXRefreshAll) :call markx#RefreshAll() " Toggle 'display signs for ALL marks in current buffer' nnoremap (MarkXToggleShowAll) :call markx#ToggleShowAll() " ------------------------------------------------------------------------------ " Commands " Toggle the g:MarkxAutoLForce configuration setting command MarkXToggleAutoForce let g:MarkxAutoLForce = (get(g:, 'MarkxAutoLForce', 0) ? 0 : 1) | echohl StatusMsg | echo "MarkX: Auto placement forced (recycle existing marks) ".((g:MarkxAutoLForce) ? 'on' : 'off')."" | echohl None " Toggle the g:MarkxSteponAuto configuration setting command MarkXToggleSteponAuto let g:MarkxSteponAuto = (get(g:, 'MarkxSteponAuto', 0) ? 0 : 1) | echohl StatusMsg | echo "MarkX: Step on auto sel. after manual placement ".((g:MarkxSteponAuto) ? 'on' : 'off')."" | echohl None " Toggle the g:MarkxConfirmDelAll configuration setting command MarkXToggleDelAllConfirm let g:MarkxConfirmDelAll = (get(g:, 'MarkxConfirmDelAll', 0) ? 0 : 1) | echohl StatusMsg | echo "MarkX: Confirm 'delete all' mappings ".((g:MarkxConfirmDelAll) ? 'on' : 'off')."" | echohl None " Toggle the g:MarkxDelAllUGlobal configuration setting command MarkXToggleDelUGlobal let g:MarkxDelAllUGlobal = (get(g:, 'MarkxDelAllUGlobal', 0) ? 0 : 1) | echohl StatusMsg | echo "MarkX: 'Delete all A-Z' mappings now operates ".((g:MarkxDelAllUGlobal) ? 'globally' : 'on local buffer only')."" | echohl None " ------------------------------------------------------------------------------ " Default mappings (for details of global options used here, see README) if get(g:, 'MarkxSetDefaultMaps', 1) nmap m (MarkXAdd) vmap m (MarkXAdd) nmap mm (MarkXAdda) vmap mm (MarkXAdda) nmap mM (MarkXAddA) vmap mM (MarkXAddA) nmap md (MarkXDel) nmap ma (MarkXDelAllL) nmap mA (MarkXDelAllU) nmap mp (MarkXDelAllP) nmap mq (MarkXDelAllAutoL) nmap mQ (MarkXDelAllAutoU) nmap m~ (MarkXRefresh) nmap m# (MarkXRefreshAll) nmap m@ (MarkXToggleShowAll) endif " Iniitialise. " Note that this ought to be executed locally from ./autoload/markx.vim but it " performs some error checking and the error messages are lost if run that way. " Runing it from here on startup will preserve the error message output call markx#Init() " Events that trigger a refresh autocmd VimEnter,BufWinEnter,BufLeave,FileAppendPre,FileAppendPost,FileReadPost,FilterReadPost,ShellFilterPost * silent call markx#Refresh() autocmd TabEnter,CursorHold * silent call markx#RefreshAll() " ------------------------------------------------------------------------------ " eof