Skip to content

Commit

Permalink
docs: add Custom contexts chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
kermanx committed Jun 14, 2024
1 parent d667692 commit 1f8043a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default defineConfig({
{ text: 'Configurations', link: '/guide/config' },
{ text: 'Editor & Document', link: '/guide/editor' },
{ text: 'Window & Workspace', link: '/guide/window' },
{ text: 'Custom contexts', link: '/guide/context' },
{ text: 'Disposables', link: '/guide/disposable' },
{ text: 'Events', link: '/guide/event' },
{ text: 'VueUse Integration', link: '/guide/vueuse' },
Expand Down
19 changes: 19 additions & 0 deletions docs/guide/context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Custom contexts

VSCode's [when clause contexts](https://code.visualstudio.com/api/references/when-clause-contexts) can be used to selectively enable or disable extension commands and UI elements, such as menus and views. <ReactiveVscode /> provides `reactive::useVscodeContext` to define custom contexts in a reactive way.

```ts
import { computed, defineExtension, ref, useVscodeContext } from 'reactive-vscode'

export = defineExtension(() => {
const contextA = useVscodeContext('demo.fromValue', true)
// ^?

const contextB = useVscodeContext('demo.fromRef', contextA)

const contextC = useVscodeContext('demo.fromGetter', () => !contextA.value)
// ^?
})
```

For more information about when clause contexts, please refer to the [official documentation](https://code.visualstudio.com/api/references/when-clause-contexts).

0 comments on commit 1f8043a

Please sign in to comment.