Skip to content

Commit

Permalink
feat: allow customisations (partially addresses github #2)
Browse files Browse the repository at this point in the history
allow colour overrides
allow font style customisations
update README
  • Loading branch information
bartekjaszczak committed Jan 23, 2025
1 parent c3ce3d3 commit 013c415
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 33 deletions.
110 changes: 107 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
## Features

- 10 carefully selected accent colours, along with 10 pastel variations
- Supports **treesitter** highlighting as well as **semantic tokens**
- Supports **tree-sitter** highlighting as well as **semantic tokens**
- Supports some major plugins (feel free to open an issue if you'd like your plugin supported)
- Includes themes for **lualine** and **barbecue**
- Supports colour overrides and some font style customisations (bold, italic) for syntax

## Usage

### Lazy

There are no settings to this theme, so there's no need to call `setup()`. Simply enable and activate the theme:
If you don't want any customisations, there's no need to call `setup()`. Simply enable and activate the theme:

```lua
{
Expand All @@ -27,6 +28,110 @@ There are no settings to this theme, so there's no need to call `setup()`. Simpl
}
```

Colours can be overridden and some formatting (bold, italics) adjusted. You'll need to call `setup()` function for that.

<details>
<summary>Expand to see configuration options</summary>

### Example configuration

````lua
{
"https://gitlab.com/bartekjaszczak/finale-nvim",

priority = 1000,

config = function()
require("finale").setup({
styles = {
-- These are the default styles
comments = {
bold = false,
italic = true,
},
statements = {
bold = true,
italic = false,
}, -- Statements that are NOT keywords + preproc statements (include, define) but NOT macros
keywords = {
bold = true,
italic = false,
},
operators = {
bold = false,
italic = false,
},
},
colour_overrides = {
-- suggestions = "#FFFFFF", -- Copilot inline suggestions
--
-- syntax = {
-- text = "#FFFFFF", -- Normal text
-- comment = "#FFFFFF",
-- comment_special = "#FFFFFF", -- Documentation comments
--
-- string = "#FFFFFF", -- String literals
-- char = "#FFFFFF", -- Character literals
-- stringspecial = "#FFFFFF", -- Regex, escape characters and other special parts of the string
--
-- constant = "#FFFFFF", -- Constant literals
-- enummember = "#FFFFFF",
--
-- number = "#FFFFFF", -- Number literals
-- boolean = "#FFFFFF", -- Boolean literals
--
-- variable = "#FFFFFF", -- Normal variables
-- param = "#FFFFFF", -- Function parameters
-- field = "#FFFFFF", -- Member variables, properties
-- global = "#FFFFFF", -- Global variables
-- static = "#FFFFFF", -- Static variables
-- builtin = "#FFFFFF", -- Built in variables
--
-- func = "#FFFFFF", -- Functions
-- method = "#FFFFFF", -- Methods
--
-- statement = "#FFFFFF", -- Statements (usually overridden by another highlight groups, such as keywords, operators, labels, etc.)
-- keyword = "#FFFFFF",
-- keyword_flow = "#FFFFFF", -- Keywords related to execution flow, such as conditionals (if, else), loops (for, while), break, continue, goto, etc.
-- operator = "#FFFFFF",
--
-- preproc = "#FFFFFF", -- Preprocessor directives
--
-- type = "#FFFFFF", -- Types
-- type_builtin = "#FFFFFF", -- Built in types, such as int, float, bool (depends on the language)
--
-- special = "#FFFFFF", -- Special punctuation, parts of comments, special characters in a string, matching parenthesis
--
-- debug = "#FFFFFF", -- Debugging statements
-- error = "#FFFFFF", -- Errors
--
-- bracket = "#FFFFFF", -- Brackets: (), {}, []
-- delimiter = "#FFFFFF", -- Operators such as: +, *, =, sizeof (C/C++), etc.
--
-- label = "#FFFFFF", -- Labels (cases, default)
-- namespace = "#FFFFFF",
-- module = "#FFFFFF",
-- tag = "#FFFFFF",
-- attribute = "#FFFFFF",
--
-- h1 = "#FFFFFF", -- Headers (HTML, markup, documentation)
-- h2 = "#FFFFFF",
-- h3 = "#FFFFFF",
-- h4 = "#FFFFFF",
-- h5 = "#FFFFFF",
-- h6 = "#FFFFFF",
-- link = "#FFFFFF", -- Links in HTML, markdown, text
-- },
},
})

vim.cmd.colorscheme("finale")
end,
}
````

</details>

### Lualine

```lua
Expand All @@ -41,7 +146,6 @@ require("lualine").setup({

### Barbecue


```lua
require("barbecue").setup({
-- ...
Expand Down
77 changes: 51 additions & 26 deletions lua/finale/highlights/syntax.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,56 @@ local M = {}

function M.get_highlights(theme)
return {
Comment = { fg = theme.syntax.comment, italic = true }, -- (preferred) any constant
Constant = { fg = theme.syntax.constant }, -- (preferred) any constant
String = { fg = theme.syntax.string }, -- a string constant: "this is a string"
Character = { fg = theme.syntax.char }, -- a character constant: 'c', '\n'
Number = { fg = theme.syntax.number }, -- a number constant: 234, 0xff
Boolean = { fg = theme.syntax.boolean }, -- a boolean constant: TRUE, false
Float = { fg = theme.syntax.number }, -- a floating point constant: 2.3e10

Identifier = { fg = theme.syntax.variable }, -- (preferred) any variable name
Function = { fg = theme.syntax.func }, -- function name (also: methods for classes)

Statement = { fg = theme.syntax.statement }, -- (preferred) any statement
-- Conditional = { }, -- if, then, else, endif, switch, etc.
-- Repeat = { }, -- for, do, while, etc.
Label = { fg = theme.syntax.label }, -- case, default, etc.
Operator = { fg = theme.syntax.operator }, -- "sizeof", "+", "*", etc.
Keyword = { fg = theme.syntax.keyword, bold = true }, -- any other keyword
Comment = {
fg = theme.syntax.comment,
bold = theme.styles.comments.bold,
italic = theme.styles.comments.italic,
}, -- (preferred) any constant
Constant = { fg = theme.syntax.constant }, -- (preferred) any constant
String = { fg = theme.syntax.string }, -- a string constant: "this is a string"
Character = { fg = theme.syntax.char }, -- a character constant: 'c', '\n'
Number = { fg = theme.syntax.number }, -- a number constant: 234, 0xff
Boolean = { fg = theme.syntax.boolean }, -- a boolean constant: TRUE, false
Float = { fg = theme.syntax.number }, -- a floating point constant: 2.3e10

Identifier = { fg = theme.syntax.variable }, -- (preferred) any variable name
Function = { fg = theme.syntax.func }, -- function name (also: methods for classes)

Statement = {
fg = theme.syntax.statement,
bold = theme.styles.statements.bold,
italic = theme.styles.statements.italic,
}, -- (preferred) any statement
Conditional = {
fg = theme.syntax.keyword_flow,
bold = theme.styles.keywords.bold,
italic = theme.styles.keywords.italic,
}, -- if, then, else, endif, switch, etc.
Repeat = { link = "Conditional" }, -- for, do, while, etc.
Label = {
fg = theme.syntax.label,
bold = theme.styles.statements.bold,
italic = theme.styles.statements.italic,
}, -- case, default, etc.
Operator = {
fg = theme.syntax.operator,
bold = theme.styles.operators.bold,
italic = theme.styles.operators.italic,
}, -- "sizeof", "+", "*", etc.
Keyword = {
fg = theme.syntax.keyword,
bold = theme.styles.keywords.bold,
italic = theme.styles.keywords.italic,
}, -- any other keyword
-- Exception = { }, -- try, catch, throw
PreProc = { fg = theme.syntax.keyword }, -- (preferred) generic Preprocessor
PreProc = { link = "Statement" }, -- (preferred) generic Preprocessor
-- Include = { }, -- preprocessor #include
-- Define = {}, -- preprocessor #define
Macro = { fg = theme.syntax.preproc }, -- same as Define
-- PreCondit = { }, -- preprocessor #if, #else, #endif, etc.

Type = { fg = theme.syntax.type }, -- (preferred) int, long, char, etc.
StorageClass = { fg = theme.syntax.keyword }, -- static, register, volatile, etc.
Type = { fg = theme.syntax.type }, -- (preferred) int, long, char, etc.
StorageClass = { link = "Statement" }, -- static, register, volatile, etc.
-- Structure = { }, -- struct, union, enum, etc.
-- Typedef = { }, -- A typedef

Expand Down Expand Up @@ -196,22 +220,23 @@ function M.get_highlights(theme)
["@function.method"] = { fg = theme.syntax.method },
-- ["@function.method.call"] = {},

["@constructor"] = { fg = theme.syntax.method }, -- For constructor calls and definitions: `= { }` in Lua, and Java constructors.
["@operator"] = { fg = theme.syntax.operator }, -- For any operator: `+`, but also `->` and `*` in C.
["@constructor"] = { fg = theme.syntax.method }, -- For constructor calls and definitions: `= { }` in Lua, and Java constructors.
["@operator"] = { link = "Operator" }, -- For any operator: `+`, but also `->` and `*` in C.

["@keyword"] = { fg = theme.syntax.keyword, bold = true }, -- For keywords that don't fall in previous categories.
["@keyword"] = { link = "Keyword" }, -- For keywords that don't fall in previous categories.
-- ["@keyword.coroutine"] = {},
-- ["@keyword.function"] = {},
-- ["@keyword.operator"] = {},
-- ["@keyword.import"] = {},
-- ["@keyword.type"] = {},
-- ["@keyword.modifier"] = {},
["@keyword.repeat"] = { fg = theme.syntax.keyword_flow, bold = true },
["@keyword.return"] = { fg = theme.syntax.keyword_flow, bold = true },
["@keyword.repeat"] = { link = "Conditional" },
["@keyword.return"] = { link = "Conditional" },
-- ["@keyword.debug"] = {},
-- ["@keyword.exception"] = {},

["@keyword.conditional"] = { fg = theme.syntax.keyword_flow, bold = true },
["@keyword.conditional"] = { link = "Conditional" },

-- ["@keyword.conditional.ternary"] = {},

-- ["@keyword.directive"] = {},
Expand Down
29 changes: 28 additions & 1 deletion lua/finale/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
local M = {}

M.options = {
styles = {
comments = {
bold = false,
italic = true,
},
statements = {
bold = true,
italic = false,
}, -- Statements that are NOT keywords + preproc statements (include, define) but NOT macros
keywords = {
bold = true,
italic = false,
},
operators = {
bold = false,
italic = false,
},
},
colour_overrides = {},
}

function M.setup(opts)
opts = opts or {}
M.options = vim.tbl_deep_extend("force", M.options, opts)
end

local function set_highlights(theme)
local highlights = require("finale.highlights").get_highlights(theme)
for hl, opts in pairs(highlights) do
Expand All @@ -23,7 +50,7 @@ function M.load()
-- Enable highlights
local colours = require("finale.colours")
local theme = require("finale.theme")
theme = theme.get_theme(colours)
theme = theme.get_theme(colours, M.options)

set_highlights(theme)
end
Expand Down
12 changes: 9 additions & 3 deletions lua/finale/theme.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {}

function M.get_theme(colours)
return {
function M.get_theme(colours, opts)
local theme = {
none = "NONE",

-- UI elements
Expand All @@ -28,7 +28,6 @@ function M.get_theme(colours)
-- Special colour
special_accent_weak = colours.pastel.pink,
special_accent_strong = colours.main.pink,

},

diag = {
Expand Down Expand Up @@ -120,6 +119,13 @@ function M.get_theme(colours)
link = colours.pastel.blue,
},
}

if opts then
theme = vim.tbl_deep_extend("force", theme, opts.colour_overrides)
theme.styles = opts.styles
end

return theme
end

return M

0 comments on commit 013c415

Please sign in to comment.