I have followed one of the tutorial for creating sublime extension,
saving the file in
$HOME/Library/Application Support/Sublime Text/Packages/User
loading example file but nothing happened. Can you tell me why, please?
I have followed one of the tutorial for creating sublime extension,
saving the file in
$HOME/Library/Application Support/Sublime Text/Packages/User
loading example file but nothing happened. Can you tell me why, please?
Use View > Show Console
from the menu; If you’re saving a plugin, you’ll see a message saying that the plugin is reloading, followed possibly by errors (if there are any). For a syntax, every time you save you will see a message that says that a metadata summary is being generated.
If you don’t see any messages when you save files, and you’re sure that the package location is correct (you can used Preferences > Browse Packages
just to double check), then make sure that the extension on the file is correct, or Sublime won’t know what to do with it.
In the specific case of a plugin, the python file has to be directly inside the root of the package; it can’t be inside of a subdirectory of the package itself. So Packages/User/bob.py
is ok, but Packages/User/plugins/bob.py
is not.
I have got this message when saving it as a new file:
t: tracking working dir /Users/hoangduytran/Library
error parsing lexer: Packages/User/Notes.sublime-syntax: Error trying to parse sublime-syntax: illegal block entry in Packages/User/Notes.sublime-syntax:5:2
error parsing lexer: Packages/User/Notes_001.sublime-syntax: Error trying to parse sublime-syntax: illegal block entry in Packages/User/Notes_001.sublime-syntax:5:2
generating syntax summary
%YAML 1.2
---
# see
file_extensions:
- notes
scope: text.plain.notes
contexts:
main:
- match: '^\s*#\w+'
scope: entity.name.tag
looks like this line:
- notes
is causing the problem
I increased leading tabs to 3, saving and it still saying illegal block entry,
5:2
You want something like:
%YAML 1.2
---
# see
file_extensions:
- notes
scope: text.plain.notes
contexts:
main:
- match: '^\s*#\w+'
scope: entity.name.tag
the scope
needs to be indented one level more than the - match
that it is a part of,.
I have done that:
%YAML 1.2 --- # see file_extensions: - notes scope: text.plain.notes contexts: main: - match: '^\s*#\w+' scope: entity.name.tag
but no changes
Indendation is important in YAML files; you want to make sure that you’re using spaces and not tabs. Note that in my example above the overall indent is 4 characters (taken from your example post), but the indent on the scope
line is not an even multiple of 4.
My setting says:
// The number of spaces a tab is considered equal to
“tab_size”: 4,
and tab key is what I pressed.
Tabs and spaces are not the same thing; if you don’t turn on translate_tabs_to_spaces
(which defaults to being turned off) then pressing tab inserts a physical tab
character; the setting you mention there is just the indication of how Sublime should display a physical tab (since they have no explicit size).
This is my local settings:
{
“font_size”: 16,
“word_wrap”: true,
“ignored_packages”:
[
“Vintage”,
],
“translate_tabs_to_spaces”: true,
}
Do I have to restart ST after copied the translate_tab… and changed to True, then save?
I have just changed to use VSCode to save the file, but it still says:
error parsing lexer: Packages/User/Notes_002.sublime-syntax: Error trying to parse sublime-syntax: end of map not found in Packages/User/Notes_002.sublime-syntax:10:9
generating syntax summary
the last line:
%YAML 1.2 --- # see file_extensions: - notes scope: text.plain.notes contexts: main: - match: '^\s*#\w+' scope: entity.name.tag
%YAML 1.2 --- # see file_extensions: - notes scope: text.plain.notes contexts: main: - match: '^\s*#\w+' scope: entity.name.tag
You don’t need to restart to change the setting, but changing what Sublime does with the tab key doesn’t affect text that is already in the buffer. You will need to adjust the tabs into spaces.
One way to do that is click in the status bar where it says Spaces: 4
or Tabs: 4
and pick Convert indentation to Spaces
.