Add TODO and hyperlink injections to C/C++

This commit is contained in:
Andrew Dupont 2024-01-08 17:33:34 -08:00
parent 0807dcfce5
commit bbf4cb4417
2 changed files with 26 additions and 3 deletions

View File

@ -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
});
}
}
};

View File

@ -10,7 +10,7 @@
"license": "MIT",
"engines": {
"atom": "*",
"node": "*"
"node": ">=12"
},
"dependencies": {
"tree-sitter-c": "0.20.2",