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 })
return {
version,
configPath,
config: resolvedConfig,
separator: typeof userSeperator === 'undefined' ? ':' : userSeperator,

View File

@ -151,6 +151,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"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": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",

View File

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

View File

@ -21,6 +21,7 @@ import { isValidLocationForEmmetAbbreviation } from '../util/isValidLocationForE
import { getDocumentSettings } from '../util/getDocumentSettings'
import { isJsContext } from '../util/js'
import { naturalExpand } from '../util/naturalExpand'
import semver from 'semver'
function completionsFromClassList(
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(
state: State,
{ position, textDocument }: CompletionParams
@ -329,14 +330,23 @@ function provideTailwindDirectiveCompletions(
return {
isIncomplete: false,
items: [
{
label: 'base',
documentation: {
kind: MarkupKind.Markdown,
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)',
},
},
semver.gte(state.version, '1.0.0-beta.1')
? {
label: 'base',
documentation: {
kind: MarkupKind.Markdown,
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',
documentation: {

View File

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