# HG changeset patch # User Steve Losh # Date 1552498422 14400 # Node ID ba6a5cb2dc59902a2ed65f60b889e86cd81e39e3 # Parent 80f5ec3932ae23936bf69b0de735a9ab6d8d8149 Go folding and more diff -r 80f5ec3932ae -r ba6a5cb2dc59 bin/cal --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/cal Wed Mar 13 13:33:42 2019 -0400 @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +ncal -Mb "$@" diff -r 80f5ec3932ae -r ba6a5cb2dc59 vim/vimrc --- a/vim/vimrc Tue Mar 12 12:24:28 2019 -0400 +++ b/vim/vimrc Wed Mar 13 13:33:42 2019 -0400 @@ -1404,11 +1404,33 @@ " }}} " Go {{{ +function! GetGoFold(lnum) + let line = getline(a:lnum) + let prev = getline(a:lnum-1) + + if line =~# '\v^//' + if prev =~# '\v^//' + return '1' + else + return '>1' + endif + elseif line =~# '\v^\S.*[{(]$' + return '>1' + elseif line =~#'\v^[})]$' + return '1' + elseif line == "" && prev =~#'\v^[})]$' + return '<1' + else + return '=' + endif +endfunction + augroup ft_go au! au FileType go setlocal shiftwidth=8 - au FileType go setlocal foldmethod=syntax + au FileType go setlocal foldmethod=expr + au FileType go setlocal foldexpr=GetGoFold(v:lnum) au FileType go nnoremap M :GoDoc au FileType go nnoremap t :GoInfo au FileType go nnoremap h :GoDocBrowser @@ -1416,6 +1438,7 @@ " this language is incredible au FileType go iabbrev ernil if err != nil {return nil, errjA + au FileType go iabbrev erpan if err != nil {panic(err)jA augroup END " }}}