.vim/autoload/vimrc.vim

Mon, 22 May 2017 20:52:28 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 22 May 2017 20:52:28 -0400
changeset 579
0cb7adee16fe
parent 578
3e4703eef23d
child 580
5a9e9be223f0
permissions
-rw-r--r--

move begin into function too

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
579
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
22 function! vimrc#VundleInstallAndBegin() abort
578
3e4703eef23d make on_windows global
Meredith Howard <mhoward@roomag.org>
parents: 574
diff changeset
23 let l:vundle_readme = expand(g:on_windows
574
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
24 \ ? '~/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
25 \ : '~/.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
26
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
27 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
28 if !executable('git')
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
29 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
30 return
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
31 endif
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
32
578
3e4703eef23d make on_windows global
Meredith Howard <mhoward@roomag.org>
parents: 574
diff changeset
33 if g:on_windows == 0
574
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
34 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
35 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
36 else
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
37 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
38 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
39 endif
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
40
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
41 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
42 endif
579
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
43
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
44 if g:on_windows
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
45 set rtp+=~/vimfiles/bundle/vundle/
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
46 call vundle#begin('~/vimfiles/bundle')
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
47 else
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
48 set rtp+=~/.vim/bundle/vundle/
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
49 call vundle#begin()
0cb7adee16fe move begin into function too
Meredith Howard <mhoward@roomag.org>
parents: 578
diff changeset
50 endif
574
3874b97048b0 Move vundle install to func, switch to begin/end vundle interface
Meredith Howard <mhoward@roomag.org>
parents: 470
diff changeset
51 endfunction

mercurial