Skip to content

Commit

Permalink
feat: ✨ add scss filetype support
Browse files Browse the repository at this point in the history
  • Loading branch information
olimorris committed Mar 25, 2023
1 parent a431387 commit d7513a7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ require("onedarkpro").setup({
python = true,
ruby = true,
rust = true,
scss = true,
toml = true,
typescript = true,
typescriptreact = true,
Expand Down Expand Up @@ -345,6 +346,7 @@ The theme supports opinionated highlighting for filetypes, just like the origina
- `python`
- `ruby`
- `rust`
- `scss`
- `toml`
- `typescript`
- `typescriptreact`
Expand Down
7 changes: 7 additions & 0 deletions after/queries/scss/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; extends
(rule_set (selectors) @odp.selector (#set! "priority" 125))
(declaration (property_name) @odp.vendor_prefix (#match? @odp.vendor_prefix "^-"))
(declaration (variable_value) @odp.variable)
(class_selector (nesting_selector) . (class_name) @odp.nesting_selector (#set! "priority" 126))
(pseudo_class_selector (class_name) @odp.pseudo_class (#set! "priority" 125))

2 changes: 2 additions & 0 deletions doc/onedarkpro.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Click to see the default configuration ~
python = true,
ruby = true,
rust = true,
scss = true,
toml = true,
typescript = true,
typescriptreact = true,
Expand Down Expand Up @@ -368,6 +369,7 @@ are loaded at runtime. The theme currently has support for:
- `python`
- `ruby`
- `rust`
- `scss`
- `toml`
- `typescript`
- `typescriptreact`
Expand Down
43 changes: 43 additions & 0 deletions examples/scss.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Variables
$primary-color: #3498db;
$secondary-color: #2ecc71;
$font-stack: Arial, sans-serif;
$default-padding: 10px;

// Mixin for rounded corners
@mixin rounded-corners($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}

// Button styles
.button {
font-family: $font-stack;
font-weight: bold;
padding: $default-padding;
text-align: center;
cursor: pointer;
transition: background-color 0.3s ease;

&--primary {
background-color: $primary-color;
color: white;

&:hover {
background-color: darken($primary-color, 10%);
}
}

&--secondary {
background-color: $secondary-color;
color: white;

&:hover {
background-color: darken($secondary-color, 10%);
}
}

@include rounded-corners(5px);
}
1 change: 1 addition & 0 deletions lua/onedarkpro/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local defaults = {
python = true,
ruby = true,
rust = true,
scss = true,
toml = true,
typescript = true,
typescriptreact = true,
Expand Down
23 changes: 23 additions & 0 deletions lua/onedarkpro/highlights/filetypes/scss.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local M = {}

---Get the highlight groups for the filetype
---@param theme table
---@return table
function M.groups(theme)
local config = require("onedarkpro.config").config

return {
["@property.scss"] = { fg = theme.palette.fg },
["@punctuation.bracket.scss"] = { fg = theme.palette.orange },
["@string.scss"] = { fg = theme.palette.orange, style = config.styles.string },
["@type.scss"] = { fg = theme.palette.red },

["@odp.nesting_selector.scss"] = { fg = theme.palette.red },
["@odp.pseudo_class.scss"] = { fg = theme.palette.cyan },
["@odp.selector.scss"] = { fg = theme.palette.orange },
["@odp.variable.scss"] = { fg = theme.palette.red, style = config.styles.variables },
["@odp.vendor_prefix.scss"] = { fg = theme.palette.cyan },
}
end

return M

0 comments on commit d7513a7

Please sign in to comment.