Skip to content

Commit 91d302d

Browse files
committed
Initial code
1 parent 287af72 commit 91d302d

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

ftdetect/mold.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
au BufReadPost,FileReadPost,BufNewFile moldfile set filetype=mold
2+
au BufReadPost,FileReadPost,BufNewFile *.mold set filetype=mold

indent/mold.vim

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
setlocal nolisp
2+
setlocal autoindent
3+
setlocal indentkeys+=<:>,0=},0=)
4+
setlocal indentexpr=MoldIndent(v:lnum)
5+
6+
function! MoldIndent(lnum) abort
7+
let l:prevlnum = prevnonblank(a:lnum-1)
8+
if l:prevlnum == 0
9+
return 0
10+
endif
11+
12+
" strip comments from EOL
13+
let l:prevl = substitute(getline(l:prevlnum), '\(//\|#\).*$', '', '')
14+
let l:thisl = substitute(getline(a:lnum), '\(//\|#\).*$', '', '')
15+
let l:previ = indent(l:prevlnum)
16+
17+
let l:ind = l:previ
18+
19+
if l:prevl =~ '{\s*$'
20+
" previous line opened a block
21+
let l:ind += shiftwidth()
22+
endif
23+
24+
if l:thisl =~ '^\s*}'
25+
" this line closed a block
26+
let l:ind -= shiftwidth()
27+
endif
28+
29+
return l:ind
30+
endfunction

syntax/mold.vim

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
if exists("b:current_syntax")
2+
finish
3+
endif
4+
5+
syn keyword moldKeyword dir help if import recipe as require run var version
6+
syn match moldKeyword "\v\$"
7+
8+
syn match moldSymbol "\v\("
9+
syn match moldSymbol "\v\)"
10+
syn match moldSymbol "\v\{"
11+
syn match moldSymbol "\v\}"
12+
syn match moldSymbol "\v\="
13+
14+
syn match moldOperator "\v\+"
15+
syn match moldOperator "\v\|"
16+
syn match moldOperator "\v\~"
17+
18+
syn match moldWild "\v\*"
19+
20+
syn region moldString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ keepend
21+
22+
syn match moldComment1 "#.*$" display
23+
syn match moldComment2 "\/\/.*$" display
24+
25+
hi link moldWild Special
26+
hi link moldSymbol Operator
27+
hi link moldOperator Identifier
28+
hi link moldString String
29+
hi link moldWild Boolean
30+
hi link moldKeyword Keyword
31+
hi link moldComment1 Comment
32+
hi link moldComment2 Comment
33+
" hi link moldType Type
34+
" hi link moldGeneric Identifier
35+
" PreProc
36+
" Boolean
37+
" String
38+
" Number
39+
" Number
40+
" Comment
41+
" not used PreProc

0 commit comments

Comments
 (0)