Skip to content

Add settings to enable/disable specific features #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/tailwindcss-language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,22 +990,30 @@ async function createProjectService(
if (!state.enabled) return null
let document = documentService.getDocument(params.textDocument.uri)
if (!document) return null
let settings = await state.editor.getConfiguration(document.uri)
if (!settings.tailwindCSS.hovers) return null
if (await isExcluded(state, document)) return null
return doHover(state, document, params.position)
},
async onCompletion(params: CompletionParams): Promise<CompletionList> {
if (!state.enabled) return null
let document = documentService.getDocument(params.textDocument.uri)
if (!document) return null
let settings = await state.editor.getConfiguration(document.uri)
if (!settings.tailwindCSS.suggestions) return null
if (await isExcluded(state, document)) return null
return doComplete(state, document, params.position, params.context)
},
onCompletionResolve(item: CompletionItem): Promise<CompletionItem> {
if (!state.enabled) return null
return resolveCompletionItem(state, item)
},
onCodeAction(params: CodeActionParams): Promise<CodeAction[]> {
async onCodeAction(params: CodeActionParams): Promise<CodeAction[]> {
if (!state.enabled) return null
let document = documentService.getDocument(params.textDocument.uri)
if (!document) return null
let settings = await state.editor.getConfiguration(document.uri)
if (!settings.tailwindCSS.codeActions) return null
return doCodeActions(state, params)
},
provideDiagnostics: debounce((document: TextDocument) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/tailwindcss-language-service/src/util/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export type Settings = {
emmetCompletions: boolean
includeLanguages: Record<string, string>
classAttributes: string[]
suggestions: boolean
hovers: boolean
codeActions: boolean
validate: boolean
showPixelEquivalents: boolean
rootFontSize: number
Expand Down
12 changes: 12 additions & 0 deletions packages/vscode-tailwindcss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ Show `px` equivalents for `rem` CSS values in completions and hovers. **Default:

Root font size in pixels. Used to convert `rem` CSS values to their `px` equivalents. See [`tailwindCSS.showPixelEquivalents`](#tailwindcssshowpixelequivalents). **Default: `16`**

### `tailwindCSS.hovers`

Enable hovers. **Default: `true`**

### `tailwindCSS.suggestions`

Enable autocomplete suggestions. **Default: `true`**

### `tailwindCSS.codeActions`

Enable code actions. **Default: `true`**

### `tailwindCSS.validate`

Enable linting. Rules can be configured individually using the `tailwindcss.lint` settings:
Expand Down
18 changes: 18 additions & 0 deletions packages/vscode-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@
],
"markdownDescription": "The HTML attributes for which to provide class completions, hover previews, linting etc."
},
"tailwindCSS.suggestions": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable autocomplete suggestions.",
"scope": "language-overridable"
},
"tailwindCSS.hovers": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable hovers.",
"scope": "language-overridable"
},
"tailwindCSS.codeActions": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable code actions.",
"scope": "language-overridable"
},
"tailwindCSS.colorDecorators": {
"type": "boolean",
"default": true,
Expand Down