vary @tailwind completions based on version

master
Brad Cornes 2020-04-28 00:06:47 +01:00
parent 2c1a520547
commit feb19371f4
5 changed files with 28 additions and 9 deletions

View File

@ -93,6 +93,7 @@ export default async function getClassNames(
const resolvedConfig = resolveConfig({ cwd, config }) const resolvedConfig = resolveConfig({ cwd, config })
return { return {
version,
configPath, configPath,
config: resolvedConfig, config: resolvedConfig,
separator: typeof userSeperator === 'undefined' ? ':' : userSeperator, separator: typeof userSeperator === 'undefined' ? ':' : userSeperator,

View File

@ -151,6 +151,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true "dev": true
}, },
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
},
"subarg": { "subarg": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",

View File

@ -22,6 +22,7 @@
"emmet-helper": "0.0.1", "emmet-helper": "0.0.1",
"glob-exec": "^0.1.1", "glob-exec": "^0.1.1",
"line-column": "^1.0.2", "line-column": "^1.0.2",
"semver": "^7.3.2",
"tailwindcss-class-names": "0.0.1", "tailwindcss-class-names": "0.0.1",
"typescript": "^3.8.3", "typescript": "^3.8.3",
"vscode-languageserver": "^5.2.1", "vscode-languageserver": "^5.2.1",

View File

@ -21,6 +21,7 @@ import { isValidLocationForEmmetAbbreviation } from '../util/isValidLocationForE
import { getDocumentSettings } from '../util/getDocumentSettings' import { getDocumentSettings } from '../util/getDocumentSettings'
import { isJsContext } from '../util/js' import { isJsContext } from '../util/js'
import { naturalExpand } from '../util/naturalExpand' import { naturalExpand } from '../util/naturalExpand'
import semver from 'semver'
function completionsFromClassList( function completionsFromClassList(
state: State, state: State,
@ -306,7 +307,7 @@ function provideCssHelperCompletions(
} }
} }
// TODO: vary items based on Tailwind version // TODO: vary docs links based on Tailwind version
function provideTailwindDirectiveCompletions( function provideTailwindDirectiveCompletions(
state: State, state: State,
{ position, textDocument }: CompletionParams { position, textDocument }: CompletionParams
@ -329,14 +330,23 @@ function provideTailwindDirectiveCompletions(
return { return {
isIncomplete: false, isIncomplete: false,
items: [ items: [
{ semver.gte(state.version, '1.0.0-beta.1')
label: 'base', ? {
documentation: { label: 'base',
kind: MarkupKind.Markdown, documentation: {
value: kind: MarkupKind.Markdown,
'This injects Tailwinds base styles and any base styles registered by plugins.\n\n[Tailwind CSS Documentation](https://tailwindcss.com/docs/functions-and-directives/#tailwind)', value:
}, 'This injects Tailwinds base styles and any base styles registered by plugins.\n\n[Tailwind CSS Documentation](https://tailwindcss.com/docs/functions-and-directives/#tailwind)',
}, },
}
: {
label: 'preflight',
documentation: {
kind: MarkupKind.Markdown,
value:
'This injects Tailwinds base styles, which is a combination of Normalize.css and some additional base styles.\n\n[Tailwind CSS Documentation](https://v0.tailwindcss.com/docs/functions-and-directives/#tailwind)',
},
},
{ {
label: 'components', label: 'components',
documentation: { documentation: {

View File

@ -29,6 +29,7 @@ export type Settings = {
export type State = null | { export type State = null | {
enabled: boolean enabled: boolean
version?: string
configPath?: string configPath?: string
config?: any config?: any
separator?: string separator?: string