Skip to content

Commit

Permalink
Add getVDFTokeniserOptions to VDFLanguageServerConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Mar 21, 2024
1 parent 28c197e commit 3b6a429
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/lib/server/VDF/Popfile/PopfileLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class PopfileLanguageServer extends VDFLanguageServer {

constructor(name: PopfileLanguageServer["name"], languageId: PopfileLanguageServer["languageId"], connection: Connection) {
super(name, languageId, connection, {
getVDFTokeniserOptions(uri) {
return { allowMultilineStrings: true }
},
vpkRootPath: "scripts/population",
keyHash: (key) => key,
schema: {
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/server/VDF/VDFLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export abstract class VDFLanguageServer extends LanguageServer<VDFDocumentSymbol
constructor(name: VDFLanguageServer["name"], languageId: VDFLanguageServer["languageId"], connection: Connection, configuration: VDFLanguageServerConfiguration) {
super(name, languageId, connection, {
servers: configuration.servers,
parseDocumentSymbols: (uri, str) => getVDFDocumentSymbols(str),
parseDocumentSymbols: (uri, str) => getVDFDocumentSymbols(str, this.VDFLanguageServerConfiguration.getVDFTokeniserOptions(uri)),
defaultDocumentSymbols: () => new VDFDocumentSymbols()
})

Expand Down
2 changes: 2 additions & 0 deletions packages/lib/server/VDF/VDFLanguageServerConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { languageClientsInfo } from "lib/languageClientsInfo"
import type { DocumentLinkData } from "lib/types/DocumentLinkData"
import type { VDFDocumentSymbol } from "lib/VDFDocumentSymbols/VDFDocumentSymbol"
import type { VDFTokeniserOptions } from "packages/lib/VDF/VDFTokeniserOptions"
import type { Color, CompletionItem, DocumentLink } from "vscode-languageserver"

export interface VDFLanguageServerConfiguration {
getVDFTokeniserOptions(uri: string): VDFTokeniserOptions,
servers?: (keyof typeof languageClientsInfo)[]
vpkRootPath?: string
keyHash(key: string): string
Expand Down
6 changes: 6 additions & 0 deletions packages/lib/server/VDF/VGUI/VGUILanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as filesCompletion from "lib/utils/filesCompletion"
import { getHUDRoot } from "lib/utils/getHUDRoot"
import { normalizeUri } from "lib/utils/normalizeUri"
import { posix } from "path"
import { basename } from "path/posix"
import { CodeLens, Color, CompletionItem, CompletionItemKind, Diagnostic, DiagnosticSeverity, DocumentLink, Location, Range, type CodeLensParams, type CompletionParams, type Connection, type Definition, type DefinitionParams, type PrepareRenameParams, type ReferenceParams, type TextDocumentChangeEvent } from "vscode-languageserver"
import type { TextDocument } from "vscode-languageserver-textdocument"
import { z } from "zod"
Expand Down Expand Up @@ -63,6 +64,11 @@ export class VGUILanguageServer extends VDFLanguageServer {

constructor(name: VGUILanguageServer["name"], languageId: VGUILanguageServer["languageId"], connection: Connection) {
super(name, languageId, connection, {
getVDFTokeniserOptions: (uri) => {
return {
allowMultilineStrings: /(tf|chat)_.*?\.txt/.test(basename(uri))
}
},
servers: ["hudanimations"],
keyHash: (key) => {
return key.replace("_minmode", "")
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/server/VDF/VMT/VMTLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class VMTLanguageServer extends VDFLanguageServer {

constructor(name: VMTLanguageServer["name"], languageId: VMTLanguageServer["languageId"], connection: Connection) {
super(name, languageId, connection, {
getVDFTokeniserOptions(uri) {
return { allowMultilineStrings: false }
},
keyHash: (key) => key,
schema: {
keys: keys,
Expand Down

0 comments on commit 3b6a429

Please sign in to comment.