Skip to content

Commit

Permalink
Merge pull request #927 from wakatime/feature/mojo-lexer
Browse files Browse the repository at this point in the history
Add support for Mojo programming language
  • Loading branch information
gandarez authored Sep 13, 2023
2 parents 1c3fb24 + 0e75d84 commit c25291e
Show file tree
Hide file tree
Showing 4 changed files with 41 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 @@ -891,6 +891,8 @@ const (
LanguageModula2
// LanguageMoinWiki represents the MoinWiki programming language.
LanguageMoinWiki
// LanguageMojo represents the Mojo programming language.
LanguageMojo
// LanguageMonkey represents the Monkey programming language.
LanguageMonkey
// LanguageMonkeyC represents the MonkeyC programming language.
Expand Down Expand Up @@ -2004,6 +2006,7 @@ const (
languageModelicaStr = "Modelica"
languageModula2Str = "Modula-2"
languageMoinWikiStr = "MoinMoin/Trac Wiki markup"
languageMojoStr = "Mojo"
languageMonkeyStr = "Monkey"
languageMonkeyCStr = "MonkeyC"
languageMonteStr = "Monte"
Expand Down Expand Up @@ -3280,6 +3283,8 @@ func ParseLanguage(s string) (Language, bool) {
return LanguageModula2, true
case normalizeString(languageMoinWikiStr):
return LanguageMoinWiki, true
case normalizeString(languageMojoStr):
return LanguageMojo, true
case normalizeString(languageMonkeyStr):
return LanguageMonkey, true
case normalizeString(languageMonkeyCStr):
Expand Down Expand Up @@ -4956,6 +4961,8 @@ func (l Language) String() string {
return languageModula2Str
case LanguageMoinWiki:
return languageMoinWikiStr
case LanguageMojo:
return languageMojoStr
case LanguageMonkey:
return languageMonkeyStr
case LanguageMonkeyC:
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 @@ -453,6 +453,7 @@ func languageTests() map[string]heartbeat.Language {
"Modelica": heartbeat.LanguageModelica,
"Modula-2": heartbeat.LanguageModula2,
"MoinMoin/Trac Wiki markup": heartbeat.LanguageMoinWiki,
"Mojo": heartbeat.LanguageMojo,
"Monkey": heartbeat.LanguageMonkey,
"MonkeyC": heartbeat.LanguageMonkeyC,
"Monte": heartbeat.LanguageMonte,
Expand Down
1 change: 1 addition & 0 deletions pkg/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func RegisterAll() error {
MiniScript{},
Modelica{},
Modula2{},
Mojo{},
Monkey{},
Monte{},
MoonScript{},
Expand Down
32 changes: 32 additions & 0 deletions pkg/lexer/mojo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package lexer

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

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

// Mojo lexer.
type Mojo struct{}

// Lexer returns the lexer.
func (l Mojo) Lexer() chroma.Lexer {
return chroma.MustNewLexer(
&chroma.Config{
Name: l.Name(),
Aliases: []string{"mojo"},
Filenames: []string{"*.🔥", "*.mojo"},
MimeTypes: []string{"text/x-mojo"},
},
func() chroma.Rules {
return chroma.Rules{
"root": {},
}
},
)
}

// Name returns the name of the lexer.
func (Mojo) Name() string {
return heartbeat.LanguageMojo.StringChroma()
}

0 comments on commit c25291e

Please sign in to comment.