Skip to content

Commit

Permalink
Snippets: Add common pragma names & values as snippets
Browse files Browse the repository at this point in the history
This is worse than a completion that could be provided by a plugin or
an LSP, but until LSP is developed enough to be useful for KDE, this
should be good enough for common use-cases.
  • Loading branch information
ratijas committed Nov 21, 2023
1 parent bc8f924 commit d01e755
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This package provides the following features:

- Complete syntax highlighting for QML and qmldir files.
- GoTo indexing for `id`s, property declarations and inline components.
- Snippets for commonly used properties and types.
- Snippets for commonly used properties, types and pragmas.
- Command to turn property names into their `onPropertyChanged` signal handlers and vice-versa.

If you are a KDE developer, check out [kdesrc-build plugin for Sublime Text](https://github.com/ratijas/kdesrc-build-sublime) as well!
Expand Down
11 changes: 11 additions & 0 deletions Snippets/qml_pragma_ComponentBehavior_Bound.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<!-- Note: The extra line break is intentional -->
<!-- See also: qtdeclarative/src/qmlcompiler/qqmljsimportvisitor.cpp -->
<content><![CDATA[
pragma ComponentBehavior: Bound
]]></content>
<tabTrigger>pragma ComponentBehavior: Bound</tabTrigger>
<scope>source.qml - meta.block.qml</scope>
<description>pragma</description>
</snippet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<!-- Note: The extra line break is intentional -->
<!-- See also: qtdeclarative/src/qmlcompiler/qqmljsimportvisitor.cpp -->
<content><![CDATA[
pragma FunctionSignatureBehavior: Enforced
]]></content>
<tabTrigger>pragma FunctionSignatureBehavior: Enforced</tabTrigger>
<scope>source.qml - meta.block.qml</scope>
<description>pragma</description>
</snippet>
11 changes: 11 additions & 0 deletions Snippets/qml_pragma_ListPropertyAssignBehavior.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<!-- Note: The extra line break is intentional -->
<!-- See also: qtdeclarative/src/qmlcompiler/qqmljsimportvisitor.cpp -->
<content><![CDATA[
pragma ListPropertyAssignBehavior:${1: Append}${2: Replace}${3: ReplaceIfNotDefault}
]]></content>
<tabTrigger>pragma ListPropertyAssignBehavior:</tabTrigger>
<scope>source.qml - meta.block.qml</scope>
<description>pragma</description>
</snippet>
11 changes: 11 additions & 0 deletions Snippets/qml_pragma_Singleton.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<!-- Note: The extra line break is intentional -->
<!-- See also: qtdeclarative/src/qmlcompiler/qqmljsimportvisitor.cpp -->
<content><![CDATA[
pragma Singleton
]]></content>
<tabTrigger>pragma Singleton</tabTrigger>
<scope>source.qml - meta.block.qml</scope>
<description>pragma</description>
</snippet>
11 changes: 11 additions & 0 deletions Snippets/qml_pragma_Strict.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<!-- Note: The extra line break is intentional -->
<!-- See also: qtdeclarative/src/qmlcompiler/qqmljsimportvisitor.cpp -->
<content><![CDATA[
pragma Strict
]]></content>
<tabTrigger>pragma Strict</tabTrigger>
<scope>source.qml - meta.block.qml</scope>
<description>pragma</description>
</snippet>
11 changes: 11 additions & 0 deletions Snippets/qml_pragma_ValueTypeBehavior.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<snippet>
<!-- Note: The extra line break is intentional -->
<!-- See also: qtdeclarative/src/qmlcompiler/qqmljsimportvisitor.cpp -->
<content><![CDATA[
pragma ValueTypeBehavior: ${1:Copy}${2:, Reference}${3:, Addressable}${4:, Inaddressable}
]]></content>
<tabTrigger>pragma ValueTypeBehavior:</tabTrigger>
<scope>source.qml - meta.block.qml</scope>
<description>pragma</description>
</snippet>
3 changes: 3 additions & 0 deletions messages/1.7.0.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
QML for Sublime Text 1.7.0 has been released!

Added new snippets for common pragma names & values. Just start
typing "pragma" outside of the top-level object declaration.

A brand new command allows converting between property names and their change
signal handlers! Try now, put a cursor on the words below, open command
palette, and find "QML: Convert Between Property And Signal Handler" entry:
Expand Down

0 comments on commit d01e755

Please sign in to comment.