forked from pulsar-edit/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
43 lines (37 loc) · 1.16 KB
/
Copy pathmain.js
File metadata and controls
43 lines (37 loc) · 1.16 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
exports.activate = () => {
const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/;
const HYPERLINK_PATTERN = /\bhttps?:/
atom.grammars.addInjectionPoint('source.css', {
type: 'comment',
language(node) {
return TODO_PATTERN.test(node.text) ? 'todo' : undefined;
},
content: (node) => node,
languageScope: null
});
for (let type of ['comment', 'string_value']) {
atom.grammars.addInjectionPoint('source.css', {
type,
language(node) {
return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined;
},
content: (node) => node,
languageScope: null
});
}
// Catch things like
//
// @import url(https://www.example.com/style.css);
//
// where the URL is unquoted.
atom.grammars.addInjectionPoint('source.css', {
type: 'call_expression',
language: () => 'hyperlink',
content: (node) => {
let functionName = node.descendantsOfType('function_value')[0]?.text;
if (!functionName === 'url') { return null; }
return node.descendantsOfType('plain_value');
},
languageScope: null
});
};