mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Add TODO and hyperlink injections to Rust
This commit is contained in:
parent
5e62e205b5
commit
0807dcfce5
@ -1,4 +1,4 @@
|
||||
exports.activate = function() {
|
||||
exports.activate = function () {
|
||||
for (const nodeType of ['macro_invocation', 'macro_rule']) {
|
||||
atom.grammars.addInjectionPoint('source.rust', {
|
||||
type: nodeType,
|
||||
@ -13,4 +13,29 @@ exports.activate = function() {
|
||||
coverShallowerScopes: true
|
||||
});
|
||||
}
|
||||
|
||||
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?:/
|
||||
|
||||
for (let type of ['line_comment', 'block_comment']) {
|
||||
atom.grammars.addInjectionPoint('source.rust', {
|
||||
type,
|
||||
language: (node) => {
|
||||
return TODO_PATTERN.test(node.text) ? 'todo' : undefined;
|
||||
},
|
||||
content: (node) => node,
|
||||
languageScope: null
|
||||
});
|
||||
}
|
||||
|
||||
for (let type of ['string_literal', 'raw_string_literal', 'line_comment', 'block_comment']) {
|
||||
atom.grammars.addInjectionPoint('source.rust', {
|
||||
type,
|
||||
language: (node) => {
|
||||
return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined;
|
||||
},
|
||||
content: (node) => node,
|
||||
languageScope: null
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user