Home

tailwind-ctp-intellisense @16864d96ae6f55ae8d3e2de4cbbb36b42b935de4 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / 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
import type { TextDocument, Position } from 'vscode-languageserver'
import { isInsideTag, isVueDoc, isSvelteDoc, isHtmlDoc } from './html'
import { isJsDoc } from './js'
import { State } from './state'
import { cssLanguages } from './languages'

export function isCssDoc(state: State, doc: TextDocument): boolean {
  const userCssLanguages = Object.keys(state.editor.userLanguages).filter((lang) =>
    cssLanguages.includes(state.editor.userLanguages[lang])
  )

  return [...cssLanguages, ...userCssLanguages].indexOf(doc.languageId) !== -1
}

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

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

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

  return false
}