Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
363 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
id: julia | ||
title: Julia | ||
sidebar_label: Julia | ||
--- | ||
|
||
## What | ||
|
||
Display the currently active julia version when a folder contains `.jl` files. | ||
|
||
## Sample Configuration | ||
|
||
```json | ||
{ | ||
"type": "julia", | ||
"style": "powerline", | ||
"powerline_symbol": "\uE0B0", | ||
"foreground": "#ffffff", | ||
"background": "#4063D8", | ||
"properties": { | ||
"prefix": " \uE624 " | ||
} | ||
} | ||
``` | ||
|
||
## Properties | ||
|
||
- display_version: `boolean` - display the julia version - defaults to `true` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ module.exports = { | |
"exit", | ||
"git", | ||
"golang", | ||
"julia", | ||
"kubectl", | ||
"node", | ||
"os", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,24 @@ | ||
package main | ||
|
||
import "regexp" | ||
|
||
type golang struct { | ||
props *properties | ||
env environmentInfo | ||
golangVersion string | ||
language *language | ||
} | ||
|
||
func (g *golang) string() string { | ||
if g.props.getBool(DisplayVersion, true) { | ||
return g.golangVersion | ||
} | ||
return "" | ||
return g.language.string() | ||
} | ||
|
||
func (g *golang) init(props *properties, env environmentInfo) { | ||
g.props = props | ||
g.env = env | ||
g.language = &language{ | ||
env: env, | ||
props: props, | ||
commands: []string{"go"}, | ||
versionParam: "version", | ||
extensions: []string{"*.go"}, | ||
versionRegex: `go(?P<version>[0-9]+.[0-9]+.[0-9]+)`, | ||
} | ||
} | ||
|
||
func (g *golang) enabled() bool { | ||
if !g.env.hasFiles("*.go") { | ||
return false | ||
} | ||
if !g.env.hasCommand("go") { | ||
return false | ||
} | ||
versionInfo, _ := g.env.runCommand("go", "version") | ||
r := regexp.MustCompile(`go(?P<version>[0-9]+.[0-9]+.[0-9]+)`) | ||
values := groupDict(r, versionInfo) | ||
g.golangVersion = values["version"] | ||
return true | ||
return g.language.enabled() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
type julia struct { | ||
language *language | ||
} | ||
|
||
func (j *julia) string() string { | ||
return j.language.string() | ||
} | ||
|
||
func (j *julia) init(props *properties, env environmentInfo) { | ||
j.language = &language{ | ||
env: env, | ||
props: props, | ||
commands: []string{"julia"}, | ||
versionParam: "--version", | ||
extensions: []string{"*.jl"}, | ||
versionRegex: `julia version (?P<version>[0-9]+.[0-9]+.[0-9]+)`, | ||
} | ||
} | ||
|
||
func (j *julia) enabled() bool { | ||
return j.language.enabled() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import "regexp" | ||
|
||
type language struct { | ||
props *properties | ||
env environmentInfo | ||
extensions []string | ||
commands []string | ||
versionParam string | ||
versionRegex string | ||
version string | ||
} | ||
|
||
func (l *language) string() string { | ||
if l.props.getBool(DisplayVersion, true) { | ||
return l.version | ||
} | ||
return "" | ||
} | ||
|
||
func (l *language) enabled() bool { | ||
for i, extension := range l.extensions { | ||
if l.env.hasFiles(extension) { | ||
break | ||
} | ||
if i == len(l.extensions)-1 { | ||
return false | ||
} | ||
} | ||
var executable string | ||
for i, command := range l.commands { | ||
if l.env.hasCommand(command) { | ||
executable = command | ||
break | ||
} | ||
if i == len(l.commands)-1 { | ||
return false | ||
} | ||
} | ||
versionInfo, _ := l.env.runCommand(executable, l.versionParam) | ||
r := regexp.MustCompile(l.versionRegex) | ||
values := groupDict(r, versionInfo) | ||
l.version = values["version"] | ||
return true | ||
} |
Oops, something went wrong.