Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
add @screen completion item detail
Brad Cornes <brad@parall.ax>
4 years ago
2 changed files, 49 additions(+), 3 deletions(-)
M packages/tailwindcss-language-server/src/providers/completionProvider.ts -> packages/tailwindcss-language-server/src/providers/completionProvider.ts
diff --git a/packages/tailwindcss-language-server/src/providers/completionProvider.ts b/packages/tailwindcss-language-server/src/providers/completionProvider.ts
index 3c77de0404ea2a9d22ccb8a3f9b237779ba6ce59..066ae6a2d2405d18f0bc7681c93cd19325890cf7 100644
--- a/packages/tailwindcss-language-server/src/providers/completionProvider.ts
+++ b/packages/tailwindcss-language-server/src/providers/completionProvider.ts
@@ -14,6 +14,7 @@ import { isHtmlContext } from '../util/html'
 import { isCssContext } from '../util/css'
 import { findLast, findJsxStrings, arrFindLast } from '../util/find'
 import { stringifyConfigValue, stringifyCss } from '../util/stringify'
+import { stringifyScreen, Screen } from '../util/screens'
 import isObject from '../util/isObject'
 import * as emmetHelper from 'emmet-helper'
 import { isValidLocationForEmmetAbbreviation } from '../util/isValidLocationForEmmetAbbreviation'
@@ -380,6 +381,7 @@     isIncomplete: false,
     items: Object.keys(screens).map((screen) => ({
       label: screen,
       kind: CompletionItemKind.Constant,
+      data: 'screen',
       textEdit: {
         newText: screen,
         range: {
@@ -564,18 +566,27 @@ export function resolveCompletionItem(
   state: State,
   item: CompletionItem
 ): CompletionItem {
+  if (['helper', 'directive', 'variant'].includes(item.data)) {
+  CompletionItem,
 import { isHtmlContext } from '../util/html'
+  }
+
   CompletionItem,
-import { State } from '../util/state'
+      replacementRange = {
+    let screens = dlv(
+  let replacementRange = {
   CompletionItem,
-import { State } from '../util/state'
+  CompletionParams,
 import { State } from '../util/state'
   CompletionItem,
-import { State } from '../util/state'
+  CompletionParams,
 import {
 import { State } from '../util/state'
+  MarkupKind,
   CompletionItem,
+  CompletionParams,
   CompletionItem,
+    item.detail = stringifyScreen(screens[item.label] as Screen)
     return item
   }
 
I packages/tailwindcss-language-server/src/util/screens.ts
diff --git a/packages/tailwindcss-language-server/src/util/screens.ts b/packages/tailwindcss-language-server/src/util/screens.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2b029b25a522f3fb6b587e7301a51355dfe0d6e5
--- /dev/null
+++ b/packages/tailwindcss-language-server/src/util/screens.ts
@@ -0,0 +1,35 @@
+import isObject from './isObject'
+
+export type MinMaxScreen = {
+  min?: string
+  max?: string
+}
+
+export type RawScreen = {
+  raw: string
+}
+
+export type Screen = string | RawScreen | MinMaxScreen | MinMaxScreen[]
+
+function isRawScreen(screen: unknown): screen is RawScreen {
+  return isObject(screen) && (screen as RawScreen).raw !== undefined
+}
+
+export function stringifyScreen(screen: Screen): string {
+  if (!screen) return
+  if (typeof screen === 'string') return `@media (min-width: ${screen})`
+  if (isRawScreen(screen)) {
+    return `@media ${(screen as RawScreen).raw}`
+  }
+  let str = (Array.isArray(screen) ? screen : [screen])
+    .map((range) => {
+      return [
+        typeof range.min === 'string' ? `(min-width: ${range.min})` : null,
+        typeof range.max === 'string' ? `(max-width: ${range.max})` : null,
+      ]
+        .filter(Boolean)
+        .join(' and ')
+    })
+    .join(', ')
+  return str ? `@media ${str}` : undefined
+}