-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
146 lines (117 loc) Β· 3.55 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
"**********************************
" Skyler Spaeth's .vimrc (v1.0)
" github.com/skylerspaeth/DotFiles
"**********************************
"Use normal backspace behavior:
set nocompatible
set backspace=2
"Make vim pretty:
set background=dark
syntax on
syntax sync minlines=20
colorscheme PaperColor
"Install plugin(s) if VimPlug is setup
if !empty(globpath(&rtp, 'autoload/plug.vim'))
filetype plugin indent on
call plug#begin()
Plug 'chemzqm/vim-jsx-improve'
Plug 'ap/vim-css-color'
Plug 'hashivim/vim-terraform'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()
endif
"Language-specific customizations:
"For Terraform:
function Tfmt()
execute '%!terraform fmt -no-color -'
endfunction
"For Jenkinsfiles:
autocmd BufNewFile,BufRead Jenkinsfile setf groovy
"For *.hbs:
autocmd BufNewFile,BufRead *.handlebars,*.hbs set filetype=html
"For *.js:
autocmd FileType javascript setlocal ts=2 sts=2 sw=2
"For *.jsx:
autocmd FileType javascriptreact setlocal sts=2 sts=2 sw=2
"For *.sh:
autocmd FileType sh setlocal sts=2 sts=2 sw=2
"Disable error bells:
set noerrorbells
set belloff=all
set number
set nowrap
set relativenumber
set cursorline
set nohlsearch
"Insert spaces when tab key is pressed, preventing
"spaces from becoming tabs outside the editor:
set expandtab
"Indent automatically when making new lines:
set autoindent
"Use spaces for tabs globally:
set ts=2
set sts=2
set sw=2
"Always show filename:
set laststatus=2
set statusline=
set statusline+=%9*
set statusline+=\
set statusline+=%f
set statusline+=\
set statusline+=%m
set statusline+=%=
set statusline+=%1*
set statusline+=\
set statusline+=%{b:gitbranch}
set statusline+=\
set statusline+=%9*
set statusline+=\
hi User1 ctermbg=213 ctermfg=white guibg=black guifg=white
hi User9 ctermbg=098 ctermfg=white guibg=black guifg=white
function! StatuslineGitBranch()
let b:gitbranch=""
if &modifiable
try
let l:dir=expand('%:p:h')
let b:gitbranch = system('local headfile head branch; local dir="$PWD"; while [ -n "$dir" ]; do if [ -e "$dir/.git/HEAD" ]; then; headfile="$dir/.git/HEAD"; break; fi; dir="${dir%/*}"; done; if [ -e "$headfile" ]; then; read -r head < "$headfile" || return; case "$head" in ref:*) branch="${head##*/}" ;; "") branch="" ;; *) branch="${head:0:7}" ;; esac; fi; if [ -z "$branch" ]; then return 0; fi; printf "$branch"')
" this is still a wip
" if empty(b:gitbranch)
" b:gitbranch = system('echo not a git branch')
" endif
catch
endtry
endif
endfunction
augroup GetGitBranch
autocmd!
autocmd VimEnter,WinEnter,BufEnter * call StatuslineGitBranch()
augroup END
"Window resizing for Mac (special chars generated by keystrokes):
if has('macunix')
"Horizontal resize binds:
"opt + equals:
nnoremap β :res +5<CR>
"opt + minus:
nnoremap β :res -5<CR>
"Vertical resize binds:
"shift + equals (+):
nnoremap + :vert res +5<CR>
"shift + minus (_):
nnoremap _ :vert res -5<CR>
"Font size override for MacVim:
set guifont=Menlo\ Regular:h18
endif
"Really delete (send contents to blackhole register)
"from https://stackoverflow.com/a/3641942/3291472:
nnoremap R "_d
"Bind F2 to refresh syntax highlighting
map <F2> :syntax sync fromstart<CR>
syntax sync fromstart
"Make fold views save and load automatically
autocmd BufWinLeave *.*,Jenkinsfile mkview
autocmd BufWinEnter *.*,Jenkinsfile silent loadview
"Disable autocommenting when on another comment line (helpful for shebang)
autocmd BufNewFile,BufRead * setlocal formatoptions-=cro
"Register length fix
set viminfo='20,<1000