Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge decaffinated master into rebrand #29

Merged
merged 46 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
477b075
➡️ Migrate all language packages
icecream17 Jun 25, 2022
3399c06
lint
icecream17 Jun 26, 2022
18164b3
Bumped all languages to recent tree-sitter
mauricioszabo Jun 26, 2022
7299966
Bump Atom's tree-sitter
mauricioszabo Jun 26, 2022
ca062aa
remove all references to atom or atom community
Aug 7, 2022
9ccd895
Change the Discord links
Aug 7, 2022
bb658d9
Decaffeinate.
fabianfiorotto Aug 5, 2022
f6331c3
Merge remote-tracking branch 'origin/master' into bump-tree-sitter
mauricioszabo Aug 12, 2022
a61fd8c
Merge remote-tracking branch 'origin/master' into bump-tree-sitter
mauricioszabo Aug 12, 2022
3953211
Simpler way of running tests
mauricioszabo Aug 12, 2022
fd5028a
Fixed package-lock name
mauricioszabo Aug 13, 2022
63d1f26
Fixed tokenization for method invocation
mauricioszabo Aug 13, 2022
96c087f
Disabled an outdated test, and one that is a bug on tree-sitter
mauricioszabo Aug 13, 2022
59c0795
Adding some development notes
mauricioszabo Aug 14, 2022
23f08de
Fixed typo
mauricioszabo Aug 14, 2022
56ef773
Code-fying doc
mauricioszabo Aug 14, 2022
61b9df4
Merge remote-tracking branch 'origin/master' into bump-tree-sitter
mauricioszabo Aug 16, 2022
9eba102
Javascript fix
mauricioszabo Aug 16, 2022
ca3f822
Merge remote-tracking branch 'origin/master' into bump-tree-sitter
mauricioszabo Aug 16, 2022
e2d7a00
Update autocomplete-html
mauricioszabo Aug 16, 2022
16ad343
Lockfile update
mauricioszabo Aug 16, 2022
6e24438
Merge pull request #11 from stech11845/stech11845-patch-1
mauricioszabo Aug 18, 2022
6e42472
Merge pull request #14 from pulsar-edit/bump-tree-sitter
mauricioszabo Aug 18, 2022
e7f345d
Merge branch 'master' into decaffeinate
fabianfiorotto Aug 19, 2022
95bbdef
Fix some errors.
fabianfiorotto Aug 23, 2022
d56d37d
Merge pull request #13 from fabianfiorotto/decaffeinate
mauricioszabo Aug 23, 2022
9faae4f
Merge remote-tracking branch 'origin/master' into rebrand
Spiker985 Aug 23, 2022
c6c175d
Update docs/dev/README.md
confused-Techie Aug 29, 2022
02a42e5
Update packages/language-c/CONTRIBUTING.md
confused-Techie Aug 29, 2022
4b44a9c
Update packages/language-git/CONTRIBUTING.md
confused-Techie Aug 29, 2022
53afd13
Update packages/language-git/README.md
confused-Techie Aug 29, 2022
e53d789
Update packages/language-git/README.md
confused-Techie Aug 29, 2022
b083210
Update packages/language-git/README.md
confused-Techie Aug 29, 2022
ce27885
Update packages/language-c/README.md
confused-Techie Aug 29, 2022
34d8d80
Update packages/language-c/README.md
confused-Techie Aug 29, 2022
917d0b0
Update packages/language-clojure/README.md
confused-Techie Aug 29, 2022
26d12ca
Update packages/language-clojure/README.md
confused-Techie Aug 29, 2022
1143f35
Update packages/language-coffee-script/README.md
confused-Techie Aug 29, 2022
85a2c77
Update packages/language-coffee-script/README.md
confused-Techie Aug 29, 2022
b9d0df2
Update packages/language-csharp/README.md
confused-Techie Aug 29, 2022
32c267f
Update packages/language-csharp/README.md
confused-Techie Aug 29, 2022
a65ad52
Update packages/language-css/CONTRIBUTING.md
confused-Techie Aug 29, 2022
75c1a18
Update packages/language-css/README.md
confused-Techie Aug 29, 2022
f19b1a3
Update packages/language-css/README.md
confused-Techie Aug 29, 2022
9f3e1f0
Update packages/language-gfm/README.md
confused-Techie Aug 29, 2022
b0cf0d2
Update packages/language-gfm/CONTRIBUTING.md
confused-Techie Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
icecream17 committed Jun 26, 2022
commit 3399c06de1c874327da3b6e37f0d87fd0c1101f0
14 changes: 9 additions & 5 deletions packages/language-c/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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) { return language },
content (node) { return node.lastNamedChild }
})
language(node) {
return language;
},
content(node) {
return node.lastNamedChild;
}
});
}
}
}
};
64 changes: 44 additions & 20 deletions packages/language-html/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,63 @@
exports.activate = function () {
exports.activate = function() {
atom.grammars.addInjectionPoint('text.html.basic', {
type: 'script_element',
language () { return 'javascript' },
content (node) { return node.child(1) }
})
language() {
return 'javascript';
},
content(node) {
return node.child(1);
}
});

atom.grammars.addInjectionPoint('text.html.basic', {
type: 'style_element',
language () { return 'css' },
content (node) { return node.child(1) }
})
language() {
return 'css';
},
content(node) {
return node.child(1);
}
});

atom.grammars.addInjectionPoint('text.html.ejs', {
type: 'template',
language (node) { return 'javascript' },
content (node) { return node.descendantsOfType('code') },
language(node) {
return 'javascript';
},
content(node) {
return node.descendantsOfType('code');
},
newlinesBetween: true
})
});

atom.grammars.addInjectionPoint('text.html.ejs', {
type: 'template',
language (node) { return 'html' },
content (node) { return node.descendantsOfType('content') }
})
language(node) {
return 'html';
},
content(node) {
return node.descendantsOfType('content');
}
});

atom.grammars.addInjectionPoint('text.html.erb', {
type: 'template',
language (node) { return 'ruby' },
content (node) { return node.descendantsOfType('code') },
language(node) {
return 'ruby';
},
content(node) {
return node.descendantsOfType('code');
},
newlinesBetween: true
})
});

atom.grammars.addInjectionPoint('text.html.erb', {
type: 'template',
language (node) { return 'html' },
content (node) { return node.descendantsOfType('content') }
})
}
language(node) {
return 'html';
},
content(node) {
return node.descendantsOfType('content');
}
});
};
43 changes: 21 additions & 22 deletions packages/language-html/spec/tree-sitter-spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const dedent = require('dedent')
const dedent = require('dedent');

describe('Tree-sitter HTML grammar', () => {

beforeEach(async () => {
atom.config.set('core.useTreeSitterParsers', true)
await atom.packages.activatePackage('language-html')
})
atom.config.set('core.useTreeSitterParsers', true);
await atom.packages.activatePackage('language-html');
});

it('tokenizes punctuation in HTML tags and attributes', async () => {
const editor = await atom.workspace.open(`test.html`)
const editor = await atom.workspace.open(`test.html`);

editor.setText(dedent`
<html lang="en">
Expand All @@ -18,64 +17,64 @@ describe('Tree-sitter HTML grammar', () => {
</head>
<body>
</html>
`)
`);

// Tag punctuation.
expect(editor.scopeDescriptorForBufferPosition([0, 0]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.tag.begin'
)
);

expect(editor.scopeDescriptorForBufferPosition([0, 15]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.tag.end'
)
);

expect(editor.scopeDescriptorForBufferPosition([6, 0]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.tag.begin'
)
);

expect(editor.scopeDescriptorForBufferPosition([6, 6]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.tag.end'
)
);

// Attribute-value pair punctuation.
expect(editor.scopeDescriptorForBufferPosition([0, 10]).toString()).toBe(
'.text.html.basic .source.html .punctuation.separator.key-value.html'
)
);

expect(editor.scopeDescriptorForBufferPosition([2, 18]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.string.begin'
)
);

expect(editor.scopeDescriptorForBufferPosition([2, 24]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.string.end'
)
);

// Ensure an attribute value delimited by single-quotes won't mark a
// double-quote in the value as punctuation.
expect(editor.scopeDescriptorForBufferPosition([3, 15]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.string.begin'
)
);

expect(editor.scopeDescriptorForBufferPosition([3, 16]).toString()).toBe(
'.text.html.basic .source.html .string.html'
)
);

expect(editor.scopeDescriptorForBufferPosition([3, 17]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.string.end'
)
);

// Ensure an attribute value delimited by double-quotes won't mark a
// single-quote in the value as punctuation.
expect(editor.scopeDescriptorForBufferPosition([3, 27]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.string.begin'
)
);

expect(editor.scopeDescriptorForBufferPosition([3, 32]).toString()).toBe(
'.text.html.basic .source.html .string.html'
)
);

expect(editor.scopeDescriptorForBufferPosition([3, 66]).toString()).toBe(
'.text.html.basic .source.html .punctuation.definition.string.end'
)
})
})
);
});
});
74 changes: 39 additions & 35 deletions packages/language-javascript/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,86 @@
exports.activate = function () {
if (!atom.grammars.addInjectionPoint) return
exports.activate = function() {
if (!atom.grammars.addInjectionPoint) return;

atom.grammars.addInjectionPoint('source.js', {
type: 'call_expression',

language (callExpression) {
const {firstChild} = callExpression
language(callExpression) {
const { firstChild } = callExpression;
switch (firstChild.type) {
case 'identifier':
return languageStringForTemplateTag(firstChild.text)
return languageStringForTemplateTag(firstChild.text);
case 'call_expression':
return languageStringForTemplateTag(firstChild.children[0].text)
return languageStringForTemplateTag(firstChild.children[0].text);
case 'member_expression':
if (firstChild.startPosition.row === firstChild.endPosition.row) {
return languageStringForTemplateTag(firstChild.text)
return languageStringForTemplateTag(firstChild.text);
}
}
},

content (callExpression) {
const {lastChild} = callExpression
content(callExpression) {
const { lastChild } = callExpression;
if (lastChild.type === 'template_string') {
return lastChild
return lastChild;
}
}
})
});

atom.grammars.addInjectionPoint('source.js', {
type: 'assignment_expression',

language (callExpression) {
const {firstChild} = callExpression
language(callExpression) {
const { firstChild } = callExpression;
if (firstChild.type === 'member_expression') {
if (firstChild.lastChild.text === 'innerHTML') {
return 'html'
return 'html';
}
}
},

content (callExpression) {
const {lastChild} = callExpression
content(callExpression) {
const { lastChild } = callExpression;
if (lastChild.type === 'template_string') {
return lastChild
return lastChild;
}
}
})
});

atom.grammars.addInjectionPoint('source.js', {
type: 'regex_pattern',
language (regex) { return 'regex' },
content (regex) { return regex }
})
language(regex) {
return 'regex';
},
content(regex) {
return regex;
}
});

for (const scopeName of ['source.js', 'source.flow', 'source.ts']) {
atom.grammars.addInjectionPoint(scopeName, {
type: 'comment',
language (comment) {
if (comment.text.startsWith('/**')) return 'jsdoc'
language(comment) {
if (comment.text.startsWith('/**')) return 'jsdoc';
},
content (comment) {
return comment
content(comment) {
return comment;
}
})
});
}
}
};

const CSS_REGEX = /\bstyled\b|\bcss\b/i
const GQL_REGEX = /\bgraphql\b|\bgql\b/i
const SQL_REGEX = /\bsql\b/i
const CSS_REGEX = /\bstyled\b|\bcss\b/i;
const GQL_REGEX = /\bgraphql\b|\bgql\b/i;
const SQL_REGEX = /\bsql\b/i;

function languageStringForTemplateTag (tag) {
function languageStringForTemplateTag(tag) {
if (CSS_REGEX.test(tag)) {
return 'CSS'
return 'CSS';
} else if (GQL_REGEX.test(tag)) {
return 'GraphQL'
return 'GraphQL';
} else if (SQL_REGEX.test(tag)) {
return 'SQL'
return 'SQL';
} else {
return tag
return tag;
}
}
24 changes: 16 additions & 8 deletions packages/language-ruby/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
exports.activate = function() {
if (!atom.grammars.addInjectionPoint) return
if (!atom.grammars.addInjectionPoint) return;

atom.grammars.addInjectionPoint('source.ruby', {
type: 'heredoc_body',
language (node) { return node.lastChild.text },
content (node) { return node }
})
language(node) {
return node.lastChild.text;
},
content(node) {
return node;
}
});

atom.grammars.addInjectionPoint('source.ruby', {
type: 'regex',
language () { return 'regex' },
content (node) { return node }
})
}
language() {
return 'regex';
},
content(node) {
return node;
}
});
};
Loading