Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin |
| 2 | " Language: Vim |
| 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | f0b03c4 | 2017-12-17 17:17:07 +0100 | [diff] [blame] | 4 | " Last Change: 2017 Dec 05 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | |
| 6 | " Only do this when not done yet for this buffer |
| 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
| 10 | |
| 11 | " Don't load another plugin for this buffer |
| 12 | let b:did_ftplugin = 1 |
| 13 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 14 | let s:cpo_save = &cpo |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 15 | set cpo-=C |
| 16 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 17 | let b:undo_ftplugin = "setl fo< isk< com< tw< commentstring<" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 18 | \ . "| 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". |
| 22 | setlocal fo-=t fo+=croql |
| 23 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 24 | " To allow tag lookup via CTRL-] for autoload functions, '#' must be a |
| 25 | " keyword character. E.g., for netrw#Nread(). |
| 26 | setlocal isk+=# |
| 27 | |
Bram Moolenaar | 7f2e9d7 | 2017-11-11 20:58:53 +0100 | [diff] [blame] | 28 | " Use :help to lookup the keyword under the cursor with K. |
| 29 | setlocal keywordprg=:help |
| 30 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 31 | " Set 'comments' to format dashed lists in comments |
| 32 | setlocal com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" |
| 33 | |
| 34 | " Format comments to be up to 78 characters long |
| 35 | if &tw == 0 |
| 36 | setlocal tw=78 |
| 37 | endif |
| 38 | |
| 39 | " Comments start with a double quote |
| 40 | setlocal commentstring=\"%s |
| 41 | |
Bram Moolenaar | f0b03c4 | 2017-12-17 17:17:07 +0100 | [diff] [blame] | 42 | if !exists("no_plugin_maps") && !exists("no_vim_maps") |
| 43 | " Move around functions. |
| 44 | nnoremap <silent><buffer> [[ m':call search('^\s*fu\%[nction]\>', "bW")<CR> |
| 45 | vnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('^\s*fu\%[nction]\>', "bW")<CR> |
| 46 | nnoremap <silent><buffer> ]] m':call search('^\s*fu\%[nction]\>', "W")<CR> |
| 47 | vnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('^\s*fu\%[nction]\>', "W")<CR> |
| 48 | nnoremap <silent><buffer> [] m':call search('^\s*endf*\%[unction]\>', "bW")<CR> |
| 49 | vnoremap <silent><buffer> [] m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "bW")<CR> |
| 50 | nnoremap <silent><buffer> ][ m':call search('^\s*endf*\%[unction]\>', "W")<CR> |
| 51 | vnoremap <silent><buffer> ][ m':<C-U>exe "normal! gv"<Bar>call search('^\s*endf*\%[unction]\>', "W")<CR> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 52 | |
Bram Moolenaar | f0b03c4 | 2017-12-17 17:17:07 +0100 | [diff] [blame] | 53 | " Move around comments |
| 54 | nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> |
| 55 | vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> |
| 56 | nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> |
| 57 | vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> |
| 58 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 59 | |
| 60 | " Let the matchit plugin know what items can be matched. |
| 61 | if exists("loaded_matchit") |
| 62 | let b:match_ignorecase = 0 |
| 63 | let b:match_words = |
| 64 | \ '\<fu\%[nction]\>:\<retu\%[rn]\>:\<endf\%[unction]\>,' . |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 65 | \ '\<\(wh\%[ile]\|for\)\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<end\(w\%[hile]\|fo\%[r]\)\>,' . |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 66 | \ '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,' . |
| 67 | \ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' . |
| 68 | \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' . |
| 69 | \ '(:)' |
Bram Moolenaar | 6e93246 | 2014-09-09 18:48:09 +0200 | [diff] [blame] | 70 | " Ignore syntax region commands and settings, any 'en*' would clobber |
| 71 | " if-endif. |
| 72 | " - set spl=de,en |
| 73 | " - au! FileType javascript syntax region foldBraces start=/{/ end=/}/ … |
| 74 | let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") |
| 75 | \ =~? "comment\\|string\\|vimSynReg\\|vimSet"' |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 76 | endif |
| 77 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 78 | let &cpo = s:cpo_save |
| 79 | unlet s:cpo_save |
Bram Moolenaar | 26a60b4 | 2005-02-22 08:49:11 +0000 | [diff] [blame] | 80 | |
| 81 | " removed this, because 'cpoptions' is a global option. |
| 82 | " setlocal cpo+=M " makes \%( match \) |