mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Add TODO and hyperlink injections to C/C++
This commit is contained in:
parent
0807dcfce5
commit
bbf4cb4417
@ -1,10 +1,10 @@
|
||||
exports.activate = function() {
|
||||
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(node) {
|
||||
language() {
|
||||
return language;
|
||||
},
|
||||
content(node) {
|
||||
@ -12,5 +12,28 @@ exports.activate = function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"atom": "*",
|
||||
"node": "*"
|
||||
"node": ">=12"
|
||||
},
|
||||
"dependencies": {
|
||||
"tree-sitter-c": "0.20.2",
|
||||
|
Loading…
Reference in New Issue
Block a user