Skip to content

Commit

Permalink
Path to 1.2.0 (#7)
Browse files Browse the repository at this point in the history
* fix: builtin constants can know be configured with 'keyword'

* refactor: builtin constants can be configured by themselves

* More styling options for syntax, and treesitter highlights (#8)

* add(style): more styling options for syntax, see comment

Added styling options (`gui`) for, boolean, number, float, error,
loop keywords, label keywords, exception keywords

* add(style): styling options for different builtins

* Adjust highlights to better match prime's colorscheme. Less warm colors (#9)

* adjust(highlights): Less warm colors

* adjust(color): strings and property are slightly brighter

* update README.md

---------

Co-authored-by: Daniel Vieites <dvieitest@gmail.com>
  • Loading branch information
vague2k and vieitesss authored Jul 25, 2024
1 parent f71aa81 commit 8ebe301
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 100 deletions.
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

vague is a dark, low contrast theme inspired [ThePrimeagen](https://github.com/ThePrimeagen)'s use of [tokyonight](https://github.com/folke/tokyonight.nvim) without fixing [tmux](https://github.com/tmux/tmux)'s colors.

Here's a preview of what that looks like in golang

<img width="1446" alt="Screenshot 2024-07-12 at 10 14 43 PM" src="https://github.com/user-attachments/assets/a9c9894c-f83c-4f4f-a65c-55e257692c5a">
![vague-compare](https://github.com/user-attachments/assets/3d97f7c0-72a1-4f70-a129-304d8d2b97eb)

## Installation

Expand All @@ -27,18 +25,32 @@ require("vague").setup({
transparent = false, -- don't set background
style = {
-- "none" is the same thing as default. But "italic" and "bold" are also valid options
boolean = "none",
number = "none",
float = "none",
error = "none",
comments = "italic",
conditionals = "none",
functions = "none",
keywords = "none",
headings = "bold", -- markdown headings
headings = "bold",
operators = "none",
keyword_return = "none",
strings = "italic",
variables = "none",

-- keywords
keywords = "none",
keyword_return = "none",
keywords_loop = "none",
keywords_label = "none",
keywords_exception = "none",

-- builtin
builtin_constants = "none",
builtin_functions = "none",
builtin_types = "none",
builtin_variables = "none",
},
-- These are the default colors, but they are overideable.
-- Different highlights which may be non related share some colors, so expirement.
-- Override colors
colors = {
bg = "#18191a",
fg = "#cdcdcd",
Expand All @@ -47,9 +59,9 @@ require("vague").setup({
comment = "#646477",
builtin = "#bad1ce",
func = "#be8c8c",
string = "#d7b797",
string = "#deb896",
number = "#d2a374",
property = "#b4b4ce",
property = "#c7c7d4",
constant = "#b4b4ce",
parameter = "#b9a3ba",
visual = "#363738",
Expand All @@ -60,10 +72,9 @@ require("vague").setup({
keyword = "#7894ab",
type = "#a1b3b9",
search = "#465362",
-- used mostly in git related highlights
plus = "#8faf77",
delta = "#e6be8c",
}
},
})
```

Expand Down
46 changes: 36 additions & 10 deletions lua/vague/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ local M = {}
---@alias CodeStyle "none"|"italic"|"bold"

---@class VagueConfig.style
---@field boolean? CodeStyle
---@field number? CodeStyle -- number constants
---@field float? CodeStyle -- floating point numbers
---@field error? CodeStyle -- any erroneous construct
---@field comments? CodeStyle
---@field conditionals? CodeStyle
---@field functions? CodeStyle
---@field keywords? CodeStyle
---@field headings? CodeStyle
---@field operators? CodeStyle
---@field keyword_return? CodeStyle
---@field functions? CodeStyle -- function name
---@field headings? CodeStyle -- markdown headings
---@field operators? CodeStyle -- like "+"
---@field strings? CodeStyle
---@field variables? CodeStyle
---@field keywords? CodeStyle
---@field keyword_return? CodeStyle
---@field keywords_loop? CodeStyle -- "for", "while", etc
---@field keywords_label? CodeStyle -- "default", "case", etc
---@field keywords_exception? CodeStyle -- "try", "catch", etc
---@field builtin_constants? CodeStyle -- like "nil" in lua and golang
---@field builtin_functions? CodeStyle -- like "nil" in lua and golang
---@field builtin_types? CodeStyle -- like "nil" in lua and golang
---@field builtin_variables? CodeStyle -- like "this", "self"

---@class VagueConfig.colors
---@field bg? string
Expand Down Expand Up @@ -46,15 +57,30 @@ local DEFAULT_SETTINGS = {
transparent = false, -- don't set background
style = {
-- "none" is the same thing as default. But "italic" and "bold" are also valid options
boolean = "none",
number = "none",
float = "none",
error = "none",
comments = "italic",
conditionals = "none",
functions = "none",
keywords = "none",
headings = "bold", -- markdown headings
headings = "bold",
operators = "none",
keyword_return = "none",
strings = "italic",
variables = "none",

-- keywords
keywords = "none",
keyword_return = "none",
keywords_loop = "none",
keywords_label = "none",
keywords_exception = "none",

-- builtin
builtin_constants = "none",
builtin_functions = "none",
builtin_types = "none",
builtin_variables = "none",
},
-- Override colors
colors = {
Expand All @@ -65,9 +91,9 @@ local DEFAULT_SETTINGS = {
comment = "#646477",
builtin = "#bad1ce",
func = "#be8c8c",
string = "#d7b797",
string = "#deb896",
number = "#d2a374",
property = "#b4b4ce",
property = "#c7c7d4",
constant = "#b4b4ce",
parameter = "#b9a3ba",
visual = "#363738",
Expand Down
149 changes: 71 additions & 78 deletions lua/vague/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,88 +92,87 @@ hl.common = {
}

hl.syntax = {
Boolean = { fg = c.number }, -- boolean constants
Boolean = { fg = c.number, gui = config.style.boolean }, -- boolean constants
Character = { fg = c.string }, -- character constants
Comment = { fg = c.comment, gui = config.style.comments }, -- comments
Constant = { fg = c.constant }, -- (preferred) any constant
Delimiter = { fg = c.fg }, -- delimiter characters
Float = { fg = c.number }, -- float constants
Float = { fg = c.number, gui = config.style.float }, -- float constants
Function = { fg = c.func, gui = config.style.functions }, -- functions
Error = { fg = c.error, gui = "bold" }, -- (preferred) any erroneous construct
Exception = { fg = c.error }, -- 'try', 'catch', 'throw'
Error = { fg = c.error, gui = config.style.error }, -- (preferred) any erroneous construct
Exception = { fg = c.keyword, gui = config.style.keywords_exception }, -- 'try', 'catch', 'throw'
Identifier = { fg = c.constant, gui = config.style.variables }, -- (preferred) any variable
Keyword = { fg = c.keyword, gui = config.style.keywords }, -- any other keyword
Conditional = { fg = c.keyword, gui = config.style.conditionals }, -- conditionals
-- Repeat = { fg = c.preproc, gui = config.code_style.keywords }, -- loop keywords: 'for', 'while' etc
-- Label = { fg = c.preproc }, -- 'case', 'default', etc
Number = { fg = c.number }, -- number constant
Repeat = { fg = c.keyword, gui = config.style.keywords_loop }, -- loop keywords: 'for', 'while' etc
Label = { fg = c.keyword, gui = config.style.keywords_label }, -- 'case', 'default', etc
Number = { fg = c.number, gui = config.style.number }, -- number constant
Operator = { fg = c.operator, gui = config.style.operators }, -- '+', '*', 'sizeof' etc
PreProc = { fg = c.constant }, -- (preferred) generic preprocessor
-- Define = { fg = c.comment }, -- preprocessor '#define'
-- Include = { fg = c.keyword, gui = config.code_style.keywords }, -- preprocessor '#include'
-- Macro = { fg = c.constant, gui = config.code_style.constants }, -- macros
-- PreCondit = { fg = c.comment }, -- preprocessor conditionals '#if', '#endif' etc
Define = { fg = c.comment }, -- preprocessor '#define'
Include = { fg = c.keyword }, -- preprocessor '#include'
Macro = { fg = c.constant }, -- macros
PreCondit = { fg = c.comment }, -- preprocessor conditionals '#if', '#endif' etc
Special = { fg = c.builtin }, -- (preferred) any special symbol
SpecialChar = { fg = c.keyword }, -- special character in a constant
-- SpecialComment = { fg = c.keyword, gui = config.code_style.comments }, -- special things inside comments
-- Tag = { fg = c.builtin }, -- can use <C-]> on this
SpecialComment = { fg = c.keyword }, -- special things inside comments
Tag = { fg = c.builtin }, -- can use <C-]> on this
Statement = { fg = c.keyword }, -- (preferred) any statement
String = { fg = c.string, gui = config.style.strings }, -- string constants
Title = { fg = c.property },
Type = { fg = c.type }, -- (preferred) 'int', 'long', 'char' etc
-- StorageClass = { fg = c.constant, gui = config.code_style.keywords }, -- 'static', 'volatile' etc
-- Structure = { fg = c.constant }, -- 'struct', 'union', 'enum' etc
-- Typedef = { fg = c.constant }, -- 'typedef'
StorageClass = { fg = c.constant }, -- 'static', 'volatile' etc
Structure = { fg = c.constant }, -- 'struct', 'union', 'enum' etc
Typedef = { fg = c.constant }, -- 'typedef'
Todo = { fg = c.func, gui = config.style.comments }, -- (preferred) 'TODO' keywords in comments
}

if vim.api.nvim_call_function("has", { "nvim-0.8" }) == 1 then
hl.treesitter = {
-- identifiers
["@variable"] = { fg = c.fg, gui = config.style.variables }, -- any variable that does not have another highlight
["@variable.builtin"] = hl.syntax["Special"], -- variable names that are defined by the language, like 'this' or 'self'
["@variable.builtin"] = { fg = c.builtin, gui = config.style.builtin_variables }, -- variable names that are defined by the language, like 'this' or 'self'
["@variable.member"] = { fg = c.builtin }, -- fields
["@variable.parameter"] = { fg = c.parameter }, -- parameters of a function
-- ["@variable.field"] = { fg = c.builtin }, -- fields

-- ["@constant"] = { link = "Constant" }, -- constants
["@constant.builtin"] = { fg = c.builtin, gui = "bold" }, -- constants that are defined by the language, like 'nil' in lua
-- ["@constant.macro"] = { link = "Macro" }, -- constants that are defined by macros like 'NULL' in c
["@constant"] = hl.syntax["Constant"], -- constants
["@constant.builtin"] = { fg = c.number, gui = config.style.builtin_constants }, -- constants that are defined by the language, like 'nil' in lua
["@constant.macro"] = hl.syntax["Macro"], -- constants that are defined by macros like 'NULL' in c

-- ["@label"] = { link = "Label" }, -- labels
["@module"] = hl.syntax["Type"], -- modules and namespaces
["@label"] = hl.syntax["Label"], -- labels
["@module"] = hl.syntax["Constant"], -- modules and namespaces

-- literals
-- ["@string"] = { link = "String" }, -- strings
["@string.documentation"] = hl.syntax["String"] or hl.syntax["Comment"], -- doc strings
["@string"] = hl.syntax["String"], -- strings
["@string.documentation"] = hl.syntax["Comment"], -- doc strings
["@string.regexp"] = hl.syntax["SpecialChar"], -- regex
["@string.escape"] = hl.syntax["SpecialChar"], -- escape characters within string
["@string.special.symbol"] = hl.syntax["Identifier"],
-- ["@string.special.url"] = { fg = c.func }, -- urls, links, emails
["@string.special.url"] = { fg = c.func }, -- urls, links, emails

-- ["@character"] = { link = "String" }, -- character literals
-- ["@character.special"] = hl.syntax["SpecialChar"], -- special characters
["@character"] = hl.syntax["String"], -- character literals
["@character.special"] = hl.syntax["SpecialChar"], -- special characters

-- ["@boolean"] = { link = "Constant" }, -- booleans
-- ["@number"] = { link = "Number" }, -- all numbers
-- ["@number.float"] = { link = "Number" }, -- floats
["@boolean"] = hl.syntax["Boolean"], -- booleans
["@number"] = hl.syntax["Number"], -- all numbers
["@number.float"] = hl.syntax["Float"], -- floats

-- types
-- ["@type"] = hl.syntax["Type"], -- types
["@type.builtin"] = { fg = c.builtin, gui = config.style.keywords }, --builtin types
-- ["@type.definition"] = hl.syntax["Typedef"], -- typedefs
-- ["@type.qualifier"]
["@type"] = hl.syntax["Type"], -- types
["@type.builtin"] = { fg = c.builtin, gui = config.style.builtin_types }, --builtin types
["@type.definition"] = hl.syntax["Typedef"], -- typedefs
["@type.declaration"] = { fg = c.constant },

["@attribute"] = hl.syntax["Constant"], -- attributes, like <decorators> in python
-- ["@property"] = { fg = c.property }, --same as TSField
["@property"] = { fg = c.property }, --same as TSField

-- functions
-- ["@function"] = { link = "Function" }, -- functions
["@function.builtin"] = hl.syntax["Function"], --builtin functions
-- ["@function.macro"] = { link = "Macro" }, -- macro defined functions
-- ["@function.call"]
-- ["@function.method"]
-- ["@function.method.call"]
["@function"] = hl.syntax["Function"], -- functions
["@function.builtin"] = { fg = c.func, gui = config.style.builtin_functions }, --builtin functions
["@function.macro"] = hl.syntax["Macro"], -- macro defined functions
["@function.call"] = { fg = c.parameter },
["@function.method"] = { fg = c.func },
["@function.method.call"] = { fg = c.type },

["@constructor"] = { fg = c.constant, gui = config.style.functions }, -- constructor calls and definitions
["@constructor.lua"] = { fg = c.type, gui = config.style.functions }, -- constructor calls and definitions, `= { }` in lua
Expand All @@ -186,23 +185,12 @@ if vim.api.nvim_call_function("has", { "nvim-0.8" }) == 1 then
["@keyword.conditional"] = { fg = c.keyword, gui = config.style.conditionals }, -- keywords for conditional statements
["@keyword.operator"] = { fg = c.keyword, gui = config.style.operators }, -- keyword operator (eg, 'in' in python)
["@keyword.return"] = { fg = c.keyword, gui = config.style.keyword_return }, -- keywords used to define a function
-- ["@keyword.builtin"] = hl.syntax["Type"], -- keywords used to define a function
-- ["@keyword.function"] = hl.syntax["Function"], -- keywords used to define a function
-- ["@keyword.import"] = hl.syntax["Include"], -- includes, like '#include' in c, 'require' in lua
-- ["@keyword.storage"] = hl.syntax["StorageClass"], -- visibility/life-time 'static'
-- ["@keyword.repeat"] = hl.syntax["Repeat"], -- for keywords related to loops

-- punctuation
["@punctuation.delimiter"] = { fg = c.fg }, -- delimiters, like `; . , `
["@punctuation.bracket"] = { fg = c.fg }, -- brackets and parentheses
["@punctuation.special"] = hl.syntax["SpecialChar"], -- punctuation that does not fall into above categories, like `{}` in string interpolation

-- comment
-- ["@comment"]
-- ["@comment.error"]
-- ["@comment.warning"]
-- ["@comment.note"]

-- markup
["@markup"] = { fg = c.fg }, -- text in markup language
["@markup.strong"] = { fg = c.fg, gui = "bold" }, -- bold
Expand Down Expand Up @@ -232,35 +220,38 @@ if vim.api.nvim_call_function("has", { "nvim-0.8" }) == 1 then

if vim.api.nvim_call_function("has", { "nvim-0.9" }) == 1 then
hl.lsp = {
-- ["@lsp.type.class"] = { link = "Structure" },
-- If you are seeing this comment, and would like to contribute, specifically to the semantic tokens highlighting,
-- See the semantic token classification, I find this article very useful
-- https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#semantic-token-classification

-- types
["@lsp.type.class"] = hl.syntax["Structure"],
["@lsp.type.comment"] = hl.syntax["Comment"],
-- ["@lsp.type.enum"] = { link = "Structure" },
-- ["@lsp.type.enumMember"] = { link = "Constant" },
-- ["@lsp.type.interface"] = { link = "Structure" },
-- ["@lsp.type.typeParameter"] = { link = "Typedef" },
["@lsp.type.enum"] = hl.syntax["Structure"],
["@lsp.type.enumMember"] = hl.treesitter["@variable.member"],
["@lsp.type.interface"] = hl.syntax["Structure"],
["@lsp.type.typeParameter"] = hl.syntax["Typedef"],
["@lsp.type.namespace"] = hl.treesitter["@module"],
["@lsp.type.parameter"] = hl.treesitter["@variable.parameter"],
-- ["@lsp.type.property"] = { link = "Identifier" },
-- ["@lsp.type.variable"] = hl.treesitter["@variable"],
-- ["@lsp.type.macro"] = { link = "Macro" },
-- ["@lsp.type.method"] = { link = "@function.method" },
-- ["@lsp.type.generic"] = { link = "Type" },
-- ["@lsp.type.builtinType"] = { link = "Special" },
["@lsp.type.property"] = hl.treesitter["@type"],
["@lsp.type.variable"] = hl.treesitter["@constant"],
["@lsp.type.macro"] = hl.syntax["Macro"],
["@lsp.type.method"] = hl.treesitter["@function.method"],
["@lsp.type.function"] = hl.treesitter["@function.call"],
["@lsp.type.generic"] = hl.treesitter["@type"],
["@lsp.type.builtinType"] = hl.treesitter["@type.builtin"],
["@lsp.type.selfParameter"] = hl.syntax["Special"],
["@lsp.type.builtinConstant"] = hl.syntax["Special"],
["@lsp.typemod.method.defaultLibrary"] = hl.syntax["Special"],
["@lsp.typemod.function.defaultLibrary"] = hl.syntax["Special"],
["@lsp.typemod.function.builtin"] = hl.syntax["Special"],
["@lsp.typemod.operator.injected"] = hl.syntax["Operator"],
["@lsp.typemod.string.injected"] = hl.syntax["String"],
["@lsp.typemod.variable.injected"] = hl.treesitter["@variable"],
["@lsp.typemod.variable.defaultLibrary"] = hl.syntax["Special"],
["@lsp.typemod.variable.static"] = hl.syntax["Constant"],
["@lsp.typemod.variable.global"] = hl.syntax["Constant"],
["@lsp.typemod.operator.controlFlow"] = hl.treesitter["@keyword.exception"],
["@lsp.typemod.keyword.documentation"] = hl.syntax["Special"],
["@lsp.mod.readonly"] = hl.syntax["Constant"],
["@lsp.mod.typeHint"] = hl.syntax["Type"],
["@lsp.type.builtinConstant"] = hl.treesitter["@constant.builtin"],

-- type function modifiers
["@lsp.typemod.function"] = hl.treesitter["@function.call"],
["@lsp.typemod.function.defaultLibrary"] = hl.treesitter["@function.builtin"],
["@lsp.typemod.function.builtin"] = hl.treesitter["@function.builtin"],
["@lsp.typemod.function.definition"] = hl.treesitter["@function"],

-- type variable modifiers
["@lsp.typemod.variable.defaultLibrary"] = hl.treesitter["@constant.builtin"],
["@lsp.typemod.variable.definition"] = hl.treesitter["@property"],
}
end
end
Expand Down Expand Up @@ -297,6 +288,8 @@ hl.plugins.cmp = {
CmpItemAbbrMatchFuzzy = { fg = c.keyword, gui = "underline" },
CmpItemMenu = { fg = c.comment },
CmpItemKind = { fg = c.comment },
CmpItemKindFunction = { fg = c.func },
CmpItemKindInterfaceDefault = { fg = c.type },
}

hl.plugins.gitsigns = {
Expand Down

0 comments on commit 8ebe301

Please sign in to comment.