vhdl.vim 3.4 KB

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