Skip to content Skip to sidebar Skip to footer

Syntax Highlight (.tmlanguage) In Sublime Text 3 For Packages

I work on this plugin Syntax highlight does not work with Sublime Text 3 when plugin is installed using package control. Error loading syntax file 'Sublime Text 3/Installed Package

Solution 1:

Quick summary of my manual solution of adding custom .tmLanguage files based on others' suggestions:

  1. Put the myLang.tmLanguage file into a folder with your desired syntax name.
  2. Zip the folder so that it's named myLang.zip
  3. Rename the zip archive to myLang.sublime-package
  4. Put the myLang.sublime-package into the Sublime 3 packages folder. It will now appear in the sublime syntax highlighting menu.

Based on ST3 docs, I can't seem to find an alternative to this manual method right now, but it will work.

Package control will likely do everything you need behind the scene

Solution 2:

Do you need the content of the tmLanguage file? If so, you shouldn't be accessing it directly. Instead, you should be using sublime.load_resource(name), where name is something like Packages/Robot Framework Assistant/robot.tmLanguage. If you are just trying to set the file syntax, you should be using view.set_syntax_file(syntax_file), where syntax_file is like name for the resource. I did not look at your plugin in detail, so please clarify what you are trying to do if both of those answers are incorrect.

As a side note, based on that error, you would probably see issues in ST2 also. You are only looking at the root packages folder, not in your package.

In ST3, jps decided to make plugins runnable from .sublime-package files, rather than needing to be extracted. These files are simply renamed .zip files. Updates do need to be made if you are accessing resources within your plugin, but the API has been extended to support it.

This isn't a great list, but it covers some of the changes in ST3 from ST2.

http://www.sublimetext.com/docs/3/porting_guide.html

Solution 3:

The issue seems to be solved. Please refer to this fix.

Why I had problems with syntax settings(.tmLanguage) in ST3?

Because it is totally confusing and not clear from ST3 docs where that file should be located. (Even if it says that files lookup is continued in Packages directory if file was not found in Installed Packages).

There are two 'main' folders under Sublime Text 3 directory: Installed Packages and Packages.

When the plugin is installed using Package Control it goes into Installed Packages directory packed into archive file called like Robot Framework Assistant.sublime-package (which is actually ZIP file). The robot.tmLanguage file (syntax file) is inside Robot Framework Assistant.sublime-package.

So, in few words, my question was: how to refer to that file (what path should be provided to view.set_syntax_file method)?

Unintuitive, but I should refer to non-existent path Packages/Robot Framework Assistant/robot.tmLanguage. Actually, in my case the Packages directory contains only Users folder. The only thing, that I can guess is that folder name should be the same as package name(Robot Framework Assistant in my case).

Post a Comment for "Syntax Highlight (.tmlanguage) In Sublime Text 3 For Packages"