Skip to content

Commit 87a9621

Browse files
committed
inital commit
0 parents  commit 87a9621

26 files changed

+2065
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.nrepl-port
2+
3+
obj
4+
bin
5+
6+
*.suo
7+
8+
fs-src/ltfsclient/log.txt
9+
10+
target
11+

LICENSE.md

+596
Large diffs are not rendered by default.

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## F# plugin for Light Table
2+
3+
This plugin is an alpha implementation of a F# plugin for the [Light Table](http://www.lighttable.com) IDE. It can evaluate the contents of a fsharp file selection.
4+
5+
## Installation and Usage
6+
7+
1. From LightTable's plugin manager, choose the available tab and double-click the "F#" plugin to install it.
8+
2. fsi (fsharp interactive) should be in your PATH
9+
4. Open up a fsharp file, select some code and use `ctrl/cmd-enter` to eval it.
10+
11+
## Requirements
12+
13+
You'll need .NET Framework 4 and FSharp 3.0 installed
14+
15+
## Acknowledgements
16+
17+
The clojurescript / lighttable side started by using the Python plugin as a template.
18+
19+
The CodeMirror file is from [CodeMirror](https://github.com/marijnh/CodeMirror)
20+
21+
## Changelog
22+
23+
##### 0.0.1
24+
25+
Initial release with eval of selections
26+
27+
###License
28+
29+
Copyright (C) 2014 Enrico Sada
30+
31+
Distributed under the GPLv3, see LICENSE.md for the full text.
32+
33+
CodeMirror file 'codemirror/fsharp.js' is under [CodeMirror license](https://github.com/marijnh/CodeMirror/blob/master/LICENSE)

codemirror/fsharp.js

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
// copied from: https://github.com/marijnh/CodeMirror/blob/master/mode/mllike/mllike.js
2+
// under license: https://github.com/marijnh/CodeMirror/blob/master/LICENSE
3+
4+
CodeMirror.defineMode('mllike', function(_config, parserConfig) {
5+
6+
var words = {
7+
'let': 'keyword',
8+
'rec': 'keyword',
9+
'in': 'keyword',
10+
'of': 'keyword',
11+
'and': 'keyword',
12+
'if': 'keyword',
13+
'then': 'keyword',
14+
'else': 'keyword',
15+
'for': 'keyword',
16+
'to': 'keyword',
17+
'while': 'keyword',
18+
'do': 'keyword',
19+
'done': 'keyword',
20+
'fun': 'keyword',
21+
'function': 'keyword',
22+
'val': 'keyword',
23+
'type': 'keyword',
24+
'mutable': 'keyword',
25+
'match': 'keyword',
26+
'with': 'keyword',
27+
'try': 'keyword',
28+
'open': 'builtin',
29+
'ignore': 'builtin',
30+
'begin': 'keyword',
31+
'end': 'keyword'
32+
};
33+
34+
var extraWords = parserConfig.extraWords || {};
35+
for (var prop in extraWords) {
36+
if (extraWords.hasOwnProperty(prop)) {
37+
words[prop] = parserConfig.extraWords[prop];
38+
}
39+
}
40+
41+
function tokenBase(stream, state) {
42+
var ch = stream.next();
43+
44+
if (ch === '"') {
45+
state.tokenize = tokenString;
46+
return state.tokenize(stream, state);
47+
}
48+
if (ch === '(') {
49+
if (stream.eat('*')) {
50+
state.commentLevel++;
51+
state.tokenize = tokenComment;
52+
return state.tokenize(stream, state);
53+
}
54+
}
55+
if (ch === '~') {
56+
stream.eatWhile(/\w/);
57+
return 'variable-2';
58+
}
59+
if (ch === '`') {
60+
stream.eatWhile(/\w/);
61+
return 'quote';
62+
}
63+
if (ch === '/' && parserConfig.slashComments && stream.eat('/')) {
64+
stream.skipToEnd();
65+
return 'comment';
66+
}
67+
if (/\d/.test(ch)) {
68+
stream.eatWhile(/[\d]/);
69+
if (stream.eat('.')) {
70+
stream.eatWhile(/[\d]/);
71+
}
72+
return 'number';
73+
}
74+
if ( /[+\-*&%=<>!?|]/.test(ch)) {
75+
return 'operator';
76+
}
77+
stream.eatWhile(/\w/);
78+
var cur = stream.current();
79+
return words[cur] || 'variable';
80+
}
81+
82+
function tokenString(stream, state) {
83+
var next, end = false, escaped = false;
84+
while ((next = stream.next()) != null) {
85+
if (next === '"' && !escaped) {
86+
end = true;
87+
break;
88+
}
89+
escaped = !escaped && next === '\\';
90+
}
91+
if (end && !escaped) {
92+
state.tokenize = tokenBase;
93+
}
94+
return 'string';
95+
};
96+
97+
function tokenComment(stream, state) {
98+
var prev, next;
99+
while(state.commentLevel > 0 && (next = stream.next()) != null) {
100+
if (prev === '(' && next === '*') state.commentLevel++;
101+
if (prev === '*' && next === ')') state.commentLevel--;
102+
prev = next;
103+
}
104+
if (state.commentLevel <= 0) {
105+
state.tokenize = tokenBase;
106+
}
107+
return 'comment';
108+
}
109+
110+
return {
111+
startState: function() {return {tokenize: tokenBase, commentLevel: 0};},
112+
token: function(stream, state) {
113+
if (stream.eatSpace()) return null;
114+
return state.tokenize(stream, state);
115+
},
116+
117+
blockCommentStart: "(*",
118+
blockCommentEnd: "*)",
119+
lineComment: parserConfig.slashComments ? "//" : null
120+
};
121+
});
122+
123+
CodeMirror.defineMIME('text/x-fsharp', {
124+
name: 'mllike',
125+
extraWords: {
126+
'abstract': 'keyword',
127+
'as': 'keyword',
128+
'assert': 'keyword',
129+
'base': 'keyword',
130+
'class': 'keyword',
131+
'default': 'keyword',
132+
'delegate': 'keyword',
133+
'downcast': 'keyword',
134+
'downto': 'keyword',
135+
'elif': 'keyword',
136+
'exception': 'keyword',
137+
'extern': 'keyword',
138+
'finally': 'keyword',
139+
'global': 'keyword',
140+
'inherit': 'keyword',
141+
'inline': 'keyword',
142+
'interface': 'keyword',
143+
'internal': 'keyword',
144+
'lazy': 'keyword',
145+
'let!': 'keyword',
146+
'member' : 'keyword',
147+
'module': 'keyword',
148+
'namespace': 'keyword',
149+
'new': 'keyword',
150+
'null': 'keyword',
151+
'override': 'keyword',
152+
'private': 'keyword',
153+
'public': 'keyword',
154+
'return': 'keyword',
155+
'return!': 'keyword',
156+
'select': 'keyword',
157+
'static': 'keyword',
158+
'struct': 'keyword',
159+
'upcast': 'keyword',
160+
'use': 'keyword',
161+
'use!': 'keyword',
162+
'val': 'keyword',
163+
'when': 'keyword',
164+
'yield': 'keyword',
165+
'yield!': 'keyword',
166+
167+
'List': 'builtin',
168+
'Seq': 'builtin',
169+
'Map': 'builtin',
170+
'Set': 'builtin',
171+
'int': 'builtin',
172+
'string': 'builtin',
173+
'raise': 'builtin',
174+
'failwith': 'builtin',
175+
'not': 'builtin',
176+
'true': 'builtin',
177+
'false': 'builtin'
178+
},
179+
slashComments: true
180+
});

0 commit comments

Comments
 (0)