Skip to content

Commit

Permalink
feat: add name option
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Dec 20, 2023
1 parent 0090e62 commit ff29df2
Show file tree
Hide file tree
Showing 21 changed files with 87 additions and 68 deletions.
1 change: 1 addition & 0 deletions packages/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Provide {

export function create(): ServicePlugin {
return {
name: 'css',
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/css-language-features/server/src/cssServer.ts#L97
triggerCharacters: ['/', '-', ':'],
create(context): ServicePluginInstance<Provide> {
Expand Down
1 change: 1 addition & 0 deletions packages/emmet/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ console.warn('volar-service-emmet: this module is not yet supported for web.');

export function create(): ServicePlugin {
return {
name: 'emmet (stub)',
create() {
return {};
},
Expand Down
1 change: 1 addition & 0 deletions packages/emmet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getHtmlDocument } from 'volar-service-html';

export function create(): ServicePlugin {
return {
name: 'emmet',
// https://docs.emmet.io/abbreviations/syntax/
triggerCharacters: '>+^*()#.[]$@-{}'.split(''),
create(context): ServicePluginInstance {
Expand Down
1 change: 1 addition & 0 deletions packages/eslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function create(resolveConfig?: (program: ts.Program) => Linter.Config):
const uriToLintResult = new Map<string, ESLint.LintResult[]>();

return {
name: 'eslint',
create(context): ServicePluginInstance {
return {
async provideSemanticDiagnostics(document) {
Expand Down
1 change: 1 addition & 0 deletions packages/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function create({
useCustomDataProviders?: boolean;
} = {}): ServicePlugin {
return {
name: 'html',
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/html-language-features/server/src/htmlServer.ts#L183
triggerCharacters: ['.', ':', '<', '"', '=', '/'],
create(context): ServicePluginInstance<Provide> {
Expand Down
1 change: 1 addition & 0 deletions packages/json/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Provide {

export function create(settings?: json.LanguageSettings): ServicePlugin {
return {
name: 'json',
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/json-language-features/server/src/jsonServer.ts#L150
triggerCharacters: ['"', ':'],
create(context): ServicePluginInstance<Provide> {
Expand Down
1 change: 1 addition & 0 deletions packages/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function assert(condition: unknown, message: string): asserts condition {

export function create(options: CreateOptions): ServicePlugin {
return {
name: 'markdown',
create(context): ServicePluginInstance<Provide> {

let lastProjectVersion: string | undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/prettier/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function create(
},
): ServicePlugin {
return {
name: 'prettier',
create(context): ServicePluginInstance {

let prettier: typeof import('prettier');
Expand Down
1 change: 1 addition & 0 deletions packages/pretty-ts-errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { formatDiagnostic } from 'pretty-ts-errors-lsp';

export function create(format: (text: string) => string): ServicePlugin {
return {
name: 'pretty-ts-errors',
create(): ServicePluginInstance {
return {
provideDiagnosticMarkupContent(diagnostic) {
Expand Down
1 change: 1 addition & 0 deletions packages/prettyhtml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as prettyhtml from '@starptech/prettyhtml';

export function create(configs: NonNullable<Parameters<typeof prettyhtml>[1]>): ServicePlugin {
return {
name: 'prettyhtml',
create(): ServicePluginInstance {
return {
provideDocumentFormattingEdits(document, range, options) {
Expand Down
1 change: 1 addition & 0 deletions packages/pug-beautify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ServicePluginInstance, ServicePlugin } from '@volar/language-servi

export function create(): ServicePlugin {
return {
name: 'pug-beautify',
create(): ServicePluginInstance {
return {
provideDocumentFormattingEdits(document, range, options) {
Expand Down
1 change: 1 addition & 0 deletions packages/pug/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ console.warn('volar-service-pug: this module is not yet supported for web.');

export function create(): ServicePlugin {
return {
name: 'pug (stub)',
create() {
return {};
},
Expand Down
1 change: 1 addition & 0 deletions packages/pug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function create(): ServicePlugin {
const _htmlService = createHtmlService();
return {
..._htmlService,
name: 'pug',
create(context): ServicePluginInstance<Provide> {

const htmlService = _htmlService.create(context);
Expand Down
1 change: 1 addition & 0 deletions packages/sass-formatter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SassFormatter } from 'sass-formatter';

export function create(configs: Parameters<typeof SassFormatter.Format>[1]): ServicePlugin {
return {
name: 'sass-formatter',
create(): ServicePluginInstance {
return {
provideDocumentFormattingEdits(document, range, options) {
Expand Down
1 change: 1 addition & 0 deletions packages/tsconfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function mapChildren<R>(node: jsonc.Node | undefined, f: (x: jsonc.Node) => R):

export function create(): ServicePlugin {
return {
name: 'tsconfig',
create(context): ServicePluginInstance {

const patterns = [
Expand Down
1 change: 1 addition & 0 deletions packages/tslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function create(rules: IRule[]): ServicePlugin {
const diagnosticToFailure = new Map<string, RuleFailure[]>();

return {
name: 'tslint',
create(context): ServicePluginInstance {
return {
provideSemanticDiagnostics(document, token) {
Expand Down
1 change: 1 addition & 0 deletions packages/typescript-twoslash-queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Provide } from 'volar-service-typescript';

export function create(): ServicePlugin {
return {
name: 'typescript-twoslash-queries',
create(context): ServicePluginInstance {
return {
provideInlayHints(document, range) {
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export interface Provide {
'typescript/syntacticLanguageServiceHost': () => ts.LanguageServiceHost;
};


export function create(ts: typeof import('typescript/lib/tsserverlibrary')): ServicePlugin {
const basicTriggerCharacters = getBasicTriggerCharacters(ts.version);
const jsDocTriggerCharacter = '*';
const directiveCommentTriggerCharacter = '@';
return {
name: 'typescript',
triggerCharacters: [
...basicTriggerCharacters,
jsDocTriggerCharacter,
Expand Down
1 change: 1 addition & 0 deletions packages/vetur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getGlobalSnippetDir } from './lib/userSnippetDir';

export function create(): ServicePlugin {
return {
name: 'vetur',
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/html-language-features/server/src/htmlServer.ts#L183
triggerCharacters: ['.', ':', '<', '"', '=', '/', /* vue event shorthand */'@'],
create(context): ServicePluginInstance {
Expand Down
1 change: 1 addition & 0 deletions packages/yaml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function noop(): undefined { }
*/
export function create(settings?: LanguageSettings): ServicePlugin {
return {
name: 'yaml',
triggerCharacters: [' ', ':'],
create(context): ServicePluginInstance<Provide> {

Expand Down
Loading

0 comments on commit ff29df2

Please sign in to comment.