oh-my-posh/src/segments/lua.go

49 lines
1.3 KiB
Go
Raw Normal View History

2022-07-18 21:38:38 -07:00
package segments
import (
2022-12-28 08:30:48 -08:00
"github.com/jandedobbeleer/oh-my-posh/platform"
"github.com/jandedobbeleer/oh-my-posh/properties"
2022-07-18 21:38:38 -07:00
)
type Lua struct {
language
}
const (
PreferredExecutable properties.Property = "preferred_executable"
)
func (l *Lua) Template() string {
return languageTemplate
}
2022-11-09 11:27:54 -08:00
func (l *Lua) Init(props properties.Properties, env platform.Environment) {
2022-07-18 21:38:38 -07:00
l.language = language{
env: env,
props: props,
extensions: []string{"*.lua", "*.rockspec"},
folders: []string{"lua"},
commands: []*cmd{
{
executable: "lua",
args: []string{"-v"},
regex: `Lua (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+)(.(?P<patch>[0-9]+))?))`,
versionURLTemplate: "https://www.lua.org/manual/{{ .Major }}.{{ .Minor }}/readme.html#changes",
},
{
executable: "luajit",
args: []string{"-v"},
regex: `LuaJIT (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+)(.(?P<patch>[0-9]+))?))`,
versionURLTemplate: "https://github.com/LuaJIT/LuaJIT/tree/v{{ .Major}}.{{ .Minor}}",
},
},
}
if l.props.GetString(PreferredExecutable, "lua") == "luajit" {
l.commands = []*cmd{l.commands[1], l.commands[0]}
}
}
func (l *Lua) Enabled() bool {
return l.language.Enabled()
}