vis icon indicating copy to clipboard operation
vis copied to clipboard

syntax highlight for conky, remind and groff

Open Docbroke opened this issue 3 years ago • 4 comments

Hi, I have recently moved from vim to vis and I am missing syntax highlighting for conky, remind and groff (mom macros) files. I tried to find out lexer files for them but couldn't get any. Any pointers would be great. thanks

Docbroke avatar Jul 11 '21 06:07 Docbroke

Easiest method is to find a similar language among the list and add it to scintillua (and your local lexers).

ninewise avatar Aug 05 '21 12:08 ninewise

I'm currently working on a Roff highlighter actually

chilledfrogs avatar Aug 05 '21 15:08 chilledfrogs

Question @Docbroke: I am currently trying to make generic Roff highlighting rules for any macro set (or a lack thereof), but do you think it would be really useful to have specific highlighting for standard macros for instance and maybe therefore separate highlighting rules per macro set (and 1 for generic/none)?

chilledfrogs avatar Aug 09 '21 14:08 chilledfrogs

I don't have any experience regarding how syntax highlight works. Any file written using some macro can have generic groff requests as well, so you can use .bp to break page even when you are using .mom or .ms macros. Therefore generic rules will be needed, and specific rules for macro can be added to that.

I have syntax file for vim created by .mom macro creator, original source url has changed/ or not available so I am posting it here

" Copyright (C) 2012-2020 Free Software Foundation, Inc.
"
" Copying and distribution of this file, with or without modification,
" are permitted in any medium without royalty provided the copyright
" notice and this notice are preserved.

" Vim syntax file
" Language:    mom
" Maintainer:  Peter Schaffter ([email protected])
" Last Change: So 06 M�r 2005 17:28:13 CET
" Filenames:   *.mom
" URL:         http://www.cvjb.de/comp/vim/mom.vim
" Note:        Remove or overwrite troff syntax for *.mom-files with filetype/filedetect.
" Version:     0.1
"
" Mom: Macro set for easy typesetting with troff/nroff/groff.

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
	syntax clear
elseif exists("b:current_syntax")
	finish
endif

" Mom is case sensitive
syn case match

" Synchronization, I know it is a huge number, but normal texts can be
" _very_ long ;-)
syn sync lines=1000

" Characters allowed in keywords
if version >= 600
	setlocal iskeyword=@,#,$,%,48-57,.,@-@,_,\\,{,},192-255
else
	set iskeyword=@,#,$,%,48-57,.,@-@,_,\\,{,},192-255
endif

" mom/groff macros and requests (the initial dot or single-quote)
"
" Highlighting carries through to EOL; macro names, requests and
" arguments are contained
syn match startRequest /^\s*\(\.\|'\)\s*.*$/ contains=momMacro,groffCommentLine,groffRequest,momRegister,groffNoLineBreak,momInteger,groffUnit,momString,momSpecialParam,groffDelimiter,groffRegister,groffPreprocessor,groffBraces

" mom macros
syn region momMacro start=/^\s*\(\.\|'\)\s*\zs[A-Z0-9_(){}\[\]]\+/ end=/\s\+\|$/

" mom registers and strings
syn match momRegister /\(\$\|#\)[A-Za-z][_0-9A-Za-z]*/ contains=momRegisterStart

syn match momRegisterStart /#\|\$/ contained

" mom comment region
syn region momCommentRegion matchgroup=startRequest start='\<\.\(COMMENT\)\|\(SILENT\)\>' end='\<\.\(COMMENT\s\+OFF\)\|\(SILENT\s\+OFF\)\>' skip='$'

" groff requests
syn match groffRequest /^\s*\(\.\|'\)\s*\zs[a-z0-9]\+/

" groff comment region
syn region groffCommentLine start='\(\\!\)\|\(\\"\)\|\(\\#\)' end='$' contains=momTodo
syn region groffCommentRegion start="^\s*\.\s*ig" matchgroup=startRequest end="^\.\.$" contains=startRequest

" Preprocessor requests
syn match groffPreprocessor /[^A-Z]\zs\(EQ\s*$\|EN\s*$\|GS\s*$\|GE\s*$\|GF\s*$\|PS\s*$\|PE\s*$\|R1\s*$\|R2\s*$\|TS\s*$\|TE\s*$\|TH\s*$\)/ contained
syn match groffPreprocessor /[^A-Z]\zs\(G1\s*$\|G2\s*$\|IS\s*$\|IE\s*$\|cstart\s*$\|cend\s*$\)/ contained

" Preprocessor requests for refer
syn match groffPreprocessor /\(\[\s*$\|\]\s*$\)/ contained

" Quoted strings
syn region momString matchgroup=startRequest start='"\zs' end='"\|$' contains=groffNoLineBreak,groffGreek,groffSpecialChar,momInteger,momFloatEN,momFloatDE,momBracketRegion,momBracketError,momSpecialMove contained

" Special characters
syn match groffSpecialChar '\\\((\|\[\)[-+A-Za-z0-9*<>=~!\/]\+\]*'

" Greek symbols
syn match groffGreek '\\(\*[A-Za-z]\+'

" Hyphenation marks
syn match groffHyphenation '\\%'

" Masking of line breaks
syn match groffNoLineBreak /\\\s*$/ contains=groffBraces

" groff number and string register delimiters
syn region groffDelimiter start=/\\*\\\(n+*\|\*\)\((\|\[\)\</ end=/\(\s\|\]\|$\)/ contains=momRegister,groffRegister,groffOperators

" groff registers
syn match groffRegister /\\\((\|\[\)\zs\.*[a-z]\+/

" groff operators
syn match groffOperators /\(+\|-\|\/\|\*[^[]\)/ contained

" Units (of measure)
syn match groffUnit '[-+]\=\([0-9]\|]\)\+\zs[icPpvusfz]\=' contained

" Braces
syn match groffBraces /\(\\{\|\\}\)/ contained

" Error
syn match groffError '\\\[ \+[[:print:]]\+ \+[[:print:]]\+\]'

" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_mom_syn_inits")
	if version < 508
		let did_mom_syn_inits = 1
		command -nargs=+ HiLink hi link <args>
	else
		command -nargs=+ HiLink hi def link <args>
	endif

HiLink groffError               Error
HiLink groffBraces              darkmagenta
HiLink groffCommentLine		darkcyan
HiLink groffCommentRegion	cyan
HiLink groffDelimiter		cyan
HiLink groffGreek		cyan
HiLink groffHyphenation		cyan
HiLink groffNoLineBreak		cyan
HiLink groffOperators		white
HiLink groffPreprocessor	brown
HiLink groffRegister		darkgreen
HiLink groffRequest		magenta
HiLink groffSpecialChar		darkcyan
HiLink groffUnit		brown
HiLink momCommentRegion		darkcyan
HiLink momMacro			red
HiLink momRegister		green
HiLink momRegisterStart         magenta
HiLink momSpecialParam		red
HiLink momString		white
HiLink startRequest		yellow
	delcommand HiLink
endif

let b:current_syntax = "mom"

" vim:ts=8:sw=4:nocindent:smartindent:

Docbroke avatar Aug 11 '21 06:08 Docbroke

@ninewise, this should be probably closed, or if still applicable, this should be moved to the https://github.com/orbitalquark/scintillua/issues.

mcepl avatar Nov 29 '22 23:11 mcepl

@rnpnr ??? What about this one?

mcepl avatar Aug 10 '23 20:08 mcepl

I think groff is supported upstream since orbitalquark/scintillua@369ee2b. I'll add an item to the release plans to resync the lexers.

The others can be requested upstream. From my perspective it is better if we don't implement our own lexers unless there is a very compelling reason to do so.

rnpnr avatar Aug 10 '23 21:08 rnpnr