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