Home

tailwind-ctp-intellisense @3d57b3c9c86dfffbf8be7f567f13781837e3bb51 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / src / lsp / util / lexers.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
43
44
45
46
47
48
49
50
51
52
53
import moo from 'moo'
import { lazy } from './lazy'

const classAttributeStates: { [x: string]: moo.Rules } = {
  doubleClassList: {
    lbrace: { match: /(?<!\\)\{/, push: 'interp' },
    rbrace: { match: /(?<!\\)\}/, pop: 1 },
    end: { match: /(?<!\\)"/, pop: 1 },
    classlist: { match: /[\s\S]/, lineBreaks: true },
  },
  singleClassList: {
    lbrace: { match: /(?<!\\)\{/, push: 'interp' },
    rbrace: { match: /(?<!\\)\}/, pop: 1 },
    end: { match: /(?<!\\)'/, pop: 1 },
    classlist: { match: /[\s\S]/, lineBreaks: true },
  },
  tickClassList: {
    lbrace: { match: /(?<=(?<!\\)\$)\{/, push: 'interp' },
    rbrace: { match: /(?<!\\)\}/, pop: 1 },
    end: { match: /(?<!\\)`/, pop: 1 },
    classlist: { match: /[\s\S]/, lineBreaks: true },
  },
  interp: {
    startSingle: { match: /(?<!\\)'/, push: 'singleClassList' },
    startDouble: { match: /(?<!\\)"/, push: 'doubleClassList' },
    startTick: { match: /(?<!\\)`/, push: 'tickClassList' },
    lbrace: { match: /(?<!\\)\{/, push: 'interp' },
    rbrace: { match: /(?<!\\)\}/, pop: 1 },
    text: { match: /[\s\S]/, lineBreaks: true },
  },
}

export const getClassAttributeLexer = lazy(() =>
  moo.states({
    main: {
      start1: { match: '"', push: 'doubleClassList' },
      start2: { match: "'", push: 'singleClassList' },
      start3: { match: '{', push: 'interp' },
    },
    ...classAttributeStates,
  })
)

export const getComputedClassAttributeLexer = lazy(() =>
  moo.states({
    main: {
      quote: { match: /['"{]/, push: 'interp' },
    },
    // TODO: really this should use a different interp definition that is
    // terminated correctly based on the initial quote type
    ...classAttributeStates,
  })
)