mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-26 11:08:40 +03:00
Final rule for js* and native/raw macros
This commit is contained in:
parent
24b3f91b6d
commit
d28f28dd9c
@ -14,6 +14,11 @@
|
||||
.
|
||||
(sym_lit) @keyword.control.conditional.when (#eq? @keyword.control.conditional.when "when"))
|
||||
|
||||
(list_lit
|
||||
"(" @punctuation.section.expression.begin (#is-not? test.descendantOfNodeWithData clojure.dismissTag)
|
||||
.
|
||||
(sym_lit) @keyword.control.js.clojure (#eq? @keyword.control.js.clojure "js*"))
|
||||
|
||||
;; Syntax quoting
|
||||
((syn_quoting_lit)
|
||||
@meta.syntax-quoted
|
||||
|
@ -3,17 +3,19 @@ const path = require('path');
|
||||
exports.activate = function() {
|
||||
if (!atom.grammars.addInjectionPoint) return;
|
||||
|
||||
const notDisChild = (node) => {
|
||||
let parent = node.parent
|
||||
while(parent) {
|
||||
if(parent.type === 'dis_expr') return null
|
||||
parent = parent.parent
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
atom.grammars.addInjectionPoint('source.clojure', {
|
||||
type: 'quoting_lit',
|
||||
language: () => 'source-clojure-edn',
|
||||
content: (node) => {
|
||||
let parent = node.parent
|
||||
while(parent) {
|
||||
if(parent.type === 'dis_expr') return null
|
||||
parent = parent.parent
|
||||
}
|
||||
return node
|
||||
},
|
||||
content: notDisChild,
|
||||
includeChildren: true,
|
||||
languageScope: 'source.clojure',
|
||||
coverShallowerScopes: true
|
||||
@ -31,4 +33,30 @@ exports.activate = function() {
|
||||
languageScope: 'source.clojure',
|
||||
coverShallowerScopes: true
|
||||
});
|
||||
|
||||
const checkFormCall = (specialFormText, node) => {
|
||||
let parent = node.parent
|
||||
let grandparent = parent?.parent
|
||||
return grandparent &&
|
||||
grandparent.children[2].id === parent.id &&
|
||||
grandparent.children[1].text === specialFormText
|
||||
}
|
||||
|
||||
atom.grammars.addInjectionPoint('source.clojure', {
|
||||
type: 'str_content',
|
||||
language: (node) => checkFormCall('js*', node) && 'javascript',
|
||||
content: notDisChild,
|
||||
includeChildren: true,
|
||||
languageScope: 'source.js',
|
||||
coverShallowerScopes: true
|
||||
});
|
||||
|
||||
atom.grammars.addInjectionPoint('source.clojure', {
|
||||
type: 'str_content',
|
||||
language: (node) => checkFormCall('native/raw', node) && 'cpp',
|
||||
content: notDisChild,
|
||||
includeChildren: true,
|
||||
languageScope: 'source.cpp',
|
||||
coverShallowerScopes: true
|
||||
});
|
||||
}
|
||||
|
@ -177,3 +177,16 @@ error/
|
||||
#_
|
||||
(cond-> true 10)
|
||||
; ^ !keyword.control.conditional.cond
|
||||
|
||||
;; Specific stuff
|
||||
(js* "console.log('abc');", "'foo'")
|
||||
; ^ keyword.control.js.clojure
|
||||
; ^ support.class.builtin.console.js
|
||||
; ^ string.quoted.single.js
|
||||
; ^ !string.quoted.single.js
|
||||
|
||||
(native/raw "cout << 10;", "10")
|
||||
; ^ keyword.operator.bitwise.cpp
|
||||
; ^ constant.numeric.cpp
|
||||
; ^ !constant.numeric.cpp
|
||||
;; ^ keyword.control.jank.clojure
|
||||
|
@ -9,8 +9,9 @@ function setConfigForLanguageMode(mode) {
|
||||
}
|
||||
|
||||
describe('Clojure grammars', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await atom.packages.activatePackage('language-c');
|
||||
await atom.packages.activatePackage('language-javascript');
|
||||
await atom.packages.activatePackage('language-clojure');
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user