Home

tailwind-ctp-intellisense @cba601d776d91f08085c752a0f715dda83b60d89 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / src / lsp / providers / codeActions / provideSuggestionCodeActions.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
import { State } from '../../util/state'
import {
  CodeActionParams,
  CodeAction,
  CodeActionKind,
} from 'vscode-languageserver'
import {
  InvalidConfigPathDiagnostic,
  InvalidTailwindDirectiveDiagnostic,
  InvalidScreenDiagnostic,
  InvalidVariantDiagnostic,
} from '../diagnostics/types'

export function provideSuggestionCodeActions(
  _state: State,
  params: CodeActionParams,
  diagnostic:
    | InvalidConfigPathDiagnostic
    | InvalidTailwindDirectiveDiagnostic
    | InvalidScreenDiagnostic
    | InvalidVariantDiagnostic
): CodeAction[] {
  return diagnostic.suggestions.map((suggestion) => ({
    title: `Replace with '${suggestion}'`,
    kind: CodeActionKind.QuickFix,
    diagnostics: [diagnostic],
    edit: {
      changes: {
        [params.textDocument.uri]: [
          {
            range: diagnostic.range,
            newText: suggestion,
          },
        ],
      },
    },
  }))
}