Skip to content

Commit

Permalink
Add Lastro lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Sep 18, 2023
1 parent 0c6007a commit cb700c6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/heartbeat/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const (
LanguageAspxVBNet
// LanguageAssembly represents the Assembly programming language.
LanguageAssembly
// LanguageAstro represents the Astro programming language.
LanguageAstro
// LanguageAsymptote represents the Asymptote programming language.
LanguageAsymptote
// LanguageATS represents the ATS programming language.
Expand Down Expand Up @@ -1610,6 +1612,7 @@ const (
languageAspxCSharpStr = "aspx-cs"
languageAspxVBNetStr = "aspx-vb"
languageAssemblyStr = "Assembly"
languageAstroStr = "Astro"
languageAsymptoteStr = "Asymptote"
languageATSStr = "ATS"
languageAugeasStr = "Augeas"
Expand Down Expand Up @@ -2490,6 +2493,8 @@ func ParseLanguage(s string) (Language, bool) {
return LanguageAspxVBNet, true
case normalizeString(languageAssemblyStr):
return LanguageAssembly, true
case normalizeString(languageAstroStr):
return LanguageAstro, true
case normalizeString(languageAsymptoteStr):
return LanguageAsymptote, true
case normalizeString(languageATSStr):
Expand Down Expand Up @@ -4176,6 +4181,8 @@ func (l Language) String() string {
return languageAspxVBNetStr
case LanguageAssembly:
return languageAssemblyStr
case LanguageAstro:
return languageAstroStr
case LanguageAsymptote:
return languageAsymptoteStr
case LanguageATS:
Expand Down
1 change: 1 addition & 0 deletions pkg/heartbeat/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func languageTests() map[string]heartbeat.Language {
"aspx-cs": heartbeat.LanguageAspxCSharp,
"aspx-vb": heartbeat.LanguageAspxVBNet,
"Assembly": heartbeat.LanguageAssembly,
"Astro": heartbeat.LanguageAstro,
"Asymptote": heartbeat.LanguageAsymptote,
"ATS": heartbeat.LanguageATS,
"Augeas": heartbeat.LanguageAugeas,
Expand Down
31 changes: 31 additions & 0 deletions pkg/lexer/astro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"

"github.com/alecthomas/chroma/v2"
)

// Astro lexer.
type Astro struct{}

// Lexer returns the lexer.
func (l Astro) Lexer() chroma.Lexer {
return chroma.MustNewLexer(
&chroma.Config{
Name: l.Name(),
Aliases: []string{"astro"},
Filenames: []string{"*.astro"},
},
func() chroma.Rules {
return chroma.Rules{
"root": {},
}
},
)
}

// Name returns the name of the lexer.
func (Astro) Name() string {
return heartbeat.LanguageAstro.StringChroma()
}
1 change: 1 addition & 0 deletions pkg/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func RegisterAll() error {
AspectJ{},
AspxCSharp{},
AspxVBNet{},
Astro{},
Asymptote{},
Augeas{},
BARE{},
Expand Down

0 comments on commit cb700c6

Please sign in to comment.