blob: 0249b542be6a86220ccb8d5c5d8290a262626c85 [file] [log] [blame]
Bram Moolenaarf740b292006-02-16 22:11:02 +00001" VHDL filetype plugin
2" Language: VHDL
Bram Moolenaarf1568ec2011-12-14 21:17:39 +01003" Maintainer: R.Shankar <shankar.pec?gmail.com>
Bram Moolenaarf740b292006-02-16 22:11:02 +00004" Modified By: Gerald Lai <laigera+vim?gmail.com>
Bram Moolenaarf1568ec2011-12-14 21:17:39 +01005" Last Change: 2011 Dec 11
Bram Moolenaar748bf032005-02-02 23:04:36 +00006
7" Only do this when not done yet for this buffer
8if exists("b:did_ftplugin")
9 finish
10endif
11
12" Don't load another plugin for this buffer
13let b:did_ftplugin = 1
14
Bram Moolenaarf1568ec2011-12-14 21:17:39 +010015let s:cpo_save = &cpo
16set cpo&vim
17
Bram Moolenaar748bf032005-02-02 23:04:36 +000018" Set 'formatoptions' to break comment lines but not other lines,
19" and insert the comment leader when hitting <CR> or using "o".
20"setlocal fo-=t fo+=croqlm1
21
22" Set 'comments' to format dashed lists in comments.
23"setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
24
25" Format comments to be up to 78 characters long
Bram Moolenaarf740b292006-02-16 22:11:02 +000026"setlocal tw=75
Bram Moolenaar748bf032005-02-02 23:04:36 +000027
Bram Moolenaar748bf032005-02-02 23:04:36 +000028" Win32 can filter files in the browse dialog
29"if has("gui_win32") && !exists("b:browsefilter")
30" let b:browsefilter = "Verilog Source Files (*.v)\t*.v\n" .
31" \ "All Files (*.*)\t*.*\n"
32"endif
33
34" Let the matchit plugin know what items can be matched.
35if ! exists("b:match_words") && exists("loaded_matchit")
36 let b:match_ignorecase=1
37 let s:notend = '\%(\<end\s\+\)\@<!'
Bram Moolenaarf740b292006-02-16 22:11:02 +000038 let b:match_words =
39 \ s:notend.'\<if\>:\<elsif\>:\<else\>:\<end\s\+if\>,'.
40 \ s:notend.'\<case\>:\<when\>:\<end\s\+case\>,'.
41 \ s:notend.'\<loop\>:\<end\s\+loop\>,'.
42 \ s:notend.'\<for\>:\<end\s\+for\>,'.
43 \ s:notend.'\<generate\>:\<end\s\+generate\>,'.
44 \ s:notend.'\<record\>:\<end\s\+record\>,'.
45 \ s:notend.'\<units\>:\<end\s\+units\>,'.
46 \ s:notend.'\<process\>:\<end\s\+process\>,'.
47 \ s:notend.'\<block\>:\<end\s\+block\>,'.
48 \ s:notend.'\<function\>:\<end\s\+function\>,'.
49 \ s:notend.'\<entity\>:\<end\s\+entity\>,'.
50 \ s:notend.'\<component\>:\<end\s\+component\>,'.
51 \ s:notend.'\<architecture\>:\<end\s\+architecture\>,'.
52 \ s:notend.'\<package\>:\<end\s\+package\>,'.
53 \ s:notend.'\<procedure\>:\<end\s\+procedure\>,'.
54 \ s:notend.'\<configuration\>:\<end\s\+configuration\>'
Bram Moolenaar748bf032005-02-02 23:04:36 +000055endif
Bram Moolenaarf740b292006-02-16 22:11:02 +000056
57" count repeat
58function! <SID>CountWrapper(cmd)
59 let i = v:count1
60 if a:cmd[0] == ":"
61 while i > 0
62 execute a:cmd
63 let i = i - 1
64 endwhile
65 else
66 execute "normal! gv\<Esc>"
67 execute "normal ".i.a:cmd
68 let curcol = col(".")
69 let curline = line(".")
70 normal! gv
71 call cursor(curline, curcol)
72 endif
73endfunction
74
75" explore motion
76" keywords: "architecture", "block", "configuration", "component", "entity", "function", "package", "procedure", "process", "record", "units"
77let b:vhdl_explore = '\%(architecture\|block\|configuration\|component\|entity\|function\|package\|procedure\|process\|record\|units\)'
78noremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
79noremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
80noremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
81noremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
82vnoremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper('[[')<CR>
83vnoremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(']]')<CR>
84vnoremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper('[]')<CR>
85vnoremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper('][')<CR>
Bram Moolenaarf1568ec2011-12-14 21:17:39 +010086
87let &cpo = s:cpo_save
88unlet s:cpo_save