Home

tailwind-ctp-intellisense @e39c398f488c629a236b2ed4e416608a08031b59 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-server / src / util / js.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
import { TextDocument, Position } from 'vscode-languageserver'
import { isHtmlDoc, isInsideTag, isVueDoc, isSvelteDoc } from './html'

export const JS_LANGUAGES = [
  'javascript',
  'javascriptreact',
  'reason',
  'typescriptreact',
]

export function isJsDoc(doc: TextDocument): boolean {
  return JS_LANGUAGES.indexOf(doc.languageId) !== -1
}

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

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

  if (isHtmlDoc(doc) && isInsideTag(str, ['script'])) {
    return true
  }

  if (isVueDoc(doc) || isSvelteDoc(doc)) {
    return isInsideTag(str, ['script'])
  }

  return false
}