Skip to content

Commit

Permalink
Merge pull request #117 from mkslanc/client-capabilities
Browse files Browse the repository at this point in the history
Move clientCapabilities to BaseService
  • Loading branch information
mkslanc authored May 16, 2024
2 parents 20ab149 + ef274f6 commit dcbe802
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 59 deletions.
57 changes: 57 additions & 0 deletions packages/ace-linters/src/services/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,63 @@ export abstract class BaseService<OptionsType extends ServiceOptions = ServiceOp
globalOptions: OptionsType = {} as OptionsType;
serviceData: ServiceConfig;
serviceCapabilities: lsp.ServerCapabilities = {};

clientCapabilities: lsp.ClientCapabilities = {
textDocument: {
hover: {
dynamicRegistration: true,
contentFormat: ['markdown', 'plaintext'],
},
synchronization: {
dynamicRegistration: true,
willSave: false,
didSave: false,
willSaveWaitUntil: false,
},
formatting: {
dynamicRegistration: true
},
completion: {
dynamicRegistration: true,
completionItem: {
snippetSupport: true,
commitCharactersSupport: false,
documentationFormat: ['markdown', 'plaintext'],
deprecatedSupport: false,
preselectSupport: false,
},
contextSupport: false,
},
signatureHelp: {
signatureInformation: {
documentationFormat: ['markdown', 'plaintext'],
activeParameterSupport: true
}
},
documentHighlight: {
dynamicRegistration: true
},
semanticTokens: {
multilineTokenSupport: false,
overlappingTokenSupport: false,
tokenTypes: [],
tokenModifiers: [],
formats: ["relative"],
requests: {
full: {
delta: false
},
range: true
},
augmentsSyntaxTokens: true
}
},
workspace: {
didChangeConfiguration: {
dynamicRegistration: true,
},
} as lsp.WorkspaceClientCapabilities,
};

protected constructor(mode: string) {
this.mode = mode;
Expand Down
58 changes: 1 addition & 57 deletions packages/ace-linters/src/services/language-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,63 +21,7 @@ export class LanguageClient extends BaseService implements LanguageService {
private readonly socket: WebSocket;
private connection: lsp.ProtocolConnection;
private requestsQueue: Function[] = [];

clientCapabilities: lsp.ClientCapabilities = {
textDocument: {
hover: {
dynamicRegistration: true,
contentFormat: ['markdown', 'plaintext'],
},
synchronization: {
dynamicRegistration: true,
willSave: false,
didSave: false,
willSaveWaitUntil: false,
},
formatting: {
dynamicRegistration: true
},
completion: {
dynamicRegistration: true,
completionItem: {
snippetSupport: true,
commitCharactersSupport: false,
documentationFormat: ['markdown', 'plaintext'],
deprecatedSupport: false,
preselectSupport: false,
},
contextSupport: false,
},
signatureHelp: {
signatureInformation: {
documentationFormat: ['markdown', 'plaintext'],
activeParameterSupport: true
}
},
documentHighlight: {
dynamicRegistration: true
},
semanticTokens: {
multilineTokenSupport: false,
overlappingTokenSupport: false,
tokenTypes: [],
tokenModifiers: [],
formats: ["relative"],
requests: {
full: {
delta: false
},
range: true
},
augmentsSyntaxTokens: true
}
},
workspace: {
didChangeConfiguration: {
dynamicRegistration: true,
},
} as lsp.WorkspaceClientCapabilities,
};

ctx;

constructor(serverData: LanguageClientConfig, ctx) {
Expand Down
4 changes: 3 additions & 1 deletion packages/ace-linters/src/services/yaml/yaml-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class YamlService extends BaseService<YamlServiceOptions> implements Lang
resolveRelativePath: (relativePath, resource) => {
return relativePath + resource;
}
}
},
// @ts-ignore
clientCapabilities: this.clientCapabilities
});
}

Expand Down
1 change: 1 addition & 0 deletions packages/ace-linters/types/language-provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export declare class LanguageProvider {
/**
* Removes document from all linked services by session id
* @param session
* @param [callback]
*/
closeDocument(session: Ace.EditSession, callback?: any): void;
}
1 change: 1 addition & 0 deletions packages/ace-linters/types/services/base-service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export declare abstract class BaseService<OptionsType extends ServiceOptions = S
globalOptions: OptionsType;
serviceData: ServiceConfig;
serviceCapabilities: lsp.ServerCapabilities;
clientCapabilities: lsp.ClientCapabilities;
protected constructor(mode: string);
addDocument(document: lsp.TextDocumentItem): void;
getDocument(uri: string): TextDocument;
Expand Down
1 change: 0 additions & 1 deletion packages/ace-linters/types/services/language-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export declare class LanguageClient extends BaseService implements LanguageServi
private readonly socket;
private connection;
private requestsQueue;
clientCapabilities: lsp.ClientCapabilities;
ctx: any;
constructor(serverData: LanguageClientConfig, ctx: any);
private $connectSocket;
Expand Down

0 comments on commit dcbe802

Please sign in to comment.