Skip to content

Commit 1279565

Browse files
committed
Include Haskell syntax file with minor modifications
This fixes #24
1 parent f764437 commit 1279565

File tree

3 files changed

+214
-2
lines changed

3 files changed

+214
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ this to sending current paragraph. If this is happening you either:
339339

340340
1. Opened a file without `.tidal` extension, or changed file type accidentally.
341341
*Solution*: Reopen Vim or set filetype for current buffer with `:set
342-
ft=haskell.tidal`.
342+
ft=tidal`.
343343
2. Have `g:tidal_no_mappings` setting on your `.vimrc`. This disables all
344344
mappings.
345345
*Solution*: Remove `<c-e>` binding, or rebind to something else.

ftdetect/tidal.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
autocmd BufRead,BufNewFile *.tidal setfiletype haskell.tidal
1+
autocmd BufRead,BufNewFile *.tidal setfiletype tidal

syntax/tidal.vim

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
" syntax highlighting for tidal/haskell
2+
"
3+
" Very minor modifications from syntax file of
4+
" https://github.com/neovimhaskell/haskell-vim
5+
"
6+
" Heavily modified version of the haskell syntax
7+
" highlighter to support haskell.
8+
"
9+
" author: raichoo ([email protected])
10+
11+
if version < 600
12+
syn clear
13+
elseif exists("b:current_syntax")
14+
finish
15+
endif
16+
17+
if get(g:, 'haskell_backpack', 0)
18+
syn keyword haskellBackpackStructure unit signature
19+
syn keyword haskellBackpackDependency dependency
20+
endif
21+
22+
syn spell notoplevel
23+
syn match haskellRecordField contained containedin=haskellBlock
24+
\ "[_a-z][a-zA-Z0-9_']*\(,\s*[_a-z][a-zA-Z0-9_']*\)*\_s\+::\_s"
25+
\ contains=
26+
\ haskellIdentifier,
27+
\ haskellOperators,
28+
\ haskellSeparator,
29+
\ haskellParens
30+
syn match haskellTypeSig
31+
\ "^\s*\(where\s\+\|let\s\+\|default\s\+\)\?[_a-z][a-zA-Z0-9_']*#\?\(,\s*[_a-z][a-zA-Z0-9_']*#\?\)*\_s\+::\_s"
32+
\ contains=
33+
\ haskellWhere,
34+
\ haskellLet,
35+
\ haskellDefault,
36+
\ haskellIdentifier,
37+
\ haskellOperators,
38+
\ haskellSeparator,
39+
\ haskellParens
40+
syn keyword haskellWhere where
41+
syn keyword haskellLet let
42+
syn match HaskellDerive "\<deriving\>\(\s\+\<\(anyclass\|instance\|newtype\|stock\)\>\)\?"
43+
syn keyword haskellDeclKeyword module class instance newtype in
44+
syn match haskellDecl "\<\(type\|data\)\>\s\+\(\<family\>\)\?"
45+
syn keyword haskellDefault default
46+
syn keyword haskellImportKeywords import qualified safe as hiding contained
47+
syn keyword haskellForeignKeywords foreign export import ccall safe unsafe interruptible capi prim contained
48+
syn region haskellForeignImport start="\<foreign\>" end="\_s\+::\s" keepend
49+
\ contains=
50+
\ haskellString,
51+
\ haskellOperators,
52+
\ haskellForeignKeywords,
53+
\ haskellIdentifier
54+
syn match haskellImport "^\s*\<import\>\s\+\(\<safe\>\s\+\)\?\(\<qualified\>\s\+\)\?.\+\(\s\+\<as\>\s\+.\+\)\?\(\s\+\<hiding\>\)\?"
55+
\ contains=
56+
\ haskellParens,
57+
\ haskellOperators,
58+
\ haskellImportKeywords,
59+
\ haskellType,
60+
\ haskellLineComment,
61+
\ haskellBlockComment,
62+
\ haskellString,
63+
\ haskellPragma
64+
syn keyword haskellKeyword do case of
65+
if get(g:, 'haskell_enable_static_pointers', 0)
66+
syn keyword haskellStatic static
67+
endif
68+
syn keyword haskellConditional if then else
69+
syn match haskellNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>\|\<0[bB][10]\+\>"
70+
syn match haskellFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
71+
syn match haskellSeparator "[,;]"
72+
syn region haskellParens matchgroup=haskellDelimiter start="(" end=")" contains=TOP,haskellTypeSig,@Spell
73+
syn region haskellBrackets matchgroup=haskellDelimiter start="\[" end="]" contains=TOP,haskellTypeSig,@Spell
74+
syn region haskellBlock matchgroup=haskellDelimiter start="{" end="}" contains=TOP,@Spell
75+
syn keyword haskellInfix infix infixl infixr
76+
syn keyword haskellBottom undefined error
77+
syn match haskellOperators "[-!#$%&\*\+/<=>\?@\\^|~:.]\+\|\<_\>"
78+
syn match haskellQuote "\<'\+" contained
79+
syn match haskellQuotedType "[A-Z][a-zA-Z0-9_']*\>" contained
80+
syn region haskellQuoted start="\<'\+" end="\>"
81+
\ contains=
82+
\ haskellType,
83+
\ haskellQuote,
84+
\ haskellQuotedType,
85+
\ haskellSeparator,
86+
\ haskellParens,
87+
\ haskellOperators,
88+
\ haskellIdentifier
89+
syn match haskellLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$"
90+
\ contains=
91+
\ haskellTodo,
92+
\ @Spell
93+
syn match haskellBacktick "`[A-Za-z_][A-Za-z0-9_\.']*#\?`"
94+
syn region haskellString start=+"+ skip=+\\\\\|\\"+ end=+"+
95+
\ contains=@Spell
96+
syn match haskellIdentifier "[_a-z][a-zA-z0-9_']*" contained
97+
syn match haskellChar "\<'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'\>"
98+
syn match haskellType "\<[A-Z][a-zA-Z0-9_']*\>"
99+
syn region haskellBlockComment start="{-" end="-}"
100+
\ contains=
101+
\ haskellBlockComment,
102+
\ haskellTodo,
103+
\ @Spell
104+
syn region haskellPragma start="{-#" end="#-}"
105+
syn region haskellLiquid start="{-@" end="@-}"
106+
"syn match haskellPreProc "^#.*$"
107+
syn keyword haskellTodo TODO FIXME contained
108+
" Treat a shebang line at the start of the file as a comment
109+
syn match haskellShebang "\%^#!.*$"
110+
if !get(g:, 'haskell_disable_TH', 0)
111+
syn match haskellQuasiQuoted "." containedin=haskellQuasiQuote contained
112+
syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-zA-Z][a-zA-z0-9._']*|" end="|\]"
113+
syn region haskellTHBlock matchgroup=haskellTH start="\[\(d\|t\|p\)\?|" end="|]" contains=TOP
114+
syn region haskellTHDoubleBlock matchgroup=haskellTH start="\[||" end="||]" contains=TOP
115+
endif
116+
if get(g:, 'haskell_enable_typeroles', 0)
117+
syn keyword haskellTypeRoles phantom representational nominal contained
118+
syn region haskellTypeRoleBlock matchgroup=haskellTypeRoles start="type\s\+role" end="$" keepend
119+
\ contains=
120+
\ haskellType,
121+
\ haskellTypeRoles
122+
endif
123+
if get(g:, 'haskell_enable_quantification', 0)
124+
syn keyword haskellForall forall
125+
endif
126+
if get(g:, 'haskell_enable_recursivedo', 0)
127+
syn keyword haskellRecursiveDo mdo rec
128+
endif
129+
if get(g:, 'haskell_enable_arrowsyntax', 0)
130+
syn keyword haskellArrowSyntax proc
131+
endif
132+
if get(g:, 'haskell_enable_pattern_synonyms', 0)
133+
syn keyword haskellPatternKeyword pattern
134+
endif
135+
136+
highlight def link haskellBottom Macro
137+
highlight def link haskellTH Boolean
138+
highlight def link haskellIdentifier Identifier
139+
highlight def link haskellForeignKeywords Structure
140+
highlight def link haskellKeyword Keyword
141+
highlight def link haskellDefault Keyword
142+
highlight def link haskellConditional Conditional
143+
highlight def link haskellNumber Number
144+
highlight def link haskellFloat Float
145+
highlight def link haskellSeparator Delimiter
146+
highlight def link haskellDelimiter Delimiter
147+
highlight def link haskellInfix Keyword
148+
highlight def link haskellOperators Operator
149+
highlight def link haskellQuote Operator
150+
highlight def link haskellShebang Comment
151+
highlight def link haskellLineComment Comment
152+
highlight def link haskellBlockComment Comment
153+
highlight def link haskellPragma SpecialComment
154+
highlight def link haskellLiquid SpecialComment
155+
highlight def link haskellString String
156+
highlight def link haskellChar String
157+
highlight def link haskellBacktick Operator
158+
highlight def link haskellQuasiQuoted String
159+
highlight def link haskellTodo Todo
160+
"highlight def link haskellPreProc PreProc
161+
highlight def link haskellAssocType Type
162+
highlight def link haskellQuotedType Type
163+
highlight def link haskellType Type
164+
highlight def link haskellImportKeywords Include
165+
if get(g:, 'haskell_classic_highlighting', 0)
166+
highlight def link haskellDeclKeyword Keyword
167+
highlight def link HaskellDerive Keyword
168+
highlight def link haskellDecl Keyword
169+
highlight def link haskellWhere Keyword
170+
highlight def link haskellLet Keyword
171+
else
172+
highlight def link haskellDeclKeyword Structure
173+
highlight def link HaskellDerive Structure
174+
highlight def link haskellDecl Structure
175+
highlight def link haskellWhere Structure
176+
highlight def link haskellLet Structure
177+
endif
178+
179+
if get(g:, 'haskell_enable_quantification', 0)
180+
highlight def link haskellForall Operator
181+
endif
182+
if get(g:, 'haskell_enable_recursivedo', 0)
183+
highlight def link haskellRecursiveDo Keyword
184+
endif
185+
if get(g:, 'haskell_enable_arrowsyntax', 0)
186+
highlight def link haskellArrowSyntax Keyword
187+
endif
188+
if get(g:, 'haskell_enable_static_pointers', 0)
189+
highlight def link haskellStatic Keyword
190+
endif
191+
if get(g:, 'haskell_classic_highlighting', 0)
192+
if get(g:, 'haskell_enable_pattern_synonyms', 0)
193+
highlight def link haskellPatternKeyword Keyword
194+
endif
195+
if get(g:, 'haskell_enable_typeroles', 0)
196+
highlight def link haskellTypeRoles Keyword
197+
endif
198+
else
199+
if get(g:, 'haskell_enable_pattern_synonyms', 0)
200+
highlight def link haskellPatternKeyword Structure
201+
endif
202+
if get(g:, 'haskell_enable_typeroles', 0)
203+
highlight def link haskellTypeRoles Structure
204+
endif
205+
endif
206+
207+
if get(g:, 'haskell_backpack', 0)
208+
highlight def link haskellBackpackStructure Structure
209+
highlight def link haskellBackpackDependency Include
210+
endif
211+
212+
let b:current_syntax = "tidal"

0 commit comments

Comments
 (0)