diff --git a/nvim/.config/nvim/ftdetect/metamath.vim b/nvim/.config/nvim/ftdetect/metamath.vim new file mode 100644 index 0000000..48d2f6d --- /dev/null +++ b/nvim/.config/nvim/ftdetect/metamath.vim @@ -0,0 +1,2 @@ +au BufRead,BufNewFile *.mm set filetype=metamath +au BufRead,BufNewFile *.mma set filetype=metamath diff --git a/nvim/.config/nvim/syntax/metamath.vim b/nvim/.config/nvim/syntax/metamath.vim new file mode 100644 index 0000000..bbcafa3 --- /dev/null +++ b/nvim/.config/nvim/syntax/metamath.vim @@ -0,0 +1,240 @@ +" Vim syntax file +" Language: Metamath +" Maintainer: David A. Wheeler +" Latest Revision: 7 July 2016 +" Metamath is a tiny language that can express theorems in abstract +" mathematics, accompanied by proofs that can be verified by a computer +" program with absolute rigor. For more info see: http://metamath.org/ + +if exists('b:current_syntax') + finish +endif + +syn case match + +" Synchronize display on the last-seen comment closer, for speed. +syn sync match metamathSyncComment grouphere NONE '\<$)\>' + +" Whitespace and newlines delimit nearly everything. +" Identifiers can contain '.' and '$'; parentheses are valid constants. +setlocal iskeyword=33-255 + +" Highlight $.. commands that don't match anything else. +syn match metamathBadStatement '$[^ {}]' + +" Handle special constructs within a comment. + +" A cross-reference in a comment; begins with '~'. +syn region metamathXref contained + \ start='\<\~ \+' + \ end='\>' + +" An expression in a comment; enclosed by `...` (backquotes). +syn region metamathEmbeddedExpression contained + \ start='\<"\?`\>' + \ end='\<`\>' + \ contains=@metamathExpression + \ skip='``' + +" An date in a comment; these are common enough to visually distinguish. +syn match metamathDate contained + \ '\([1-2][0-9]\|3[0-1]\|[1-9]\)-[A-Z][a-z][a-z]-[1-9][0-9][0-9][0-9]' + +syn keyword metamathTodo contained TODO FIXME Todo + +syn match metamathDiscouraged contained + \ '\((Proof modification is discouraged.)\|(New usage is discouraged.)\)' + +" External bibliography reference. See 'help write bibliography' +" in the metamath C program, which says: +" A name in square brackets in a statement's description (the comment before +" a $a or $p statement) indicates a bibliographic reference. The full +" reference must be of the form +" [] p. +" There should be no comma between '[]' and 'p.'. +" Whitespace, comma, period, or semicolon should follow . +" Example: +" Theorem 3.1 of [Monk] p. 22, +" The , which is not case-sensitive, +" must be one of the following: Axiom, Chapter, Compare, Condition, +" Corollary, Definition, Equation, Example, Exercise, Figure, Item, +" Lemma, Lemmas, Line, Lines, Notation, Part, Postulate, Problem, Property, +" Proposition, Remark, Rule, Scheme, Section, Theorem. +" The is optional, as in for example +" "Remark in [Monk] p. 22". +" The are zero or more from the list: from, in, of, on. +" These are ignored when +" generating the bibliographic cross-reference. The must be present +" in the file identified with the htmlbibliography assignment (e.g. +" mmset.html) in the database $t comment, in the form +" e.g. . The may be any alphanumeric string such as +" an integer or Roman numeral. +syn match metamathBibReference contained + \ '\c\(Axiom\|Chapter\|Compare\|Condition\|\|Corollary\|Definition\|Equation\|Example\|Exercise\|Figure\|Item\|Lemmas\?\|Lines\?\|Notation\|Part\|Postulate\|Problem\|Property\|Proposition\|Remark\|Rule\|Scheme\|Section\|Theorem\)[ \t\n\r]\+\([^\t\n\r]\{1,10\}[ \t\n\r]\+\)\?\(\(from\|in\|of\|on\)[ \t\n\r]\+\)\?\[[^ \t\n\r\[\]]*\][ \t\n\r]\+p\.[ \t\n\r]\+[^ \t\n\r]\+' + +syn match metamathURL contained + \ '\' + +" Specially match long-standing bugs in the introductory set.mm comments +" (they're not as critical because it's never rendered). +syn match metamathSetMMBug contained + \ '\(changed \"D e\. Met\" to \"D e\. ( Met ` X )\",\|revised ( ( fLim ` J ) ` F ) -> ( J fLim F )\|is interpreted as a single ` \. A special\|\"( f ` x )\" should be read \"the value of function f at x\"\)' + +" Highlight characters other than the officially +" legal characters (per spec), which are A-Z, a-z, 0-9, and: +" ` ~ ! @ # $ % ^ & * ( ) - _ = + +" [ ] { } ; : ' " , . < > / ? \ | +syn match metamathIllegalChar contained + \ '[^A-Za-z0-9`~!@#$%^&*()_=+\[\]{};:'\",.<>/?\\| \t\n\r\f-]' + +" Some text within a comment is special; this cluster lists them. +syn cluster metamathSpecialComment + \ contains=metamathXref,metamathEmbeddedExpression,metamathDate,metamathTodo,metamathDiscouraged,metamathBibReference,metamathURL,metamathSetMMBug,metamathIllegalChar + + +" metamathComments do NOT nest, so we use keepend. +syn region metamathComment + \ start='\<$(\>' + \ end='\<$)\>' + \ contains=metamathTrailingSpace,@metamathSpecialComment,@Spell + " \ conceal keepend + +" $c ... $. - Constant declaration +syn region metamathConstant + \ start='\<$c\>' + \ end='\<$\.\>' + +" $v ... $. - Variable declaration +syn region metamathVariable + \ start='\<$v\>' + \ end='\<$\.\>' + +" $d ... $. - Disjoint (distinct) variable restriction +syn region metamathDisjoint + \ start='\<$d\>' + \ end='\<$\.\>' + +" The following constructs require labels, so require that the label +" be processed first. + +"