Home

tailwind-ctp-intellisense @dcde392ba6da8c0e507564d5f88aa1dda2feb268 - 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
31
32
33
34
35
36
37
38
39
40
41
42
import type { TextDocument, Position } from 'vscode-languageserver'
import { isInsideTag, isVueDoc, isSvelteDoc, isHtmlDoc } from './html'
import { State } from './state'

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

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

  return [...CSS_LANGUAGES, ...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)) {
    let str = doc.getText({
      start: { line: 0, character: 0 },
      end: position,
    })

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

  return false
}