verilog.vim 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. " Vim filetype plugin file
  2. " Language: Verilog HDL
  3. " Maintainer: Chih-Tsun Huang <cthuang@cs.nthu.edu.tw>
  4. " Last Change: 2017 Aug 25 by Chih-Tsun Huang
  5. " 2024 Jan 14 by Vim Project (browsefilter)
  6. " 2024 May 20 by Riley Bruins <ribru17@gmail.com> (commentstring)
  7. " URL: http://www.cs.nthu.edu.tw/~cthuang/vim/ftplugin/verilog.vim
  8. "
  9. " Credits:
  10. " Suggestions for improvement, bug reports by
  11. " Shao <shaominghai2005@163.com>
  12. " Only do this when not done yet for this buffer
  13. if exists("b:did_ftplugin")
  14. finish
  15. endif
  16. " Don't load another plugin for this buffer
  17. let b:did_ftplugin = 1
  18. " Set 'cpoptions' to allow line continuations
  19. let s:cpo_save = &cpo
  20. set cpo&vim
  21. " Undo the plugin effect
  22. let b:undo_ftplugin = "setlocal fo< com< tw< cms<"
  23. \ . "| unlet! b:browsefilter b:match_ignorecase b:match_words"
  24. " Set 'formatoptions' to break comment lines but not other lines,
  25. " and insert the comment leader when hitting <CR> or using "o".
  26. setlocal fo-=t fo+=croqlm1
  27. " Set 'comments' to format dashed lists in comments.
  28. setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
  29. setlocal commentstring=//\ %s
  30. " Format comments to be up to 78 characters long
  31. if &textwidth == 0
  32. setlocal tw=78
  33. endif
  34. " Win32 and GTK can filter files in the browse dialog
  35. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  36. let b:browsefilter = "Verilog Source Files (*.v)\t*.v\n"
  37. if has("win32")
  38. let b:browsefilter .= "All Files (*.*)\t*\n"
  39. else
  40. let b:browsefilter .= "All Files (*)\t*\n"
  41. endif
  42. endif
  43. " Let the matchit plugin know what items can be matched.
  44. if exists("loaded_matchit")
  45. let b:match_ignorecase=0
  46. let b:match_words=
  47. \ '\<begin\>:\<end\>,' .
  48. \ '\<case\>\|\<casex\>\|\<casez\>:\<endcase\>,' .
  49. \ '\<module\>:\<endmodule\>,' .
  50. \ '\<if\>:`\@<!\<else\>,' .
  51. \ '\<function\>:\<endfunction\>,' .
  52. \ '`ifn\?def\>:`elsif\>:`else\>:`endif\>,' .
  53. \ '\<task\>:\<endtask\>,' .
  54. \ '\<specify\>:\<endspecify\>,' .
  55. \ '\<config\>:\<endconfig\>,' .
  56. \ '\<generate\>:\<endgenerate\>,' .
  57. \ '\<fork\>:\<join\>,' .
  58. \ '\<primitive\>:\<endprimitive\>,' .
  59. \ '\<table\>:\<endtable\>'
  60. endif
  61. " Reset 'cpoptions' back to the user's setting
  62. let &cpo = s:cpo_save
  63. unlet s:cpo_save