Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 1 | " VHDL filetype plugin |
| 2 | " Language: VHDL |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 3 | " Maintainer: R.Shankar <shankar.pec?gmail.com> |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 4 | " Modified By: Gerald Lai <laigera+vim?gmail.com> |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 5 | " Last Change: 2011 Dec 11 |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 6 | " 2023 Aug 28 by Vim Project (undo_ftplugin, commentstring) |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 7 | |
| 8 | " Only do this when not done yet for this buffer |
| 9 | if exists("b:did_ftplugin") |
| 10 | finish |
| 11 | endif |
| 12 | |
| 13 | " Don't load another plugin for this buffer |
| 14 | let b:did_ftplugin = 1 |
| 15 | |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 16 | let s:cpo_save = &cpo |
| 17 | set cpo&vim |
| 18 | |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 19 | " 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 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 26 | setlocal commentstring=--\ %s |
| 27 | |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 28 | " Format comments to be up to 78 characters long |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 29 | "setlocal tw=75 |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 30 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 31 | " let b:undo_ftplugin = "setl cms< com< fo< tw<" |
| 32 | |
| 33 | let b:undo_ftplugin = "setl cms< " |
| 34 | |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 35 | " 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" |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 39 | " let b:undo_ftplugin .= " | unlet! b:browsefilter" |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 40 | "endif |
| 41 | |
| 42 | " Let the matchit plugin know what items can be matched. |
| 43 | if ! exists("b:match_words") && exists("loaded_matchit") |
| 44 | let b:match_ignorecase=1 |
| 45 | let s:notend = '\%(\<end\s\+\)\@<!' |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 46 | 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\>' |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 63 | let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words" |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 64 | endif |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 65 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 66 | if !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 Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 84 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 85 | " 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> ]['" |
| 105 | endif |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 106 | |
| 107 | let &cpo = s:cpo_save |
| 108 | unlet s:cpo_save |