Skip to content

Commit

Permalink
Merge branch 'main' into document-editor-integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Dec 23, 2024
2 parents a239f86 + 54bebbc commit 9ef8041
Show file tree
Hide file tree
Showing 32 changed files with 737 additions and 452 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-rabbits-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mdx-js/language-service': patch
---

Fix bug in virtual code generation for JSX closing elements
5 changes: 5 additions & 0 deletions .changeset/tiny-geese-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vscode-mdx': patch
---

Update the TextMate grammar
15 changes: 15 additions & 0 deletions packages/language-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @mdx-js/language-server

## 0.5.0

### Minor Changes

- [#473](https://github.com/mdx-js/mdx-analyzer/pull/473) [`2854c38`](https://github.com/mdx-js/mdx-analyzer/commit/2854c38ceaf9202a9a3aa5ae33e50ca2a8c41f1e) Thanks [@remcohaszing](https://github.com/remcohaszing)! - Convert the custom MDX syntax toggle request types into LSP commands.

### Patch Changes

- [#478](https://github.com/mdx-js/mdx-analyzer/pull/478) [`3b135e8`](https://github.com/mdx-js/mdx-analyzer/commit/3b135e82607f0d5d19f9cf27e6bb465543c7c841) Thanks [@remcohaszing](https://github.com/remcohaszing)! - Use an asterisk to toggle emphasis

- [#477](https://github.com/mdx-js/mdx-analyzer/pull/477) [`ed87d22`](https://github.com/mdx-js/mdx-analyzer/commit/ed87d226bdc18afb60332bc55f0fd687efd98d42) Thanks [@remcohaszing](https://github.com/remcohaszing)! - Use two tildes to toggle delete syntax

- Updated dependencies [[`3b135e8`](https://github.com/mdx-js/mdx-analyzer/commit/3b135e82607f0d5d19f9cf27e6bb465543c7c841), [`ed87d22`](https://github.com/mdx-js/mdx-analyzer/commit/ed87d226bdc18afb60332bc55f0fd687efd98d42), [`2854c38`](https://github.com/mdx-js/mdx-analyzer/commit/2854c38ceaf9202a9a3aa5ae33e50ca2a8c41f1e)]:
- @mdx-js/language-service@0.6.0

## 0.4.10

### Patch Changes
Expand Down
62 changes: 62 additions & 0 deletions packages/language-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,66 @@ This language server supports all features supported by
[`volar-service-typescript`][volar-service-typescript], plus some additional
features specific to MDX.

#### Commands

The language server supports the following [LSP commands][]:

##### `mdx.toggleDelete`

Toggle delete syntax at the cursor position.
It uses the `workspace/applyEdit` command to apply edits.

###### Arguments

* `uri` — The URI of the document to apply changes to.
* `range` — The current selection range of the user.

###### Returns

`null`

##### `mdx.toggleEmphasis`

Toggle emphasis syntax at the cursor position.
It uses the `workspace/applyEdit` command to apply edits.

###### Arguments

* `uri` — The URI of the document to apply changes to.
* `range` — The current selection range of the user.

###### Returns

`null`

##### `mdx.toggleInlineCode`

Toggle inline code syntax at the cursor position.
It uses the `workspace/applyEdit` command to apply edits.

###### Arguments

* `uri` — The URI of the document to apply changes to.
* `range` — The current selection range of the user.

###### Returns

`null`

##### `mdx.toggleStrong`

Toggle strong syntax at the cursor position.
It uses the `workspace/applyEdit` command to apply edits.

###### Arguments

* `uri` — The URI of the document to apply changes to.
* `range` — The current selection range of the user.

###### Returns

`null`

### Initialize Options

MDX language server supports the following LSP initialization options:
Expand Down Expand Up @@ -290,6 +350,8 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m

[lsp]: https://microsoft.github.io/language-server-protocol

[lsp commands]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#command

[lsp-mode]: https://github.com/emacs-lsp/lsp-mode

[mdx]: https://mdxjs.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

/**
* @import {Commands} from '@mdx-js/language-service'
* @import {PluggableList, Plugin} from 'unified'
*/

Expand All @@ -26,7 +25,6 @@ import remarkGfm from 'remark-gfm'
import {create as createMarkdownServicePlugin} from 'volar-service-markdown'
import {create as createTypeScriptServicePlugin} from 'volar-service-typescript'
import {create as createTypeScriptSyntacticServicePlugin} from 'volar-service-typescript/lib/plugins/syntactic.js'
import {URI} from 'vscode-uri'

process.title = 'mdx-language-server'

Expand Down Expand Up @@ -68,7 +66,7 @@ connection.onInitialize(async (parameters) => {
return context.env.getConfiguration?.('mdx.validate')
}
}),
createMdxServicePlugin()
createMdxServicePlugin(connection.workspace)
]

if (tsEnabled) {
Expand Down Expand Up @@ -123,26 +121,6 @@ connection.onInitialize(async (parameters) => {
}
})

connection.onRequest('mdx/toggleDelete', async (parameters) => {
const commands = await getCommands(parameters.uri)
return commands.toggleDelete(parameters)
})

connection.onRequest('mdx/toggleEmphasis', async (parameters) => {
const commands = await getCommands(parameters.uri)
return commands.toggleEmphasis(parameters)
})

connection.onRequest('mdx/toggleInlineCode', async (parameters) => {
const commands = await getCommands(parameters.uri)
return commands.toggleInlineCode(parameters)
})

connection.onRequest('mdx/toggleStrong', async (parameters) => {
const commands = await getCommands(parameters.uri)
return commands.toggleStrong(parameters)
})

connection.onInitialized(() => {
const extensions = ['mdx']
if (tsEnabled) {
Expand All @@ -164,12 +142,3 @@ connection.onInitialized(() => {
})

connection.listen()

/**
* @param {string} uri
* @returns {Promise<Commands>}
*/
async function getCommands(uri) {
const service = await server.project.getLanguageService(URI.parse(uri))
return service.context.inject('mdxCommands')
}
15 changes: 7 additions & 8 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdx-js/language-server",
"version": "0.4.10",
"version": "0.5.0",
"type": "module",
"description": "A language server for MDX",
"repository": {
Expand All @@ -13,12 +13,11 @@
"author": "Remco Haszing <[email protected]>",
"funding": "https://opencollective.com/unified",
"license": "MIT",
"exports": "./index.js",
"exports": "./lib/index.js",
"bin": {
"mdx-language-server": "./index.js"
"mdx-language-server": "./lib/index.js"
},
"files": [
"*.js",
"lib"
],
"keywords": [
Expand All @@ -32,18 +31,18 @@
"test": "npm run test-api"
},
"dependencies": {
"@mdx-js/language-service": "0.5.8",
"@mdx-js/language-service": "0.6.0",
"@volar/language-server": "~2.4.0",
"load-plugin": "^6.0.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"volar-service-markdown": "0.0.61",
"volar-service-typescript": "0.0.61",
"vscode-uri": "^3.0.0"
"volar-service-typescript": "0.0.61"
},
"devDependencies": {
"@types/node": "^22.0.0",
"@volar/test-utils": "~2.4.0",
"unified": "^11.0.0"
"unified": "^11.0.0",
"vscode-uri": "^3.0.0"
}
}
8 changes: 8 additions & 0 deletions packages/language-server/test/initialize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ test('initialize', async () => {
},
documentRangeFormattingProvider: true,
documentSymbolProvider: true,
executeCommandProvider: {
commands: [
'mdx.toggleDelete',
'mdx.toggleEmphasis',
'mdx.toggleInlineCode',
'mdx.toggleStrong'
]
},
experimental: {
autoInsertionProvider: {
configurationSections: [
Expand Down
Loading

0 comments on commit 9ef8041

Please sign in to comment.