Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
lhaskell.vim136 linesDownload Raw Back to syntax
1" Vim syntax file2" Language:		Haskell with literate comments, Bird style,3"			Markdown style, TeX style and plain text surrounding4"			\begin{code} \end{code} blocks5" Maintainer:		Haskell Cafe mailinglist <haskell-cafe@haskell.org>6" 			(need to be subscribed to post)7" Original Author:	Arthur van Leeuwen <arthurvl@cs.uu.nl>8" Last Change:		2020 Feb 259" Version:		1.0510"11" Thanks to Ian Lynagh for thoughtful comments on initial versions and12" for the inspiration for writing this in the first place.13"14" This style guesses as to the type of markup used in a literate haskell15" file and will highlight (La)TeX markup if it finds any16" This behaviour can be overridden, both glabally and locally using17" the lhs_markup variable or b:lhs_markup variable respectively.18"19" lhs_markup	    must be set to either  tex	or  none  to indicate that20"		    you always want (La)TeX highlighting or no highlighting21"		    must not be set to let the highlighting be guessed22" b:lhs_markup	    must be set to eiterh  tex	or  none  to indicate that23"		    you want (La)TeX highlighting or no highlighting for24"		    this particular buffer25"		    must not be set to let the highlighting be guessed26"27"28" 2004 February 18: New version, based on Ian Lynagh's TeX guessing29"		    lhaskell.vim, cweb.vim, tex.vim, sh.vim and fortran.vim30" 2004 February 20: Cleaned up the guessing and overriding a bit31" 2004 February 23: Cleaned up syntax highlighting for \begin{code} and32"		    \end{code}, added some clarification to the attributions33" 2008 July 1:      Removed % from guess list, as it totally breaks plain34"                   text markup guessing35" 2009 April 29:    Fixed highlighting breakage in TeX mode, 36"                   thanks to Kalman Noel37"38 39 40" quit when a syntax file was already loaded41if exists("b:current_syntax")42  finish43endif44 45" First off, see if we can inherit a user preference for lhs_markup46if !exists("b:lhs_markup")47    if exists("lhs_markup")48	if lhs_markup =~ '\<\%(tex\|md\|none\)\>'49	    let b:lhs_markup = matchstr(lhs_markup,'\<\%(tex\|md\|none\)\>')50	else51	    echohl WarningMsg | echo "Unknown value of lhs_markup" | echohl None52	    let b:lhs_markup = "unknown"53	endif54    else55	let b:lhs_markup = "unknown"56    endif57else58    if b:lhs_markup !~ '\<\%(tex\|md\|none\)\>'59	let b:lhs_markup = "unknown"60    endif61endif62 63" Remember where the cursor is, and go to upperleft64let s:oldline=line(".")65let s:oldcolumn=col(".")66call cursor(1,1)67 68" If no user preference, scan buffer for our guess of the markup to69" highlight. We only differentiate between TeX and plain markup, where70" plain is not highlighted. The heuristic for finding TeX markup is if71" one of the following occurs anywhere in the file:72"   - \documentclass73"   - \begin{env}       (for env != code)74"   - \part, \chapter, \section, \subsection, \subsubsection, etc75if b:lhs_markup == "unknown"76    if search('\\documentclass\|\\begin{\(code}\)\@!\|\\\(sub\)*section\|\\chapter|\\part','W') != 077	let b:lhs_markup = "tex"78    elseif search('```haskell','W') != 079        let b:lhs_markup = "md"80    else81	let b:lhs_markup = "plain"82    endif83endif84 85" If user wants us to highlight TeX syntax or guess thinks it's TeX, read it.86if b:lhs_markup == "tex"87    runtime! syntax/tex.vim88    unlet b:current_syntax89    " Tex.vim removes "_" from 'iskeyword', but we need it for Haskell.90    setlocal isk+=_91    syntax cluster lhsTeXContainer contains=tex.*Zone,texAbstract92elseif b:lhs_markup == "md"93    runtime! syntax/markdown.vim94    unlet b:current_syntax95    syntax cluster lhsTeXContainer contains=markdown.*96else97    syntax cluster lhsTeXContainer contains=.*98endif99 100" Literate Haskell is Haskell in between text, so at least read Haskell101" highlighting102syntax include @haskellTop syntax/haskell.vim103 104syntax region lhsHaskellBirdTrack start="^>" end="\%(^[^>]\)\@=" contains=@haskellTop,lhsBirdTrack containedin=@lhsTeXContainer105syntax region lhsHaskellBeginEndBlock start="^\\begin{code}\s*$" matchgroup=NONE end="\%(^\\end{code}.*$\)\@=" contains=@haskellTop,beginCodeBegin containedin=@lhsTeXContainer106syntax region lhsHaskellMDBlock start="^```haskell$" matchgroup=NONE end="^```$" keepend contains=@haskellTop,lhsMarkdownCode containedin=@lhsTeXContainer107 108syntax match lhsBirdTrack "^>" contained109 110syntax match lhsMarkdownCode "^\(```haskell\|^```\)$" contained111 112syntax match beginCodeBegin "^\\begin" nextgroup=beginCodeCode contained113syntax region beginCodeCode  matchgroup=texDelimiter start="{" end="}"114 115" Define the default highlighting.116" Only when an item doesn't have highlighting yet117 118hi def link lhsBirdTrack Comment119 120hi def link lhsMarkdownCode Comment121 122hi def link beginCodeBegin	      texCmdName123hi def link beginCodeCode	      texSection124 125 126" Restore cursor to original position, as it may have been disturbed127" by the searches in our guessing code128call cursor (s:oldline, s:oldcolumn)129 130unlet s:oldline131unlet s:oldcolumn132 133let b:current_syntax = "lhaskell"134 135" vim: ts=8136 
codekingpro/portable-devtools · Team Ai