Sublime Forum

Snippet scope for sql (Postgresql)

#1

I am using the sql (Postgresql) syntax highlighting on .sql files. Unfortunately, that disables snippets I’ve written for working with the scope <scope>source.sql</scope>. I’ve looked and there does not seem to be a scope written for something like <scope>source.sql-Postgresql</scope> Is it possible to easily write an extension for increasing this capability?

I know nothing about writing an extension beyond carefully copying and pasting code into a file for excellent work others create for enormously helpful functions.:wink:

0 Likes

#2

I’m not entirely sure what you’re asking here, but the syntax in that package is using the scope source.psql ; so for your snippets, if you want it to work in both places you want <scope>source.sql, source.psql</scope> if that answers your question.

0 Likes

#3

It does address my question but unfortunately is not an answer that works. I amended the scope tags as you suggested for the snippets. Trying to use the snippet by typing the TabTrigger or Ctrl+Shift+P then typing keywords to call the snippet and Sublime Text does not provide the snippet for the scope does not match whatever ST is looking for.

I tried <scope>source.sql, source.psql</scope> , <scope>source.sql, source.postgresql</scope> and <scope>source.sql, source.sql-postgresql</scope>. None of these suffice if the syntax highlighting is set to ‘SQL (PostgreSQL)’. If I change the syntax highlighting to simple ‘SQL’, the snippet will work.

Can it be the case a contributor can write a package for syntax highlighting but not code for the package to work with snippets?

0 Likes

#4

No, snippets are handled by the core, they work with any syntax that exists no matter who created it.

Best advice is to open up a file that has this syntax assigned to it (verify with the status bar in the bottom right of the window), then use Tools > Developer > Show Scope Name.

In the popup that appears, the very first line is the top level scope that is assigned by that syntax and is the scope you would use here, though based on the link you provided above the one I mentioned should be the correct one, if that syntax is actually in use.

0 Likes

#5

Following the steps Tools > Developer > Show Scope Name yielded pgsql. Modifying my snippets with a scope of <scope>source.sql, source.pgsql</scope> and the snippets indeed work on those files.

Thanks Odatnurd for your help.

1 Like