main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. exports.activate = function () {
  2. if (!atom.grammars.addInjectionPoint) return;
  3. atom.grammars.addInjectionPoint('source.ruby', {
  4. type: 'heredoc_body',
  5. language(node) {
  6. return node.lastChild.text;
  7. },
  8. content(node) {
  9. return node.descendantsOfType('heredoc_content')
  10. },
  11. });
  12. atom.grammars.addInjectionPoint('source.ruby', {
  13. type: 'regex',
  14. language() {
  15. return 'rb-regex';
  16. },
  17. content(node) {
  18. return node;
  19. },
  20. languageScope: null,
  21. includeChildren: true,
  22. // coverShallowerScopes: false
  23. });
  24. const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/;
  25. const HYPERLINK_PATTERN = /\bhttps?:/
  26. atom.grammars.addInjectionPoint('source.ruby', {
  27. type: 'comment',
  28. language: (node) => {
  29. return TODO_PATTERN.test(node.text) ? 'todo' : null;
  30. },
  31. content: (node) => node,
  32. languageScope: null
  33. });
  34. atom.grammars.addInjectionPoint('source.ruby', {
  35. type: 'comment',
  36. language: (node) => {
  37. return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : null;
  38. },
  39. content: (node) => node,
  40. languageScope: null
  41. });
  42. atom.grammars.addInjectionPoint('source.ruby', {
  43. type: 'string_content',
  44. language: (node) => {
  45. return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : null;
  46. },
  47. content: (node) => node,
  48. languageScope: null
  49. });
  50. };