Sublime Forum

Custom Completions Not Displaying

#1

Hi,

I’m trying to create a simple creations file for use with Sahi (.sah) files. I’ve followed the instructions in the documentation and in this forum but for whatever reason, they do not display. I’ve created a file named sahi.sublime-completions (see condensed contents below) and put it in AppData/Roaming/Sublime Text 2/Packages/User/ . I open a .sah file and hit ctrl-space and none of the completions display… nor when I start typing their names.

What am I doing wrong?

TIA,
Brian

{
    "scope": "source.sah",
    "completions":
    
		"_alert",
		"_assertEqual",
		"_assertNotEqual",
		"_assertNotNull",
		"_assertNull",
		"_set"
    ]
}
0 Likes

#2

If I save a file with extension .sah it still says ‘Plain Text’ at the bottom-right corner.

Your completions show if I amend the scope to “text”, but I don’t know if there is a way to register .sah as a “source” file (rather than plain text). I’m guessing it requires a corresponding .tmLanguage file before it’s recognised.

0 Likes

#3

Ahhh… interesting.

FYI, Sahi code is 99.9% javascript, and I’m associating (“open all with current extension as…”) my .sah files the javascript syntax highlighting (which is what I want). So then is there a way to associate .sah files more formally with Javascript so that I could then add my completions and retain js syntax highlights? Or perhaps another way to accomplish the same?

Thanks,
Brian

0 Likes

#4

If it’s treating .sah as JS then try amending the scope for your completions to:

"scope": "source.js -string -comment -constant",

If you look towards the top of the ‘JavaScript.tmLanguage’ file you should see this:

<dict> <key>comment</key> <string>JavaScript Syntax: version 2.0</string> <key>fileTypes</key> <array> <string>js</string> <string>htc</string> <string>jsx</string> </array>

I assume you could just add sah to this (carefully!!). In which case, you might be able to revert to ‘source.sah’ as your scope. Andy.

0 Likes

#5

… also, completions files can include snippets, as well as just simple word lists. So you could consider replacing “_set” with:

{ "trigger": "_set", "contents": "_set(${1:variableName}, ${2:value});$0" },

so that you could Tab between, and insert, the arguments. If an argument is optional, I tend to use square brackets:

{ "trigger": "_set", "contents": "_set(${1:variableName}${2:, value]});$0" },

this way, it reminds me that it’s optional, and I can either press delete, or over-type with ‘, my_value’. Andy.

PS I realise ‘value’ is not (really) optional in this case :wink:

0 Likes

#6

Nice ideas Andy but I’m afraid it’s still not working.

To clarify, ST2 is currently applying JS syntax to .sah files I open. This is great and works as expected.

I tried changing the scope to js (eg. source.js…) but no joy. I also tried adding sah to the javascript.tmLanguage file… also no joy. Also tried changing the scope back to source.sah after altering the language file. Still nothing.

What am I missing?

Thanks a bunch for the help. I really want this to work! While it won’t spell doom for NP++, it’ll net ST2 $59 :smile:

B

0 Likes

#7


It appears you are having trouble with scope. Would you like some help? Try pressing ctrl+alt+shift+p. This should list the current scope under the cursor in the status bar. The leftmost scope is the most specific and as you move right, it gets more general. If the scope is in fact Javascript, the rightmost scope will say source.js. Furthermore, whatever that rightmost scope is is what you want to reflect in your completions file.

0 Likes

#8

Scope is certainly part of it. With one of my .sah files open, ctrl+alt+shift+p displays source.js. I changed the scope of my sahi.sublime-completions file to “scope”: “source.js”, saved, restarted app and still nothing. My completions don’t show up.

Any other ideas?

0 Likes

#9

It looks like your completions file is syntactically wrong. It should be something like:[code]{
“scope”: “source.js”,
“completions”:

    { "trigger": "_a", "contents": "_alert" },
    { "trigger": "_a", "contents": "_assertEqual" }

]

}[/code]

0 Likes

#10

A trigger doesn’t need to be provided for completions which are just “words”.

Added: Make sure you don’t have a *spare *comma at the end of your completions list :astonished:

Check the Console for error messages (Ctrl ’ apostrophe)

Check your settings to ensure that completions are enabled.

0 Likes

#11

Thanks for the help all, still can’t get this working.

The documentation specifically says you can use just an array of words instead of triggers. So that likely isn’t the issue.

No spare commas at the end.

Nothing in the console.

completions are enabled (ctrl-space DOES bring up commands used in the current page… just not my custom completions).

B

0 Likes

#12

[quote=“dasspunk”]Thanks for the help all, still can’t get this working.

The documentation specifically says you can use just an array of words instead of triggers. So that likely isn’t the issue.

No spare commas at the end.

Nothing in the console.

completions are enabled (ctrl-space DOES bring up commands used in the current page… just not my custom completions).

B[/quote]

I suppose you could post the completions file, just in case there’s something you’ve missed.

0 Likes

#13

My completions file is bellow (couldn’t attach: “The extension sublime-completions is not allowed.”). Thanks for the help again…

B

Filename: sahi.sublime-completions

{
    "scope": "source.sah",
    
		"_alert",
		"_assertEqual",
		"_assertNotEqual",
		"_assertNotNull",
		"_assertNull",
		"_assertTrue",
		"_assert",
		"_assertNotTrue",
		"_assertFalse",
		"_assertExists",
		"_assertNotExists",
		"_callServer",
		"_click",
		"_clickLinkByAccessor",
		"_dragDrop",
		"_getSelectedText",
		"_resetSavedRandom",
		"_setSelected",
		"_setValue",
		"_simulateEvent",
		"_call",
		"_eval",
		"_setGlobal",
		"_wait",
		"_highlight",
		"_log",
		"_navigateTo",
		"_doubleClick",
		"_rightClick",
		"_addMock",
		"_removeMock",
		"_expectConfirm",
		"_setFile",
		"_expectPrompt",
		"_debug",
		"_debugToErr",
		"_debugToFile",
		"_mouseOver",
		"_keyPress",
		"_focus",
		"_keyDown",
		"_keyUp",
		"_mockImage",
		"_execute",
		"_assertContainsText",
		"_enableKeepAlive",
		"_disableKeepAlive",
		"_dragDropXY",
		"_deleteCookie",
		"_createCookie",
		"_clearPrintCalled",
		"_saveDownloadedAs",
		"_clearLastDownloadedFileName",
		"_rteWrite",
		"_type",
		"_check",
		"_uncheck",
		"_blur",
		"_removeFocus",
		"_clearLastAlert",
		"_clearLastPrompt",
		"_clearLastConfirm",
		"_closeWindow",
		"_accessor",
		"_button",
		"_check",
		"_checkbox",
		"_image",
		"_imageSubmitButton",
		"_link",
		"_password",
		"_radio",
		"_select",
		"_submit",
		"_textarea",
		"_textbox",
		"_event",
		"_getGlobal",
		"_random",
		"_savedRandom",
		"_cell",
		"_table",
		"_contains",
		"_containsText",
		"_containsHTML",
		"_byId",
		"_row",
		"_getText",
		"_getCellText",
		"_div",
		"_span",
		"_spandiv",
		"_option",
		"_lastConfirm",
		"_reset",
		"_file",
		"_getDB",
		"_readFile",
		"_lastPrompt",
		"_lastAlert",
		"_get",
		"_style",
		"_byText",
		"_cookie",
		"_position",
		"_print",
		"_printCalled",
		"_label",
		"_lastDownloadedFileName",
		"_rteHTML",
		"_rteText",
		"_re",
		"_prompt",
		"_scriptName",
		"_logException",
		"_logExceptionAsFailure",
		"_isVisible",
		"_listItem",
		"_stopOnError",
		"_continueOnError",
		"_parentNode",
		"_parentCell",
		"_parentRow",
		"_parentTable",
		"_in",
		"_scriptPath",
		"_near",
		"_rte",
		"_iframe",
		"_tableHeader",
		"_heading1",
		"_heading2",
		"_heading3",
		"_heading4",
		"_heading5",
		"_heading6",
		"_hidden",
		"_title",
		"_exists",
		"_area",
		"_map",
		"_italic",
		"_bold",
		"_emphasis",
		"_strong",
		"_preformatted",
		"_code",
		"_blockquote",
		"_xy",
		"_popup",
		"_include",
		"_condition",
		"_sahi",
		"_set"

    ]
}
0 Likes

#14

You’ve omitted the word “completions”

{
“scope”: “source.sah”,
“completions”:

0 Likes

#15

CRAP!

must have happened during one of my MANY trials… Thanks a bunch for sticking with me on this. I had a feeling it was something simple.

FYI, at this point (because I’ve associated .sah with javascript syntax), the source does indeed need to be “source.js”. Source.sah does NOT work.

Glad to have this one solved.

Brian

0 Likes

#16

Perhaps the only way to use ‘Source.sah’ is to create a tmLanguage file for Sah :frowning: . But perhaps ‘text.sah’ might work :question:

0 Likes

#17

text.sah won’t make a difference. For more info: readthedocs.org/docs/sublime-tex … xdefs.html

0 Likes

#18

It would be nice to be able to create a tmLanguage for Sahi… but it’s really just Javascript with “$” vars (to distinguish sahi vars in Rhino I believe). So in that, Javascript highlighting is totally fine. Maybe I’ll eventually dig in and make dollar signs valid on vars…

Thanks again for the help!

B

0 Likes