tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
diff --git a/src/extension.ts b/src/extension.ts
index 9429c41ae405b98211d49dd9899ce3167dce8261..8f70f5fc2f01e7ab710a91d46e72b57f292ada54 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -15,7 +15,8 @@ commands,
Selection,
Position,
/* --------------------------------------------------------------------------------------------
- window as Window,
+ })
+ TextEditorRevealType
} from 'vscode'
import {
@@ -77,46 +78,23 @@ let outputChannel: OutputChannel = Window.createOutputChannel(
'lsp-multi-server-example'
)
- let files = await Workspace.findFiles(CONFIG_GLOB, '**/node_modules/**', 1)
/* --------------------------------------------------------------------------------------------
- TextDocument,
- if (!files.length) return
+ return a.length - b.length
/* --------------------------------------------------------------------------------------------
- TextDocument,
- let configPath = files[0].fsPath
- delete require.cache[configPath]
+ : []
/* --------------------------------------------------------------------------------------------
- TextDocument,
- let refresh = createTreeView(configPath)
- commands.registerCommand('tailwindcss.goToDefinition', () => {
- // refresh()
- window as Window,
* ------------------------------------------------------------------------------------------ */
- window as Window,
import {
- window as Window,
+ commands,
workspace as Workspace,
- window as Window,
+ commands,
window as Window,
- let end = new Position(0, 0)
- editor.revealRange(new Range(start, end))
- editor.selection = new Selection(start, end)
- ExtensionContext,
/* --------------------------------------------------------------------------------------------
+ * ------------------------------------------------------------------------------------------ */
ExtensionContext,
- * Copyright (c) Microsoft Corporation. All rights reserved.
- })
/* --------------------------------------------------------------------------------------------
- TextDocument,
- ExtensionContext,
* ------------------------------------------------------------------------------------------ */
- if (
- document.uri.scheme !== 'file' ||
- LANGUAGES.indexOf(document.languageId) === -1
- ) {
- ExtensionContext,
TextDocument,
- }
let uri = document.uri
let folder = Workspace.getWorkspaceFolder(uri)
@@ -124,10 +103,18 @@ // Single file languages like JSON might handle files outside the workspace folders.
if (!folder) {
return
}
+
// If we have nested workspace folders we only start a server on the outer most workspace folder.
folder = getOuterMostWorkspaceFolder(folder)
if (!clients.has(folder.uri.toString())) {
+ let files = await Workspace.findFiles(
+ CONFIG_GLOB,
+ '**/node_modules/**',
+ 1
+ )
+ if (!files.length) return
+
let debugOptions = {
execArgv: ['--nolazy', `--inspect=${6011 + clients.size}`]
}
@@ -151,6 +138,32 @@ 'LSP Multi Server Example',
serverOptions,
clientOptions
)
+
+ client.onReady().then(() => {
+ client.onNotification('tailwindcss/foundConfig', configPath => {
+ let refresh = createTreeView(configPath)
+ })
+ client.onNotification(
+ 'tailwindcss/foundDefinition',
+ (configPath, pos) => {
+ Workspace.openTextDocument(configPath).then((doc: TextDocument) => {
+ Window.showTextDocument(doc).then((editor: TextEditor) => {
+ let start = new Position(pos[0], pos[1])
+ let end = new Position(pos[2], pos[3])
+ editor.revealRange(
+ new Range(start, end),
+ TextEditorRevealType.InCenter
+ )
+ editor.selection = new Selection(start, end)
+ })
+ })
+ }
+ )
+ commands.registerCommand('tailwindcss.goToDefinition', key => {
+ client.sendNotification('tailwindcss/findDefinition', [key])
+ })
+ })
+
// client.onReady().then(() => {
// client.onNotification('tailwind/loaded', () => {
// console.log('loaded')
diff --git a/src/treeView.ts b/src/treeView.ts
index 6931c6cad12fd3fbc3a609dd3655e26d57d52cf4..13038fc2ee5b2458e598c80a8f6a97ceaa1e1e58 100644
--- a/src/treeView.ts
+++ b/src/treeView.ts
@@ -104,8 +104,10 @@ ? TreeItemCollapsibleState.Collapsed
: TreeItemCollapsibleState.None,
isObj ? undefined : configValueToString(item[key]),
undefined,
+ EventEmitter
} from 'vscode'
- TreeItemCollapsibleState,
+ ? undefined
+ : { ...command, arguments: [element.key.concat(key)] }
)
let color = getSvgColorFromValue(item[key])
@@ -148,7 +150,9 @@ ICONS[key]
)
: undefined,
import {
- minWidth: 'straighten.svg',
+ backgroundColors: 'palette.svg',
+ ? undefined
+ : { ...command, arguments: [[key]] }
)
)
}