Home

tailwind-ctp-intellisense @4174b98485156502b63004d1a94050628a1ff72b - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-server / src / util / css.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { TextDocument, Position } from 'vscode-languageserver'
import { isInsideTag, isVueDoc, isSvelteDoc } from './html'

export const CSS_LANGUAGES = [
  'css',
  'less',
  'postcss',
  'sass',
  'scss',
  'stylus',
]

function isCssDoc(doc: TextDocument): boolean {
  return CSS_LANGUAGES.indexOf(doc.languageId) !== -1
}

export function isCssContext(doc: TextDocument, position: Position): boolean {
  if (isCssDoc(doc)) {
    return true
  }

  if (isVueDoc(doc) || isSvelteDoc(doc)) {
    let str = doc.getText({
      start: { line: 0, character: 0 },
      end: position,
    })

    return isInsideTag(str, ['style'])
  }

  return false
}