monaco-languageserver-types
Convert between language server types and Monaco editor
types.
Table of Contents
Installation
npm install monaco-languageserver-types
Usage
This package exports function to convert language server types to Monaco editor types and vise
versa. It does so without importing monaco-editor
or vscode-languageserver-protocol
, meaning it
has no runtime dependencies.
For each Monaco editor / language server type, there are two functions:
from*
converts a value from a Monaco editor type to a language server type.to*
converts a value from a language server type to a Monaco editor type.
Some types require the Monaco editor module. However, users may load Monaco from different sources.
To support this, you should call setMonaco(monaco)
once in your application.
For example:
import * as monaco from 'monaco-editor'
import { fromRange, setMonaco, toRange } from 'monaco-languageserver-types'
setMonaco(monaco)
const monacoRange: monaco.IRange = {
startLineNumber: 1,
startColumn: 2,
endLineNumber: 3,
endColumn: 4
}
const lsRange = fromRange(monacoRange)
console.log(toRange(lsRange))
License
MIT © Remco Haszing