0

How to set completion file

ただ かわ 7 years ago in iPad updated 7 years ago 10

 I got a open source code "simongregory / actionscript3-tmbundle" from web.
And then I located it, syntax hilighting works well.
Next, I modified AS3 Completions.tmPreferences to Json file and located on #Textastic/CodeCompletion, but it could't work.
Please tell me how to set it, or some  important points.

Thanks.

Textastic only uses the syntax definitions in the "Languages" folder of a TextMate bundle and some settings from the "Preferences" folder.


For code completion, it uses its own format: https://github.com/blach/Textastic-Customization - you can find the built-in definitions in the CodeCompletion directory.

Thanks for a comment rapidly.


I've read all of manuals, but I have not done.

Where are the linkage points the language file and the completion file.

Is it needs uuid or etc?

Then, where should I get uuid?


Sorry for my incapability.

Each completion file needs its own uuid to identify the file uniquely in the system and to make it load correctly.


The "completionSets" array defines a list of completion strings and gives them a name.


The "contexts" array at bottom of a completion file defines where the completion strings should be shown. This is the linkage point of the language file and the completion file:


The "scope" and the "pattern" work together: "scope" is a scope selector like "source.objc - comment - string" (see http://manual.macromates.com/en/scope_selectors). It must match the scope at the cursor.

 

"pattern" is a regular expression. It must also match backwards at the cursor position. 


The "completionCaptureIndex" defines which capture of the "pattern" will be used as the string to complete. 


The "completionSetNames" array defines which completion sets should be consulted for code completion in this context.


I hope this helps.

You can generate a uuid on the Mac command line with this command:

uuidgen

Thanks.


I could understand the composition of the textastic's json file mostly.

And I found that syntax hilighting needs only info.plist file and Syntaxes/ActionScript 3.tmLanguage file, but I still don't understand where is the part of these files seeks their linkage "completion file".


Sorry for my repeated question.

I'm not sure if I understand you correctly, but maybe this is the info you are looking for:


If you want to create a new code completion definition, you can put the .json file in the local "#Textastic/CodeCompletion" folder. Textastic will pick up the changes at application startup time, so you have to manually quit the app. 


The combination of "scope" and "pattern" defines where code completion are shown.

I'm about giving up, but this is my last question.


Please check this short program if you could.

I could make a template file, so I could make valid uuid.

For now, I copied a part of  java.json from your repo, and modified some parts for as file, and renamed "as.json".

However I couldn't use at least code completion of "for" syntax.


[code--

 {
  "description": "Textastic Code Completion for ActionScript 3",
  "uuid": "xxxxxx",
  "category": "ActionScript 3",
  "completionSets": [
  {
  "name": "as.keywords.control",
  "defaultAppend": "",
  "strings": [
  "return",
  {
  "string": "for",
  "append": " (${1:${2:var i = 0}; ${3:i < count}; ${4:i++}}) {\n\t$0\n}"
  }
  ]
  }
  ],
  "contexts": [
  {
  "description": "Control keywords",
  "scope": "source.as - comment - string",
  "pattern": "(?<!\\.|\\[|\\(|,)\\b([a-zA-Z]*)",
  "completionCaptureIndex": 1,
  "completionSetNames": [
  "as.keywords.control"
  ]
  }
  ]
}


--]


Thank you for your sincere support.

I understand your frustration. But, can you please send me the file to support@textasticapp.com ? Unfortunately, the forum software messed with the formatting.


I will have a look at it and send you a working example.

I received your file.


The problem is this line:


"scope": "source.as - comment - string",


If you look at the file "Syntaxes/ActionScript 3.tmLanguage" in the ActionScript 3 bundle, you can see that the scopeName for ActionScript 3 files is defined as "source.actionscript.3", not "source.as":


<key>scopeName</key>
<string>source.actionscript.3</string>


So, you need to change the line in the as.json file in this way:


"scope": "source.actionscript.3 - comment - string",


Also make sure that you select the "ActionScript 3" syntax definition in the File Properties in Textastic after you open the file.


After this change, Textastic successfully displayed a list of completions.

+1

Thanks again!
I've gotten a result which I expected.
I'm ashame I said that I understand the style of Textastic's json.

If Textastic has a function of reviewing code library, it will be a competitor close a scripting tool on PC.
I'm eager to experience it.

Thank you for your repeated and rapid support.