Skip to content

Commit 19707ef

Browse files
authored
Merge pull request #123 from sublimetext-io/feature/st4-completions-fields
Add ST4 completions fields to reference
2 parents 8f123bc + 905c742 commit 19707ef

File tree

6 files changed

+157
-6
lines changed

6 files changed

+157
-6
lines changed

CONTRIBUTING.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ can be found [on Wikipedia][wiki-text].
155155
[wiki-text]: https://en.wikipedia.org/wiki/Text
156156
```
157157

158-
For relative links,
158+
For internal links,
159159
follow the Vitepress recommendation
160160
of referencing the files with their `.md` extensions.
161161
Use absolute paths when linking
@@ -164,6 +164,22 @@ If the relative URL is short,
164164
you MAY directly specify the target URL in text.
165165

166166

167+
### Footnotes
168+
169+
Footnotes are supported
170+
using a plugin
171+
and use a similar syntax to hyperlinks.
172+
The link definition
173+
is treated as the footnote's content.
174+
It is thus also subject to Markdown parsing itself.
175+
176+
```md
177+
I am text with a footnote[^1].
178+
179+
[^1]: This footnote can use **Markdown**, such as [hyperlinks](#).
180+
```
181+
182+
167183
### Headings
168184

169185
The page's title is specified in YAML front matter
@@ -204,6 +220,27 @@ With text
204220
### This SHOULD NOT be a h4
205221
```
206222

223+
224+
### Custom blocks
225+
226+
A custom block feature is provided
227+
by the [vitepress default theme][vp-default].
228+
Supported block types are
229+
`tip`,
230+
`warning`,
231+
`danger`,
232+
and `details`.
233+
234+
Additionally, special CSS is provided
235+
for a custom block using [markdown-it-attrs][]
236+
to mark when a certain feature was added:
237+
238+
```
239+
::: tip Added in build 4050 {added}
240+
:::
241+
```
242+
243+
207244
### File Paths
208245

209246
File paths (relative or absolute)

docs/.vitepress/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import markdownItAttrs from 'markdown-it-attrs';
12
import markdownItDeflist from 'markdown-it-deflist';
23
import markdownItFootnote from 'markdown-it-footnote';
34
import { defineConfig, type HeadConfig } from 'vitepress';
@@ -191,6 +192,7 @@ export default defineConfig({
191192
},
192193
lineNumbers: true,
193194
config: md => {
195+
md.use(markdownItAttrs);
194196
md.use(markdownItDeflist);
195197
md.use(markdownItFootnote);
196198
},

docs/.vitepress/theme/custom.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
--vp-home-hero-name-color: var(--vp-c-brand);
2525
--vp-button-brand-bg: var(--vp-c-brand);
2626

27+
--vp-custom-block-added-bg: hsl(90, 55%, 87%);
2728
--vp-custom-block-tip-bg: rgb(204 204 204 / 16%);
2829
--vp-custom-block-tip-code-bg: var(--vp-code-bg);
2930

@@ -37,17 +38,19 @@
3738
--vp-c-bg-soft: hsl(215, 17%, 16%);
3839

3940
--docsearch-container-background: hsla(0,0%,40%,0.3);
41+
--vp-custom-block-added-bg: hsl(90, 14%, 27%);
4042
}
4143

4244

4345
.VPNavBar:not(.has-sidebar):not(.top) {
4446
border-bottom-color: transparent !important;
4547
}
4648

47-
.VPNavBar.top #local-search>button {
49+
.VPNavBar.top #local-search > button {
4850
background-color: var(--vp-c-bg-elv);
4951
}
5052

53+
5154
/* Custom Style */
5255
kbd {
5356
display: inline-block;
@@ -77,3 +80,10 @@ a.term {
7780
a.term:hover {
7881
border-color: var(--vp-c-brand-2);
7982
}
83+
84+
/* "Added in build" */
85+
.tip.custom-block[added] {
86+
/* Specify symmetric padding since we only use the heading. */
87+
padding: 8px 16px;
88+
background-color: var(--vp-custom-block-added-bg);
89+
}

docs/reference/completions.md

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Here's an example (with HTML completions):
5252

5353
See [Scopes][] for more information.
5454

55-
[Scopes]: /guide/extensibility/syntaxdefs.md#scopes
55+
[Scopes]: /guide/extensibility/syntaxdefs.md#scopes
5656

5757
**completions**
5858
: Array of *completions*.
@@ -79,20 +79,23 @@ is identical to the `contents`:
7979

8080
```json
8181
{ "trigger": "foo", "contents": "foobar" },
82-
{ "trigger": "foo\ttest", "contents": "foobar" }
82+
{ "trigger": "foo\ttest", "contents": "foobar" },
8383
```
8484

85-
**trigger**
85+
**trigger** {#trigger}
8686
: Text that will be displayed in the completions list
8787
and will cause the `contents`
8888
to be inserted when chosen.
8989

9090
You can use a `\t` tab character
9191
to add an *annotation* for the preceding trigger.
9292
The annotation will be displayed right-aligned,
93-
slightly grayed
93+
slightly dimmed
9494
and does not affect the trigger itself.
9595

96+
See also the [`annotation`](#annotation) field
97+
for a more explicit way of defining this.
98+
9699
**contents**
97100
: Text to be inserted in the buffer.
98101
Supports the same string interpolation features
@@ -108,3 +111,47 @@ you have to escape it like this: `\\$`
108111
(double backslashes are needed
109112
because we are within a JSON string).
110113
:::
114+
115+
116+
## Completions Metadata
117+
118+
``` json
119+
{
120+
"trigger": "func",
121+
"contents": "funcbar",
122+
"annotation": "function",
123+
"kind": "function",
124+
"details": "A short description of what this string function does.",
125+
}
126+
```
127+
128+
These do not affect the triggers themselves,
129+
but allow for customization of the appearance of completions
130+
in the completions list.
131+
132+
**annotation** {#annotation}
133+
: Displays as right-aligned dimmed text
134+
to the right of the entry
135+
in the completions list.
136+
Does not affect the trigger itself.
137+
138+
Before this field was added,
139+
annotations could (and still can) also be defined
140+
using a tab character `\t` in [`trigger`](#trigger).
141+
142+
::: tip Added in build 4050 {added}
143+
:::
144+
145+
**kind**
146+
: Allows for categorization of the completion via a colored
147+
kind letter to the left of the entry in the completions list.
148+
Colors are determined by the user's color scheme.
149+
150+
::: tip Added in build 4050 {added}
151+
:::
152+
153+
**details**
154+
: Displays at the bottom of the completions list when the entry is highlighted.
155+
156+
::: tip Added in build 4050 {added}
157+
:::

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"author": "",
1313
"license": "CC BY-SA 3.0 Deed",
1414
"dependencies": {
15+
"markdown-it-attrs": "^4.3.1",
1516
"markdown-it-deflist": "^3.0.0",
1617
"markdown-it-footnote": "^4.0.0",
1718
"vitepress": "1.6.3",

pnpm-lock.yaml

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)