From 09e7d8398fd168fd0aabfd908ffbdf429d7fc53e Mon Sep 17 00:00:00 2001 From: exbb2 Date: Sun, 21 Jul 2013 19:45:28 +0300 Subject: [PATCH] Haskell filetype improvements and support for Literal Haskell Closes #155 and also closes #139 --- data/filetype_extensions.conf | 2 +- data/filetypes.haskell | 20 +++++++++++++++----- src/editor.c | 4 +++- src/highlighting.c | 11 +++++++++-- src/highlightingmappings.h | 4 +++- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/data/filetype_extensions.conf b/data/filetype_extensions.conf index a20d2b22..dd629c54 100644 --- a/data/filetype_extensions.conf +++ b/data/filetype_extensions.conf @@ -30,7 +30,7 @@ FreeBasic=*.bas;*.bi; Genie=*.gs; GLSL=*.glsl;*.frag;*.vert; Go=*.go; -Haskell=*.hs;*.lhs; +Haskell=*.hs;*.lhs;*.hs-boot;*.lhs-boot; Haxe=*.hx; HTML=*.htm;*.html;*.shtml;*.hta;*.htd;*.htt;*.cfm; Java=*.java;*.jsp; diff --git a/data/filetypes.haskell b/data/filetypes.haskell index 68adb3ba..65baa82e 100644 --- a/data/filetypes.haskell +++ b/data/filetypes.haskell @@ -6,8 +6,11 @@ commentline=comment_line commentblock=comment commentblock2=comment commentblock3=comment +literate_comment=comment +literate_codedelim=preprocessor number=number_1 keyword=keyword_1 +reserved_operator=keyword_1 import=preprocessor string=string_1 character=character @@ -15,20 +18,27 @@ class=class operator=operator identifier=identifier_1 instance=type -capital=string_2 +capital=type module=function data=number_2 pragma=preprocessor preprocessor=preprocessor stringeol=string_eol -reserved_operator=operator -literate_comment=comment -literate_codedelim=other [keywords] # all items must be in one line -keywords=as case class data deriving do else if import in infixl infixr instance let module of primitive qualified then type where +keywords=case class data default deriving do else forall foreign if import in infix infixl infixr instance let module newtype of then type where +ffi=capi ccall export import interruptible prim safe stdcall unsafe +reserved_operators=-> .. :: <- = => @ \ | ~ ← → ∀ ∷ ★ +[lexer_properties] +lexer.haskell.allow.hash=1 +lexer.haskell.allow.quotes=1 +lexer.haskell.allow.questionmark=0 +lexer.haskell.import.safe=1 +lexer.haskell.cpp=1 +styling.within.preprocessor=0 +fold.haskell.imports=0 [settings] # default extension used when saving files diff --git a/src/editor.c b/src/editor.c index e3d5fb97..722d10ab 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2900,7 +2900,9 @@ static gint get_multiline_comment_style(GeanyEditor *editor, gint line_start) style_comment = SCE_H_COMMENT; break; } - case SCLEX_HASKELL: style_comment = SCE_HA_COMMENTBLOCK; break; + case SCLEX_HASKELL: + case SCLEX_LITERATEHASKELL: + style_comment = SCE_HA_COMMENTBLOCK; break; case SCLEX_LUA: style_comment = SCE_LUA_COMMENT; break; case SCLEX_CSS: style_comment = SCE_CSS_COMMENT; break; case SCLEX_SQL: style_comment = SCE_SQL_COMMENT; break; diff --git a/src/highlighting.c b/src/highlighting.c index 92676284..ab1b89fd 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -1511,6 +1511,7 @@ gboolean highlighting_is_string_style(gint lexer, gint style) style == SCE_LUA_STRING); case SCLEX_HASKELL: + case SCLEX_LITERATEHASKELL: return (style == SCE_HA_CHARACTER || style == SCE_HA_STRINGEOL || style == SCE_HA_STRING); @@ -1671,11 +1672,13 @@ gboolean highlighting_is_comment_style(gint lexer, gint style) style == SCE_LUA_COMMENTDOC); case SCLEX_HASKELL: + case SCLEX_LITERATEHASKELL: return (style == SCE_HA_COMMENTLINE || style == SCE_HA_COMMENTBLOCK || style == SCE_HA_COMMENTBLOCK2 || style == SCE_HA_COMMENTBLOCK3 || - style == SCE_HA_LITERATE_COMMENT); + style == SCE_HA_LITERATE_COMMENT || + style == SCE_HA_LITERATE_CODEDELIM); case SCLEX_FREEBASIC: return (style == SCE_B_COMMENT); @@ -1737,14 +1740,18 @@ gboolean highlighting_is_code_style(gint lexer, gint style) switch (lexer) { case SCLEX_CPP: + { if (style == SCE_C_PREPROCESSOR) return FALSE; break; - + } case SCLEX_HASKELL: + case SCLEX_LITERATEHASKELL: + { if (style == SCE_HA_PREPROCESSOR) return FALSE; break; + } } return !(highlighting_is_comment_style(lexer, style) || highlighting_is_string_style(lexer, style)); diff --git a/src/highlightingmappings.h b/src/highlightingmappings.h index 20102a03..6cf6a30c 100644 --- a/src/highlightingmappings.h +++ b/src/highlightingmappings.h @@ -642,7 +642,9 @@ static const HLStyle highlighting_styles_HASKELL[] = }; static const HLKeyword highlighting_keywords_HASKELL[] = { - { 0, "keywords", FALSE } + { 0, "keywords", FALSE }, + { 1, "ffi", FALSE }, + { 2, "reserved_operators", FALSE } }; #define highlighting_properties_HASKELL EMPTY_PROPERTIES