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 Packages/robot.tmLanguage": Unable to open Sublime Text 3/Installed Packages/robot.tmLanguage

The plugin is under Installed Packcages/Robot Framework Assistant.sublime-package, the file 'robot.tmLanguage' in inside Robot Framework Assistant.sublime-package archive.

Here is how I set paths https://github.com/andriyko/sublime-robot-framework-assistant/blob/master/rfassistant/init.py

My question is similar to this thread, but in my case the plugin is installed as archive(.sublime-package) not folder with with files.

  1. I am not sure that my path settings mentioned above are correct in python3.

  2. How can I refer to tmLanguage file that is inside .sublime-package file?

  3. Where should I put that file? It is totally confusing why does it work on Sublime Text 2 and Sublime Text 3(when installed into dir from github) but does not work when installed via Package Control.

So, how do I set path to tmLanguage file and where should I store it. Just want to clarify, that it works fine when plugin is installed from github zip file(because I put it's content into RobotFrameworkAssistant folder under Packages directory). It does not work when plugin is installed via Package Control.

有帮助吗?

解决方案 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).

其他提示

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top