-
Notifications
You must be signed in to change notification settings - Fork 1
/
filetype.vim
87 lines (76 loc) · 3.63 KB
/
filetype.vim
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
" whitespace formatting {{{
" defined by language
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
autocmd FileType markdown setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType go setlocal noexpandtab
" hugo
autocmd BufRead layouts/*.html setfiletype gohtmltmpl
" autocmd BufRead content/*.md setfiletype gomarkdown
" Turn spell check on for documents (and code comments).
let s:spell_types = [
\ 'css',
\ 'cpanchanges',
\ 'gitcommit',
\ 'html',
\ 'markdown',
\ 'rst',
\ 'ruby',
\ 'scss',
\ ]
exe "autocmd FileType " . join(s:spell_types, ',') . " setlocal spell spelllang=en_us"
" }}}
" custom file types {{{
autocmd BufNewFile,BufRead *.bb setf clojure " babashka
autocmd BufNewFile,BufRead *.csv setf csv
autocmd BufNewFile,BufRead .env.* setf sh
autocmd BufNewFile,BufRead *.fnl setf lisp " fennel
autocmd BufNewFile,BufRead .gitignore setf gitignore
autocmd BufNewFile,BufRead *.hx setf haxe
autocmd BufReadPost Jenkinsfile* setf groovy
autocmd BufNewFile,BufRead *.joke,.joker setf joker
autocmd BufNewFile,BufRead *.imap setf mail
autocmd BufNewFile,BufRead *.inputrc,.inputrc* setf readline
autocmd BufRead *.md setf markdown
autocmd BufRead *.npmrc setf dosini
autocmd BufNewFile,BufRead *.pshrc,*.psgi setf perl
autocmd BufNewFile,BufRead *.porklog setf porklog
autocmd BufNewFile,BufRead *.rxml,*.rake,*.irbrc,.irbrc,.irb_history setf ruby
autocmd BufNewFile,BufRead Vagrantfile,_Vagrantfile setf ruby
autocmd BufNewFile,BufRead *.sc setf scala
autocmd BufNewFile,BufRead *.screenrc,.screenrc* setf screen
autocmd BufNewFile,BufRead tox.ini setf cfg
autocmd BufNewFile,BufRead *.tsx setf typescript
autocmd BufNewFile,BufRead *.wsgi setf python
autocmd BufRead * call SetFiletypeFromShebang(getline(1))
if !exists("g:filetypeFromShebang")
let g:filetypeFromShebang = {
\ 'bb': 'clojure',
\ 'joker': 'joker',
\ 'plackup': 'perl',
\ }
function SetFiletypeFromShebang(line)
let l:parts = split(a:line, " ")
if len(l:parts) > 1 && l:parts[0] == "#!/usr/bin/env"
let l:base = fnamemodify(l:parts[1], ":t")
let l:ft = get(g:filetypeFromShebang, l:base, "")
if l:ft != ""
exe "setf " l:ft
end
end
endfunction
endif
" fake one, just color it a little bit
autocmd BufNewFile,BufRead CHANGELOG,HACKING,INSTALL,README,README.txt,TODO call s:setfReadme()
func! s:setfReadme()
if getline(1) == '---'
setf yaml
else
setf readme
endif
endfunc
" }}}
" try again, w/o the .extra_extension at the end
"autocmd BufNewFile,BufRead *.svn-base,*.bak,*.bkp let f = expand("<amatch>") | exe "doautocmd BufNewFile,BufRead " . f[:strridx(f, ".")-1]
" warn me when editing a file that doesn't have a modeline
" (need to escape the backslashes)
"autocmd FileType * if join(getline(1,2)) !~ "vim:\\s*set\\s.\\+:" | echohl ToDo | echomsg "Vim modeline not found at the top" | echohl None | endif