blob: ff56166ebe7adc6386b1d31205f36807984985d2 [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
dkearnsf937ab32023-08-29 05:32:27 +10006" 2023 Aug 28 by Vim Project (undo_ftplugin, commentstring)
Bram Moolenaar748bf032005-02-02 23:04:36 +00007
8" Only do this when not done yet for this buffer
9if exists("b:did_ftplugin")
10 finish
11endif
12
13" Don't load another plugin for this buffer
14let b:did_ftplugin = 1
15
Bram Moolenaarf1568ec2011-12-14 21:17:39 +010016let s:cpo_save = &cpo
17set cpo&vim
18
Bram Moolenaar748bf032005-02-02 23:04:36 +000019" Set 'formatoptions' to break comment lines but not other lines,
20" and insert the comment leader when hitting <CR> or using "o".
21"setlocal fo-=t fo+=croqlm1
22
23" Set 'comments' to format dashed lists in comments.
24"setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
25
dkearnsf937ab32023-08-29 05:32:27 +100026setlocal commentstring=--\ %s
27
Bram Moolenaar748bf032005-02-02 23:04:36 +000028" Format comments to be up to 78 characters long
Bram Moolenaarf740b292006-02-16 22:11:02 +000029"setlocal tw=75
Bram Moolenaar748bf032005-02-02 23:04:36 +000030
dkearnsf937ab32023-08-29 05:32:27 +100031" let b:undo_ftplugin = "setl cms< com< fo< tw<"
32
33let b:undo_ftplugin = "setl cms< "
34
Bram Moolenaar748bf032005-02-02 23:04:36 +000035" Win32 can filter files in the browse dialog
36"if has("gui_win32") && !exists("b:browsefilter")
37" let b:browsefilter = "Verilog Source Files (*.v)\t*.v\n" .
38" \ "All Files (*.*)\t*.*\n"
dkearnsf937ab32023-08-29 05:32:27 +100039" let b:undo_ftplugin .= " | unlet! b:browsefilter"
Bram Moolenaar748bf032005-02-02 23:04:36 +000040"endif
41
42" Let the matchit plugin know what items can be matched.
43if ! exists("b:match_words") && exists("loaded_matchit")
44 let b:match_ignorecase=1
45 let s:notend = '\%(\<end\s\+\)\@<!'
Bram Moolenaarf740b292006-02-16 22:11:02 +000046 let b:match_words =
47 \ s:notend.'\<if\>:\<elsif\>:\<else\>:\<end\s\+if\>,'.
48 \ s:notend.'\<case\>:\<when\>:\<end\s\+case\>,'.
49 \ s:notend.'\<loop\>:\<end\s\+loop\>,'.
50 \ s:notend.'\<for\>:\<end\s\+for\>,'.
51 \ s:notend.'\<generate\>:\<end\s\+generate\>,'.
52 \ s:notend.'\<record\>:\<end\s\+record\>,'.
53 \ s:notend.'\<units\>:\<end\s\+units\>,'.
54 \ s:notend.'\<process\>:\<end\s\+process\>,'.
55 \ s:notend.'\<block\>:\<end\s\+block\>,'.
56 \ s:notend.'\<function\>:\<end\s\+function\>,'.
57 \ s:notend.'\<entity\>:\<end\s\+entity\>,'.
58 \ s:notend.'\<component\>:\<end\s\+component\>,'.
59 \ s:notend.'\<architecture\>:\<end\s\+architecture\>,'.
60 \ s:notend.'\<package\>:\<end\s\+package\>,'.
61 \ s:notend.'\<procedure\>:\<end\s\+procedure\>,'.
62 \ s:notend.'\<configuration\>:\<end\s\+configuration\>'
dkearnsf937ab32023-08-29 05:32:27 +100063 let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words"
Bram Moolenaar748bf032005-02-02 23:04:36 +000064endif
Bram Moolenaarf740b292006-02-16 22:11:02 +000065
dkearnsf937ab32023-08-29 05:32:27 +100066if !exists("no_plugin_maps") && !exists("no_vhdl_maps")
67 " count repeat
68 function! <SID>CountWrapper(cmd)
69 let i = v:count1
70 if a:cmd[0] == ":"
71 while i > 0
72 execute a:cmd
73 let i = i - 1
74 endwhile
75 else
76 execute "normal! gv\<Esc>"
77 execute "normal ".i.a:cmd
78 let curcol = col(".")
79 let curline = line(".")
80 normal! gv
81 call cursor(curline, curcol)
82 endif
83 endfunction
Bram Moolenaarf740b292006-02-16 22:11:02 +000084
dkearnsf937ab32023-08-29 05:32:27 +100085 " explore motion
86 " keywords: "architecture", "block", "configuration", "component", "entity", "function", "package", "procedure", "process", "record", "units"
87 let b:vhdl_explore = '\%(architecture\|block\|configuration\|component\|entity\|function\|package\|procedure\|process\|record\|units\)'
88 noremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
89 noremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\%(\\<end\\s\\+\\)\\@<!\\<".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
90 noremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR>
91 noremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR>
92 vnoremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper('[[')<CR>
93 vnoremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(']]')<CR>
94 vnoremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper('[]')<CR>
95 vnoremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper('][')<CR>
96 let b:undo_ftplugin .=
97 \ " | silent! execute 'nunmap <buffer> [['" .
98 \ " | silent! execute 'nunmap <buffer> ]]'" .
99 \ " | silent! execute 'nunmap <buffer> []'" .
100 \ " | silent! execute 'nunmap <buffer> ]['" .
101 \ " | silent! execute 'vunmap <buffer> [['" .
102 \ " | silent! execute 'vunmap <buffer> ]]'" .
103 \ " | silent! execute 'vunmap <buffer> []'" .
104 \ " | silent! execute 'vunmap <buffer> ]['"
105endif
Bram Moolenaarf1568ec2011-12-14 21:17:39 +0100106
107let &cpo = s:cpo_save
108unlet s:cpo_save