mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 03:49:40 -08:00
feat(language): add configurable extensions
This commit is contained in:
parent
5256c90531
commit
435e362256
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,9 +1,6 @@
|
|||
{
|
||||
"go.lintTool": "golangci-lint",
|
||||
"go.useLanguageServer": true,
|
||||
"go.languageServerExperimentalFeatures": {
|
||||
"diagnostics": false
|
||||
},
|
||||
"go.lintFlags": ["--fast"],
|
||||
"go.testOnSave": true,
|
||||
"[go]": {
|
||||
|
|
|
@ -127,6 +127,17 @@ func (p properties) getKeyValueMap(property Property, defaultValue map[string]st
|
|||
return keyValues
|
||||
}
|
||||
|
||||
func (p properties) getStringArray(property Property, defaultValue []string) []string {
|
||||
val, found := p[property]
|
||||
if !found {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
keyValues := parseStringArray(val)
|
||||
|
||||
return keyValues
|
||||
}
|
||||
|
||||
func parseStringArray(param interface{}) []string {
|
||||
switch v := param.(type) {
|
||||
default:
|
||||
|
|
|
@ -25,7 +25,8 @@ type cmd struct {
|
|||
executable string
|
||||
args []string
|
||||
regex string
|
||||
version *version
|
||||
|
||||
version
|
||||
}
|
||||
|
||||
func (c *cmd) parse(versionInfo string) error {
|
||||
|
@ -33,7 +34,7 @@ func (c *cmd) parse(versionInfo string) error {
|
|||
if len(values) == 0 {
|
||||
return errors.New("cannot parse version string")
|
||||
}
|
||||
c.version = &version{}
|
||||
|
||||
c.version.Full = values["version"]
|
||||
c.version.Major = values["major"]
|
||||
c.version.Minor = values["minor"]
|
||||
|
@ -98,6 +99,8 @@ const (
|
|||
EnableVersionMismatch Property = "enable_version_mismatch"
|
||||
// HomeEnabled displays the segment in the HOME folder or not
|
||||
HomeEnabled Property = "home_enabled"
|
||||
// LanguageExtensions the list of extensions to validate
|
||||
LanguageExtensions Property = "extensions"
|
||||
)
|
||||
|
||||
func (l *language) string() string {
|
||||
|
@ -151,6 +154,9 @@ func (l *language) string() string {
|
|||
}
|
||||
|
||||
func (l *language) enabled() bool {
|
||||
// override default extensions if needed
|
||||
l.extensions = l.props.getStringArray(LanguageExtensions, l.extensions)
|
||||
|
||||
inHomeDir := func() bool {
|
||||
return l.env.getcwd() == l.env.homeDir()
|
||||
}
|
||||
|
|
|
@ -31,11 +31,12 @@ func TestNodeMatchesVersionFile(t *testing.T) {
|
|||
for _, tc := range cases {
|
||||
env := new(MockedEnvironment)
|
||||
env.On("getFileContent", ".nvmrc").Return(tc.RCVersion)
|
||||
|
||||
node := &node{
|
||||
language: &language{
|
||||
env: env,
|
||||
activeCommand: &cmd{
|
||||
version: &nodeVersion,
|
||||
version: nodeVersion,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue