-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from wkillerud/feat/astro
feat: add support for SCSS in Astro + some bugfixes for completions
- Loading branch information
Showing
33 changed files
with
798 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# editorconfig.org | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
--- | ||
|
||
<p class="foo"></p> | ||
|
||
<style lang="scss"> | ||
$color: blue; | ||
$fonts: -apple-system; | ||
|
||
.foo { | ||
color: $; | ||
} | ||
|
||
@import "~foo/bar.scss"; | ||
|
||
.foo { | ||
color: $; | ||
} | ||
|
||
@import "./partial"; | ||
|
||
.foo { | ||
color: $; | ||
} | ||
|
||
@use '../namespace' as ns; | ||
|
||
.foo { | ||
color: ns. | ||
@include ns. | ||
--runtime-var: var(--other-var, #{ns.}) | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ $fonts: -apple-system; | |
.foo { | ||
color: ns. | ||
@include ns. | ||
--runtime-var: var(--other-var, #{ns.}) | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ $fonts: -apple-system; | |
.foo { | ||
color: ns. | ||
@include ns. | ||
--runtime-var: var(--other-var, #{ns.}) | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,5 @@ $fonts: -apple-system; | |
.foo { | ||
color: ns. | ||
@include ns. | ||
--runtime-var: var(--other-var, #{ns.}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
--- | ||
|
||
<p class="foo" /> | ||
|
||
<style lang="scss"> | ||
@use '../functions' as *; | ||
@use '../mixins' as *; | ||
@use '../variables' as *; | ||
|
||
.test { | ||
content: $variable + function(); | ||
|
||
@include mixin(); | ||
} | ||
|
||
@use '../namespace' as ns; | ||
|
||
.foo { | ||
color: ns.$var-var-variable; | ||
@include ns.mix-mix-mixin; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
--- | ||
|
||
<p class="foo" /> | ||
|
||
<style lang="scss"> | ||
@use './helpers' as *; | ||
|
||
/// @deprecated Use something else | ||
$_old-private-variable: 1px; | ||
|
||
.test { | ||
content: $old-variable + old-function(); | ||
|
||
@include old-mixin(); | ||
|
||
content: $_old-private-variable; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
--- | ||
|
||
<p class="foo" /> | ||
|
||
<style lang="scss"> | ||
@use '../functions' as *; | ||
@use '../mixins' as *; | ||
@use '../variables' as *; | ||
|
||
.test { | ||
content: $variable + function(); | ||
|
||
@include mixin(); | ||
} | ||
|
||
@use '../namespace' as ns; | ||
|
||
.foo { | ||
color: ns.$var-var-variable; | ||
@include ns.mix-mix-mixin; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
--- | ||
|
||
<p class="foo" /> | ||
|
||
<style lang="scss"> | ||
@use '../functions' as *; | ||
@use '../mixins' as *; | ||
|
||
.test { | ||
@include square(); | ||
@include square(1,); | ||
|
||
content: pow() + pow(1,); | ||
} | ||
|
||
@use '../namespace' as ns; | ||
|
||
.foo { | ||
@include ns.mix-mix-square(); | ||
@include ns.mix-mix-square(1,); | ||
|
||
content: ns.fun-fun-pow() + ns.fun-fun-pow(1,); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import type { ScssMixin, ScssParameter } from '../../types/symbols'; | ||
import { asDollarlessVariable } from '../../utils/string'; | ||
|
||
export const rePrivate = /^\$?[_-].*$/; | ||
|
||
/** | ||
* Return Mixin as string. | ||
*/ | ||
export function makeMixinDocumentation(symbol: ScssMixin): string { | ||
const args = symbol.parameters.map(item => `${item.name}: ${item.value}`).join(', '); | ||
return `${symbol.name}(${args})`; | ||
} | ||
|
||
/** | ||
* Use the SnippetString syntax to provide smart completions of parameter names. | ||
*/ | ||
export function mapParameterSnippet(p: ScssParameter, index: number): string { | ||
if (p.sassdoc?.type?.length) { | ||
const choices = parseStringLiteralChoices(p.sassdoc.type) | ||
if (choices.length) { | ||
return "${" + (index + 1) + "|" + choices.join(",") + "|}" | ||
} | ||
} | ||
|
||
return "${" + (index + 1) + ":" + asDollarlessVariable(p.name) + "}"; | ||
} | ||
|
||
export function mapParameterSignature(p: ScssParameter): string { | ||
return p.value ? `${p.name}: ${p.value}` : p.name; | ||
} | ||
|
||
const reStringLiteral = /^["'].+["']$/; // yes, this will match 'foo", but let the parser deal with yelling about that. | ||
|
||
/** | ||
* @param docstring A TypeScript-like string of accepted string literal values, for example `"standard" | "entrance" | "exit"`. | ||
*/ | ||
export function parseStringLiteralChoices(docstring: string | string[]): string[] { | ||
const docstrings = typeof docstring === "string" ? [docstring] : docstring; | ||
const result: string[] = []; | ||
|
||
for (const doc of docstrings) { | ||
const parts = doc.split("|"); | ||
if (parts.length === 1) { | ||
// This may be a docstring to indicate only a single valid string literal option. | ||
const trimmed = doc.trim(); | ||
if (reStringLiteral.test(trimmed)) { | ||
result.push(trimmed); | ||
} | ||
} else { | ||
for (const part of parts) { | ||
const trimmed = part.trim(); | ||
if (reStringLiteral.test(trimmed)) { | ||
result.push(trimmed); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} |
Oops, something went wrong.