Sort imports (#6101)
* add package.json Signed-off-by: Jess Frazelle <github@jessfraz.com> initial run; Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> more fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> clientsidescne Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> paths Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fix styles Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> combine Signed-off-by: Jess Frazelle <github@jessfraz.com> eslint rule Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> my ocd Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> constants file Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> no more import sceneInfra Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> try fix circular import Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { encoder, decoder } from '../codec'
|
||||
import { decoder, encoder } from './encode-decode'
|
||||
|
||||
export default class Bytes {
|
||||
static encode(input: string): Uint8Array {
|
||||
@ -10,7 +10,7 @@ export default class Bytes {
|
||||
}
|
||||
|
||||
static append<
|
||||
T extends { length: number; set(arr: T, offset: number): void }
|
||||
T extends { length: number; set(arr: T, offset: number): void },
|
||||
>(constructor: { new (length: number): T }, ...arrays: T[]) {
|
||||
let totalLength = 0
|
||||
for (const arr of arrays) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as vsrpc from 'vscode-jsonrpc'
|
||||
|
||||
import { Codec } from '.'
|
||||
import Bytes from './bytes'
|
||||
import PromiseMap from './map'
|
||||
import Queue from './queue'
|
||||
import Tracer from './tracer'
|
||||
import PromiseMap from './map'
|
||||
import { Codec } from './utils'
|
||||
|
||||
export default class StreamDemuxer extends Queue<Uint8Array> {
|
||||
readonly responses: PromiseMap<number | string, vsrpc.ResponseMessage> =
|
||||
|
@ -0,0 +1,2 @@
|
||||
export const encoder = new TextEncoder()
|
||||
export const decoder = new TextDecoder()
|
@ -1,8 +1,7 @@
|
||||
import * as jsrpc from 'json-rpc-2.0'
|
||||
import * as vsrpc from 'vscode-jsonrpc'
|
||||
import type * as vsrpc from 'vscode-jsonrpc'
|
||||
|
||||
import Bytes from './bytes'
|
||||
import StreamDemuxer from './demuxer'
|
||||
import { decoder } from './encode-decode'
|
||||
import Headers from './headers'
|
||||
import Queue from './queue'
|
||||
import Tracer from './tracer'
|
||||
@ -12,25 +11,6 @@ export enum LspWorkerEventType {
|
||||
Call = 'call',
|
||||
}
|
||||
|
||||
export const encoder = new TextEncoder()
|
||||
export const decoder = new TextDecoder()
|
||||
|
||||
export class Codec {
|
||||
static encode(
|
||||
json: jsrpc.JSONRPCRequest | jsrpc.JSONRPCResponse
|
||||
): Uint8Array {
|
||||
const message = JSON.stringify(json)
|
||||
const delimited = Headers.add(message)
|
||||
return Bytes.encode(delimited)
|
||||
}
|
||||
|
||||
static decode<T>(data: Uint8Array): T {
|
||||
const delimited = Bytes.decode(data)
|
||||
const message = Headers.remove(delimited)
|
||||
return JSON.parse(message) as T
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: tracing efficiency
|
||||
export class IntoServer
|
||||
extends Queue<Uint8Array>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Message } from 'vscode-languageserver-protocol'
|
||||
import type { Message } from 'vscode-languageserver-protocol'
|
||||
|
||||
export default class Tracer {
|
||||
static client(message: string): void {
|
||||
|
20
packages/codemirror-lsp-client/src/client/codec/utils.ts
Normal file
20
packages/codemirror-lsp-client/src/client/codec/utils.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type * as jsrpc from 'json-rpc-2.0'
|
||||
|
||||
import Bytes from './bytes'
|
||||
import Headers from './headers'
|
||||
|
||||
export class Codec {
|
||||
static encode(
|
||||
json: jsrpc.JSONRPCRequest | jsrpc.JSONRPCResponse
|
||||
): Uint8Array {
|
||||
const message = JSON.stringify(json)
|
||||
const delimited = Headers.add(message)
|
||||
return Bytes.encode(delimited)
|
||||
}
|
||||
|
||||
static decode<T>(data: Uint8Array): T {
|
||||
const delimited = Bytes.decode(data)
|
||||
const message = Headers.remove(delimited)
|
||||
return JSON.parse(message) as T
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import type * as LSP from 'vscode-languageserver-protocol'
|
||||
|
||||
import { FromServer, IntoServer } from './codec'
|
||||
import type { LanguageServerPlugin } from '../plugin/lsp'
|
||||
import type { FromServer, IntoServer } from './codec'
|
||||
import Client from './jsonrpc'
|
||||
import { LanguageServerPlugin } from '../plugin/lsp'
|
||||
|
||||
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/
|
||||
|
||||
@ -12,15 +12,15 @@ interface LSPRequestMap {
|
||||
'textDocument/hover': [LSP.HoverParams, LSP.Hover]
|
||||
'textDocument/completion': [
|
||||
LSP.CompletionParams,
|
||||
LSP.CompletionItem[] | LSP.CompletionList | null
|
||||
LSP.CompletionItem[] | LSP.CompletionList | null,
|
||||
]
|
||||
'textDocument/semanticTokens/full': [
|
||||
LSP.SemanticTokensParams,
|
||||
LSP.SemanticTokens
|
||||
LSP.SemanticTokens,
|
||||
]
|
||||
'textDocument/formatting': [
|
||||
LSP.DocumentFormattingParams,
|
||||
LSP.TextEdit[] | null
|
||||
LSP.TextEdit[] | null,
|
||||
]
|
||||
'textDocument/foldingRange': [LSP.FoldingRangeParams, LSP.FoldingRange[]]
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import * as jsrpc from 'json-rpc-2.0'
|
||||
import * as LSP from 'vscode-languageserver-protocol'
|
||||
|
||||
import type { FromServer, IntoServer } from './codec'
|
||||
import { Codec } from './codec/utils'
|
||||
import {
|
||||
registerServerCapability,
|
||||
unregisterServerCapability,
|
||||
} from './server-capability-registration'
|
||||
import { Codec, FromServer, IntoServer } from './codec'
|
||||
|
||||
const client_capabilities: LSP.ClientCapabilities = {
|
||||
textDocument: {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {
|
||||
import type {
|
||||
Registration,
|
||||
ServerCapabilities,
|
||||
Unregistration,
|
||||
|
@ -1,36 +1,34 @@
|
||||
import { foldService } from '@codemirror/language'
|
||||
import { Extension, EditorState } from '@codemirror/state'
|
||||
import type { EditorState, Extension } from '@codemirror/state'
|
||||
import { ViewPlugin } from '@codemirror/view'
|
||||
|
||||
import type { LanguageServerOptions } from './plugin/lsp'
|
||||
import {
|
||||
docPathFacet,
|
||||
LanguageServerPlugin,
|
||||
LanguageServerPluginSpec,
|
||||
docPathFacet,
|
||||
languageId,
|
||||
workspaceFolders,
|
||||
LanguageServerOptions,
|
||||
} from './plugin/lsp'
|
||||
|
||||
export type { LanguageServerClientOptions } from './client'
|
||||
export { LanguageServerClient } from './client'
|
||||
export type { LanguageServerClientOptions } from './client'
|
||||
export { FromServer, IntoServer, LspWorkerEventType } from './client/codec'
|
||||
export { Codec } from './client/codec/utils'
|
||||
export {
|
||||
Codec,
|
||||
FromServer,
|
||||
IntoServer,
|
||||
LspWorkerEventType,
|
||||
} from './client/codec'
|
||||
export type { LanguageServerOptions } from './plugin/lsp'
|
||||
lspDiagnosticsEvent,
|
||||
lspFormatCodeEvent,
|
||||
lspSemanticTokensEvent,
|
||||
} from './plugin/annotation'
|
||||
export {
|
||||
LanguageServerPlugin,
|
||||
LanguageServerPluginSpec,
|
||||
docPathFacet,
|
||||
languageId,
|
||||
workspaceFolders,
|
||||
lspSemanticTokensEvent,
|
||||
lspDiagnosticsEvent,
|
||||
lspFormatCodeEvent,
|
||||
} from './plugin/lsp'
|
||||
export { posToOffset, offsetToPos } from './plugin/util'
|
||||
export type { LanguageServerOptions } from './plugin/lsp'
|
||||
export { offsetToPos, posToOffset } from './plugin/util'
|
||||
|
||||
export function lspPlugin(options: LanguageServerOptions): Extension {
|
||||
let plugin: LanguageServerPlugin | null = null
|
||||
|
12
packages/codemirror-lsp-client/src/plugin/annotation.ts
Normal file
12
packages/codemirror-lsp-client/src/plugin/annotation.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Annotation } from '@codemirror/state'
|
||||
|
||||
export enum LspAnnotation {
|
||||
SemanticTokens = 'semantic-tokens',
|
||||
FormatCode = 'format-code',
|
||||
Diagnostics = 'diagnostics',
|
||||
}
|
||||
|
||||
const lspEvent = Annotation.define<LspAnnotation>()
|
||||
export const lspSemanticTokensEvent = lspEvent.of(LspAnnotation.SemanticTokens)
|
||||
export const lspFormatCodeEvent = lspEvent.of(LspAnnotation.FormatCode)
|
||||
export const lspDiagnosticsEvent = lspEvent.of(LspAnnotation.Diagnostics)
|
@ -9,17 +9,18 @@ import {
|
||||
prevSnippetField,
|
||||
startCompletion,
|
||||
} from '@codemirror/autocomplete'
|
||||
import { Prec, Extension } from '@codemirror/state'
|
||||
import { EditorView, keymap, KeyBinding, ViewPlugin } from '@codemirror/view'
|
||||
|
||||
import { syntaxTree } from '@codemirror/language'
|
||||
import type { Extension } from '@codemirror/state'
|
||||
import { Prec } from '@codemirror/state'
|
||||
import type { EditorView, KeyBinding, ViewPlugin } from '@codemirror/view'
|
||||
import { keymap } from '@codemirror/view'
|
||||
import {
|
||||
CompletionItemKind,
|
||||
CompletionTriggerKind,
|
||||
} from 'vscode-languageserver-protocol'
|
||||
|
||||
import { LanguageServerPlugin } from './lsp'
|
||||
import type { LanguageServerPlugin } from './lsp'
|
||||
import { offsetToPos } from './util'
|
||||
import { syntaxTree } from '@codemirror/language'
|
||||
|
||||
export const CompletionItemKindMap = Object.fromEntries(
|
||||
Object.entries(CompletionItemKind).map(([key, value]) => [value, key])
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Extension, Prec } from '@codemirror/state'
|
||||
import { EditorView, keymap, KeyBinding, ViewPlugin } from '@codemirror/view'
|
||||
import type { Extension } from '@codemirror/state'
|
||||
import { Prec } from '@codemirror/state'
|
||||
import type { EditorView, KeyBinding, ViewPlugin } from '@codemirror/view'
|
||||
import { keymap } from '@codemirror/view'
|
||||
|
||||
import { LanguageServerPlugin } from './lsp'
|
||||
import type { LanguageServerPlugin } from './lsp'
|
||||
|
||||
export default function lspFormatExt(
|
||||
plugin: ViewPlugin<LanguageServerPlugin>
|
||||
|
@ -1,12 +1,8 @@
|
||||
import { Extension } from '@codemirror/state'
|
||||
import {
|
||||
hoverTooltip,
|
||||
tooltips,
|
||||
ViewPlugin,
|
||||
EditorView,
|
||||
} from '@codemirror/view'
|
||||
import type { Extension } from '@codemirror/state'
|
||||
import type { ViewPlugin } from '@codemirror/view'
|
||||
import { EditorView, hoverTooltip, tooltips } from '@codemirror/view'
|
||||
|
||||
import { LanguageServerPlugin } from './lsp'
|
||||
import type { LanguageServerPlugin } from './lsp'
|
||||
import { offsetToPos } from './util'
|
||||
|
||||
export default function lspHoverExt(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { indentService } from '@codemirror/language'
|
||||
import { Extension } from '@codemirror/state'
|
||||
import type { Extension } from '@codemirror/state'
|
||||
|
||||
export default function lspIndentExt(): Extension {
|
||||
// Match the indentation of the previous line (if present).
|
||||
|
@ -4,39 +4,34 @@ import type {
|
||||
CompletionResult,
|
||||
} from '@codemirror/autocomplete'
|
||||
import { completeFromList, snippetCompletion } from '@codemirror/autocomplete'
|
||||
import {
|
||||
Facet,
|
||||
StateEffect,
|
||||
Extension,
|
||||
Transaction,
|
||||
Annotation,
|
||||
} from '@codemirror/state'
|
||||
import type {
|
||||
ViewUpdate,
|
||||
PluginValue,
|
||||
PluginSpec,
|
||||
ViewPlugin,
|
||||
} from '@codemirror/view'
|
||||
import { EditorView, Tooltip } from '@codemirror/view'
|
||||
import { linter } from '@codemirror/lint'
|
||||
|
||||
import type { PublishDiagnosticsParams } from 'vscode-languageserver-protocol'
|
||||
import type { Extension, StateEffect } from '@codemirror/state'
|
||||
import { Facet, Transaction } from '@codemirror/state'
|
||||
import type {
|
||||
EditorView,
|
||||
PluginSpec,
|
||||
PluginValue,
|
||||
Tooltip,
|
||||
ViewPlugin,
|
||||
ViewUpdate,
|
||||
} from '@codemirror/view'
|
||||
import type * as LSP from 'vscode-languageserver-protocol'
|
||||
import {
|
||||
DiagnosticSeverity,
|
||||
import type {
|
||||
CompletionTriggerKind,
|
||||
PublishDiagnosticsParams,
|
||||
} from 'vscode-languageserver-protocol'
|
||||
import { DiagnosticSeverity } from 'vscode-languageserver-protocol'
|
||||
import { URI } from 'vscode-uri'
|
||||
|
||||
import { LanguageServerClient } from '../client'
|
||||
import { CompletionItemKindMap } from './autocomplete'
|
||||
import { addToken, SemanticToken } from './semantic-tokens'
|
||||
import { posToOffset, formatMarkdownContents } from './util'
|
||||
import lspAutocompleteExt from './autocomplete'
|
||||
import lspHoverExt from './hover'
|
||||
import type { LanguageServerClient } from '../client'
|
||||
import { lspFormatCodeEvent, lspSemanticTokensEvent } from './annotation'
|
||||
import lspAutocompleteExt, { CompletionItemKindMap } from './autocomplete'
|
||||
import lspFormatExt from './format'
|
||||
import lspHoverExt from './hover'
|
||||
import lspIndentExt from './indent'
|
||||
import lspSemanticTokensExt from './semantic-tokens'
|
||||
import type { SemanticToken } from './semantic-tokens'
|
||||
import lspSemanticTokensExt, { addToken } from './semantic-tokens'
|
||||
import { formatMarkdownContents, posToOffset } from './util'
|
||||
|
||||
const useLast = (values: readonly any[]) => values.reduce((_, v) => v, '')
|
||||
export const docPathFacet = Facet.define<string, string>({
|
||||
@ -48,17 +43,6 @@ export const workspaceFolders = Facet.define<
|
||||
LSP.WorkspaceFolder[]
|
||||
>({ combine: useLast })
|
||||
|
||||
export enum LspAnnotation {
|
||||
SemanticTokens = 'semantic-tokens',
|
||||
FormatCode = 'format-code',
|
||||
Diagnostics = 'diagnostics',
|
||||
}
|
||||
|
||||
const lspEvent = Annotation.define<LspAnnotation>()
|
||||
export const lspSemanticTokensEvent = lspEvent.of(LspAnnotation.SemanticTokens)
|
||||
export const lspFormatCodeEvent = lspEvent.of(LspAnnotation.FormatCode)
|
||||
export const lspDiagnosticsEvent = lspEvent.of(LspAnnotation.Diagnostics)
|
||||
|
||||
export interface LanguageServerOptions {
|
||||
// We assume this is the main project directory, we are currently working in.
|
||||
workspaceFolders: LSP.WorkspaceFolder[]
|
||||
@ -98,7 +82,10 @@ export class LanguageServerPlugin implements PluginValue {
|
||||
// document.
|
||||
private sendScheduled: number | null = null
|
||||
|
||||
constructor(options: LanguageServerOptions, private view: EditorView) {
|
||||
constructor(
|
||||
options: LanguageServerOptions,
|
||||
private view: EditorView
|
||||
) {
|
||||
this.client = options.client
|
||||
this.documentVersion = 0
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { highlightingFor } from '@codemirror/language'
|
||||
import { StateEffect, StateField, Extension } from '@codemirror/state'
|
||||
import { EditorView, Decoration, DecorationSet } from '@codemirror/view'
|
||||
import type { Extension } from '@codemirror/state'
|
||||
import { StateEffect, StateField } from '@codemirror/state'
|
||||
import type { DecorationSet } from '@codemirror/view'
|
||||
import { Decoration, EditorView } from '@codemirror/view'
|
||||
import type { Tag } from '@lezer/highlight'
|
||||
import { tags } from '@lezer/highlight'
|
||||
|
||||
import { Tag, tags } from '@lezer/highlight'
|
||||
|
||||
import { lspSemanticTokensEvent } from './lsp'
|
||||
import { lspSemanticTokensEvent } from './annotation'
|
||||
|
||||
export interface SemanticToken {
|
||||
from: number
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Text } from '@codemirror/state'
|
||||
import { Marked, MarkedOptions } from '@ts-stack/markdown'
|
||||
|
||||
import type { Text } from '@codemirror/state'
|
||||
import type { MarkedOptions } from '@ts-stack/markdown'
|
||||
import { Marked } from '@ts-stack/markdown'
|
||||
import type * as LSP from 'vscode-languageserver-protocol'
|
||||
|
||||
import { isArray } from '../lib/utils'
|
||||
|
||||
// takes a function and executes it after the wait time, if the function is called again before the wait time is up, the timer is reset
|
||||
|
Reference in New Issue
Block a user