-
Notifications
You must be signed in to change notification settings - Fork 33
Language Server Details
Datapack Helper Plus, a VSCode extension, is also an NPM package published at npmjs.com, served as a language server for Minecraft datapacks.
Since it's a language server, you can simply implement the features provided by DHP on any other modern editors. Here are all the technical details you may concern.
Check out this page to see if there's already an LSP client integration available.
You can also launch the language server as a command and connect to it. For that, install the datapack-language-server npm module:
npm i -g datapack-language-server
Start the language server with the datapack-language-server
command.
The language server supports request on documents of language id mcfunction
and json
.
- There's no specification for
mcfunction
files. The language server tries it best to imitate how Minecraft: Java Edition behaves. All inconsistencies are considerd as bugs of either the language server or Minecraft, and should be reported at either Issues or Mojira. - Only JSON files under specific directories can be handled by the language server. The supports come from
vscode-json-languageservice
package.-
Advancements:
data/*/advancements/**.json
. -
Loot tables:
data/*/loot_tables/**.json
. -
Predicates:
data/*/predicates/**.json
. -
Recipes:
data/*/recipes/**.json
. -
Tags:
data/*/tags/{block,entity_types,fluids,functions,items}/**.json
.
-
Advancements:
The language server protocol consists of a number of capabilities. Here's a list of capabilities that are implemented by the language server.
- ✅ Call hierarchy provider
- ✅ Color provider
- ☑️ Completion provider
- ✅ Definition provider
- ☑️ Document formatting provider
- ✅ Document highlight provider
- ✅ Document link provider
- ✅ Execute command provider
- ✅
workspace/executeCommand
⚠️ Available commands-
datapack.regenerateCache
: regenerate the cache file.
-
- ✅
- ✅ Folding range provider
- ❌ Hover provider
- ✅ Reference provider
- ✅ Rename provider
- ✅ Selection range provider
- ☑️ Semantic tokens provider
- ✅
textDocument/semanticTokens
- ✅
textDocument/semanticTokens/edits
- ❌
textDocument/semanticTokens/range
⚠️ Semantic legend: #308
- ✅
- ✅ Signature help provider
- ☑️ Text document sync
- ✅
textDocument/didOpen
- ✅
textDocument/didChange
: Incremental update. - ✅
textDocument/willSave
- ❌
textDocument/willSaveWaitUntil
- ❌
textDocument/didSave
- ✅
textDocument/didClose
- ✅
- ✅ Watch files
- ✅
workspace/didChangeWatchedFiles
⚠️ Watched filesdata/**/*.{json,mcfunction}
- ✅
- ✅ Workspace
- ✅ Multi-root workspace.
- ✅
workspace/didChangeWorkspaceFolders
The language server expects the client to only send requests and notifications for documents of language id mcfunction
and certain json
:
{
documentSelector: [
{ language: 'mcfunction' },
{ language: 'json', pattern: 'data/*/advancements/**.json' },
{ language: 'json', pattern: 'data/*/loot_tables/**.json' },
{ language: 'json', pattern: 'data/*/predicates/**.json' },
{ language: 'json', pattern: 'data/*/recipes/**.json' },
{ language: 'json', pattern: 'data/*/tags/{block,entity_types,fluids,functions,items}/**.json' }
]
}
The client must have following capabilities:
-
datapackLanguageServer/checkVersion
notification: check if the version where the language server was started last time is older than current version. If so, the client may show an information box indicating the user.-
currentVersion
: A string. The current version of the language server. -
title
: A string. If the client decides to show an information box, this title should be used. -
action
: A string. If the client decides to show an information box, this action should be used as the title of the action. -
url
: A string. If the client decides to show an information box, clicking the action should open this url.
-
textDocument/publishDiagnostics
window/showMessage
window/showMessageRequest
workspace/configuration
workspace/workspaceFolders
Also, the client should somehow provide supports for stuff marked as
-
globalStoragePath
: A string. Should be a path to a folder where the language server can store global cache file, like the block definitions, registries, and nbtdocs for Minecraft. The folder doesn't need to exist, but the client must ensure that the server has the permission to create, read, and write to that folder. -
storagePath
: A string. Should be a path to a folder where the language server can store workspace-specific cache file. The folder doesn't need to exist, but the client must ensure that the server has the permission to create, read, and write to that folder.
The client's response for the workspace/configuration
request must match the Config
interface in src/types/Config.ts
.