@@ -781,6 +781,33 @@ func (b *Buffer) searchRuntimeHeader(ft string, syntaxFiles *[]syntaxFileBuffer,
781781 return syntaxFile , header
782782}
783783
784+ // searchRuntimeSyntax search in the runtime syntax files
785+ func (b * Buffer ) searchRuntimeSyntax (name string , header * highlight.Header ) {
786+ for _ , f := range config .ListRuntimeFiles (config .RTSyntax ) {
787+ if f .Name () == name {
788+ data , err := f .Data ()
789+ if err != nil {
790+ screen .TermMessage ("Error loading syntax file " + f .Name () + ": " + err .Error ())
791+ continue
792+ }
793+
794+ file , err := highlight .ParseFile (data )
795+ if err != nil {
796+ screen .TermMessage ("Error parsing syntax file " + f .Name () + ": " + err .Error ())
797+ continue
798+ }
799+
800+ syndef , err := highlight .ParseDef (file , header )
801+ if err != nil {
802+ screen .TermMessage ("Error parsing syntax file " + f .Name () + ": " + err .Error ())
803+ continue
804+ }
805+ b .SyntaxDef = syndef
806+ break
807+ }
808+ }
809+ }
810+
784811// UpdateRules updates the syntax rules and filetype for this buffer
785812// This is called when the colorscheme changes
786813func (b * Buffer ) UpdateRules () {
@@ -840,29 +867,7 @@ func (b *Buffer) UpdateRules() {
840867
841868 if syntaxFile != "" && ! foundDef {
842869 // we found a syntax file using a syntax header file
843- for _ , f := range config .ListRuntimeFiles (config .RTSyntax ) {
844- if f .Name () == syntaxFile {
845- data , err := f .Data ()
846- if err != nil {
847- screen .TermMessage ("Error loading syntax file " + f .Name () + ": " + err .Error ())
848- continue
849- }
850-
851- file , err := highlight .ParseFile (data )
852- if err != nil {
853- screen .TermMessage ("Error parsing syntax file " + f .Name () + ": " + err .Error ())
854- continue
855- }
856-
857- syndef , err := highlight .ParseDef (file , header )
858- if err != nil {
859- screen .TermMessage ("Error parsing syntax file " + f .Name () + ": " + err .Error ())
860- continue
861- }
862- b .SyntaxDef = syndef
863- break
864- }
865- }
870+ b .searchRuntimeSyntax (syntaxFile , header )
866871 }
867872
868873 if b .SyntaxDef != nil && highlight .HasIncludes (b .SyntaxDef ) {
0 commit comments