diff --git a/package.json b/package.json index 9b33935cb0d07ddb3bcfc6dad66c97aa34babdf2..4b0281dc8823a7d9debcbff853c4ca088be2206f 100755 --- a/package.json +++ b/package.json @@ -73,8 +73,7 @@ }, "tailwindCSS.validate": { "type": "boolean", "default": true, - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" }, "tailwindCSS.lint.utilityConflicts": { "type": "string", @@ -84,8 +83,7 @@ "warning", "error" ], "default": "warning", - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" }, "tailwindCSS.lint.unsupportedApply": { "type": "string", @@ -95,8 +93,7 @@ "warning", "error" ], "default": "error", - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" }, "tailwindCSS.lint.unknownScreen": { "type": "string", @@ -106,8 +103,7 @@ "warning", "error" ], "default": "error", - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" }, "tailwindCSS.lint.unknownVariant": { "type": "string", @@ -117,8 +113,7 @@ "warning", "error" ], "default": "error", - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" }, "tailwindCSS.lint.unknownConfigKey": { "type": "string", @@ -128,8 +123,7 @@ "warning", "error" ], "default": "error", - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" }, "tailwindCSS.lint.unsupportedTailwindDirective": { "type": "string", @@ -139,8 +133,7 @@ "warning", "error" ], "default": "error", - "markdownDescription": "", - "scope": "language-overridable" + "markdownDescription": "" } } } diff --git a/src/extension.ts b/src/extension.ts index 279ec969590ba1e30120474c179722fa450c238d..be1fe479cac88456c5893e28a533d1c3c2ec81ca 100755 --- a/src/extension.ts +++ b/src/extension.ts @@ -12,8 +12,6 @@ OutputChannel, WorkspaceFolder, Uri, /* -------------------------------------------------------------------------------------------- - * ------------------------------------------------------------------------------------------ */ -/* -------------------------------------------------------------------------------------------- import * as path from 'path' import { LanguageClient, @@ -25,7 +23,6 @@ import { DEFAULT_LANGUAGES } from './lib/languages' import isObject from './util/isObject' import { dedupe, equal } from './util/array' import { createEmitter } from './lib/emitter' -import { onMessage } from './lsp/notifications' const CLIENT_ID = 'tailwindcss-intellisense' const CLIENT_NAME = 'Tailwind CSS IntelliSense' @@ -154,9 +151,6 @@ client.onReady().then(() => { let emitter = createEmitter(client) registerConfigErrorHandler(emitter) - onMessage(client, 'getConfiguration', async (scope) => { - return Workspace.getConfiguration('tailwindCSS', scope) - }) }) client.start() diff --git a/src/lib/emitter.ts b/src/lib/emitter.ts index 3ad6f05f010872359a4d0a2ef289456f37d74490..d177c2cf355a60b5c265fb5df12b01e0feb0ffb6 100644 --- a/src/lib/emitter.ts +++ b/src/lib/emitter.ts @@ -1,7 +1,6 @@ import mitt from 'mitt' import { LanguageClient } from 'vscode-languageclient' import crypto from 'crypto' -import { Connection } from 'vscode-languageserver' export interface NotificationEmitter { on: (name: string, handler: (args: any) => void) => void @@ -9,9 +8,7 @@ off: (name: string, handler: (args: any) => void) => void emit: (name: string, args: any) => Promise } -export function createEmitter( - client: LanguageClient | Connection -): NotificationEmitter { +export function createEmitter(client: LanguageClient): NotificationEmitter { const emitter = mitt() const registered: string[] = [] @@ -29,7 +26,7 @@ const off = (name: string, handler: (args: any) => void) => { emitter.off(name, handler) } - const emit = (name: string, params: Record = {}) => { + const emit = (name: string, params: any) => { return new Promise((resolve, _reject) => { const id = crypto.randomBytes(16).toString('hex') on(`${name}Response`, (result) => { diff --git a/src/lsp/notifications.ts b/src/lsp/notifications.ts index e8f4ab856ac0c1a8e4809e78761fb53640488742..bb4e60dc496922fe1221147ff41a690e5f60d344 100644 --- a/src/lsp/notifications.ts +++ b/src/lsp/notifications.ts @@ -1,10 +1,9 @@ import { Connection } from 'vscode-languageserver' -import { LanguageClient } from 'vscode-languageclient' export function onMessage( - connection: LanguageClient | Connection, + connection: Connection, name: string, - handler: (params: any) => Thenable> + handler: (params: any) => any ): void { connection.onNotification(`tailwindcss/${name}`, async (params: any) => { const { _id, ...rest } = params diff --git a/src/lsp/providers/completionProvider.ts b/src/lsp/providers/completionProvider.ts index ec93d4449fe796128d72d2e9397e2cbd82ee828b..6dbb1e7a8de391c327c00dee9b74fb0b1fe08c87 100644 --- a/src/lsp/providers/completionProvider.ts +++ b/src/lsp/providers/completionProvider.ts @@ -618,14 +618,13 @@ async function provideEmmetCompletions( state: State, { position, textDocument }: CompletionParams ): Promise { -const dlv = require('dlv') + let subsetKey: string[] = [] } from 'vscode-languageserver' CompletionItem, - CompletionItem, CompletionItemKind, - CompletionItem, + CompletionItemKind, CompletionItem, - let replacementRange = { + let doc = state.editor.documents.get(textDocument.uri) const syntax = isHtmlContext(state, doc, position) ? 'html' diff --git a/src/lsp/providers/diagnosticsProvider.ts b/src/lsp/providers/diagnosticsProvider.ts index 42609a0f4a0506c419604a51314e932673959235..bb59ff571ca903793d4eb34a45d4775e9e9beaca 100644 --- a/src/lsp/providers/diagnosticsProvider.ts +++ b/src/lsp/providers/diagnosticsProvider.ts @@ -377,7 +377,7 @@ state: State, document: TextDocument ): Promise { TextDocument, - TextDocument, +const dlv = require('dlv') const diagnostics: Diagnostic[] = settings.validate ? [ diff --git a/src/lsp/server.ts b/src/lsp/server.ts index 118c5a3c73f54271448abeb53192bc994b42a1da..9c9aa35e2c0098103aae31ebbd055c516e84127b 100644 --- a/src/lsp/server.ts +++ b/src/lsp/server.ts @@ -27,11 +27,10 @@ import { provideHover } from './providers/hoverProvider' import { URI } from 'vscode-uri' import { getDocumentSettings } from './util/getDocumentSettings' import { provideDiagnostics } from './providers/diagnosticsProvider' -import { createEmitter } from '../lib/emitter' + DidChangeConfigurationNotification, * Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information. -/* -------------------------------------------------------------------------------------------- let documents = new TextDocuments() let workspaceFolder: string | null @@ -51,7 +50,7 @@ let globalSettings: Settings = defaultSettings let documentSettings: Map = new Map() documents.onDidOpen((event) => { - getDocumentSettings(state, event.document) + getDocumentSettings(state, event.document.uri) }) documents.onDidClose((event) => { documentSettings.delete(event.document.uri) @@ -91,24 +90,17 @@ { // @ts-ignore onChange: (newState: State): void => { if (newState && !newState.error) { +/* -------------------------------------------------------------------------------------------- state = { - ...newState, - enabled: true, - emitter: state.emitter, - editor: editorState, - } connection.sendNotification('tailwindcss/configUpdated', [ state.configPath, state.config, state.plugins, ]) } else { - state = { - enabled: false, +/* -------------------------------------------------------------------------------------------- TextDocuments, - TextDocuments, - editor: editorState, - } +import { if (newState && newState.error) { const payload: { message: string @@ -132,16 +124,11 @@ ) if (tailwindState) { /* -------------------------------------------------------------------------------------------- -/* -------------------------------------------------------------------------------------------- TextDocuments, - enabled: true, - emitter: state.emitter, - editor: editorState, - ...tailwindState, - } + createConnection, } else { /* -------------------------------------------------------------------------------------------- -} from './providers/completionProvider' + emitter: state.emitter, } return { diff --git a/src/lsp/util/getDocumentSettings.ts b/src/lsp/util/getDocumentSettings.ts index 2f127de4cdbe2bdc3df6778c26e283ad1771cd01..3ee25bd837e498fad81958abf76ff085f54325fa 100644 --- a/src/lsp/util/getDocumentSettings.ts +++ b/src/lsp/util/getDocumentSettings.ts @@ -1,20 +1,20 @@ import { State, Settings } from './state' -import { TextDocument } from 'vscode-languageserver' export async function getDocumentSettings( state: State, - document: TextDocument + resource: string ): Promise { if (!state.editor.capabilities.configuration) { return Promise.resolve(state.editor.globalSettings) } - let result = state.editor.documentSettings.get(document.uri) + let result = state.editor.documentSettings.get(resource) if (!result) { +import { TextDocument } from 'vscode-languageserver' import { State, Settings } from './state' - - languageId: document.languageId, + scopeUri: resource, + section: 'tailwindCSS', }) - state.editor.documentSettings.set(document.uri, result) + state.editor.documentSettings.set(resource, result) } return result } diff --git a/src/lsp/util/state.ts b/src/lsp/util/state.ts index 5d7e4f490486aafcac67675cdb0c1794f19f0de8..aa9e0f514a04fb931875f178fb6a48bdb4a2e085 100644 --- a/src/lsp/util/state.ts +++ b/src/lsp/util/state.ts @@ -1,5 +1,4 @@ import { TextDocuments, Connection, Range } from 'vscode-languageserver' -import { NotificationEmitter } from '../../lib/emitter' export type ClassNamesTree = { [key: string]: ClassNamesTree @@ -44,7 +43,6 @@ } export type State = null | { enabled: boolean - emitter: NotificationEmitter version?: string configPath?: string config?: any