hamster.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: 2017 Mar 18
  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. let b:undo_ftplugin = "setl fo< com< tw< commentstring<"
  15. \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
  16. " Set 'formatoptions' to break comment lines but not other lines,
  17. " and insert the comment leader when hitting <CR> or using "o".
  18. setlocal fo-=t fo+=croql
  19. " Use the # sign for comments
  20. setlocal comments=:#
  21. " Format comments to be up to 78 characters long
  22. if &tw == 0
  23. setlocal tw=78
  24. endif
  25. " Comments start with a double quote
  26. setlocal commentstring=#%s
  27. " Move around functions.
  28. noremap <silent><buffer> [[ :call search('^\s*sub\>', "bW")<CR>
  29. noremap <silent><buffer> ]] :call search('^\s*sub\>', "W")<CR>
  30. noremap <silent><buffer> [] :call search('^\s*endsub\>', "bW")<CR>
  31. noremap <silent><buffer> ][ :call search('^\s*endsub\>', "W")<CR>
  32. " Move around comments
  33. noremap <silent><buffer> ]# :call search('^\s*#\@!', "W")<CR>
  34. noremap <silent><buffer> [# :call search('^\s*#\@!', "bW")<CR>
  35. " Let the matchit plugin know what items can be matched.
  36. if exists("loaded_matchit")
  37. let b:match_ignorecase = 0
  38. let b:match_words =
  39. \ '\<sub\>:\<return\>:\<endsub\>,' .
  40. \ '\<do\|while\|repeat\|for\>:\<break\>:\<continue\>:\<loop\|endwhile\|until\|endfor\>,' .
  41. \ '\<if\>:\<else\%[if]\>:\<endif\>'
  42. " Ignore ":syntax region" commands, the 'end' argument clobbers if-endif
  43. " let b:match_skip = 'getline(".") =~ "^\\s*sy\\%[ntax]\\s\\+region" ||
  44. " \ synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string"'
  45. endif
  46. setlocal ignorecase
  47. let &cpo = s:cpo_save
  48. unlet s:cpo_save
  49. setlocal cpo+=M " makes \%( match \)