Sublime Forum

Cannot see sublime-syntax changes

#1

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?

0 Likes

#2

Do you see messages in the console when you save the plugin?

0 Likes

#3

No I don’t see anything, how do you see the console?

0 Likes

#4

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.

0 Likes

#5

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

0 Likes

#6
%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

0 Likes

#7

The scope on the last line is not indented properly

0 Likes

#8

It has two TAB characters, what else should I do?

0 Likes

#9

I increased leading tabs to 3, saving and it still saying illegal block entry,
5:2

0 Likes

#10

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,.

0 Likes

#11
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

0 Likes

#12

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.

0 Likes

#13

My setting says:

// The number of spaces a tab is considered equal to
“tab_size”: 4,

and tab key is what I pressed.

0 Likes

#14

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).

0 Likes

#15

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?

0 Likes

#16

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
0 Likes

#17
%YAML 1.2
---
# see 
file_extensions:
    - notes
scope: text.plain.notes
contexts:
    main:
        - match: '^\s*#\w+'
          scope: entity.name.tag
0 Likes

#18

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.

0 Likes