blob: 1f2e57c6752eceba3bd605209b69eedaa30cbc70 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin
2" Language: Vim
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar7f2e9d72017-11-11 20:58:53 +01004" Last Change: 2017 Nov 06
Bram Moolenaar071d4272004-06-13 20:20:40 +00005
6" Only do this when not done yet for this buffer
7if exists("b:did_ftplugin")
8 finish
9endif
10
11" Don't load another plugin for this buffer
12let b:did_ftplugin = 1
13
Bram Moolenaar5c736222010-01-06 20:54:52 +010014let s:cpo_save = &cpo
Bram Moolenaar071d4272004-06-13 20:20:40 +000015set cpo-=C
16
Bram Moolenaar5c736222010-01-06 20:54:52 +010017let b:undo_ftplugin = "setl fo< isk< com< tw< commentstring<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000018 \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
19
20" Set 'formatoptions' to break comment lines but not other lines,
21" and insert the comment leader when hitting <CR> or using "o".
22setlocal fo-=t fo+=croql
23
Bram Moolenaar5c736222010-01-06 20:54:52 +010024" To allow tag lookup via CTRL-] for autoload functions, '#' must be a
25" keyword character. E.g., for netrw#Nread().
26setlocal isk+=#
27
Bram Moolenaar7f2e9d72017-11-11 20:58:53 +010028" Use :help to lookup the keyword under the cursor with K.
29setlocal keywordprg=:help
30
Bram Moolenaar071d4272004-06-13 20:20:40 +000031" Set 'comments' to format dashed lists in comments
32setlocal com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\"
33
34" Format comments to be up to 78 characters long
35if &tw == 0
36 setlocal tw=78
37endif
38
39" Comments start with a double quote
40setlocal commentstring=\"%s
41
42" Move around functions.
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000043nnoremap <silent><buffer> [[ m':call search('^\s*fu\%[nction]\>', "bW")<CR>
44vnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('^\s*fu\%[nction]\>', "bW")<CR>
45nnoremap <silent><buffer> ]] m':call search('^\s*fu\%[nction]\>', "W")<CR>
46vnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('^\s*fu\%[nction]\>', "W")<CR>
47nnoremap <silent><buffer> [] m':call search('^\s*endf*\%[unction]\>', "bW")<CR>
48vnoremap <silent><buffer> [] m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "bW")<CR>
49nnoremap <silent><buffer> ][ m':call search('^\s*endf*\%[unction]\>', "W")<CR>
50vnoremap <silent><buffer> ][ m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "W")<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +000051
52" Move around comments
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000053nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
54vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
55nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
56vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
58" Let the matchit plugin know what items can be matched.
59if exists("loaded_matchit")
60 let b:match_ignorecase = 0
61 let b:match_words =
62 \ '\<fu\%[nction]\>:\<retu\%[rn]\>:\<endf\%[unction]\>,' .
Bram Moolenaar5c736222010-01-06 20:54:52 +010063 \ '\<\(wh\%[ile]\|for\)\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<end\(w\%[hile]\|fo\%[r]\)\>,' .
Bram Moolenaar071d4272004-06-13 20:20:40 +000064 \ '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,' .
65 \ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' .
66 \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' .
67 \ '(:)'
Bram Moolenaar6e932462014-09-09 18:48:09 +020068 " Ignore syntax region commands and settings, any 'en*' would clobber
69 " if-endif.
70 " - set spl=de,en
71 " - au! FileType javascript syntax region foldBraces start=/{/ end=/}/
72 let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name")
73 \ =~? "comment\\|string\\|vimSynReg\\|vimSet"'
Bram Moolenaar071d4272004-06-13 20:20:40 +000074endif
75
Bram Moolenaar5c736222010-01-06 20:54:52 +010076let &cpo = s:cpo_save
77unlet s:cpo_save
Bram Moolenaar26a60b42005-02-22 08:49:11 +000078
79" removed this, because 'cpoptions' is a global option.
80" setlocal cpo+=M " makes \%( match \)