Mercurial > dotfiles
view vim/autoload/ludo.vim @ 430:71a080d4d83c
Vim stuff: Goyo writing mode, Ack with Ag.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 01 Apr 2018 22:44:59 -0700 |
parents | 67f14a8c2304 |
children | b7682004288d |
line wrap: on
line source
let g:ludo_trace = 0 " Debug logging. function! ludo#trace(msg) abort if g:ludo_trace echom a:msg endif endfunction " Warning message. function! ludo#warn(msg) abort echohl WarningMsg echomsg "ludo: Warning: ".a:msg echohl None endfunction " Error message. function! ludo#error(msg) abort let v:errmsg = "ludo: Error: ".a:msg echohl ErrorMsg echom v:errmsg echohl None endfunction " Loads `pathogenrc` files in each bundle directory and, if found, " builds an exclude list based on the glob patterns found in them. " function! ludo#setup_pathogen(bundle_dirs) abort for bundle_dir in a:bundle_dirs let l:rcfile = bundle_dir.'.pathogenrc' if !filereadable(l:rcfile) call ludo#trace("No bundle configuration file: ".l:rcfile) continue endif let l:included = [] let l:excluded = [] call ludo#trace("Reading bundle configuration file: ".l:rcfile) let l:rclines = readfile(l:rcfile) for line in l:rclines if line[0] == '#' continue endif if line[0] == '-' let l:excls = glob(bundle_dir.'/'.line[1:], 1, 1) for excl in l:excls let l:idx = index(l:included, excl) if l:idx >= 0 call remove(l:included, l:idx) endif call add(l:excluded, excl) endfor else let l:incls = glob(bundle_dir.'/'.line, 1, 1) for incl in l:incls let l:idx = index(l:excluded, incl) if l:idx >= 0 call remove(l:excluded, l:idx) endif call add(l:included, incl) endfor endif endfor for excl in l:excluded if isdirectory(excl) let l:excl_name = fnamemodify(excl, ':t') call add(g:pathogen_disabled, l:excl_name) endif endfor endfor call ludo#trace("Exclude list: ".join(g:pathogen_disabled, ', ')) endfunction let s:ludo_revert = {} function! ludo#on_goyo_enter() let s:ludo_revert = { \'spell': &spell, \'copyindent': ©indent, \'smartindent': &smartindent, \'autoindent': &autoindent, \'list': &list, \'showmode': &showmode, \'showcmd': &showcmd, \'scrolloff': &scrolloff, \'complete': &complete, \'background': &background \} set spell set nocopyindent nosmartindent noautoindent nolist noshowmode noshowcmd set scrolloff=999 set complete+=s set bg=light if !has('gui_running') let g:solarized_termcolors=256 endif endfunction function! ludo#on_goyo_leave() if len(s:ludo_revert) == 0 call ludo#error("Can't revert settings!") return endif for [key, val] in items(s:ludo_revert) execute 'let &'.key.' = '.string(val) endfor let s:ludo_revert = {} endfunction function! ludo#writingmode() Goyo endfunction