aboutsummaryrefslogtreecommitdiff
path: root/vim.dot.link/filetype.vim
blob: e75d2e050c4a3d3ede824f972bd523bc868aab50 (plain)
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
" Vim support file to detect file types

" Check if file type config is already loaded {{{
if exists("did_load_filetypes")
  finish
endif
" }}}

" Filetype detection {{{
"
" According to ":help BufRead", this augroup is also evaluated also on
" ":filetype detect".
augroup filetypedetect
  autocmd!

  " Calendar
  autocmd BufRead,BufNewFile *.rem       setfiletype remind

  " Trac
  autocmd BufRead,BufNewFile *.trac      setfiletype tracwiki
  autocmd BufRead,BufNewFile *.tracwiki  setfiletype tracwiki

  " Programming languages
  autocmd BufRead,BufNewFile kvmxfile    setfiletype sh
  autocmd BufRead,BufNewFile Vagrantfile setfiletype ruby
  autocmd BufRead,BufNewFile *.py        setfiletype python
  autocmd BufRead,BufNewFile *.pp        setfiletype puppet
  autocmd BufRead,BufNewFile *.php       setfiletype php
  autocmd BufRead,BufNewFile *.thtml     setfiletype php
  autocmd BufRead,BufNewFile *.vue       setfiletype html

  " Markdown
  "
  " This handling is disabled by default, since it leads to some settings on
  " ftplugin/markdown.vim being ignored.
  "
  "autocmd BufRead,BufNewFile,BufEnter *.mdwn setfiletype markdown
  "autocmd BufRead,BufNewFile,BufEnter *.md   setfiletype markdown
augroup END
" }}}

" Markdown workaround {{{
"
" Since the following configuration is not working at ftplugin/markdown.vim,
" it's being used here.
"
" Also note that BufEnter event also need to be included, otherwise foldings
" won't be correctly applied in some Markdown files loaded in new windows.
augroup filetype_markdown
  autocmd!
  "autocmd BufRead,BufNewFile,BufEnter *.md setlocal foldexpr=NestedMarkdownFolds()
  "autocmd BufRead,BufNewFile,BufEnter *.md setlocal autoindent smartindent
  "autocmd BufRead,BufNewFile,BufEnter *.md setlocal formatoptions=tcroqn2 comments=n:>
  autocmd BufRead,BufNewFile,BufEnter  *.md setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab
augroup END
" }}}

" VIM filetype {{{
augroup filetype_vim
  autocmd!
  autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}

" Drupal {{{
" Handle *.module, *.install, *.profile etc
if has("autocmd")
  augroup filetype_drupal
    autocmd!
    autocmd BufRead,BufNewFile,BufEnter *.profile setfiletype php
    autocmd BufRead,BufNewFile,BufEnter *.module  setfiletype php
    autocmd BufRead,BufNewFile,BufEnter *.install setfiletype php
    autocmd BufRead,BufNewFile,BufEnter *.test    setfiletype php
  augroup END
endif
" }}}