Home

tailwind-ctp-intellisense @19cb859b5d92897c16cdd271786ca07d8d06d011 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / src / util / html.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 type { Position } from 'vscode-languageserver'
import type { TextDocument } from 'vscode-languageserver-textdocument'
import { State } from './state'
import { htmlLanguages } from './languages'
import { getLanguageBoundaries } from './getLanguageBoundaries'

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

  return [...htmlLanguages, ...userHtmlLanguages].indexOf(doc.languageId) !== -1
}

export function isVueDoc(doc: TextDocument): boolean {
  return doc.languageId === 'vue'
}

export function isSvelteDoc(doc: TextDocument): boolean {
  return doc.languageId === 'svelte'
}

export function isHtmlContext(state: State, doc: TextDocument, position: Position): boolean {
  let str = doc.getText({
    start: { line: 0, character: 0 },
    end: position,
  })

  let boundaries = getLanguageBoundaries(state, doc, str)

  return boundaries ? boundaries[boundaries.length - 1].type === 'html' : false
}