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
39 lines (36 loc) · 1.15 KB
/
Copy pathmain.js
File metadata and controls
39 lines (36 loc) · 1.15 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
exports.activate = function () {
// Highlight macro bodies as C/C++
for (const language of ['c', 'cpp']) {
for (const nodeType of ['preproc_def', 'preproc_function_def']) {
atom.grammars.addInjectionPoint(`source.${language}`, {
type: nodeType,
language() {
return language;
},
content(node) {
return node.lastNamedChild;
}
});
}
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.${language}`, {
type: 'comment',
language: (node) => {
return TODO_PATTERN.test(node.text) ? 'todo' : undefined;
},
content: (node) => node,
languageScope: null
});
for (let type of ['string_literal', 'comment']) {
atom.grammars.addInjectionPoint(`source.${language}`, {
type,
language: (node) => {
return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined;
},
content: (node) => node,
languageScope: null
});
}
}
};