Vanilla 1.1.1 is a product of Lussumo. More Information: Documentation, Community Support.
I think this’ll work…
{
content: 'echo \'${1:string}\'${2: . };$0'
title: 'echo \'..\''
scope: 'source.php'
tab_trigger: 'echo'
}
All I did was copy and edit the php_print.itSnippets file and modified it to use echo, and your requested feature change (single quote over double)...not that hard at all…......
Forgot to mention, this should be created/saved in your Intype install folder under bundles/PHP.itBundle/snippets/php_echo.itSnippet
Oh, oops…there is an edit. Okay, a change needs to be made somewhere else too to allow for the snippet to be recognized. I haven’t read any documentation, so once I figure it out I’ll also update this. :P
As soon as you restart Intype the tab trigger should function, to add it to the menu you’ve got to edit ~/bundles/PHP.itBundle/info.itInfo. :)
I’ve tried and it won’t take. I’m guessing I have a parse error somewhere, though I can’t see where or how. I also thought that perhaps since it references source.php I should edit the info.itInfo file under the PHP.itBundle directory and add echo in with print, but that didn’t seem to take either. I don’t quite understand what the it.Grammar files work, and I’m thinking that in order to successfully add echo, I’ll have to understand this file first. Oh well, I thought it’d be easy.
It is easy but you can’t give up, you’re not able to escape quotes:
{
content: "echo '${1:string}'${2: . };$0"
title: ''
scope: 'source.php'
tab_trigger: 'echo'
}
:)
Can’t escape quotes?! Boo! I didn’t want to try that…although, I thought I tried that, I must not have restarted Intype when I tested it…oops.
Quote escaping would be nice to have…hmmm… Thanks though, David. That worked great, though I changed the title property to be more appropriate:
title "echo '..'"
Anyone know what the point of the grammar file for the languages’ purpose actually is? If it references it, I’d think there’s a reason…but it works without it actually being found in the grammar file.
Threre are two types of string in Jasmine: single quoted and double quoted.
Single quoted string is a very simple string for direct input and it does not translate any escape sequences. ‘ \n ‘ outputs \n as chars not as new line character. There’s only one special sequence for inserting a single quote into string: ‘’ (two single quotes).
Double quoted string supports these escapes:
Both strings are multilined. There are many other features in Jasmine and will be detailed in documentation.
Thank you for the explanation, Martin. Much appreciated! I’ll have to play around a bit to understand exactly how the ‘’ works, but I’m sure that’ll help me to figure this out more (but not explicitly asking you). ;) Thanks again!
this is nice-
{
content: “echo ${1:$2${3:value}$2};$0”
title: ‘echo..’
scope: ‘source.php’
tab_trigger: ‘echo’
}
first- do you want literal or not
2nd- use “value” or ‘value’
3rd- value
I’m not yet familiar with the syntax of bundles and highlighting. But it would be very conveniant for me that variables (and methods and properties in classes) would highlight in a specific color (now, it renders white). I’m currently using the “blackboard” theme.
Anyone can help to extend this?
Well, to add coloring, just add something like this to the theme file:
foreground: '#66CC33'
The PHP grammar file doesn’t have detection for class methods. To match $var->method(), the following regex *should* work:
(?<=\$[a-zA-Z_][a-zA-Z0-9_]*->)(\w+\()
But it doesn’t work. After an hour of trying out possibilities, I saw this little note in the Oniguruma Regex Library that Intype uses
Oniguruma Regex Readme: Subexp of look-behind must be fixed character length.
So, that means that we won’t be able to match just the “method(” part of the expression.. :(
ok, no problem, it would already be great if the following would be coloured.
$variabel01
$this->variable01
Wouldn’t changing the foreground color change the entire foreground color of all non-matchable text (including variables, but also e.g. equal signs etc)?
Just add/change the foreground attribute of the specific scope in the theme file. You can just color the variables scope in the itTheme file of your current theme. :)
$variable has already been assigned the variables scope in the PHP grammar file. You’re seeing it as white because the “blackboard” theme doesn’t color the scope “variables”. ;)
As for $this->variable01, you can use define a new scope in the grammar file by using lookbehinds using this regex: (?<=\$this->)([a-zA-Z_][a-zA-Z0-9_]*). Note that this regex won’t work for cases like “$variable2->variable01” because of the limitation of the Oniguruma regex implementation (since a pattern matching “variable2” will need to match strings of different lengths).
I didn’t really want to mention this possibility, since its.. err.. somewhat messy/unclean… but you can match “$variable2->methodN(” by a lookbehind that matches “—>” instead of the whole “$variable2->”. I don’t think its good practice to match class variables/methods without first ensuring that the text in front of the “->” is a variable.
After some email discussions with martin, he suggested naming captured submatches, which could achieve the same results as lookbehinds.
So, add the following to the PHP grammar file:
{
begin: /(\$[a-zA-Z_][a-zA-Z0-9_]*)(->)([a-zA-Z_][a-zA-Z0-9_]*)\(/
begin_captures: {
1: { name: 'variable.other.php' }
2: { name: 'keyword.operator.php' }
3: { name: 'meta.function.method.php' } // You can name this whatever you like
}
end: /\)/
}
You can then assign a color to the “meta.function.method.php” scope. Or simply color the “meta.function.php” scope, and rename “meta.function.method.php” accordingly, and get the same coloring as normal functions (which probably defeats the purpose of wanting to differentiate anyway, heh).
1 to 18 of 18