Add settings to enable/disable specific features (#535)

* Add `suggest` and `hover` settings

* Rename settings, add `codeActions` setting
master
Brad Cornes 2022-04-20 15:04:51 +01:00 committed by GitHub
parent 97bfbb1c3e
commit c56e800f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 1 deletions

View File

@ -990,6 +990,8 @@ 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)
},
@ -997,6 +999,8 @@ 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.suggestions) return null
if (await isExcluded(state, document)) return null
return doComplete(state, document, params.position, params.context)
},
@ -1004,8 +1008,12 @@ async function createProjectService(
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) => {

View File

@ -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

View File

@ -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:

View File

@ -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,