.vim/autoload/vimrc.vim

Sun, 21 May 2017 23:28:19 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 21 May 2017 23:28:19 -0400
changeset 574
3874b97048b0
parent 470
4c2db769baac
child 578
3e4703eef23d
permissions
-rw-r--r--

Move vundle install to func, switch to begin/end vundle interface

470
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 function! vimrc#AutoFmtToggle() abort
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 if &formatoptions =~ 'a'
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 setl fo-=a
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 echo '-a'
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 else
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7 setl fo+=a
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 echo '+a'
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 endif
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 endfunction
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 " Make paths when writing, as necessary
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 function! vimrc#MkNonExDir(file, buf) abort
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14 if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 let dir=fnamemodify(a:file, ':h')
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 if !isdirectory(dir)
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 call mkdir(dir, 'p')
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 endif
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 endif
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 endfunction
4c2db769baac Move into autoload
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21
574
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
22 function! vimrc#VundleInstall() abort
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
23 " on windows and not cygwin
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
24 let l:on_windows = (has('win32') || has('win64'))
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
25
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
26 let l:vundle_readme = expand(l:on_windows
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
27 \ ? '~/vimfiles/bundle/vundle/README.md'
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
28 \ : '~/.vim/bundle/vundle/README.md')
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
29
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
30 if !filereadable(l:vundle_readme)
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
31 if !executable('git')
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
32 echo "Can't autoinstall Vundle without git"
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
33 return
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
34 endif
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
35
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
36 if l:on_windows == 0
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
37 silent !mkdir -p ~/.vim/bundle
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
38 silent !git clone --depth 1 https://github.com/gmarik/vundle ~/.vim/bundle/vundle
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
39 else
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
40 silent execute '!mkdir "'. $HOME .'\vimfiles\bundle"'
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
41 silent execute '!git clone --depth 1 https://github.com/gmarik/vundle "'. $HOME .'\vimfiles\bundle\vundle"'
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
42 endif
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
43
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
44 echo "Installed Vundle, run :PluginInstall if desired"
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
45 endif
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
46
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
47 endfunction

mercurial