Home

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

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

  return [...jsLanguages, ...userJsLanguages].indexOf(doc.languageId) !== -1
}

export function isJsxContext(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 === 'jsx' : false
}