Integrate the Rust lexer with the rest of Geany's functionality

This commit is contained in:
SiegeLord 2013-10-16 17:19:29 -04:00
parent a085573212
commit 3d7ade4e02
10 changed files with 99 additions and 71 deletions

View File

@ -53,7 +53,7 @@ Python=*.py;*.pyw;SConstruct;SConscript;wscript;
PowerShell=*.ps1;*.psm1; PowerShell=*.ps1;*.psm1;
reStructuredText=*.rest;*.reST;*.rst; reStructuredText=*.rest;*.reST;*.rst;
R=*.R;*.r; R=*.R;*.r;
Rust=*.rs Rust=*.rs;
Ruby=*.rb;*.rhtml;*.ruby;*.gemspec;Gemfile;rakefile;Rakefile; Ruby=*.rb;*.rhtml;*.ruby;*.gemspec;Gemfile;rakefile;Rakefile;
Scala=*.scala;*.scl; Scala=*.scala;*.scl;
Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.mksh;*.zsh;*.ash;*.bash;*.m4;PKGBUILD;*profile; Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.mksh;*.zsh;*.ash;*.bash;*.m4;PKGBUILD;*profile;

View File

@ -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=

View File

@ -1,24 +1,39 @@
# For complete documentation of this file, please see Geany's main documentation # 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] [keywords]
# all items must be in one line # 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 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 int uint i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str Self self secondary=bool char f32 f64 i16 i32 i64 i8 int str u16 u32 u64 u8 uint
tertiary=Self
[lexer_properties] [lexer_properties]
styling.within.preprocessor=1 styling.within.preprocessor=1
lexer.cpp.track.preprocessor=0 lexer.cpp.track.preprocessor=0
[settings] [settings]
lexer_filetype=C
# default extension used when saving files # default extension used when saving files
extension=rs extension=rs
# the following characters are these which a "word" can contains, see documentation
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# single comments, like # in this file # single comments, like # in this file
comment_single=// comment_single=//
# multiline comments # multiline comments

View File

@ -2317,6 +2317,7 @@ void document_highlight_tags(GeanyDocument *doc)
case GEANY_FILETYPES_JAVA: case GEANY_FILETYPES_JAVA:
case GEANY_FILETYPES_OBJECTIVEC: case GEANY_FILETYPES_OBJECTIVEC:
case GEANY_FILETYPES_VALA: case GEANY_FILETYPES_VALA:
case GEANY_FILETYPES_RUST:
{ {
/* index of the keyword set in the Scintilla lexer, for /* index of the keyword set in the Scintilla lexer, for

View File

@ -1257,6 +1257,7 @@ static gboolean lexer_has_braces(ScintillaObject *sci)
case SCLEX_PERL: case SCLEX_PERL:
case SCLEX_TCL: case SCLEX_TCL:
case SCLEX_R: case SCLEX_R:
case SCLEX_RUST:
return TRUE; return TRUE;
default: default:
return FALSE; 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_CAML: style_comment = SCE_CAML_COMMENT; break;
case SCLEX_D: style_comment = SCE_D_COMMENT; break; case SCLEX_D: style_comment = SCE_D_COMMENT; break;
case SCLEX_PASCAL: style_comment = SCE_PAS_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; default: style_comment = SCE_C_COMMENT;
} }
@ -3415,6 +3417,10 @@ static gboolean in_block_comment(gint lexer, gint style)
case SCLEX_CSS: case SCLEX_CSS:
return (style == SCE_CSS_COMMENT); return (style == SCE_CSS_COMMENT);
case SCLEX_RUST:
return (style == SCE_RUST_COMMENTBLOCK ||
style == SCE_RUST_COMMENTBLOCKDOC);
default: default:
return FALSE; return FALSE;
} }
@ -4951,6 +4957,7 @@ void editor_set_indentation_guides(GeanyEditor *editor)
case SCLEX_FREEBASIC: case SCLEX_FREEBASIC:
case SCLEX_D: case SCLEX_D:
case SCLEX_OCTAVE: case SCLEX_OCTAVE:
case SCLEX_RUST:
mode = SC_IV_LOOKBOTH; mode = SC_IV_LOOKBOTH;
break; break;

View File

@ -1049,6 +1049,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
init_styleset_case(PYTHON); init_styleset_case(PYTHON);
init_styleset_case(R); init_styleset_case(R);
init_styleset_case(RUBY); init_styleset_case(RUBY);
init_styleset_case(RUST);
init_styleset_case(SH); init_styleset_case(SH);
init_styleset_case(SQL); init_styleset_case(SQL);
init_styleset_case(TCL); init_styleset_case(TCL);
@ -1131,6 +1132,7 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft)
styleset_case(PYTHON); styleset_case(PYTHON);
styleset_case(R); styleset_case(R);
styleset_case(RUBY); styleset_case(RUBY);
styleset_case(RUST);
styleset_case(SH); styleset_case(SH);
styleset_case(SQL); styleset_case(SQL);
styleset_case(TCL); styleset_case(TCL);
@ -1543,6 +1545,12 @@ gboolean highlighting_is_string_style(gint lexer, gint style)
case SCLEX_ABAQUS: case SCLEX_ABAQUS:
return (style == SCE_ABAQUS_STRING); 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; return FALSE;
} }
@ -1692,6 +1700,12 @@ gboolean highlighting_is_comment_style(gint lexer, gint style)
return (style == SCE_ASM_COMMENT || return (style == SCE_ASM_COMMENT ||
style == SCE_ASM_COMMENTBLOCK || style == SCE_ASM_COMMENTBLOCK ||
style == SCE_ASM_COMMENTDIRECTIVE); 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; return FALSE;
} }

View File

@ -1290,6 +1290,41 @@ static const HLKeyword highlighting_keywords_RUBY[] =
}; };
#define highlighting_properties_RUBY EMPTY_PROPERTIES #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 */ /* SH */
#define highlighting_lexer_SH SCLEX_BASH #define highlighting_lexer_SH SCLEX_BASH

View File

@ -776,6 +776,22 @@ static void add_top_level_items(GeanyDocument *doc)
NULL); NULL);
break; 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: case GEANY_FILETYPES_PERL:
{ {
tag_list_add_groups(tag_store, tag_list_add_groups(tag_store,

View File

@ -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 \ 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 \ 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 \ 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 vstring.o r.o
$(AR) rc $@ $^ $(AR) rc $@ $^
$(RANLIB) $@ $(RANLIB) $@

View File

@ -105,6 +105,7 @@ ctags_sources = set([
'tagmanager/ctags/read.c', 'tagmanager/ctags/read.c',
'tagmanager/ctags/rest.c', 'tagmanager/ctags/rest.c',
'tagmanager/ctags/ruby.c', 'tagmanager/ctags/ruby.c',
'tagmanager/ctags/rust.c',
'tagmanager/ctags/sh.c', 'tagmanager/ctags/sh.c',
'tagmanager/ctags/sort.c', 'tagmanager/ctags/sort.c',
'tagmanager/ctags/sql.c', 'tagmanager/ctags/sql.c',