diff --git a/data/filetype_extensions.conf b/data/filetype_extensions.conf index 3965b467..6ec67e1e 100644 --- a/data/filetype_extensions.conf +++ b/data/filetype_extensions.conf @@ -53,7 +53,7 @@ Python=*.py;*.pyw;SConstruct;SConscript;wscript; PowerShell=*.ps1;*.psm1; reStructuredText=*.rest;*.reST;*.rst; R=*.R;*.r; -Rust=*.rs +Rust=*.rs; Ruby=*.rb;*.rhtml;*.ruby;*.gemspec;Gemfile;rakefile;Rakefile; Scala=*.scala;*.scl; Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.mksh;*.zsh;*.ash;*.bash;*.m4;PKGBUILD;*profile; diff --git a/data/filetypes.Rust.conf b/data/filetypes.Rust.conf deleted file mode 100644 index ceb37863..00000000 --- a/data/filetypes.Rust.conf +++ /dev/null @@ -1,61 +0,0 @@ -# For complete documentation of this file, please see Geany's main documentation -[styling=C] - -[keywords] -# all items must be in one line -primary=as break const copy do drop else enum extern false fn for if impl let log loop match mod mut priv pub pure ref return self static struct super true trait type unsafe use while -secondary= -# these are the Doxygen keywords -docComment=a addindex addtogroup anchor arg attention author authors b brief bug c callergraph callgraph category cite class code cond copybrief copydetails copydoc copyright date def defgroup deprecated details dir dontinclude dot dotfile e else elseif em endcode endcond enddot endhtmlonly endif endinternal endlatexonly endlink endmanonly endmsc endrtfonly endverbatim endxmlonly enum example exception extends file fn headerfile hideinitializer htmlinclude htmlonly if ifnot image implements include includelineno ingroup interface internal invariant latexonly li line link mainpage manonly memberof msc mscfile n name namespace nosubgrouping note overload p package page par paragraph param post pre private privatesection property protected protectedsection protocol public publicsection ref related relatedalso relates relatesalso remark remarks result return returns retval rtfonly sa section see short showinitializer since skip skipline snippet struct subpage subsection subsubsection tableofcontents test throw throws todo tparam typedef union until var verbatim verbinclude version warning weakgroup xmlonly xrefitem - -[lexer_properties] -# preprocessor properties - possibly useful for tweaking #[attribute] highlighting -#styling.within.preprocessor=1 -#lexer.cpp.track.preprocessor=0 -#preprocessor.symbol.$(file.patterns.cpp)=# -#preprocessor.start.$(file.patterns.cpp)=if ifdef ifndef -#preprocessor.middle.$(file.patterns.cpp)=else elif -#preprocessor.end.$(file.patterns.cpp)=endif - -[settings] -# default extension used when saving files -extension=rs -lexer_filetype=C - -# the following characters are these which a "word" can contains, see documentation -#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - -# single comments, like # in this file -comment_single=// -# multiline comments -comment_open=/* -comment_close=*/ - -# set to false if a comment character/string should start at column 0 of a line, true uses any -# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d - #command_example(); -# setting to false would generate this -# command_example(); -# This setting works only for single line comments -comment_use_indent=true - -# context action command (please see Geany's main documentation for details) -context_action_cmd= - -[indentation] -#width=4 -# 0 is spaces, 1 is tabs, 2 is tab & spaces -#type=1 - -[build-menu] -FT_00_LB=_Compile -FT_00_CM=rustc -c "%f" -FT_00_WD= -FT_01_LB=_Build -FT_01_CM=rustc "%f" -FT_01_WD= -EX_00_LB=_Run -EX_00_CM="./%e" -EX_00_WD= - - diff --git a/data/filetypes.rust b/data/filetypes.rust index a69cb23f..45a2b028 100644 --- a/data/filetypes.rust +++ b/data/filetypes.rust @@ -1,24 +1,39 @@ # For complete documentation of this file, please see Geany's main documentation -[styling=C] +[styling] +# Edit these in the colorscheme .conf file instead +default=default +commentblock=comment +commentline=comment_line +commentblockdoc=comment_doc +commentlinedoc=comment_doc +number=number_1 +word=keyword_1 +word2=keyword_2 +word3=keyword_3 +word4=type +string=string_1 +stringraw=string_2 +character=character +operator=operator +identifier=identifier_1 +lifetime=parameter +macro=preprocessor +lexerror=error [keywords] # all items must be in one line -primary=fn type as break const copy do else enum extern fail for if impl let log loop match mod mut priv pub ref return static struct trait unsafe use while in continue alignof be offsetof pure sizeof typeof yield -secondary=bool int uint i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str Self self +primary=alignof as be box break const continue do else enum extern false fn for if impl in let __log_level loop match mod mut offsetof once priv proc pub pure ref return self sizeof static struct super trait true type typeof unsafe unsized use while yield +secondary=bool char f32 f64 i16 i32 i64 i8 int str u16 u32 u64 u8 uint +tertiary=Self [lexer_properties] styling.within.preprocessor=1 lexer.cpp.track.preprocessor=0 [settings] -lexer_filetype=C - # default extension used when saving files extension=rs -# the following characters are these which a "word" can contains, see documentation -#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - # single comments, like # in this file comment_single=// # multiline comments diff --git a/src/document.c b/src/document.c index 37dbe97b..14b7643e 100644 --- a/src/document.c +++ b/src/document.c @@ -2317,6 +2317,7 @@ void document_highlight_tags(GeanyDocument *doc) case GEANY_FILETYPES_JAVA: case GEANY_FILETYPES_OBJECTIVEC: case GEANY_FILETYPES_VALA: + case GEANY_FILETYPES_RUST: { /* index of the keyword set in the Scintilla lexer, for diff --git a/src/editor.c b/src/editor.c index 1d6676ee..0db81c47 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1257,6 +1257,7 @@ static gboolean lexer_has_braces(ScintillaObject *sci) case SCLEX_PERL: case SCLEX_TCL: case SCLEX_R: + case SCLEX_RUST: return TRUE; default: return FALSE; @@ -2893,6 +2894,7 @@ static gint get_multiline_comment_style(GeanyEditor *editor, gint line_start) case SCLEX_CAML: style_comment = SCE_CAML_COMMENT; break; case SCLEX_D: style_comment = SCE_D_COMMENT; break; case SCLEX_PASCAL: style_comment = SCE_PAS_COMMENT; break; + case SCLEX_RUST: style_comment = SCE_RUST_COMMENTBLOCK; break; default: style_comment = SCE_C_COMMENT; } @@ -3415,6 +3417,10 @@ static gboolean in_block_comment(gint lexer, gint style) case SCLEX_CSS: return (style == SCE_CSS_COMMENT); + case SCLEX_RUST: + return (style == SCE_RUST_COMMENTBLOCK || + style == SCE_RUST_COMMENTBLOCKDOC); + default: return FALSE; } @@ -4951,6 +4957,7 @@ void editor_set_indentation_guides(GeanyEditor *editor) case SCLEX_FREEBASIC: case SCLEX_D: case SCLEX_OCTAVE: + case SCLEX_RUST: mode = SC_IV_LOOKBOTH; break; diff --git a/src/highlighting.c b/src/highlighting.c index d84b4893..073acef5 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -1049,6 +1049,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co init_styleset_case(PYTHON); init_styleset_case(R); init_styleset_case(RUBY); + init_styleset_case(RUST); init_styleset_case(SH); init_styleset_case(SQL); init_styleset_case(TCL); @@ -1131,6 +1132,7 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft) styleset_case(PYTHON); styleset_case(R); styleset_case(RUBY); + styleset_case(RUST); styleset_case(SH); styleset_case(SQL); styleset_case(TCL); @@ -1543,6 +1545,12 @@ gboolean highlighting_is_string_style(gint lexer, gint style) case SCLEX_ABAQUS: return (style == SCE_ABAQUS_STRING); + + case SCLEX_RUST: + return (style == SCE_RUST_CHARACTER || + style == SCE_RUST_STRING || + style == SCE_RUST_STRINGR || + style == SCE_RUST_LEXERROR); } return FALSE; } @@ -1692,6 +1700,12 @@ gboolean highlighting_is_comment_style(gint lexer, gint style) return (style == SCE_ASM_COMMENT || style == SCE_ASM_COMMENTBLOCK || style == SCE_ASM_COMMENTDIRECTIVE); + + case SCLEX_RUST: + return (style == SCE_RUST_COMMENTBLOCK || + style == SCE_RUST_COMMENTLINE || + style == SCE_RUST_COMMENTBLOCKDOC || + style == SCE_RUST_COMMENTLINEDOC); } return FALSE; } diff --git a/src/highlightingmappings.h b/src/highlightingmappings.h index 1eba579a..8c34d530 100644 --- a/src/highlightingmappings.h +++ b/src/highlightingmappings.h @@ -1290,6 +1290,41 @@ static const HLKeyword highlighting_keywords_RUBY[] = }; #define highlighting_properties_RUBY EMPTY_PROPERTIES +/* Rust */ +#define highlighting_lexer_RUST SCLEX_RUST +static const HLStyle highlighting_styles_RUST[] = +{ + { SCE_RUST_DEFAULT, "default", FALSE }, + { SCE_RUST_COMMENTBLOCK, "commentblock", FALSE }, + { SCE_RUST_COMMENTLINE, "commentline", FALSE }, + { SCE_RUST_COMMENTBLOCKDOC, "commentblockdoc", FALSE }, + { SCE_RUST_COMMENTLINEDOC, "commentlinedoc", FALSE }, + { SCE_RUST_NUMBER, "number", FALSE }, + { SCE_RUST_WORD, "word", FALSE }, + { SCE_RUST_WORD2, "word2", FALSE }, + { SCE_RUST_WORD3, "word3", FALSE }, + { SCE_RUST_WORD4, "word4", FALSE }, + { SCE_RUST_WORD5, "word5", FALSE }, + { SCE_RUST_WORD6, "word6", FALSE }, + { SCE_RUST_WORD7, "word7", FALSE }, + { SCE_RUST_STRING, "string", FALSE }, + { SCE_RUST_STRINGR, "stringraw", FALSE }, + { SCE_RUST_CHARACTER, "character", FALSE }, + { SCE_RUST_OPERATOR, "operator", FALSE }, + { SCE_RUST_IDENTIFIER, "identifier", FALSE }, + { SCE_RUST_LIFETIME, "lifetime", FALSE }, + { SCE_RUST_MACRO, "macro", FALSE }, + { SCE_RUST_LEXERROR, "lexerror", FALSE } +}; +static const HLKeyword highlighting_keywords_RUST[] = +{ + { 0, "primary", FALSE }, + /* SCI_SETKEYWORDS = 1 - secondary + global tags file types */ + { 1, "secondary", TRUE }, + { 2, "tertiary", FALSE }, + /* SCI_SETKEYWORDS = 3 is for current session types - see editor_lexer_get_type_keyword_idx() */ +}; +#define highlighting_properties_RUST EMPTY_PROPERTIES /* SH */ #define highlighting_lexer_SH SCLEX_BASH diff --git a/src/symbols.c b/src/symbols.c index 2caa0f21..f03626fd 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -776,6 +776,22 @@ static void add_top_level_items(GeanyDocument *doc) NULL); break; } + case GEANY_FILETYPES_RUST: + { + tag_list_add_groups(tag_store, + &(tv_iters.tag_namespace), _("Modules"), "classviewer-namespace", + &(tv_iters.tag_struct), _("Structures"), "classviewer-struct", + &(tv_iters.tag_interface), _("Traits"), "classviewer-class", + &(tv_iters.tag_class), _("Implementations"), "classviewer-class", + &(tv_iters.tag_function), _("Functions"), "classviewer-method", + &(tv_iters.tag_type), _("Typedefs / Enums"), "classviewer-struct", + &(tv_iters.tag_variable), _("Variables"), "classviewer-var", + &(tv_iters.tag_macro), _("Macros"), "classviewer-macro", + &(tv_iters.tag_member), _("Methods"), "classviewer-member", + &(tv_iters.tag_other), _("Other"), "classviewer-other", NULL, + NULL); + break; + } case GEANY_FILETYPES_PERL: { tag_list_add_groups(tag_store, diff --git a/tagmanager/ctags/makefile.win32 b/tagmanager/ctags/makefile.win32 index f1a11a94..59862094 100644 --- a/tagmanager/ctags/makefile.win32 +++ b/tagmanager/ctags/makefile.win32 @@ -48,7 +48,7 @@ $(COMPLIB): abaqus.o abc.o args.o c.o cobol.o fortran.o make.o conf.o pascal.o p actionscript.o nsis.o objc.o \ haskell.o haxe.o html.o python.o lregex.o asciidoc.o rest.o sh.o ctags.o entry.o get.o keyword.o nestlevel.o \ options.o \ -parse.o basic.o read.o sort.o strlist.o latex.o markdown.o matlab.o docbook.o tcl.o ruby.o asm.o sql.o txt2tags.o css.o \ +parse.o basic.o read.o sort.o strlist.o latex.o markdown.o matlab.o docbook.o tcl.o ruby.o rust.o asm.o sql.o txt2tags.o css.o \ vstring.o r.o $(AR) rc $@ $^ $(RANLIB) $@ diff --git a/wscript b/wscript index 1fac2ea8..5075f2cd 100644 --- a/wscript +++ b/wscript @@ -105,6 +105,7 @@ ctags_sources = set([ 'tagmanager/ctags/read.c', 'tagmanager/ctags/rest.c', 'tagmanager/ctags/ruby.c', + 'tagmanager/ctags/rust.c', 'tagmanager/ctags/sh.c', 'tagmanager/ctags/sort.c', 'tagmanager/ctags/sql.c',