Skip to content

Commit

Permalink
runtime(miranda): Add new syntax and ftplugin files
Browse files Browse the repository at this point in the history
  • Loading branch information
dkearns committed May 13, 2024
1 parent 14dafad commit 54ca76c
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ runtime/ftplugin/m3build.vim @dkearns
runtime/ftplugin/m3quake.vim @dkearns
runtime/ftplugin/markdown.vim @tpope
runtime/ftplugin/meson.vim @Liambeguin
runtime/ftplugin/miranda.vim @dkearns
runtime/ftplugin/modula2.vim @dkearns
runtime/ftplugin/modula3.vim @dkearns
runtime/ftplugin/nginx.vim @chr4
Expand Down Expand Up @@ -428,6 +429,7 @@ runtime/syntax/mallard.vim @jhradilek
runtime/syntax/markdown.vim @tpope
runtime/syntax/mason.vim @petdance
runtime/syntax/meson.vim @Liambeguin
runtime/syntax/miranda.vim @dkearns
runtime/syntax/modula2.vim @dkearns
runtime/syntax/modula2/opt/iso.vim @trijezdci
runtime/syntax/modula2/opt/pim.vim @trijezdci
Expand Down
6 changes: 3 additions & 3 deletions runtime/autoload/miranda.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ function miranda#GetFileTypeInfo() abort
endif

if exists("g:miranda_default_literate")
let s:literate = g:miranda_default_literate
let literate = g:miranda_default_literate
else
let s:literate = v:false
let literate = v:false
endif

return #{ literate: s:literate }
return #{ literate: literate }
endfunction

function miranda#SetFileTypeInfo(info) abort
Expand Down
5 changes: 5 additions & 0 deletions runtime/doc/syntax.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,11 @@ have the following in your .vimrc: >
let filetype_m = "mma"
MIRANDA *miranda.vim* *ft-miranda-syntax*

TODO


MODULA2 *modula2.vim* *ft-modula2-syntax*

Vim will recognise comments with dialect tags to automatically select a given
Expand Down
2 changes: 2 additions & 0 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -7322,6 +7322,7 @@ ft-metapost-commands ft_mp.txt /*ft-metapost-commands*
ft-metapost-intro ft_mp.txt /*ft-metapost-intro*
ft-metapost-mappings ft_mp.txt /*ft-metapost-mappings*
ft-metapost-settings ft_mp.txt /*ft-metapost-settings*
ft-miranda-syntax syntax.txt /*ft-miranda-syntax*
ft-mma-syntax syntax.txt /*ft-mma-syntax*
ft-modula2-syntax syntax.txt /*ft-modula2-syntax*
ft-moo-syntax syntax.txt /*ft-moo-syntax*
Expand Down Expand Up @@ -8710,6 +8711,7 @@ meta intro.txt /*meta*
method eval.txt /*method*
mf.vim ft_mp.txt /*mf.vim*
min() builtin.txt /*min()*
miranda.vim syntax.txt /*miranda.vim*
missing-options vi_diff.txt /*missing-options*
mkdir() builtin.txt /*mkdir()*
mlang.txt mlang.txt /*mlang.txt*
Expand Down
35 changes: 35 additions & 0 deletions runtime/ftplugin/miranda.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
" Vim filetype plugin file
" Language: Miranda
" Maintainer: Doug Kearns <[email protected]>
" Last Change: 2024 May 14

if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1

setlocal comments=:\|\|
setlocal commentstring=\|\|\ %s
setlocal formatoptions+=croql formatoptions-=t

setlocal iskeyword=a-z,A-Z,48-57,_,'

let &l:include = '%\%(insert\|include\)'
setlocal suffixes+=.x
setlocal suffixesadd=.m

let b:undo_ftplugin = "setl cms< com< fo< inc< isk< su< sua<"

if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter =
\ "Miranda Script Files (*.m)\t*.m\n" ..
\ "Miranda Literate Script Files (*.lit.m)\t*.lit.m\n"
if has("win32")
let b:browsefilter ..= "All Files (*.*)\t*\n"
else
let b:browsefilter ..= "All Files (*)\t*\n"
endif
let b:undo_ftplugin ..= " | unlet! b:browsefilter"
endif

" vim: nowrap sw=2 sts=2 ts=8 noet:
30 changes: 30 additions & 0 deletions runtime/syntax/miranda.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
" Vim syntax file
" Language: Miranda
" Maintainer: Doug Kearns <[email protected]>
" Last Change: 2024 May 14

if exists("b:current_syntax")
finish
endif

syn iskeyword a-z,A-Z,48-57,_,'

if miranda#GetFileTypeInfo().literate
syn include @mirandaTop syntax/shared/miranda.vim
syn region mirandaLiterate start="^[^>[:space:]]" end="^\ze\%(\s*\n\)*>\|\%$"
syn region mirandaProgram start="^>" skip="^>" end="^\ze\s*$\|\%$" contains=@mirandaTop

syn sync linebreaks=2

hi def link mirandaLiterate Comment
else
runtime! syntax/shared/miranda.vim
endif

syn match mirandaSharpBang /\%^#!.*/ display

hi def link mirandaSharpBang PreProc

let b:current_syntax = "miranda"

" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
92 changes: 92 additions & 0 deletions runtime/syntax/shared/miranda.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
" Vim syntax file
" Language: Miranda
" Maintainer: Doug Kearns <[email protected]>
" Last Change: 2024 May 14

syn iskeyword a-z,A-Z,48-57,_,'

" Operators {{{1
" list
syn match mirandaOperator /\%([:#!]\|++\|--\)/
" relational
syn match mirandaOperator _\%(\\/\|&\|\~\)\|\%(>\|>=\|=\|\~=\|<=\|<\)_
" arithmetic
syn match mirandaOperator _[+\-*/^]_
syn keyword mirandaOperator div mod
" function
syn match mirandaOperator /\.\|$\a\@=/

" Reserved {{{1
syn keyword mirandaReserved
\ abstype if otherwise readvals show type where with
"\ div mod

" Functions {{{1
syn keyword mirandaFunction
\ abs and arctan cjustify code concat const converse cos decode digit
\ drop dropwhile e entier error exp filemode filter foldl foldl1 foldr
\ foldr1 force fst getenv hd hugenum id index init integer iterate last
\ lay layn letter limit lines ljustify log log10 map map2 max max2
\ member merge min min2 mkset neg numval or pi postfix product read
\ readb rep repeat reverse rjustify scan seq showfloat showhex shownum
\ showoct showscaled sin snd sort spaces sqrt subtract sum system take
\ takewhile tinynum tl transpose undef until zip2 zip3 zip4 zip5 zip6
\ zip
" Constants {{{1
syn keyword mirandaConstant e pi tinynum
syn keyword mirandaUndef undef

" Constructors {{{1
syn keyword mirandaFunction
\ Appendfile Appendfileb Closefile Exit Stderr Stdout Stdoutb System
\ Tofile Tofileb

syn keyword mirandaType bool char num sys_message
" syn match mirandaTypeVar /\*\+/

" Literals {{{1
syn keyword mirandaBoolean True False

" Numbers {{{2
syn match mirandaNatural /\<\d\+\>/ display
syn match mirandaFloat /\<\d\+e[+-]\=\d\+\>/ display
syn match mirandaFloat /\<\d*\.\d\+\%(e[+-]\=\d\+\)\=/ display

" Strings {{{2
" syn match mirandaEscape /\\[ntfrb\\'"]/ contained
syn match mirandaEscape /\\./ contained
syn match mirandaEscape /\\\d\{1,3}/ contained
syn match mirandaEscape /\\$/ contained

syn match mirandaCharacter /\<'\%(\\.\|\%(\\$\n\)\=[[:print:]]\)'\>/ contains=mirandaEscape
syn region mirandaString start=/"/ skip=/\\\\\|\\"\|\\$/ end=/"/ end=/$/ contains=mirandaEscape,mirandaEscapeError

" Comments {{{1
syn keyword mirandaTodo contained TODO FIXME XXX NOTE
syn match mirandaComment /||.*/ contains=mirandaTodo,@Spell

" Compiler directives {{{1
syn match mirandaCompilerDirective /%\%(list\|nolist\)\>/
syn match mirandaCompilerDirective /%\%(include\|insert\)\>/ nextgroup=mirandaFileId skipwhite
syn region mirandaFileId start=/</ end=/>/ contained oneline
syn region mirandaFileId start=/"/ end=/"/ contained oneline
syn match mirandaCompilerDirective /%\%(export\|free\)\>/

" Highlighting {{{1
hi def link mirandaBoolean Boolean
hi def link mirandaCharacter Character
hi def link mirandaComment Comment
hi def link mirandaCompilerDirective PreProc
hi def link mirandaConstant Constant
hi def link mirandaEscape Special
hi def link mirandaFileId mirandaString
hi def link mirandaFloat Float
hi def link mirandaFunction Function
hi def link mirandaNatural Number
hi def link mirandaOperator Operator
hi def link mirandaReserved Keyword
hi def link mirandaString String
hi def link mirandaType Type

" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/miranda-lit_00.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
>>+0#af5f00255#ffffff0| +0#0000000&||+0#0000e05&@1| |A| |M|i|r|a|n|d|a| |l|i|t|e|r|a|t|e| |s|c|r|i|p|t| |s|p|e|c|i|f|i|e|d| |b|y| |f|o|r|m|a|l|i|s|i|n|g| |s|y|m|b|o|l| |'|>|'|.| +0#0000000&@7
@75
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |0+0#e000002&| +0#0000000&|=+0#af5f00255&| +0#0000000&|1+0#e000002&| +0#0000000&@62
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |=+0#af5f00255&| +0#0000000&|(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |*+0#af5f00255&| +0#0000000&|f|a|c| |n| @42
@75
|S+0#0000e05&|o|m|e| |c|l|o|s|i|n|g| |t|e|x|t|.| +0#0000000&@56
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|1|,|1| @10|A|l@1|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/miranda-lit_99.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|>+0#af5f00255#ffffff0| +0#0000000&||+0#0000e05&@1| |A| |M|i|r|a|n|d|a| |l|i|t|e|r|a|t|e| |s|c|r|i|p|t| |s|p|e|c|i|f|i|e|d| |b|y| |f|o|r|m|a|l|i|s|i|n|g| |s|y|m|b|o|l| |'|>|'|.| +0#0000000&@7
@75
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |0+0#e000002&| +0#0000000&|=+0#af5f00255&| +0#0000000&|1+0#e000002&| +0#0000000&@62
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |=+0#af5f00255&| +0#0000000&|(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |*+0#af5f00255&| +0#0000000&|f|a|c| |n| @42
@75
>S+0#0000e05&|o|m|e| |c|l|o|s|i|n|g| |t|e|x|t|.| +0#0000000&@56
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|6|,|1| @10|A|l@1|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/miranda.lit_00.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
>A+0#0000e05#ffffff0| |M|i|r|a|n|d|a| |l|i|t|e|r|a|t|e| |s|c|r|i|p|t| |s|p|e|c|i|f|i|e|d| |b|y| |f|i|l|e|n|a|m|e| |e|x|t|e|n|s|i|o|n| |'|*|.|l|i|t|.|m|'|.| +0#0000000&@6
@75
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |0+0#e000002&| +0#0000000&|=+0#af5f00255&| +0#0000000&|1+0#e000002&| +0#0000000&@62
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |=+0#af5f00255&| +0#0000000&|(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |*+0#af5f00255&| +0#0000000&|f|a|c| |n| @42
@75
|S+0#0000e05&|o|m|e| |c|l|o|s|i|n|g| |t|e|x|t|.| +0#0000000&@56
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|1|,|1| @10|A|l@1|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/miranda.lit_99.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
|A+0#0000e05#ffffff0| |M|i|r|a|n|d|a| |l|i|t|e|r|a|t|e| |s|c|r|i|p|t| |s|p|e|c|i|f|i|e|d| |b|y| |f|i|l|e|n|a|m|e| |e|x|t|e|n|s|i|o|n| |'|*|.|l|i|t|.|m|'|.| +0#0000000&@6
@75
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |0+0#e000002&| +0#0000000&|=+0#af5f00255&| +0#0000000&|1+0#e000002&| +0#0000000&@62
|>+0#af5f00255&| +0#0000000&@1|f|a|c| |(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |=+0#af5f00255&| +0#0000000&|(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |*+0#af5f00255&| +0#0000000&|f|a|c| |n| @42
@75
>S+0#0000e05&|o|m|e| |c|l|o|s|i|n|g| |t|e|x|t|.| +0#0000000&@56
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|6|,|1| @10|A|l@1|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/miranda_00.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
>|+0#0000e05#ffffff0@1| |A| |M|i|r|a|n|d|a| |s|c|r|i|p|t|.| +0#0000000&@54
@75
|f|a|c| |0+0#e000002&| +0#0000000&|=+0#af5f00255&| +0#0000000&|1+0#e000002&| +0#0000000&@65
|f|a|c| |(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |=+0#af5f00255&| +0#0000000&|(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |*+0#af5f00255&| +0#0000000&|f|a|c| |n| @45
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|1|,|1| @10|A|l@1|
20 changes: 20 additions & 0 deletions runtime/syntax/testdir/dumps/miranda_99.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
||+0#0000e05#ffffff0@1| |A| |M|i|r|a|n|d|a| |s|c|r|i|p|t|.| +0#0000000&@54
@75
|f|a|c| |0+0#e000002&| +0#0000000&|=+0#af5f00255&| +0#0000000&|1+0#e000002&| +0#0000000&@65
>f|a|c| |(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |=+0#af5f00255&| +0#0000000&|(|n| |++0#af5f00255&| +0#0000000&|1+0#e000002&|)+0#0000000&| |*+0#af5f00255&| +0#0000000&|f|a|c| |n| @45
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|4|,|1| @10|A|l@1|
6 changes: 6 additions & 0 deletions runtime/syntax/testdir/input/miranda-lit.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
> || A Miranda literate script specified by formalising symbol '>'.

> fac 0 = 1
> fac (n + 1) = (n + 1) * fac n

Some closing text.
6 changes: 6 additions & 0 deletions runtime/syntax/testdir/input/miranda.lit.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
A Miranda literate script specified by filename extension '*.lit.m'.

> fac 0 = 1
> fac (n + 1) = (n + 1) * fac n

Some closing text.
4 changes: 4 additions & 0 deletions runtime/syntax/testdir/input/miranda.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
|| A Miranda script.

fac 0 = 1
fac (n + 1) = (n + 1) * fac n

0 comments on commit 54ca76c

Please sign in to comment.