How to add not html syntax snippet in Sublime with Emmet? - sublimetext3

The old Emmet work fined, but now my Sublime has upgraded Emmet plugin to the latest version automatically, and the following snippets doesn't work anymore...
The latest Emmet can only accept HTML syntax on custom snippets
These snippets my seems odd, since these are my custom tag which will be convert into php code in Template Engine, so the code aren't HTML syntax.
For instance, when I type p1 and press tab, I want it give me <!--{if }-->:
{
"config": {
// Configure snippets/options for HTML syntax only.
// For a list of supported syntaxes, check out keys of `syntax_scopes`
// dictionary of `Emmet.sublime-settings`
"html": {
"snippets": {
"p1": "<!--{if }-->",
"l1": "<!--{/if}-->",
"p2": "<!--{loop }-->",
"l2": "<!--{/loop}-->",
"p3": "<!--{eval }-->",
"p4": "<!--{block }-->",
"l4": "<!--{/block}-->",
"else": "<!--{else}-->",
"elif": "<!--{elseif }-->"
}
}
}
}

New Emmet accepts snippet values as Emmet abbreviations (yep, a recursion) and plays better with native ST snippets. Thus, you should either add your snippets as native in ST, or if you still want to use Emmet for such snippets, you should write them as valid Emmet abbreviation. To output arbitrary text in Emmet abbreviation, you should write it as text node, e.g. wrap with { and }.
So, your snippet should look like this:
"p1": "{<!--{if }-->}"

Related

How to customize a popup from a toolbar button in Kentico.EMS12.MvcComponents.Widget.RichText

I recently added the nuget packaget for Kentico.EMS12.MvcComponents.Widget.RichText to take advantage of the new froala based widget and inline editor. This version (based on froala documentation) is very customizable. Unfortunately the implementation of the nuget package appears to have hidden the base froala library therefore making a big part of the froala documentation not applicable. I was curious if someone could tell me how I can go about making the calls to customize a toolbar command. The big issue I had with my initial attempts was I couldn't access the base froala library which means I couldn't make the calls listed in the documentation (for adding a command for example). I looked at using an event but still didn't seem to be able to get code running in an appropriate context.
The customization of the Rich text widget is a brand new feature and has just been documented here: https://github.com/Kentico/ems-mvc-components/wiki/Implementing-Rich-text-editor-plugins.
Kentico will pass the FroalaEditor object as a function parameter into your plugin.
Your plugin can be pushed into the Rich text plugins register. See plugins.push(myButtonPlugin);
(function (pageBuilder) {
var richTextEditor = pageBuilder.richTextEditor = pageBuilder.richTextEditor || {};
var plugins = richTextEditor.plugins = richTextEditor.plugins || [];
var sampleButtonPlugin = function (FroalaEditor) {
FroalaEditor.DefineIcon("sampleButtonIcon", { NAME: "star", SVG_KEY: "help" });
FroalaEditor.RegisterCommand("sampleButton", {
title: "Sample Button",
icon: "sampleButtonIcon",
callback: function () {
// Use the current context to work with the content of the inline editor.
console.log(this.html.get());
}
});
};
plugins.push(myButtonPlugin);
})(window.kentico.pageBuilder);

How to implement localization with dialogs exported as libraries

I have packaged some of my dialogs as libraries by following the instructions from the basics-libraries example. Before, I had all dialogs in app.js and I used localization following the instructions from the documentation. For example, I used
var chatBot = new builder.UniversalBot(chatConnector, {
localizerSettings: {
botLocalePath: "./locale",
defaultLocale: "de"
}
});
and
session.preferredLocale("de");
to use German for all the prompt labels, and stored all the German translations in ./locale/de/index.json and ./locale/de/BotBuilder.json.
However, the localization doesn't work with the dialogs I have packaged into libraries. Instead of the localized strings only the message IDs are displayed.
It works if I use session.localizer.gettext(session.preferredLocale(), "message ID") on each string. However, that is very tedious, and I am wondering if there is a way to localize all strings inside a library at once.
In order to this to work, your locale file should have the same name as your library.
./my_bot_library.js
./locale/en/my_bot_library.json
Then, to get your localized text you can either use:
session.localizer.gettext(session.preferredLocale(), 'message ID', 'my_bot_library')
Please note that the the third parameter is the namespace that
represents the library name
or just the following which internally resolves the preferred Locale and current namespace/library name
session.gettext('message_id') or session.send('message_id')

Android Studio: $END$ and $SELECTION$ in live template

I cannot get cursor in $END$ position when template inserted without surrounding (with selected text it works fine).
//region MyRegion
$SELECTION$$END$
//endregion
Is it possible to solve it in any way?
Android Studio version is 2.2.3.
UPDATE
To make question clear I have added steps to reproduce:
1) Create live template (surrounding) as it is specified above.
2) Give it some name, for example #mrgn.
3) Inside some class try to use it. So type #mrgn and press TAB.
It should insert the following text:
public class SomeClass {
//region MyRegion
< cursor should be here
//endregion
}
But it inserts text and place cursor in wrong place:
public class SomeClass {
//region MyRegion
< cursor is here.. but spaces are inserted, so only cursor does not work.
//endregion
}
You can fix this by creating 2 Live Templates. one for the surround one without.
Unfortunately that means that you will need to put up with 2 different aliases.
'regionSur'
//region MyRegion
$SELECTION$$END$
//endregion
'region'
//region MyRegion
$END$
//endregion
This isn't so bad, as the only time you see the surround syntax is when using the keyboard shortcut, instead of the auto complete lists.
The actual bug lies in the behaviour of $selection$ when it is empty, $END$ works fine.

How to differentiate color scheme

I would like to change color scheme Eiffel so that the keyword class in java files will be different color than keyword int? If I change Storage in Eiffel, both keywords change the color.
You need to find out the exact scopes of class and int. The PackageResourceViewer is a great way to open files inside .sublime-package files.
Once installed, launch *ā€¯PackageResourceViewer: Open Resource, open the Java package and look for the syntax files (e.g.Java.sublime-syntax`).
I'm not familiar enough with Java, but it looks to me like class uses the scope meta.class and int uses storage.type.primitive.array. That means, that in your theme you would at least have to change meta or storage. Needless to say that you can be more specific than that.
Using a nice little plugin called ScopeAlways, you can see in the status bar the full scope underlying your cursor (if you have multiple cursors, it just uses the first one). In Sublime Text 2, using the following code:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
int integer = 13;
}
}
The word class is scoped as storage.modifier.java, whereas int is scoped as storage.type.primitive.array.java (I removed a few unimportant extraneous scopes from each for clarity). So, in your theme, you could have one color for storage.modifier, and another for storage.type, to differentiate between class and int. Be aware, however, that many other keywords will fall under both scopes, so your custom colors won't just highlight those particular words.
Good luck!

jquery support works in html but not in .js?

Trying out komodo to build a jquery ui widget.. I enabled the jquery api reference and in a .html file it works great.. I then open my widget.js file and type in;
(function($) {
followed by
$.
I would expect to get intellisense here, but instead I get:
No completions found. (Error determining completions)
Is this a file extension thing? Are jquery ui widgets just unsupported?
From the guys at Komodo;
The problem is that Komodo doesn't know the context of the anonymous
function call - in other words Komodo is not smart enough to know that
"jQuery" == "$" in this case.
But all is not lost, you can help out Komodo by telling it what the
type is in such cases. Here is the example that uses jsDoc to help
define the type of "$":
(/** #param {jQuery} $ */function($) {
$. // will show jQuery completions now
})(jQuery)
;
The argument is the problem. Without it:
(function()
{
$. //works
jQuery. //works
...
}
);
Komodo knows both $ and jQuery as globals. Local scope takes precedence, so $ becomes undefined. Conversely, if you pass in jQuery instead, $ will work, but jQuery will not:
(function(jQuery)
{
$. //works
jQuery. //does not
...
}
);

Resources