forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
8,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
], | ||
"stopOnEntry": false, | ||
"sourceMaps": true, | ||
"outDir": "${workspaceFolder}/out", | ||
"preLaunchTask": "npm" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "2.0.0", | ||
"command": "npm", | ||
"type": "shell", | ||
"presentation": { | ||
"reveal": "silent" | ||
}, | ||
"args": ["run", "compile"], | ||
"isBackground": true, | ||
"problemMatcher": "$tsc-watch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test/** | ||
build/** | ||
out/test/** | ||
src/** | ||
tsconfig.json | ||
cgmanifest.json | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
const updateGrammar = require('../../../build/npm/update-grammar'); | ||
|
||
function adaptInjectionScope(grammar) { | ||
// we're using the HTML grammar from https://github.com/textmate/html.tmbundle which has moved away from source.js.embedded.html | ||
// also we need to add source.css scope for PHP code in <style> tags, which are handled differently in atom | ||
const oldInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js.embedded.html - (meta.embedded.block.php | meta.embedded.line.php))"; | ||
const newInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.css - (meta.embedded.block.php | meta.embedded.line.php))"; | ||
|
||
const injections = grammar.injections; | ||
const injection = injections[oldInjectionKey]; | ||
if (!injection) { | ||
throw new Error("Can not find PHP injection to patch"); | ||
} | ||
delete injections[oldInjectionKey]; | ||
injections[newInjectionKey] = injection; | ||
} | ||
|
||
function includeDerivativeHtml(grammar) { | ||
grammar.patterns.forEach(pattern => { | ||
if (pattern.include === 'text.html.basic') { | ||
pattern.include = 'text.html.derivative'; | ||
} | ||
}); | ||
} | ||
|
||
// Workaround for https://github.com/Microsoft/vscode/issues/40279 | ||
// and https://github.com/Microsoft/vscode-textmate/issues/59 | ||
function fixBadRegex(grammar) { | ||
function fail(msg) { | ||
throw new Error(`fixBadRegex callback couldn't patch ${msg}. It may be obsolete`); | ||
} | ||
|
||
const scopeResolution = grammar.repository['scope-resolution']; | ||
if (scopeResolution) { | ||
const match = scopeResolution.patterns[0].match; | ||
if (match === '(?i)([a-z_\\x{7f}-\\x{7fffffff}\\\\][a-z0-9_\\x{7f}-\\x{7fffffff}\\\\]*)(?=\\s*::)') { | ||
scopeResolution.patterns[0].match = '([A-Za-z_\\x{7f}-\\x{7fffffff}\\\\][A-Za-z0-9_\\x{7f}-\\x{7fffffff}\\\\]*)(?=\\s*::)'; | ||
} else { | ||
fail('scope-resolution.match'); | ||
} | ||
} else { | ||
fail('scope-resolution'); | ||
} | ||
|
||
const functionCall = grammar.repository['function-call']; | ||
if (functionCall) { | ||
const begin0 = functionCall.patterns[0].begin; | ||
if (begin0 === '(?xi)\n(\n \\\\?(?<![a-z0-9_\\x{7f}-\\x{7fffffff}]) # Optional root namespace\n [a-z_\\x{7f}-\\x{7fffffff}][a-z0-9_\\x{7f}-\\x{7fffffff}]* # First namespace\n (?:\\\\[a-z_\\x{7f}-\\x{7fffffff}][a-z0-9_\\x{7f}-\\x{7fffffff}]*)+ # Additional namespaces\n)\\s*(\\()') { | ||
functionCall.patterns[0].begin = '(?x)\n(\n \\\\?(?<![a-zA-Z0-9_\\x{7f}-\\x{7fffffff}]) # Optional root namespace\n [a-zA-Z_\\x{7f}-\\x{7fffffff}][a-zA-Z0-9_\\x{7f}-\\x{7fffffff}]* # First namespace\n (?:\\\\[a-zA-Z_\\x{7f}-\\x{7fffffff}][a-zA-Z0-9_\\x{7f}-\\x{7fffffff}]*)+ # Additional namespaces\n)\\s*(\\()'; | ||
} else { | ||
fail('function-call.begin0'); | ||
} | ||
|
||
const begin1 = functionCall.patterns[1].begin; | ||
if (begin1 === '(?i)(\\\\)?(?<![a-z0-9_\\x{7f}-\\x{7fffffff}])([a-z_\\x{7f}-\\x{7fffffff}][a-z0-9_\\x{7f}-\\x{7fffffff}]*)\\s*(\\()') { | ||
functionCall.patterns[1].begin = '(\\\\)?(?<![a-zA-Z0-9_\\x{7f}-\\x{7fffffff}])([a-zA-Z_\\x{7f}-\\x{7fffffff}][a-zA-Z0-9_\\x{7f}-\\x{7fffffff}]*)\\s*(\\()'; | ||
} else { | ||
fail('function-call.begin1'); | ||
} | ||
} else { | ||
fail('function-call'); | ||
} | ||
} | ||
|
||
updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex); | ||
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', grammar => { | ||
adaptInjectionScope(grammar); | ||
includeDerivativeHtml(grammar); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"registrations": [ | ||
{ | ||
"component": { | ||
"type": "git", | ||
"git": { | ||
"name": "language-php", | ||
"repositoryUrl": "https://github.com/atom/language-php", | ||
"commitHash": "b95dc79f30084c25547397ab41388af154e69895" | ||
} | ||
}, | ||
"license": "MIT", | ||
"version": "0.44.3" | ||
} | ||
], | ||
"version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"comments": { | ||
"lineComment": "//", // "#" | ||
"blockComment": [ "/*", "*/" ] | ||
}, | ||
"brackets": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"] | ||
], | ||
"autoClosingPairs": [ | ||
{ "open": "{", "close": "}", "notIn": ["string"] }, | ||
{ "open": "[", "close": "]", "notIn": ["string"] }, | ||
{ "open": "(", "close": ")", "notIn": ["string"] }, | ||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }, | ||
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, | ||
{ "open": "/**", "close": " */", "notIn": ["string"] } | ||
], | ||
"surroundingPairs": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"], | ||
["'", "'"], | ||
["\"", "\""], | ||
["`", "`"] | ||
], | ||
"indentationRules": { | ||
"increaseIndentPattern": "({(?!.*}).*|\\(|\\[|((else(\\s)?)?if|else|for(each)?|while|switch|case).*:)\\s*((/[/*].*|)?$|\\?>)", | ||
"decreaseIndentPattern": "^(.*\\*\\/)?\\s*((\\})|(\\)+[;,])|(\\][;,])|\\b(else:)|\\b((end(if|for(each)?|while|switch)|break);))" | ||
}, | ||
"folding": { | ||
"markers": { | ||
"start": "^\\s*(#|\/\/)region\\b", | ||
"end": "^\\s*(#|\/\/)endregion\\b" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "php", | ||
"displayName": "%displayName%", | ||
"description": "%description%", | ||
"version": "1.0.0", | ||
"publisher": "vscode", | ||
"license": "MIT", | ||
"engines": { | ||
"vscode": "0.10.x" | ||
}, | ||
"contributes": { | ||
"languages": [ | ||
{ | ||
"id": "php", | ||
"extensions": [ | ||
".php", | ||
".php4", | ||
".php5", | ||
".phtml", | ||
".ctp" | ||
], | ||
"aliases": [ | ||
"PHP", | ||
"php" | ||
], | ||
"firstLine": "^#!\\s*/.*\\bphp\\b", | ||
"mimetypes": [ | ||
"application/x-php" | ||
], | ||
"configuration": "./language-configuration.json" | ||
} | ||
], | ||
"grammars": [ | ||
{ | ||
"language": "php", | ||
"scopeName": "source.php", | ||
"path": "./syntaxes/php.tmLanguage.json" | ||
} | ||
], | ||
"snippets": [ | ||
{ | ||
"language": "php", | ||
"path": "./snippets/php.snippets.json" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"update-grammar": "node ./build/update-grammar.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"displayName": "PHP Language Basics", | ||
"description": "Provides syntax highlighting and bracket matching for PHP files." | ||
} |
Oops, something went wrong.