blob: 904f267fdc69d2f5c453c691373366f710e320c9 [file] [log] [blame]
Bram Moolenaar9964e462007-05-05 17:54:07 +00001" Vim filetype plugin
2" Language: Hamster Script
3" Version: 2.0.6.0
Bram Moolenaar036986f2017-03-16 17:41:02 +01004" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
Bram Moolenaare0e39172021-01-25 21:14:57 +01005" Last Change: 2021 Jan 19
Riley Bruins0a083062024-06-03 20:40:45 +02006" 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
Bram Moolenaar9964e462007-05-05 17:54:07 +00007
8" Only do this when not done yet for this buffer
9if exists("b:did_ftplugin")
10 finish
11endif
12
13" Don't load another plugin for this buffer
14let b:did_ftplugin = 1
15
Bram Moolenaar84f72352012-03-11 15:57:40 +010016let s:cpo_save = &cpo
Bram Moolenaar036986f2017-03-16 17:41:02 +010017set cpo&vim
Bram Moolenaar9964e462007-05-05 17:54:07 +000018
19let 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".
24setlocal fo-=t fo+=croql
25
26" Use the # sign for comments
27setlocal comments=:#
28
29" Format comments to be up to 78 characters long
30if &tw == 0
31 setlocal tw=78
32endif
33
34" Comments start with a double quote
Riley Bruins0a083062024-06-03 20:40:45 +020035setlocal commentstring=#\ %s
Bram Moolenaar9964e462007-05-05 17:54:07 +000036
37" Move around functions.
38noremap <silent><buffer> [[ :call search('^\s*sub\>', "bW")<CR>
39noremap <silent><buffer> ]] :call search('^\s*sub\>', "W")<CR>
40noremap <silent><buffer> [] :call search('^\s*endsub\>', "bW")<CR>
41noremap <silent><buffer> ][ :call search('^\s*endsub\>', "W")<CR>
42
43" Move around comments
44noremap <silent><buffer> ]# :call search('^\s*#\@!', "W")<CR>
45noremap <silent><buffer> [# :call search('^\s*#\@!', "bW")<CR>
46
47" Let the matchit plugin know what items can be matched.
48if 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"'
58endif
59
60setlocal ignorecase
Bram Moolenaare0e39172021-01-25 21:14:57 +010061
Bram Moolenaar84f72352012-03-11 15:57:40 +010062let &cpo = s:cpo_save
63unlet s:cpo_save
Bram Moolenaare0e39172021-01-25 21:14:57 +010064
65" Disabled, 'cpo' is a global option.
66" setlocal cpo+=M " makes \%( match \)