-
-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathlanguages.go
More file actions
137 lines (133 loc) · 2.81 KB
/
languages.go
File metadata and controls
137 lines (133 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package code
// cmds: Multiple commands; placeholders can be used
// Placeholders <file>, <name> and <path> can be used.
type cmds [][]string
// Language represents a programming language with it Extension and Commands to
// execute its programs.
type Language struct {
// Extension represents the file extension used by this language.
Extension string
// Commands [][]string // placeholders: <name> file name (without
// extension), <file> file name, <path> path without file name
Commands cmds
}
// Supported Languages
const (
Bash = "bash"
Zsh = "zsh"
Fish = "fish"
Elixir = "elixir"
Go = "go"
Javascript = "javascript"
Lua = "lua"
OCaml = "ocaml"
Perl = "perl"
Python = "python"
Ruby = "ruby"
Rust = "rust"
Java = "java"
Julia = "julia"
Cpp = "cpp"
Swift = "swift"
Dart = "dart"
V = "v"
Scala = "scala"
Haskell = "haskell"
Nushell = "nu"
)
// Languages is a map of supported languages with their extensions and commands
// to run to execute the program.
var Languages = map[string]Language{
Bash: {
Extension: "sh",
Commands: cmds{{"bash", "<file>"}},
},
Zsh: {
Extension: "zsh",
Commands: cmds{{"zsh", "<file>"}},
},
Fish: {
Extension: "fish",
Commands: cmds{{"fish", "<file>"}},
},
Elixir: {
Extension: "exs",
Commands: cmds{{"elixir", "<file>"}},
},
Go: {
Extension: "go",
Commands: cmds{{"go", "run", "<file>"}},
},
Javascript: {
Extension: "js",
Commands: cmds{{"node", "<file>"}},
},
Lua: {
Extension: "lua",
Commands: cmds{{"lua", "<file>"}},
},
Ruby: {
Extension: "rb",
Commands: cmds{{"ruby", "<file>"}},
},
OCaml: {
Extension: "ml",
Commands: cmds{{"ocaml", "<file>"}},
},
Python: {
Extension: "py",
Commands: cmds{{"python", "<file>"}},
},
Perl: {
Extension: "pl",
Commands: cmds{{"perl", "<file>"}},
},
Rust: {
Extension: "rs",
Commands: cmds{
// compile code
{"rustc", "<file>", "-o", "<path>/<name>.run"},
// run compiled file
{"<path>/<name>.run"},
},
},
Java: {
Extension: "java",
Commands: cmds{{"java", "<file>"}},
},
Julia: {
Extension: "jl",
Commands: cmds{{"julia", "<file>"}},
},
Cpp: {
Extension: "cpp",
Commands: cmds{
{"g++", "-std=c++20", "-o", "<path>/<name>.run", "<file>"},
{"<path>/<name>.run"},
},
},
Swift: {
Extension: "swift",
Commands: cmds{{"swift", "<file>"}},
},
Dart: {
Extension: "dart",
Commands: cmds{{"dart", "<file>"}},
},
V: {
Extension: "v",
Commands: cmds{{"v", "run", "<file>"}},
},
Scala: {
Extension: "sc",
Commands: cmds{{"scala-cli", "run", "<file>"}},
},
Haskell: {
Extension: "hs",
Commands: cmds{{"runghc", "<file>"}},
},
Nushell: {
Extension: "nu",
Commands: cmds{{"nu", "--no-config-file", "<file>"}},
},
}