-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc.autocmd
94 lines (72 loc) · 2.95 KB
/
.vimrc.autocmd
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
autocmd vimenter * NERDTree
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType java set omnifunc=javacomplete#Complete
"autocmd FileType go set omnifunc=gocomplete#Complete
autocmd FileType go set list!
" Save when losing focus
au FocusLost * :silent! wall
" Resize splits when the window is resized
au VimResized * :wincmd =
" Make sure Vim returns to the same line when you reopen a file.
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
augroup vimrcAu
" Clear!
au!
autocmd Syntax javascript setlocal isk+=$
" Things that use two spaces rather than four
au BufRead,BufNewFile *.rb,*.rhtml set sw=2 sts=2
au BufRead,BufNewFile *.js set sw=2 sts=2
au BufRead,BufNewFile *.ts set sw=2 sts=2 expandtab
au BufRead,BufNewFile *tsx,*.jsx,*.vue set sw=2 sts=2
au BufRead,BufNewFile *.html set sw=2 sts=2
au BufRead,BufNewFile *.go set sw=4 sts=4
au BufRead,BufNewFile *.go set noexpandtab
" set filetypes as typescriptreact
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescriptreact
autocmd BufNewFile,BufRead *.ts set filetype=typescript
" Go setup assumptions: golint, gocode, gotags all in path
"au BufRead,BufNewFile *.go set noexpandtab sw=4 sts=4 syntax=go listchars=tab:\|\ ,trail:- " Go uses tabs
"au BufWritePre *.go Fmt
"au BufWritePost,FileWritePost *.go execute 'Lint' | cwindow
let g:ale_linters = {
\ 'javascript': ['eslint'],
\}
au BufRead,BufNewFile MakeFile,Makefile,makefile set noexpandtab sw=8 sts=8 syntax=make listchars=tab:\|\ ,trail:- " so does make
" Override types
au BufNewFile,BufRead *.ahk set filetype=ahk " Autohotkey
au BufNewFile,BufRead *.ps1 set filetype=ps1 " Powershell
au BufNewFile,BufRead *.md set filetype=markdown spell " Markdown and spelling on
au BufNewFile,BufRead *.dtl set filetype=htmldjango " Django Templates
au BufNewFile,BufRead *.ejs set filetype=html
autocmd FileType vue syntax sync fromstart
au BufRead,BufNewFile *.md set filetype=markdown
augroup END
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.html :call DeleteTrailingWS()
autocmd BufWrite *.js :call DeleteTrailingWS()
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
autocmd BufWrite *.jsx :call DeleteTrailingWS()