# HG changeset patch # User Ludovic Chabant # Date 1432163719 25200 # Node ID 8959592285b953c502f50801656681a7b0cd8fc5 # Parent ffa5a9102d22b524265635b5b16c48c7cd7b74ad# Parent 27447ad19df656551605b9d38a6b0caef30c637f Merge changes. diff -r 27447ad19df6 -r 8959592285b9 .hgignore --- a/.hgignore Sat Mar 07 11:09:04 2015 -0800 +++ b/.hgignore Wed May 20 16:15:19 2015 -0700 @@ -8,6 +8,8 @@ .netrwhist hgrc/hgrc-local vim/vimrc-local +vim/local/ weechat/logs weechat/*.log +mutt/*.gpg diff -r 27447ad19df6 -r 8959592285b9 .hgsub --- a/.hgsub Sat Mar 07 11:09:04 2015 -0800 +++ b/.hgsub Wed May 20 16:15:19 2015 -0700 @@ -40,6 +40,10 @@ lib/hg/mercurial-cli-templates = https://bitbucket.org/sjl/mercurial-cli-templates lib/hg/hg-prompt = https://bitbucket.org/sjl/hg-prompt lib/hg/mutable-history = https://bitbucket.org/marmoute/mutable-history +lib/hg/terse-status = https://bitbucket.org/durin42/terse-status +lib/hg/hgremotenames = https://bitbucket.org/seanfarley/hgremotenames lib/fish/virtualfish = [git]https://github.com/adambrenecki/virtualfish.git +pentadactyl/plugins/pintaboard = [git]https://github.com/bnbeckwith/pintaboard.git + diff -r 27447ad19df6 -r 8959592285b9 .hgsubstate --- a/.hgsubstate Sat Mar 07 11:09:04 2015 -0800 +++ b/.hgsubstate Wed May 20 16:15:19 2015 -0700 @@ -1,38 +1,41 @@ -17a51b56d88bd1f1826945413790c482032bb8d3 lib/fish/virtualfish +ce7fac3bbdf0e530c06e6dc23856b2282ca02200 lib/fish/virtualfish f8703c9e2fb951ebb193b268faf7f0457abf8334 lib/hg/allpaths -d40de32ec5b1380ed20888c744d4f8f468fbf226 lib/hg/hg-git +93689e8f27ac657feed5332b71e66210c3a81cbf lib/hg/hg-git 1cb3af183d2f692622f84da88d5ca18bd4f91b1f lib/hg/hg-prompt +214cd3c6ab6f76b7aaed0b3f8f4300d09f7cb560 lib/hg/hgremotenames 66e2a34005b447d321a96838d7fe2b161e78b7a9 lib/hg/mercurial-cli-templates -1df0bf41016cc640eec03bfbd5938f5639b2f387 lib/hg/mutable-history +792998917ece57f303faefec01ad5b1fafb9036f lib/hg/mutable-history d920e3425db554497a2cfaf1a2548eafbdc8b0e7 lib/hg/onsub +2d9820cf595263bc7c651295b83f02525a23ca4a lib/hg/terse-status 3b23c55eb43849975656dd89e3f35dacd2b93e69 mutt/mutt-colors-solarized +14897c793e0978e88967afbcd2d8e85041febceb pentadactyl/plugins/pintaboard db3707cbd8706f4bb054959ecc5cee82ac45687b vim/bundle/badwolf 81c6dd7ce3169e5ad9ba92422ba6e1ce5b074e36 vim/bundle/colorschemes 9c685131a5facfa0d643feca3a61b41c007d8170 vim/bundle/commentary -faafe125db65c4a3b9537a60a968e723b88a6c8f vim/bundle/ctrlp -0b311aa53a49be0c74aa784274a70441dd40b2e7 vim/bundle/ctrlp-autoignore -9ceebf91fc137644cf0693561a386ef4071dbf87 vim/bundle/easymotion -2c8461db084d205903a792a23163faa546f143c9 vim/bundle/fugitive +f2effdc86abf172d6562ec589fa1aa2c8f136a08 vim/bundle/ctrlp +634d881b6ac6b1283e24229af3fc736faaa899ec vim/bundle/ctrlp-autoignore +8acdfc60e58bb0600ded42a4f752bec6e3b6d882 vim/bundle/easymotion +4cc201cbe3a0c3faa4cde1b82ba941d410e5e81c vim/bundle/fugitive eb9fc8676b8959c3c2c95bf6b6e8f0f44317c5c0 vim/bundle/gundo -8b3c611a4d3b0f9ea62091925cc9b8137ddd5054 vim/bundle/gutentags +50d2a7cbf7c8743e022377a87326d2e1d69f7a0e vim/bundle/gutentags 204e32721154766e03e99ff857bc798aa5b741dc vim/bundle/haml 6e0ac033107bd12c1390cbdf49398393930f3fb6 vim/bundle/interestingwords 8a8f0ed97c1751d304cf5b7241f2fe27b0e61f81 vim/bundle/jinja -7da11e02977391513169d166f5ebbe9c1d030627 vim/bundle/lawrencium -940a8defa0576385dee1ad177bab0b34738540aa vim/bundle/less -b69e54f4bf0a0ee26f6582ee8764b25529610c88 vim/bundle/linediff +7cfe9ba2c7dd99c25bbf2992fe928447e0b3de4a vim/bundle/lawrencium +902870b38df5f22803532141f11a82c74bed5ab5 vim/bundle/less +d51993ebc0227114443379b72ed2a8667731d17f vim/bundle/linediff 409c37b205afa2f9d590e23de8171482d66770e2 vim/bundle/markdown 3b98a7fcae8f9fff356907171f0406ff8cd28921 vim/bundle/nerdtree af8514b79c046a6bb447021b81351edb050ac69f vim/bundle/piecrust 114f8e5c204f1cac9b2443065910fa182de39fb8 vim/bundle/powerline c6a872a64530979f4aac46d765c577581cb7fc36 vim/bundle/pythonmode -07115a6dee0ae01b7c9c3d92e9ee3219b6780b77 vim/bundle/ragtag -5eba0f19c87402643eb8a7e7d20d9d5338fd6d71 vim/bundle/repeat +bef689a4d5ceb10bbe1b5aa216394bc3197a1258 vim/bundle/ragtag +c4f9f159e66a00e148b05d3c97c20072777d559f vim/bundle/repeat 528a59f26d12278698bb946f8fb82a63711eec21 vim/bundle/solarized -b0ca47f4570385043f270f9278ba6d50d1d2fa00 vim/bundle/supertab -fa433e0b7330753688f715f3be5d10dc480f20e5 vim/bundle/surround -0da7a1e476ef03be22718e813fbc729f9dc163b4 vim/bundle/syntastic -bfc121dc38271ab3f050609bb2ca377de07d8bd6 vim/bundle/tagbar +c8bfeceb1fc92ad58f2ae6967cbfcd6fbcb0d6e7 vim/bundle/supertab +772ab9587b7d1e2c3bae75395c9123803059ba8a vim/bundle/surround +48090a19f21a3c602b85e59605c0f2a41e5fc69d vim/bundle/syntastic +c6b473f5593a1cb9e567bb1a9a897f196f1f720a vim/bundle/tagbar 869c05195086dd1af9fe39e49621f9f880b6f07c vim/bundle/twig b9d1fa7d460dac878cbc8c945a45439d92ce0cb2 vim/bundle/vimroom a884f3a161fa3cd8c996eb53a3d1c68631f60c21 vim/bundle/yankring diff -r 27447ad19df6 -r 8959592285b9 git/gitconfig --- a/git/gitconfig Sat Mar 07 11:09:04 2015 -0800 +++ b/git/gitconfig Wed May 20 16:15:19 2015 -0700 @@ -5,3 +5,8 @@ [push] default = simple +[alias] +lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all +lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all +lg = !"git lg1" + diff -r 27447ad19df6 -r 8959592285b9 install.cmd --- a/install.cmd Sat Mar 07 11:09:04 2015 -0800 +++ b/install.cmd Wed May 20 16:15:19 2015 -0700 @@ -29,20 +29,26 @@ echo onsub = %CWD:\=/%lib/hg/onsub/onsub.py >> "%userprofile%\mercurial.ini" echo allpaths = %CWD:\=/%lib/hg/allpaths/allpaths.py >> "%userprofile%\mercurial.ini" echo prompt = %CWD:\=/%lib/hg/hg-prompt/prompt.py >> "%userprofile%\mercurial.ini" +echo changelog = %CWD:\=/%lib/hg/changelog/changelog.py >> "%userprofile%\mercurial.ini" +echo evolve = %CWD:\=/%lib/hg/mutable-history/hgext/evolve.py >> "%userprofile%\mercurial.ini" +echo terse-status = %CWD:\=/%lib/hg/terse-status/terse-status.py >> "%userprofile%\mercurial.ini" +echo remotenames = %CWD:\=/%lib/hg/hgremotenames/remotenames.py >> "%userprofile%\mercurial.ini" :: Git Files if exist "%userprofile%\.gitconfig" ( set /P confirm=Will delete existing "%userprofile%\.gitconfig". OK with that? Press CTRL-C to abort. del /Q "%userprofile%\.gitconfig" ) -copy "%CWD%git\gitconfig" "%userprofile%\.gitconfig" +echo [include] > "%userprofile%\.gitconfig" +echo path = %CWD:\=/%git/gitconfig >> "%userprofile%\.gitconfig" :: Web Browser if exist "%userprofile%\_pentadactylrc" ( set /P confirm=Will delete existing "%userprofile%\_pentadactylrc". OK with that? Press CTRL-C to abort. del /Q "%userprofile%\_pentadactylrc" ) -echo source %CWD:\=/%pentadactylrc > "%userprofile%\_pentadactylrc" +echo set runtimepath=~/.pentadactyl,%CWD:\=/%pentadactyl > "%userprofile%\_pentadactylrc" +echo source %CWD:\=/%pentadactyl/pentadactylrc >> "%userprofile%\_pentadactylrc" :: Console 2 if exist "%appdata%\Console\console.xml" ( diff -r 27447ad19df6 -r 8959592285b9 install.sh --- a/install.sh Sat Mar 07 11:09:04 2015 -0800 +++ b/install.sh Wed May 20 16:15:19 2015 -0700 @@ -29,14 +29,17 @@ echo prompt = $CWD/lib/hg/hg-prompt/prompt.py >> "$HOME/.hgrc" echo changelog = $CWD/lib/hg/changelog/changelog.py >> "$HOME/.hgrc" echo evolve = $CWD/lib/hg/mutable-history/hgext/evolve.py >> "$HOME/.hgrc" +echo terse-status = $CWD/lib/hg/terse-status/terse-status.py >> "$HOME/.hgrc" +echo remotenames = $CWD/lib/hg/hgremotenames/remotenames.py >> "$HOME/.hgrc" # GIT # --- -cp "$CWD/git/gitconfig" "$HOME/.gitconfig" +ln -s "$CWD/git/gitconfig" "$HOME/.gitconfig" # WEB BROWSER # ----------- -ln -s "$CWD/pentadactylrc" "$HOME/.pentadactylrc" +echo set runtimepath=~/.pentadactyl,$CWD/pentadactyl > "$HOME/.pentadactylrc" +echo source "$CWD/pentadactyl/pentadactylrc" >> "$HOME/.pentadactylrc" # TMUX # ---- diff -r 27447ad19df6 -r 8959592285b9 lib/hg/hggit_sync.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/hg/hggit_sync.py Wed May 20 16:15:19 2015 -0700 @@ -0,0 +1,94 @@ +import os +import os.path +import sys +import subprocess + + +class CommitInfo(object): + def __init__(self): + self.nodeid = None + self.timestamp = None + self.description = None + + +def parse_commits(text): + commits = [] + cur_commit = None + for line in text.split('\n'): + if line == '': + if cur_commit: + commits.append(cur_commit) + cur_commit = None + continue + if cur_commit is None: + cur_commit = CommitInfo() + if cur_commit.nodeid is None: + id_and_date = line.split(' ', 1) + cur_commit.nodeid = id_and_date[0] + cur_commit.timestamp = int(id_and_date[1].split('.')[0]) + else: + cur_commit.description = line + return commits + + +def build_commit_map(commits1, commits2): + commits1 = sorted(commits1, key=lambda c: c.timestamp) + commits2 = sorted(commits2, key=lambda c: c.timestamp) + commit_map = dict(map(lambda c: (c.timestamp, (c, None)), commits1)) + for c in commits2: + entry = commit_map.get(c.timestamp, (None, None)) + entry = (entry[0], c) + commit_map[c.timestamp] = entry + return commit_map + + +def main(): + hg_repo = os.getcwd() + if not os.path.exists(os.path.join(hg_repo, '.hg')): + print "You must run this in the root of a Mercurial repository." + return 1 + + git_repo = os.path.join(hg_repo, '.hg', 'git') + if not os.path.exists(git_repo): + print ("This Mercurial repository doesn't seem to have any Git mirror " + "to sync with.") + return 1 + + hg_output = subprocess.check_output([ + 'hg', 'log', + '--template', "{node} {date}\n{firstline(desc)}\n\n"]) + hg_commits = parse_commits(hg_output) + + os.chdir(git_repo) + git_output = subprocess.check_output([ + 'git', 'log', '--format=%H %ct%n%s%n%n']) + git_commits = parse_commits(git_output) + os.chdir(hg_repo) + + commit_map = build_commit_map(git_commits, hg_commits) + for key, val in commit_map.iteritems(): + if val[0] is None: + print ("Mercurial commit '%s' (%s) has no Git mirror yet: %s" % + (val[1].nodeid, val[1].timestamp, val[1].description)) + if val[1] is None: + print ("Git commit '%s' (%s) is new: %s" % + (val[0].nodeid, val[0].timestamp, val[0].description)) + + map_file = os.path.join(hg_repo, '.hg', 'git-mapfile') + if len(sys.argv) > 1: + map_file = sys.argv[1] + print "Saving map file: %s" % map_file + with open(map_file, 'w') as fp: + for key, val in commit_map.iteritems(): + if val[0] is None or val[1] is None: + continue + fp.write(val[0].nodeid) + fp.write(' ') + fp.write(val[1].nodeid) + fp.write('\n') + + +if __name__ == '__main__': + res = main() + sys.exit(res) + diff -r 27447ad19df6 -r 8959592285b9 pentadactyl/pentadactylrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pentadactyl/pentadactylrc Wed May 20 16:15:19 2015 -0700 @@ -0,0 +1,103 @@ +" Config for Pentadactyl + +" Scroll faster +nmap -builtin h 3h +nmap -builtin j 3j +nmap -builtin k 3k +nmap -builtin l 3l + +" Scroll easier +nmap -builtin d +nmap -builtin e + +" Close tab with `x` since `d` is for scrolling down now +nmap -builtin x :bd + +" Don't close the window with the last tab. +set! browser.tabs.closeWindowWithLastTab=false + +" Change tabs without awkward `CTRL` combinations +nmap -builtin J :tabprevious +nmap -builtin K :tabnext + +" Reorder tabs +nmap -builtin > :tabmove! +1 +nmap -builtin < :tabmove! -1 + +"New tab using the old classic way +nmap -builtin :tabnew + +" Use `i` to get into pass-through mode, +" `I` for temporary pass-through mode, +" and `c` for the 'caret' mode. +nmap -builtin i +nmap -builtin I +nmap -builtin c i + +" Shortcuts for common extensions +nmap -builtin ,f i +nmap -builtin ,p +nmap -builtin ,b I + +" Use and quickly hide search highlighting +set hlfind +nmap -builtin , :noh + +" Aw come on, copy/pasting is ridiculous by default. +map -builtin -modes=i,c,v +map -builtin -modes=i,c +map -builtin -modes=i,c + +" Quickly open some dialogs +nmap -builtin ,b :downloads + +" On keyboards like the Leopold FC660C, for some obscure reason, the +" key sends the ID. WTF. +noremap + +" DDG FTW +set defsearch=duckduckgo + +" Super minimal UI +"set toolbars=noaddons,nobookmarks,nomenu,nonavigation,notabs + +" Websites with useful keyboard shortcuts already +set passkeys+=fastmail.com:jkomxeyga#.rupn,/,m,c,a +set passkeys+=feedly.com:jkgvnpm +set passkeys+=feedbin.com:hjklesmvVFcf123456789rgAa?,/ +set passkeys+=groups.google.com:jkuonp + +" Plugins +loadplugins '\.(js|penta)$' +set pintaboardToken="ludovicchabant:04A05605C553E70CDA2A" + +javascript < 0) { + el[0].scrollTop -= el[0].clientHeight/2; + } else { + content.console.error("Can't find the entries list. Got: ", el); + } +} +function feedbinScrollDown() { + el = content.document.getElementsByClassName('entries'); + if (el != undefined && el.length > 0) { + el[0].scrollTop += el[0].clientHeight/2; + } else { + content.console.error("Can't find the entries list. Got: ", el); + } +} +EOF +nmap -builtin -js feedbinScrollUp() +nmap -builtin -js feedbinScrollDown() + +" vim: ft=vim diff -r 27447ad19df6 -r 8959592285b9 pentadactylrc --- a/pentadactylrc Sat Mar 07 11:09:04 2015 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -" Config for Pentadactyl - -" Scroll faster -nmap -builtin h 3h -nmap -builtin j 3j -nmap -builtin k 3k -nmap -builtin l 3l - -" Scroll easier -nmap -builtin d -nmap -builtin e - -" Close tab with `x` since `d` is for scrolling down now -nmap -builtin x :bd - -" Don't close the window with the last tab. -set! browser.tabs.closeWindowWithLastTab=false - -" Change tabs without awkward `CTRL` combinations -nmap -builtin J :tabprevious -nmap -builtin K :tabnext - -" Reorder tabs -nmap -builtin > :tabmove! +1 -nmap -builtin < :tabmove! -1 - -"New tab using the old classic way -nmap -builtin :tabnew - -" Use `i` to get into pass-through mode, -" `I` for temporary pass-through mode, -" and `c` for the 'caret' mode. -nmap -builtin i -nmap -builtin I -nmap -builtin c i - -" Shortcuts for common extensions -nmap -builtin ,f i -nmap -builtin ,p -nmap -builtin ,b I - -" Use and quickly hide search highlighting -set hlfind -nmap -builtin , :noh - -" Aw come on, copy/pasting is ridiculous by default. -map -builtin -modes=i,c,v -map -builtin -modes=i,c -map -builtin -modes=i,c - -" Quickly open some dialogs -nmap -builtin ,b :downloads - -" On keyboards like the Leopold FC660C, for some obscure reason, the -" key sends the ID. WTF. -noremap - -" DDG FTW -set defsearch=duckduckgo - -" Super minimal UI -"set toolbars=noaddons,nobookmarks,nomenu,nonavigation,notabs - -" Websites with useful keyboard shortcuts already -set passkeys+=fastmail.com:jkomxeyga#.rupn,/,m,c,a -set passkeys+=feedly.com:jkgvnpm -set passkeys+=feedbin.com:hjklesmvVFcf123456789rgAa?,/ -set passkeys+=groups.google.com:jkuonp - -" Website-specific groups -" Feedbin -group! feedbin -loc feedbin.com -javascript < 0) { - el[0].scrollTop -= el[0].clientHeight/2; - } else { - content.console.error("Can't find the entries list. Got: ", el); - } -} -function feedbinScrollDown() { - el = content.document.getElementsByClassName('entries'); - if (el != undefined && el.length > 0) { - el[0].scrollTop += el[0].clientHeight/2; - } else { - content.console.error("Can't find the entries list. Got: ", el); - } -} -EOF -nmap -builtin -js feedbinScrollUp() -nmap -builtin -js feedbinScrollDown() - -" vim: ft=vim diff -r 27447ad19df6 -r 8959592285b9 vim/vimrc --- a/vim/vimrc Sat Mar 07 11:09:04 2015 -0800 +++ b/vim/vimrc Wed May 20 16:15:19 2015 -0700 @@ -22,8 +22,10 @@ " Get the platform we're running on. if has("win32") || has("win64") || has("dos32") let s:vim_platform = "windows" + let s:path_sep = "\\" else let s:vim_platform = "unix" + let s:path_sep = '/' endif " Get our vim directory. @@ -39,8 +41,14 @@ call add(g:pathogen_disabled, 'minibufexpl') call add(g:pathogen_disabled, 'ragtag') +" Potentially add the local bundle directory. +if isdirectory(s:vim_home.s:path_sep.'local') + execute 'set runtimepath+='.s:vim_home.s:path_sep.'local' +endif + " Load pathogen. -call pathogen#infect() +"call pathogen#infect() +call pathogen#runtime_append_all_bundles() " Hide the toolbar in MacVim/gVIM, and set a nice window size. if has("gui_running") && !exists('g:resourcing_vimrc') @@ -161,9 +169,6 @@ " How to show invisible characters set listchars=eol:$,tab:>-,trail:-,extends:>,precedes:<,nbsp:%,conceal:. -" Folds are defined by markers in the text. -set foldmethod=marker - " Nice auto-complete menu. set completeopt=longest,menuone,preview @@ -191,8 +196,8 @@ set background=dark else set background=dark - let g:solarized_termcolors = 256 - let g:solarized_termtrans = 1 + "let g:solarized_termcolors = 256 + "let g:solarized_termtrans = 1 endif colorscheme solarized @@ -236,7 +241,7 @@ " Enable some cool extensions. let g:ctrlp_extensions = [ \'tag', 'buffertag', 'quickfix', 'mixed', 'bookmarkdir', - \'autoignore', 'projectjump' + \'autoignore' \] " }}} @@ -319,7 +324,8 @@ " I'm in. augroup VimRCAutoCWD au! - autocmd BufEnter * call s:SetProjectRootCwd() + autocmd BufReadPost * call s:SetProjectRootCwd(1) + autocmd BufEnter * call s:SetProjectRootCwd(0) augroup END augroup VimRCFileType_markdown @@ -342,7 +348,7 @@ augroup VimRCFileType_c au! - autocmd FileType c,c++ setlocal foldmethod=marker foldmarker={,} + autocmd FileType c,c++,cpp setlocal foldmethod=syntax augroup END augroup VimRCFileType_css @@ -362,7 +368,7 @@ augroup VimRCTrailingWhitespaces au! - autocmd FileType c,cpp,java,php,ruby,python,js,css,less autocmd BufWritePre :call StripTrailingWhitespaces() + autocmd FileType php,ruby,python,js,css,less autocmd BufWritePre :call StripTrailingWhitespaces() augroup END " }}} @@ -443,27 +449,41 @@ " Simple way to close a buffer without closing the window. nnoremap bd :bprevious:bdelete # -" File-type switching. -nnoremap ftmd :set ft=markdown - " Use sane regexes. nnoremap / /\v vnoremap / /\v +" Next/previous quickfix and location messages. +nnoremap ]q :cnextzvzz +nnoremap [q :cpreviouszvzz +nnoremap ]l :lnextzvzz +nnoremap [l :lpreviouszvzz + +" Same with change list. +nnoremap ]] g,zz +nnoremap [[ g;zz + +" Same with diff list. +nnoremap ]c ]czvzz +nnoremap [c [czvzz + " Quick search and replace. function! s:VSetSearch() - let temp = @@ - norm! gvy - let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') - let @@ = temp + let temp = @@ + norm! gvy + let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') + let @@ = temp endfunction vnoremap * :call VSetSearch()// vnoremap # :call VSetSearch()?? +nnoremap fa :vimgrep // +vnoremap fa "zy:vimgrep /z/ + " Jump to tags by keeping things better in view. Option for jumping to a tag " in a split window where everything is folded except what you need to see. function! JumpToTag() - execute "normal! \zz" + execute "normal! \zvzz" endfunction function! JumpToTagInSplit() execute "normal! \v\zMzvzz" @@ -472,19 +492,15 @@ nnoremap :silent! call JumpToTagInSplit() " Keep search matches in the middle of the window. -nnoremap n nzzzv -nnoremap N Nzzzv - -" Same when jumping around -nnoremap g; g;zz -nnoremap g, g,zz +nnoremap n nzvzz +nnoremap N Nzvzz " }}} " Folding {{{ -" Always start with all folds closed. -set foldlevelstart=0 +" Folds are defined by markers in the text. +set foldmethod=marker " Toggle folds with . nnoremap za @@ -535,7 +551,7 @@ set statusline+=) " Line and column position and counts. -set statusline+=\ (line\ %l\/%L,\ col\ %03c) +set statusline+=\ (%l\/%L,%03c) " }}} @@ -566,7 +582,7 @@ let l:previous_cur = '' let l:slash = '/' if has('win32') - let l:slash = '\\' + let l:slash = '\' endif while l:cur != l:previous_cur let l:marker_path = l:cur . l:slash . a:marker @@ -579,25 +595,42 @@ return '' endfunction -function! s:SetProjectRootCwd() abort - let l:cur_file_dir = expand('%:p:h', 1) - if l:cur_file_dir =~ '\v^.+:(//|\\\\)' +function! s:SetProjectRootCwd(recompute) abort + if a:recompute != 1 && exists('b:ludo_workdir') + execute 'lcd!' fnameescape(b:ludo_workdir) return endif - let l:root = l:cur_file_dir + + let l:cur_file_dir = expand('%:p:h', 1) + if l:cur_file_dir =~ '\v^(\w+:)?(//|\\\\)' + " Don't do shit on filenames coming from the network or something. + return + endif + let l:found_root = 0 + let l:root = '' let l:markers = [] if exists('g:ctrlp_root_markers') let l:markers += g:ctrlp_root_markers endif let l:markers += ['.git', '.hg', '.svn', '.bzr', '_darcs'] + let l:unique_markers = [] for marker in l:markers - let l:proj_root = s:FindProjectRoot(l:cur_file_dir, marker) - if l:proj_root != '' - let l:root = l:proj_root - break + if index(l:unique_markers, marker) < 0 + call add(l:unique_markers, marker) endif endfor - execute 'lcd!' fnameescape(l:root) + " Find the project root closest to the current file. + for marker in l:unique_markers + let l:proj_root = s:FindProjectRoot(l:cur_file_dir, marker) + if l:proj_root != '' && len(l:proj_root) > len(l:root) + let l:root = l:proj_root + let l:found_root = 1 + endif + endfor + if l:found_root + let b:ludo_workdir = l:root + execute 'lcd!' fnameescape(l:root) + endif endfunction function! s:ToggleNERDTree() abort