.config/nvim/autoload/vimrc.vim

changeset 1076
15007f695dfb
parent 1022
d509e282ae10
child 1078
aa4c1aa529a5
equal deleted inserted replaced
1075:3b88450bda15 1076:15007f695dfb
5 func! vimrc#AutoFmtToggle() abort 5 func! vimrc#AutoFmtToggle() abort
6 if &formatoptions =~# 'a' 6 if &formatoptions =~# 'a'
7 setl formatoptions-=a | echo '-a' 7 setl formatoptions-=a | echo '-a'
8 else 8 else
9 setl formatoptions+=a | echo '+a' 9 setl formatoptions+=a | echo '+a'
10 endif
11 endfunc
12
13 " Make paths when writing, as necessary
14 func! vimrc#MkNonExDir(file, buf) abort
15 if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
16 let dir=fnamemodify(a:file, ':h')
17 if !isdirectory(dir)
18 call mkdir(dir, 'p')
19 endif
20 endif
21 endfunc
22
23 func! vimrc#AutoSessionCheck() abort
24 if strlen(v:servername) > 0 && match(v:servername, 'VIM') == -1
25 let sessionfile = g:vimcache . "/session/" . tolower(v:servername) . ".vim"
26
27 if filereadable(sessionfile)
28 execute "source " . sessionfile
29 endif
30 endif 10 endif
31 endfunc 11 endfunc
32 12
33 func! vimrc#Grep(...) abort 13 func! vimrc#Grep(...) abort
34 let pattern = get(a:000, 0, expand('<cword>')) 14 let pattern = get(a:000, 0, expand('<cword>'))
87 unless $curbuf->Name; 67 unless $curbuf->Name;
88 END_PERL 68 END_PERL
89 endfunc 69 endfunc
90 endif 70 endif
91 71
92 func! vimrc#PrepDir(path) abort
93 if !filewritable(a:path)
94 call mkdir(a:path, 'p', 0700)
95 endif
96 endfunc
97
98 if has('ruby') 72 if has('ruby')
99 func! s:PruneFiles(path, days) abort 73 func! s:PruneFiles(path, days) abort
100 ruby <<END_RUBY 74 ruby <<END_RUBY
101 require 'pathname' 75 require 'pathname'
102 76

mercurial