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 |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 6 | " 2024 Jan 14 by Vim Project (browsefilter) |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 7 | " 2023 Aug 28 by Vim Project (undo_ftplugin, commentstring) |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 8 | |
| 9 | " Only do this when not done yet for this buffer |
| 10 | if exists("b:did_ftplugin") |
| 11 | finish |
| 12 | endif |
| 13 | |
| 14 | " Don't load another plugin for this buffer |
| 15 | let b:did_ftplugin = 1 |
| 16 | |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 17 | let s:cpo_save = &cpo |
| 18 | set cpo&vim |
| 19 | |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 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+=croqlm1 |
| 23 | |
| 24 | " Set 'comments' to format dashed lists in comments. |
| 25 | "setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// |
| 26 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 27 | setlocal commentstring=--\ %s |
| 28 | |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 29 | " Format comments to be up to 78 characters long |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 30 | "setlocal tw=75 |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 31 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 32 | let b:undo_ftplugin = "setl cms< " |
| 33 | |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 34 | " Win32 and GTK can filter files in the browse dialog |
| 35 | "if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
| 36 | " if has("win32") |
| 37 | " let b:browsefilter ..= "All Files (*.*)\t*\n" |
| 38 | " else |
| 39 | " let b:browsefilter ..= "All Files (*)\t*\n" |
| 40 | " endif |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 41 | " let b:undo_ftplugin .= " | unlet! b:browsefilter" |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 42 | "endif |
| 43 | |
| 44 | " Let the matchit plugin know what items can be matched. |
| 45 | if ! exists("b:match_words") && exists("loaded_matchit") |
| 46 | let b:match_ignorecase=1 |
| 47 | let s:notend = '\%(\<end\s\+\)\@<!' |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 48 | let b:match_words = |
| 49 | \ s:notend.'\<if\>:\<elsif\>:\<else\>:\<end\s\+if\>,'. |
| 50 | \ s:notend.'\<case\>:\<when\>:\<end\s\+case\>,'. |
| 51 | \ s:notend.'\<loop\>:\<end\s\+loop\>,'. |
| 52 | \ s:notend.'\<for\>:\<end\s\+for\>,'. |
| 53 | \ s:notend.'\<generate\>:\<end\s\+generate\>,'. |
| 54 | \ s:notend.'\<record\>:\<end\s\+record\>,'. |
| 55 | \ s:notend.'\<units\>:\<end\s\+units\>,'. |
| 56 | \ s:notend.'\<process\>:\<end\s\+process\>,'. |
| 57 | \ s:notend.'\<block\>:\<end\s\+block\>,'. |
| 58 | \ s:notend.'\<function\>:\<end\s\+function\>,'. |
| 59 | \ s:notend.'\<entity\>:\<end\s\+entity\>,'. |
| 60 | \ s:notend.'\<component\>:\<end\s\+component\>,'. |
| 61 | \ s:notend.'\<architecture\>:\<end\s\+architecture\>,'. |
| 62 | \ s:notend.'\<package\>:\<end\s\+package\>,'. |
| 63 | \ s:notend.'\<procedure\>:\<end\s\+procedure\>,'. |
| 64 | \ s:notend.'\<configuration\>:\<end\s\+configuration\>' |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 65 | let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words" |
Bram Moolenaar | 748bf03 | 2005-02-02 23:04:36 +0000 | [diff] [blame] | 66 | endif |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 67 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 68 | if !exists("no_plugin_maps") && !exists("no_vhdl_maps") |
| 69 | " count repeat |
| 70 | function! <SID>CountWrapper(cmd) |
| 71 | let i = v:count1 |
| 72 | if a:cmd[0] == ":" |
| 73 | while i > 0 |
| 74 | execute a:cmd |
| 75 | let i = i - 1 |
| 76 | endwhile |
| 77 | else |
| 78 | execute "normal! gv\<Esc>" |
| 79 | execute "normal ".i.a:cmd |
| 80 | let curcol = col(".") |
| 81 | let curline = line(".") |
| 82 | normal! gv |
| 83 | call cursor(curline, curcol) |
| 84 | endif |
| 85 | endfunction |
Bram Moolenaar | f740b29 | 2006-02-16 22:11:02 +0000 | [diff] [blame] | 86 | |
dkearns | f937ab3 | 2023-08-29 05:32:27 +1000 | [diff] [blame] | 87 | " explore motion |
| 88 | " keywords: "architecture", "block", "configuration", "component", "entity", "function", "package", "procedure", "process", "record", "units" |
| 89 | let b:vhdl_explore = '\%(architecture\|block\|configuration\|component\|entity\|function\|package\|procedure\|process\|record\|units\)' |
| 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 | noremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%^","bW")')<CR> |
| 93 | noremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper(':cal search("\\%(--.*\\)\\@<!\\<end\\s\\+".b:vhdl_explore."\\>\\c\\<Bar>\\%$","W")')<CR> |
| 94 | vnoremap <buffer><silent>[[ :<C-u>cal <SID>CountWrapper('[[')<CR> |
| 95 | vnoremap <buffer><silent>]] :<C-u>cal <SID>CountWrapper(']]')<CR> |
| 96 | vnoremap <buffer><silent>[] :<C-u>cal <SID>CountWrapper('[]')<CR> |
| 97 | vnoremap <buffer><silent>][ :<C-u>cal <SID>CountWrapper('][')<CR> |
| 98 | let b:undo_ftplugin .= |
| 99 | \ " | silent! execute 'nunmap <buffer> [['" . |
| 100 | \ " | silent! execute 'nunmap <buffer> ]]'" . |
| 101 | \ " | silent! execute 'nunmap <buffer> []'" . |
| 102 | \ " | silent! execute 'nunmap <buffer> ]['" . |
| 103 | \ " | silent! execute 'vunmap <buffer> [['" . |
| 104 | \ " | silent! execute 'vunmap <buffer> ]]'" . |
| 105 | \ " | silent! execute 'vunmap <buffer> []'" . |
| 106 | \ " | silent! execute 'vunmap <buffer> ]['" |
| 107 | endif |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 108 | |
| 109 | let &cpo = s:cpo_save |
| 110 | unlet s:cpo_save |