hamster.vim 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. " Vim filetype plugin
  2. " Language: Hamster Script
  3. " Version: 2.0.6.0
  4. " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
  5. " Last Change: 2021 Jan 19
  6. " 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
  7. " Only do this when not done yet for this buffer
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. " Don't load another plugin for this buffer
  12. let b:did_ftplugin = 1
  13. let s:cpo_save = &cpo
  14. set cpo&vim
  15. let b:undo_ftplugin = "setl fo< com< tw< commentstring<"
  16. \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
  17. " Set 'formatoptions' to break comment lines but not other lines,
  18. " and insert the comment leader when hitting <CR> or using "o".
  19. setlocal fo-=t fo+=croql
  20. " Use the # sign for comments
  21. setlocal comments=:#
  22. " Format comments to be up to 78 characters long
  23. if &tw == 0
  24. setlocal tw=78
  25. endif
  26. " Comments start with a double quote
  27. setlocal commentstring=#\ %s
  28. " Move around functions.
  29. noremap <silent><buffer> [[ :call search('^\s*sub\>', "bW")<CR>
  30. noremap <silent><buffer> ]] :call search('^\s*sub\>', "W")<CR>
  31. noremap <silent><buffer> [] :call search('^\s*endsub\>', "bW")<CR>
  32. noremap <silent><buffer> ][ :call search('^\s*endsub\>', "W")<CR>
  33. " Move around comments
  34. noremap <silent><buffer> ]# :call search('^\s*#\@!', "W")<CR>
  35. noremap <silent><buffer> [# :call search('^\s*#\@!', "bW")<CR>
  36. " Let the matchit plugin know what items can be matched.
  37. if exists("loaded_matchit")
  38. let b:match_ignorecase = 0
  39. let b:match_words =
  40. \ '\<sub\>:\<return\>:\<endsub\>,' .
  41. \ '\<do\|while\|repeat\|for\>:\<break\>:\<continue\>:\<loop\|endwhile\|until\|endfor\>,' .
  42. \ '\<if\>:\<else\%[if]\>:\<endif\>'
  43. " Ignore ":syntax region" commands, the 'end' argument clobbers if-endif
  44. " let b:match_skip = 'getline(".") =~ "^\\s*sy\\%[ntax]\\s\\+region" ||
  45. " \ synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string"'
  46. endif
  47. setlocal ignorecase
  48. let &cpo = s:cpo_save
  49. unlet s:cpo_save
  50. " Disabled, 'cpo' is a global option.
  51. " setlocal cpo+=M " makes \%( match \)