From 4917f993a627e79ea954a3e06b130b225bbd644e Mon Sep 17 00:00:00 2001 From: max miliano Date: Tue, 20 Feb 2024 16:44:41 -0300 Subject: [PATCH] feat: switch colorgen to schemecraft --- .luarc.json | 3 - CONFIG.md | 160 ----- CONTRIBUTING.md | 13 - Dockerfile | 7 + INSTALL.md | 48 -- PREVIEW.md | 19 - README.md | 24 +- after/queries/markdown/highlights.scm | 2 +- after/queries/markdown_inline/highlights.scm | 2 +- colors/dracula.lua | 5 + colors/dracula.vim | 4 - docker-compose.yml | 5 + dracula.yml | 73 ++- lua/dracula/autocmd.lua | 19 - lua/dracula/color.lua | 86 +++ lua/dracula/config.lua | 119 +--- lua/dracula/highlights/init.lua | 401 +++++++++++++ lua/dracula/init.lua | 99 +--- lua/dracula/palette/init.lua | 69 +++ lua/dracula/palettes/init.lua | 41 -- lua/dracula/palettes/soft.lua | 41 -- lua/dracula/theme.lua | 585 ------------------- lua/dracula/utils.lua | 122 +--- lua/lualine/themes/dracula.lua | 35 -- shell.nix | 4 + tests/load_spec.lua | 29 + tests/setup_spec.lua | 44 ++ 27 files changed, 775 insertions(+), 1284 deletions(-) delete mode 100644 .luarc.json delete mode 100644 CONFIG.md delete mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile delete mode 100644 INSTALL.md delete mode 100644 PREVIEW.md create mode 100644 colors/dracula.lua delete mode 100644 colors/dracula.vim create mode 100644 docker-compose.yml delete mode 100644 lua/dracula/autocmd.lua create mode 100644 lua/dracula/color.lua create mode 100644 lua/dracula/highlights/init.lua create mode 100644 lua/dracula/palette/init.lua delete mode 100644 lua/dracula/palettes/init.lua delete mode 100644 lua/dracula/palettes/soft.lua delete mode 100644 lua/dracula/theme.lua delete mode 100644 lua/lualine/themes/dracula.lua create mode 100644 shell.nix create mode 100644 tests/load_spec.lua create mode 100644 tests/setup_spec.lua diff --git a/.luarc.json b/.luarc.json deleted file mode 100644 index 23b9ee2..0000000 --- a/.luarc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "workspace.checkThirdParty": false -} \ No newline at end of file diff --git a/CONFIG.md b/CONFIG.md deleted file mode 100644 index 2c9967f..0000000 --- a/CONFIG.md +++ /dev/null @@ -1,160 +0,0 @@ -#### Configuration Instructions for Dracula.nvim - -The dracula.nvim theme can be configured using the following options: - -| Name | type | values | Description | -| ----------- | ---------------- | -------------------------------- | -------------------------------------------------------------- | -| soft | boolean | true, false | Enables the soft version of the Draculatheme | -| transparent | boolean, string | true, false, "full" | Changes the background to transparent | -| saturation | table | { enabled = false, amount = 10 } | Changes the saturation of the colorscheme | -| dracula_pro | plugin | require('draculapro') | Provides support for the Dracula Pro theme | -| override | table / function | {} | Updates of creates highlight groups | -| callback | function | function | An alternative to `override` used to customize the colorscheme | - -#### How to customize [telescope](https://github.com/nvim-telescope/telescope.nvim) - -```lua -local dracula = require 'dracula' - -function custom(c) - return { - TelescopeResultsBorder = { fg = c.bgdark, bg = c.bgdark }, - TelescopeResultsNormal = { bg = c.bgdark }, - TelescopePreviewNormal = { bg = c.bg }, - TelescopePromptBorder = { fg = c.bgdark, bg = c.bgdark }, - TelescopeTitle = { fg = c.fg, bg = c.comment }, - TelescopePromptPrefix = { fg = c.purple }, - } -end - -dracula.setup { - soft = false, - transparent = false, - saturation = { - enabled = false, - amount = 10, - }, - override = custom, - -- callback = function (c) - -- vim.api.nvim_set_hl(0, TelescopeResultsBorder, { fg = c.bgdark, bg = c.bgdark }) - -- vim.api.nvim_set_hl(0, TelescopeResultsNormal, { bg = c.bgdark }) - -- vim.api.nvim_set_hl(0, TelescopePreviewNormal, { bg = c.bg }) - -- vim.api.nvim_set_hl(0, TelescopePromptBorder, { fg = c.bgdark, bg = c.bgdark }) - -- vim.api.nvim_set_hl(0, TelescopeTitle, { fg = c.fg, bg = c.comment }) - -- vim.api.nvim_set_hl(0, TelescopePromptPrefix, { fg = c.purple }) - -- end -} - -vim.cmd.colorscheme 'dracula' -``` - -#### How to customize [cmp](https://github.com/hrsh7th/nvim-cmp) - -```lua -local dracula = require 'dracula' - -dracula.setup { - override = { - CmpItemKindText = { reverse = true }, - CmpItemKindMethod = { reverse = true }, - CmpItemKindFunction = { reverse = true }, - CmpItemKindConstructor = { reverse = true }, - CmpItemKindField = { reverse = true }, - CmpItemKindVariable = { reverse = true }, - CmpItemKindClass = { reverse = true }, - CmpItemKindInterface = { reverse = true }, - CmpItemKindModule = { reverse = true }, - CmpItemKindProperty = { reverse = true }, - CmpItemKindUnit = { reverse = true }, - CmpItemKindValue = { reverse = true }, - CmpItemKindEnum = { reverse = true }, - CmpItemKindKeyword = { reverse = true }, - CmpItemKindSnippet = { reverse = true }, - CmpItemKindColor = { reverse = true }, - CmpItemKindFile = { reverse = true }, - CmpItemKindReference = { reverse = true }, - CmpItemKindFolder = { reverse = true }, - CmpItemKindEnumMember = { reverse = true }, - CmpItemKindConstant = { reverse = true }, - CmpItemKindStruct = { reverse = true }, - CmpItemKindEvent = { reverse = true }, - CmpItemKindOperator = { reverse = true }, - CmpItemKindTypeParameter = { reverse = true }, - CmpItemKindBorder = { fg = c.bgdark, bg = c.bgdark }, - }, -} -``` - -```lua -local function border(hl_name) - return { - { '╭', hl_name }, - { '─', hl_name }, - { '╮', hl_name }, - { '│', hl_name }, - { '╯', hl_name }, - { '─', hl_name }, - { '╰', hl_name }, - { '│', hl_name }, - } -end - -cmp.setup { - window = { - completion = { - border = border 'CmpItemKindBorder' - }, - documentation = { - border = border 'CmpItemKindBorder' - } - } -} -``` - -#### How to change styles - -```lua -local dracula = require 'dracula' - -dracula.setup { - override = { - ['@type'] = { italic = true, bold = false }, - ['@function'] = { italic = false, bold = false }, - ['@comment'] = { italic = true }, - ['@keyword'] = { italic = false }, - ['@constant'] = { italic = false, bold = false }, - ['@variable'] = { italic = true }, - ['@field'] = { italic = true }, - ['@parameter'] = { italic = true }, - } -} - -vim.cmd 'colorscheme dracula' -``` - -#### How to customize Dracula colors - -```lua -local dracula = require 'dracula' - -dracula.setup { - colors = { - bg = '#color', - bgdark = '#color', - } -} - -vim.cmd.colorscheme 'dracula' -``` - -#### How to find a Highlight group - -To find a highlight group that you want to customize, you can use the `:Inspect` command. -This command shows the current highlight -groups being applied to the code in the current buffer. Here's how to use it: - -Alternatively, you can use plugins like [Telescope](https://github.com/nvim-telescope/telescope.nvim) or -[Playground](https://github.com/nvim-treesitter/playground) to find the highlight groups you need to customize your colorscheme. -For example, you can use the `:Telescope highlights` command with the Telescope -plugin to list all the available highlight -groups and select the one you want to customize. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 408bc0e..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,13 +0,0 @@ -#### CONTRIBUTING TO DRACULA - -1. Fork the `dracula.nvim` repository by clicking the `Fork` button on github. -2. Create a new branch for your contribution: - - git checkout -b feat-plugin-support - -3. Make your changes using [colorgen-nvim](https://github.com/ChristianChiarulli/colorgen-nvim) -4. Push your changes to your fork -5. Submit a pull request -6. Wait for feedback from the maintainers. - -Thank you for contributing to `dracula.nvim` diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..84bb2ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM archlinux +WORKDIR /dracula +COPY . . +RUN pacman -Syu --noconfirm +RUN pacman -S luarocks neovim gcc lua51 --noconfirm +RUN luarocks install luacheck && luarocks --lua-version=5.1 install vusted +CMD [ "vusted", "./tests" ] \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index 35b088b..0000000 --- a/INSTALL.md +++ /dev/null @@ -1,48 +0,0 @@ -### [Neovim](https://neovim.io) - -#### Prerequisits - -To install dracula you need a plugin manager. -A plugin manager is a tool that helps users install and manage plugins. -Below is a list of some plugin managers that you could install. - -- [lazy.nvim](folke/lazy.nvim) _recommended_ -- [packer.nvim](wbthomason/packer.nvim) -- [vim-plug](https://github.com/junegunn/vim-plug) - -#### Install using Plugin Manager - -Here's an example of how to install dracula using the [lazy.nvim](https://github.com/folke/lazy.nvim) plugin manager: - -```lua - local opts = { - install = { - missing = true, - colorscheme = { 'dracula' } - } - } - - require('lazy').setup({ - { - 'maxmx03/dracula.nvim', - lazy = false, -- make sure we load this during startup if it is your main colorscheme - priority = 1000, -- make sure to load this before all the other start plugins - config = function () - local dracula = require 'dracula' - - dracula.setup() - - vim.cmd.colorscheme 'dracula' - end - }, - }, opts) -``` - -Lazy will install Dracula colorscheme in the following directories: - - DATA DIRECTORY (DEFAULT) - *$XDG_DATA_HOME* Nvim: stdpath("data") - Unix: ~/.local/share ~/.local/share/nvim/lazy - Windows: ~/AppData/Local ~/AppData/Local/nvim-data/lazy - -That's it! diff --git a/PREVIEW.md b/PREVIEW.md deleted file mode 100644 index b912b89..0000000 --- a/PREVIEW.md +++ /dev/null @@ -1,19 +0,0 @@ -## Preview - -![screenshot-1](https://user-images.githubusercontent.com/50273941/230697097-f464f9ac-d08a-451a-9caa-8f21c02c979f.png) - -![screenshot-2](https://user-images.githubusercontent.com/50273941/230697099-f2610393-d175-4895-b70c-2e908c4f9eae.png) - -![screenshot-3](https://user-images.githubusercontent.com/50273941/230697100-a2a4393b-5862-4c45-a1a1-460d49846c87.png) - -![screenshot-4](https://user-images.githubusercontent.com/50273941/230697106-a9f4582f-699c-47f7-91ea-4d5b4f51f01f.png) - -![screenshot-5](https://user-images.githubusercontent.com/50273941/230697107-32a5531c-3c24-44cd-ac9b-dca6ea0cccc6.png) - -![screenshot-6](https://user-images.githubusercontent.com/50273941/230697118-5bd8527b-f030-4047-be86-3416abb81467.png) - -![screenshot-7](https://user-images.githubusercontent.com/50273941/230697122-2d498759-4662-495e-a66f-1e21055aed54.png) - -![screenshot-8](https://user-images.githubusercontent.com/50273941/230697127-ca473672-748b-46f9-8bc1-12c451a1a370.png) - -![screenshot-9](https://user-images.githubusercontent.com/50273941/230697128-6873ee2d-de8e-4db2-9d3b-b6aa4d0c1c37.png) diff --git a/README.md b/README.md index e9a5bf0..408bfe0 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,9 @@ # Dracula for [Neovim](https://neovim.io) -> Created with [colorgen](https://github.com/ChristianChiarulli/colorgen-nvim) +> Created with [schemecraft](https://github.com/maxmx03/schemecraft) ![Screenshot](https://user-images.githubusercontent.com/50273941/227779719-6e003e4a-f8e8-40bc-8a9f-ebfd7ea13fe6.png) -## Preview - -To preview the dracula.nvim colorscheme, click [here](https://github.com/maxmx03/dracula.nvim/blob/master/PREVIEW.md). - -## Install - -All instructions can be found at [INSTALL.md](https://github.com/maxmx03/dracula.nvim/blob/master/INSTALL.md). - -## How to config - -All instructions can be found at [CONFIG.md](https://github.com/maxmx03/dracula.nvim/blob/master/CONFIG.md). - -## Dracula Pro - -For users of Dracula Pro, plesae create a new private repository using this [template](https://github.com/maxmx03/draculapro-template) - -## Contributions - -All instructions can be found at [CONTRIBUTING.md](https://github.com/maxmx03/dracula.nvim/blob/master/CONTRIBUTING.md) - ## Maintainers | [![Max](https://github.com/maxmx03.png?size=100)](https://github.com/maxmx03) | @@ -32,7 +12,7 @@ All instructions can be found at [CONTRIBUTING.md](https://github.com/maxmx03/dr ## Designed by - [![Zeno Rocha](https://github.com/zenorocha.png?size=100)](https://github.com/zenorocha) +[![Zeno Rocha](https://github.com/zenorocha.png?size=100)](https://github.com/zenorocha) Zeno Rocha: [learn more](https://draculatheme.com/about) diff --git a/after/queries/markdown/highlights.scm b/after/queries/markdown/highlights.scm index 0fff08a..a5859e3 100644 --- a/after/queries/markdown/highlights.scm +++ b/after/queries/markdown/highlights.scm @@ -1,4 +1,4 @@ ; extends -((atx_heading) @text.title (#set! "priority" 125)) +((atx_heading) @markup.heading (#set! "priority" 125)) ((indented_code_block) @type (#set! "priority" 125)) (language) @keyword diff --git a/after/queries/markdown_inline/highlights.scm b/after/queries/markdown_inline/highlights.scm index 4046a55..d8812b0 100644 --- a/after/queries/markdown_inline/highlights.scm +++ b/after/queries/markdown_inline/highlights.scm @@ -1,2 +1,2 @@ ; extends -((strong_emphasis) @text.strong (#set! "priority" 125)) +((strong_emphasis) @markup.strong (#set! "priority" 125)) diff --git a/colors/dracula.lua b/colors/dracula.lua new file mode 100644 index 0000000..ffb3dce --- /dev/null +++ b/colors/dracula.lua @@ -0,0 +1,5 @@ +-- Dracula colorscheme +-- Repo: github.com/maxmx03/dracula.nvim +-- Maintainer: Max Del Canto +-- License: MIT License +require('dracula').load 'dracula' diff --git a/colors/dracula.vim b/colors/dracula.vim deleted file mode 100644 index ad0103f..0000000 --- a/colors/dracula.vim +++ /dev/null @@ -1,4 +0,0 @@ -lua << EOF -local dracula = require("dracula") -dracula.setup({}) -EOF diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bad2e30 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +services: + dracula: + build: . + volumes: + - .:/dracula \ No newline at end of file diff --git a/dracula.yml b/dracula.yml index 2f2e3b4..d2170dd 100644 --- a/dracula.yml +++ b/dracula.yml @@ -90,7 +90,6 @@ palette: shade_error: "#48303B" shade_info: "#374754" shade_hint: "#374754" - shade_other: "#3E3A53" highlights: editor: - name: ColorColumn @@ -343,7 +342,7 @@ highlights: plugins: - nvim-treesitter: - name: "@variable" - link: Indentifier + link: Identifier - name: "@variable.builtin" link: Constant - name: "@variable.parameter" @@ -434,6 +433,76 @@ highlights: link: Statement - name: "@keyword.directive.define" link: Statement + - name: "@punctuation.delimiter" + link: Delimiter + - name: "@punctuation.bracket" + link: Delimiter + - name: "@punctuation.special" + fg: pink + - name: "@comment" + link: Comment + - name: "@comment.documentation" + link: Comment + - name: "@comment.error" + fg: diag_error + bg: shade_error + - name: "@comment.warning" + fg: diag_warning + bg: shade_warning + - name: "@comment.todo" + fg: purple + bg: shade_purple + - name: "@comment.note" + fg: diag_hint + bg: shade_hint + - name: "@markup.strong" + fg: orange + bold: true + gui: bold + - name: "@markup.italic" + fg: yellow + italic: true + gui: italic + - name: "@markup.strikethrough" + fg: base01 + - name: "@markup.underline" + link: Underlined + - name: "@markup.heading" + link: Title + - name: "@markup.quote" + link: Comment + - name: "@markup.math" + link: Constant + - name: "@markup.environment" + link: Comment + - name: "@markup.link" + link: "@markup.strong" + - name: "@markup.link.label" + link: Underlined + - name: "@markup.link.url" + fg: cyan + - name: "@markup.raw" + fg: green + - name: "@markup.raw.block" + link: Comment + - name: "@markup.list" + fg: purple + - name: "@markup.list.checked" + fg: git_added + - name: "@markup.list.unchecked" + fg: git_modified + - name: "@diff.plus" + fg: git_added + - name: "@diff.minus" + fg: git_removed + - name: "@diff.delta" + fg: git_modified + - name: "@tag" + fg: pink + - name: "@tag.attribute" + fg: green + - name: "@tag.delimiter" + link: Delimiter - nvim-cmp: - name: CmpItemKindText <<: *symbol_text diff --git a/lua/dracula/autocmd.lua b/lua/dracula/autocmd.lua deleted file mode 100644 index 4a30775..0000000 --- a/lua/dracula/autocmd.lua +++ /dev/null @@ -1,19 +0,0 @@ -if vim.fn.has 'nvim-0.9.0' == 1 then - vim.api.nvim_create_autocmd('LspTokenUpdate', { - callback = function(args) - local token = args.data.token - - if token.type ~= 'variable' or token.modifiers.readonly then - return - end - - local text = vim.api.nvim_buf_get_text(args.buf, token.line, token.start_col, token.line, token.end_col, {})[1] - - if text ~= string.upper(text) then - return - end - - vim.lsp.semantic_tokens.highlight_token(token, args.buf, args.data.client_id, '@constant') - end, - }) -end diff --git a/lua/dracula/color.lua b/lua/dracula/color.lua new file mode 100644 index 0000000..d3b222b --- /dev/null +++ b/lua/dracula/color.lua @@ -0,0 +1,86 @@ +---@class dracula.color +---@field hex_to_rgb fun(hex: string): number, number, number +---@field rgb_to_hex fun(red: number, green: number, blue: number): string +---@field darken fun(hex: string, percentage: number): string +---@field lighten fun(hex: string, percentage: number): string +---@field shade fun(hex: string, i: number): string +---@field tint fun(hex: string, i: number): string +---@field blend fun(fg: string, bg: string, alpha: number): string +local M = {} + +function M.hex_to_rgb(hex) + local red = tonumber(hex:sub(2, 3), 16) + local green = tonumber(hex:sub(4, 5), 16) + local blue = tonumber(hex:sub(6, 7), 16) + return red, green, blue +end + +function M.rgb_to_hex(red, green, blue) + return string.format('#%02x%02x%02x', red, green, blue) +end + +function M.darken(hex, percentage) + local red, green, blue = M.hex_to_rgb(hex) + local i = 1 + local result = { + red = red * (1 - (percentage / 100) * i), + green = green * (1 - (percentage / 100) * i), + blue = blue * (1 - (percentage / 100) * i), + } + return M.rgb_to_hex(result.red, result.green, result.blue) +end + +function M.lighten(color, percentage) + local red, green, blue = M.hex_to_rgb(color) + local i = 1 + local result = { + red = red + (255 - red) * i * (percentage / 100), + green = green + (255 - green) * i * (percentage / 100), + blue = blue + (255 - blue) * i * (percentage / 100), + } + return M.rgb_to_hex(result.red, result.green, result.blue) +end + +function M.shade(hex, i) + local red, green, blue = M.hex_to_rgb(hex) + local result = { + red = red * (1 - 0.1 * i), + green = green * (1 - 0.1 * i), + blue = blue * (1 - 0.1 * i), + } + return M.rgb_to_hex(result.red, result.green, result.blue) +end + +function M.tint(hex, i) + local red, green, blue = M.hex_to_rgb(hex) + local result = { + red = red + (255 - red) * i * 0.1, + green = green + (255 - green) * i * 0.1, + blue = blue + (255 - blue) * i * 0.1, + } + return M.rgb_to_hex(result.red, result.green, result.blue) +end + +---@param fg number +---@param bg number +---@param alpha number +---@return number +local function blend_channel(fg, bg, alpha) + local ret = alpha * fg + ((1 - alpha) * bg) + local min = math.min + local max = math.max + local floor = math.floor + return floor(min(max(0, ret), 255) + 0.5) +end + +function M.blend(fg, bg, alpha) + local red_bg, green_bg, blue_bg = M.hex_to_rgb(bg) + local red_fg, green_fg, blue_fg = M.hex_to_rgb(fg) + return M.rgb_to_hex( + blend_channel(red_fg, red_bg, alpha), + blend_channel(green_fg, green_bg, alpha), + blend_channel(blue_fg, blue_bg, alpha) + ) +end + +return M diff --git a/lua/dracula/config.lua b/lua/dracula/config.lua index 2430245..913b42a 100644 --- a/lua/dracula/config.lua +++ b/lua/dracula/config.lua @@ -1,104 +1,15 @@ -local colors = require 'dracula.palettes' -local utils = require 'dracula.utils' - -local M = {} - -function M:new() - local config = { - saturation = { - enabled = false, - amount = 10, - }, - soft = false, - transparent = false, - dracula_pro = nil, - colors = colors, - user_config = {}, - } - - setmetatable(config, self) - self.__index = self - - return config -end - -function M:set_colors() - if not self.soft then - return - end - - self.colors = require 'dracula.palettes.soft' -end - -function M:change_colors_saturation() - if self.saturation.enabled then - for i, color in pairs(self.colors) do - local new_color = utils.reduce_saturation(color, self.saturation.amount) - - self.colors[i] = new_color - end - end -end - -function M:set_user_colors() - if self.user_config.colors then - if vim.tbl_isempty(self.colors) then - return - end - - if type(self.user_config.colors) == 'table' then - self.colors = vim.tbl_extend('force', self.colors, self.user_config.colors) - return - end - - self.colors = vim.tbl_extend('force', self.colors, self.user_config.colors(self.colors)) - end -end - -function M:set_soft(soft) - if soft then - self.soft = true - return - end - - self.soft = false -end - -function M:set_saturation(saturation) - if not saturation then - return - end - - if saturation.enabled then - self.saturation.enabled = true - - if type(saturation.amount) == 'number' then - self.saturation.amount = saturation.amount - end - else - self.saturation.enabled = false - end -end - -function M:set_transparent(transparent) - if transparent then - self.transparent = transparent - return - end - - self.transparent = false -end - -function M:call_user_callback(cb) - if type(cb) == 'function' then - cb(self.colors) - end -end - -function M:set_draculapro(dracula_pro) - if dracula_pro then - self.dracula_pro = dracula_pro - end -end - -return M +---@class dracula.config +---@field transparent? boolean +---@field on_highlights? fun(colors: dracula.palette, color: table): dracula.highlights +---@field on_colors? fun(colors: dracula.palette, color: table): dracula.palette +return { + transparent = false, + on_highlights = nil, + on_colors = nil, + plugins = { + ['nvim-treesitter'] = true, + ['nvim-cmp'] = true, + ['indent-blankline.nvim'] = true, + ['bufferline.nvim'] = true, + }, +} diff --git a/lua/dracula/highlights/init.lua b/lua/dracula/highlights/init.lua new file mode 100644 index 0000000..b581012 --- /dev/null +++ b/lua/dracula/highlights/init.lua @@ -0,0 +1,401 @@ +---@class dracula.highlights +---@field ColorColumn table +---@field Conceal table +---@field CurSearch table +---@field Cursor table +---@field lCursor table +---@field CursorIM table +---@field CursorColumn table +---@field CursorLine table +---@field Directory table +---@field DiffAdd table +---@field DiffChange table +---@field DiffDelete table +---@field DiffText table +---@field EndOfBuffer table +---@field TermCursor table +---@field TermCursorNC table +---@field ErrorMsg table +---@field WinSeparator table +---@field Folded table +---@field FoldColumn table +---@field SignColumn table +---@field IncSearch table +---@field Substitute table +---@field LineNr table +---@field LineNrAbove table +---@field LineNrBelow table +---@field CursorLineNr table +---@field CursorLineFold table +---@field CursorLineSign table +---@field MatchParen table +---@field ModeMsg table +---@field MsgArea table +---@field MsgSeparator table +---@field MoreMsg table +---@field NonText table +---@field Normal table +---@field NormalFloat table +---@field FloatBorder table +---@field FloatTitle table +---@field NormalNC table +---@field Pmenu table +---@field PmenuSel table +---@field PmenuKind table +---@field PmenuKindSel table +---@field PmenuExtra table +---@field PmenuExtraSel table +---@field PmenuSbar table +---@field PmenuThumb table +---@field Question table +---@field QuickFixLine table +---@field Search table +---@field SpecialKey table +---@field SpellBad table +---@field SpellCap table +---@field SpellLocal table +---@field SpellRare table +---@field StatusLine table +---@field StatusLineNC table +---@field TabLine table +---@field TabLineFill table +---@field TabLineSel table +---@field Title table +---@field Visual table +---@field VisualNOS table +---@field warningMsg table +---@field Whitespace table +---@field WildMenu table +---@field WinBar table +---@field WinBarNC table +---@field Comment table +---@field Constant table +---@field String table +---@field Character table +---@field Number table +---@field Boolean table +---@field Float table +---@field Identifier table +---@field Function table +---@field Statement table +---@field Conditional table +---@field Repeat table +---@field Label table +---@field Operator table +---@field Keyword table +---@field Exception table +---@field PreProc table +---@field Include table +---@field Define table +---@field Macro table +---@field PreCondit table +---@field Type table +---@field StorageClass table +---@field Structure table +---@field Typedef table +---@field Special table +---@field SpecialChar table +---@field Tag table +---@field Delimiter table +---@field SpecialComment table +---@field Debug table +---@field Underlined table +---@field Ignore table +---@field Error table +---@field Todo table +---@field CmpItemKindText table +---@field CmpItemKindMethod table +---@field CmpItemKindFunction table +---@field CmpItemKindField table +---@field CmpItemKindVariable table +---@field CmpItemKindClass table +---@field CmpItemKindInterface table +---@field CmpItemKindModule table +---@field CmpItemKindProperty table +---@field CmpItemKindUnity table +---@field CmpItemKindEnum table +---@field CmpItemKindKeyword table +---@field CmpItemKindSnippet table +---@field CmpItemKindColor table +---@field CmpItemKindFile table +---@field CmpItemKindReference table +---@field CmpItemKindFolder table +---@field CmpItemKindEnumMember table +---@field CmpItemKindConstant table +---@field CmpItemKindStruct table +---@field CmpItemKindEvent table +---@field CmpItemKindOperator table +---@field CmpItemKindTypeParameter table +---@field IblIndent table +---@field IblScope table +---@field BufferLineSeparator table +---@field BufferLineSeparatorSelected table +---@field BufferLineBufferSelected table +---@field BufferLineFill table +---@field BufferLineIndicatorSelected table + +local M = {} + +local function nvim_get_hl(opts) + local hl = vim.api.nvim_get_hl(0, opts) + + if hl.link then + return nvim_get_hl { name = hl.link } + end + + return hl +end + +local nvim_set_hl = function(group_name, group_val, config) + local val = { fg = 'NONE', bg = 'NONE' } + + if not group_val.link then + if config and config.transparent then + group_val.bg = 'NONE' + end + val = vim.tbl_extend('force', val, group_val) + vim.api.nvim_set_hl(0, group_name, val) + else + vim.api.nvim_set_hl(0, group_name, group_val) + end +end + +M.set_highlight = function(colors, config) + if config.on_colors then + colors = vim.tbl_extend('force', colors, config.on_colors(colors)) + end + -- EDITOR :h highlight-groups + nvim_set_hl('ColorColumn', { bg = colors.base04 }) + nvim_set_hl('Conceal', { fg = colors.base02 }) + nvim_set_hl('CurSearch', { fg = colors.cyan }) + nvim_set_hl('Cursor', { fg = colors.base03, bg = colors.cyan }) + nvim_set_hl('lCursor', { link = 'Cursor' }) + nvim_set_hl('CursorIM', { link = 'Cursor' }) + nvim_set_hl('CursorColumn', { link = 'ColorColumn' }) + nvim_set_hl('CursorLine', { bg = colors.base02 }) + nvim_set_hl('Directory', { fg = colors.purple }) + nvim_set_hl('DiffAdd', { fg = colors.git_added }) + nvim_set_hl('DiffChange', { fg = colors.git_modified }) + nvim_set_hl('DiffDelete', { fg = colors.git_removed, reverse = true }) + nvim_set_hl('DiffText', { fg = colors.cyan, reverse = true }) + nvim_set_hl('EndOfBuffer', { fg = colors.base03 }) + nvim_set_hl('TermCursor', { link = 'Cursor' }) + nvim_set_hl('TermCursorNC', { fg = colors.base0, reverse = true }) + nvim_set_hl('ErrorMsg', { fg = colors.diag_error }) + nvim_set_hl('WinSeparator', { fg = colors.base01, bg = colors.base04 }) + nvim_set_hl('Folded', { fg = colors.base0, bg = colors.base02 }) + nvim_set_hl('FoldColumn', { fg = colors.base0, bg = colors.base04 }) + nvim_set_hl('SignColumn', { link = 'Normal' }) + nvim_set_hl('IncSearch', { fg = colors.cyan, bg = colors.base04, bold = true }, config) + nvim_set_hl('Substitute', { link = 'IncSearch' }) + nvim_set_hl('LineNr', { fg = colors.base01, bg = colors.base03 }, config) + nvim_set_hl('LineNrAbove', { link = 'LineNr' }) + nvim_set_hl('LineNrBelow', { link = 'LineNr' }) + nvim_set_hl('CursorLineNr', { fg = colors.purple, bg = colors.base03 }, config) + nvim_set_hl('CursorLineFold', { link = 'FoldColumn' }) + nvim_set_hl('CursorLineSign', { link = 'SignColumn' }) + nvim_set_hl('MatchParen', { fg = colors.cyan }) + nvim_set_hl('ModeMsg', { fg = colors.purple }) + nvim_set_hl('MsgArea', { link = 'Normal' }) + nvim_set_hl('MsgSeparator', { link = 'Normal' }) + nvim_set_hl('MoreMsg', { link = 'ModeMsg' }) + nvim_set_hl('NonText', { fg = colors.base01 }) + nvim_set_hl('Normal', { fg = colors.base0, bg = colors.base03 }, config) + nvim_set_hl('NormalFloat', { fg = colors.base0, bg = colors.base04 }) + nvim_set_hl('FloatBorder', { link = 'WinSeparator' }) + nvim_set_hl('FloatTitle', { link = 'Title' }) + nvim_set_hl('NormalNC', { link = 'Normal' }) + nvim_set_hl('Pmenu', { fg = colors.base0, bg = colors.base04 }) + nvim_set_hl('PmenuSel', { fg = colors.cyan, reverse = true }) + nvim_set_hl('PmenuKind', { link = 'Pmenu' }) + nvim_set_hl('PmenuKindSel', { link = 'PmenuSel' }) + nvim_set_hl('PmenuExtra', { link = 'Pmenu' }) + nvim_set_hl('PmenuExtraSel', { link = 'PmenuSel' }) + nvim_set_hl('PmenuSbar', { bg = colors.base04 }) + nvim_set_hl('PmenuThumb', { bg = colors.cyan }) + nvim_set_hl('Question', { fg = colors.diag_info }) + nvim_set_hl('QuickFixLine', { fg = colors.base0, bg = colors.base03 }) + nvim_set_hl('Search', { bg = colors.base02 }) + nvim_set_hl('SpecialKey', { link = 'NonText' }) + nvim_set_hl('SpellBad', { underline = true, strikethrough = true }) + nvim_set_hl('SpellCap', { fg = colors.diag_hint }) + nvim_set_hl('SpellLocal', { link = 'SpellCap' }) + nvim_set_hl('SpellRare', { fg = colors.diag_warning }) + nvim_set_hl('StatusLine', { fg = colors.base0, bg = colors.base04 }) + nvim_set_hl('StatusLineNC', { fg = colors.base01, bg = colors.base04 }) + nvim_set_hl('TabLine', { fg = colors.base01, bg = colors.base04 }) + nvim_set_hl('TabLineFill', { fg = colors.base0, bg = colors.base04 }) + nvim_set_hl('TabLineSel', { fg = colors.base0, bg = colors.base03 }) + nvim_set_hl('Title', { fg = colors.purple, bold = true }) + nvim_set_hl('Visual', { bg = colors.base02 }) + nvim_set_hl('VisualNOS', { link = 'Visual' }) + nvim_set_hl('warningMsg', { fg = colors.diag_warning }) + nvim_set_hl('Whitespace', { fg = colors.base01 }) + nvim_set_hl('WildMenu', { fg = colors.base02 }) + nvim_set_hl('WinBar', { link = 'Pmenu' }) + nvim_set_hl('WinBarNC', { link = 'WinBar' }) -- SYNTAX :h group-name + nvim_set_hl('Comment', { fg = colors.base01 }) + nvim_set_hl('Constant', { fg = colors.purple }) + nvim_set_hl('String', { fg = colors.yellow }) + nvim_set_hl('Character', { link = 'String' }) + nvim_set_hl('Number', { link = 'Constant' }) + nvim_set_hl('Boolean', { link = 'Constant' }) + nvim_set_hl('Float', { link = 'Constant' }) + nvim_set_hl('Identifier', { fg = colors.base0 }) + nvim_set_hl('Function', { fg = colors.green }) + nvim_set_hl('Statement', { fg = colors.pink }) + nvim_set_hl('Conditional', { link = 'Statement' }) + nvim_set_hl('Repeat', { link = 'Statement' }) + nvim_set_hl('Label', { link = 'Statement' }) + nvim_set_hl('Operator', { link = 'Statement' }) + nvim_set_hl('Keyword', { link = 'Statement' }) + nvim_set_hl('Exception', { link = 'Statement' }) + nvim_set_hl('PreProc', { link = 'Statement' }) + nvim_set_hl('Include', { link = 'Statement' }) + nvim_set_hl('Define', { link = 'Statement' }) + nvim_set_hl('Macro', { link = 'Statement' }) + nvim_set_hl('PreCondit', { link = 'Statement' }) + nvim_set_hl('Type', { fg = colors.cyan }) + nvim_set_hl('StorageClass', { link = 'Statement' }) + nvim_set_hl('Structure', { link = 'Type' }) + nvim_set_hl('Typedef', { link = 'Statement' }) + nvim_set_hl('Special', { fg = colors.red }) + nvim_set_hl('SpecialChar', { link = 'Constant' }) + nvim_set_hl('Tag', { fg = colors.pink }) + nvim_set_hl('Delimiter', { fg = colors.base0 }) + nvim_set_hl('SpecialComment', { link = 'Statement' }) + nvim_set_hl('Debug', { link = 'Statement' }) + nvim_set_hl('Underlined', { fg = colors.cyan, underline = true }) + nvim_set_hl('Ignore', {}) + nvim_set_hl('Error', { fg = colors.diag_error, bold = true }) + nvim_set_hl('Todo', { link = 'Title' }) -- PLUGINS + if config.plugins['nvim-treesitter'] then + nvim_set_hl('@variable', { link = 'Indentifier' }) + nvim_set_hl('@variable.builtin', { link = 'Constant' }) + nvim_set_hl('@variable.parameter', { fg = colors.orange, italic = true }) + nvim_set_hl('@variable.member', { link = 'Identifier' }) + nvim_set_hl('@constant', { link = 'Constant' }) + nvim_set_hl('@constant.builtin', { link = 'Constant' }) + nvim_set_hl('@constant.macro', { link = 'Constant' }) + nvim_set_hl('@module', { link = 'Identifier' }) + nvim_set_hl('@module.builtin', { link = 'Constant' }) + nvim_set_hl('@label', { link = 'Label' }) + nvim_set_hl('@string', { link = 'String' }) + nvim_set_hl('@string.documentation', { link = 'Statement' }) + nvim_set_hl('@string.regexp', { link = 'Special' }) + nvim_set_hl('@string.escape', { link = 'Statement' }) + nvim_set_hl('@string.special', { link = 'String' }) + nvim_set_hl('@string.special.symbol', { link = 'Identifier' }) + nvim_set_hl('@string.special.url', { link = 'Underlined' }) + nvim_set_hl('@character', { link = 'String' }) + nvim_set_hl('@character.special', { link = 'String' }) + nvim_set_hl('@character.printf', { link = 'Special' }) + nvim_set_hl('@type', { link = 'Type' }) + nvim_set_hl('@type.builtin', { link = 'Type' }) + nvim_set_hl('@type.defition', { link = 'Type' }) + nvim_set_hl('@type.qualifier', { fg = colors.pink }) + nvim_set_hl('@function', { link = 'Function' }) + nvim_set_hl('@function.builtin', { link = 'Type' }) + nvim_set_hl('@function.call', { link = 'Function' }) + nvim_set_hl('@function.macro', { link = 'Function' }) + nvim_set_hl('@function.method', { link = 'Function' }) + nvim_set_hl('@function.method.call', { link = 'Function' }) + nvim_set_hl('@constructor', { link = 'Type' }) + nvim_set_hl('@operator', { link = 'Operator' }) + nvim_set_hl('@keyword', { link = 'Statement' }) + nvim_set_hl('@keyword.coroutine', { link = 'Statement' }) + nvim_set_hl('@keyword.function', { link = 'Statement' }) + nvim_set_hl('@keyword.operator', { link = 'Statement' }) + nvim_set_hl('@keyword.import', { link = 'Statement' }) + nvim_set_hl('@keyword.repeat', { link = 'Statement' }) + nvim_set_hl('@keyword.return', { link = 'Statement' }) + nvim_set_hl('@keyword.debug', { link = 'Statement' }) + nvim_set_hl('@keyword.exception', { link = 'Statement' }) + nvim_set_hl('@keyword.conditional', { link = 'Statement' }) + nvim_set_hl('@keyword.conditional.ternary', { link = 'Statement' }) + nvim_set_hl('@keyword.directive', { link = 'Statement' }) + nvim_set_hl('@keyword.directive.define', { link = 'Statement' }) + nvim_set_hl('@punctuation.delimiter', { link = 'Delimiter' }) + nvim_set_hl('@punctuation.bracket', { link = 'Delimiter' }) + nvim_set_hl('@punctuation.special', { fg = colors.pink }) + nvim_set_hl('@comment', { link = 'Comment' }) + nvim_set_hl('@comment.documentation', { link = 'Comment' }) + nvim_set_hl('@comment.error', { fg = colors.diag_error, bg = colors.shade_error }) + nvim_set_hl('@comment.warning', { fg = colors.diag_warning, bg = colors.shade_warning }) + nvim_set_hl('@comment.todo', { fg = colors.purple, bg = colors.shade_purple }) + nvim_set_hl('@comment.note', { fg = colors.diag_hint, bg = colors.shade_hint }) + nvim_set_hl('@markup.strong', { fg = colors.orange, bold = true }) + nvim_set_hl('@markup.italic', { fg = colors.yellow, italic = true }) + nvim_set_hl('@markup.strikethrough', { fg = colors.base01 }) + nvim_set_hl('@markup.underline', { link = 'Underlined' }) + nvim_set_hl('@markup.heading', { link = 'Title' }) + nvim_set_hl('@markup.quote', { link = 'Comment' }) + nvim_set_hl('@markup.math', { link = 'Constant' }) + nvim_set_hl('@markup.environment', { link = 'Comment' }) + nvim_set_hl('@markup.link', { link = '@markup.strong' }) + nvim_set_hl('@markup.link.label', { link = 'Underlined' }) + nvim_set_hl('@markup.link.url', { fg = colors.cyan }) + nvim_set_hl('@markup.raw', { fg = colors.green }) + nvim_set_hl('@markup.raw.block', { link = 'Comment' }) + nvim_set_hl('@markup.list', { fg = colors.purple }) + nvim_set_hl('@markup.list.checked', { fg = colors.git_added }) + nvim_set_hl('@markup.list.unchecked', { fg = colors.git_modified }) + nvim_set_hl('@diff.plus', { fg = colors.git_added }) + nvim_set_hl('@diff.minus', { fg = colors.git_removed }) + nvim_set_hl('@diff.delta', { fg = colors.git_modified }) + nvim_set_hl('@tag', { fg = colors.pink }) + nvim_set_hl('@tag.attribute', { fg = colors.green }) + nvim_set_hl('@tag.delimiter', { link = 'Delimiter' }) + end + + if config.plugins['nvim-cmp'] then + nvim_set_hl('CmpItemKindText', { link = 'String' }) + nvim_set_hl('CmpItemKindMethod', { link = 'Function' }) + nvim_set_hl('CmpItemKindFunction', { link = 'Function' }) + nvim_set_hl('CmpItemKindField', { link = 'Identifier' }) + nvim_set_hl('CmpItemKindVariable', { link = 'Identifier' }) + nvim_set_hl('CmpItemKindClass', { link = 'Type' }) + nvim_set_hl('CmpItemKindInterface', { link = 'Type' }) + nvim_set_hl('CmpItemKindModule', { link = 'Type' }) + nvim_set_hl('CmpItemKindProperty', { link = 'Identifier' }) + nvim_set_hl('CmpItemKindUnity', { link = 'Number' }) + nvim_set_hl('CmpItemKindEnum', { link = 'Type' }) + nvim_set_hl('CmpItemKindKeyword', { link = 'Statement' }) + nvim_set_hl('CmpItemKindSnippet', { link = 'Tag' }) + nvim_set_hl('CmpItemKindColor', { fg = colors.orange }) + nvim_set_hl('CmpItemKindFile', { fg = colors.Identifier }) + nvim_set_hl('CmpItemKindReference', { link = 'Underlined' }) + nvim_set_hl('CmpItemKindFolder', { link = 'Directory' }) + nvim_set_hl('CmpItemKindEnumMember', { link = 'Constant' }) + nvim_set_hl('CmpItemKindConstant', { link = 'Constant' }) + nvim_set_hl('CmpItemKindStruct', { link = 'Identifier' }) + nvim_set_hl('CmpItemKindEvent', { link = 'Function' }) + nvim_set_hl('CmpItemKindOperator', { link = 'Operator' }) + nvim_set_hl('CmpItemKindTypeParameter', { link = 'Type' }) + end + + if config.plugins['indent-blankline.nvim'] then + nvim_set_hl('IblIndent', { fg = colors.shade_purple, nocombine = true }) + nvim_set_hl('IblScope', { fg = colors.purple, nocombine = true }) + end + + if config.plugins['bufferline.nvim'] then + nvim_set_hl('BufferLineSeparator', { fg = colors.base04, bg = colors.base04 }) + nvim_set_hl('BufferLineSeparatorSelected', { fg = colors.base04, bg = colors.base03 }) + nvim_set_hl('BufferLineBufferSelected', { fg = colors.purple, bold = true }) + nvim_set_hl('BufferLineFill', { fg = colors.base0, bg = colors.base04 }) + nvim_set_hl('BufferLineIndicatorSelected', { fg = colors.purple }) + end + if config.on_highlight then + local color = require 'dracula.color' + local highlights = config.on_highlight(colors, color) + + for group_name, group_val in pairs(highlights) do + local hl = nvim_get_hl { name = group_name, link = true } + local val = vim.tbl_extend('force', hl, group_val) + vim.api.nvim_set_hl(0, group_name, val) + end + end +end + +return M diff --git a/lua/dracula/init.lua b/lua/dracula/init.lua index 3b73f34..3d434ce 100644 --- a/lua/dracula/init.lua +++ b/lua/dracula/init.lua @@ -1,99 +1,38 @@ -require 'dracula.autocmd' -local utils = require 'dracula.utils' -local theme = require 'dracula.theme' -local Config = require 'dracula.config' -local M = Config:new() +---@class dracula +---@field config dracula.config +---@field setup fun(config: dracula.config) +---@field load fun(theme: string) +local M = {} -function M:apply_transparency() - local groups = { - Normal = { bg = 'NONE' }, - SignColumn = { bg = 'NONE' }, - CursorLineNr = { bg = 'NONE' }, - LineNr = { bg = 'NONE' }, - } +M.config = require 'dracula.config' - if self.transparent then - if self.transparent == 'full' then - local groups2 = { - NormalFloat = { bg = 'NONE' }, - WinSeparator = { bg = 'NONE' }, - NvimTreeWinSeparator = { link = 'WinSeparator' }, - StatusLine = { bg = 'NONE' }, - StatusLineNC = { bg = 'NONE' }, - NvimTreeStatusLine = { bg = 'NONE' }, - } - - groups = vim.tbl_extend('keep', groups, groups2) - end - - return groups - end +M.setup = function(config) + M.config = vim.tbl_deep_extend('force', M.config, config) end -function M:support_draculapro() - if not self.dracula_pro then - return - end - - local c = self.colors - local colors = { - pro = c.purple, - blade = c.green, - buffy = c.pink, - morbius = c.orange, - lincoln = c.yellow, - van_helsing = c.cyan, - } - local accent_color = colors[self.dracula_pro.theme] - - return { - Directory = { fg = accent_color }, - TelescopeTitle = { fg = accent_color, reverse = true }, - BufferLineBufferSelected = { fg = accent_color }, - BufferLineIndicatorSelected = { fg = accent_color }, - CursorLineNr = { fg = c.fg }, - } -end - -function M.load_default() +M.load = function(theme) + theme = theme or '' if vim.g.colors_name then vim.cmd 'hi clear' end - vim.o.background = 'dark' if vim.fn.exists 'syntax_on' then vim.cmd 'syntax reset' end - vim.o.termguicolors = true - vim.g.colors_name = 'dracula' -end - -M.setup = function(user_config) - M.load_default() - - if vim.tbl_isempty(M.user_config) then - M.user_config = user_config or {} + vim.g.colors_name = theme + local ok, highlights = pcall(require, 'dracula.highlights.' .. theme) + if not ok then + highlights = require 'dracula.highlights' end - M:set_soft(M.user_config.soft) - M:set_colors() - M:set_saturation(M.user_config.saturation) - M:set_transparent(M.user_config.transparent) - M:set_draculapro(M.user_config.dracula_pro) - M:set_user_colors() - M:change_colors_saturation() - - theme.set_highlights(M.colors) - - if type(M.user_config.override) == 'function' then - M.user_config.override = M.user_config.override(M.colors) + local colors = {} + ok, colors = pcall(require, 'dracula.palette' .. theme) + if not ok then + colors = require 'dracula.palette' end - utils.update_highlight_groups(M.user_config.override) - utils.update_highlight_groups(M:apply_transparency()) - utils.update_highlight_groups(M:support_draculapro()) - M:call_user_callback(M.user_config.callback) + highlights.set_highlight(colors, M.config) end return M diff --git a/lua/dracula/palette/init.lua b/lua/dracula/palette/init.lua new file mode 100644 index 0000000..ac966e5 --- /dev/null +++ b/lua/dracula/palette/init.lua @@ -0,0 +1,69 @@ +---@class dracula.palette +---@field base0 string +---@field base01 string +---@field base02 string +---@field base03 string +---@field base04 string +---@field cyan string +---@field diag_error string +---@field diag_hint string +---@field diag_info string +---@field diag_success string +---@field diag_warning string +---@field git_added string +---@field git_modified string +---@field git_removed string +---@field green string +---@field orange string +---@field pink string +---@field purple string +---@field red string +---@field shade_add string +---@field shade_change string +---@field shade_cyan string +---@field shade_error string +---@field shade_green string +---@field shade_hint string +---@field shade_info string +---@field shade_orange string +---@field shade_pink string +---@field shade_purple string +---@field shade_red string +---@field shade_warning string +---@field shade_yellow string +---@field yellow string +return { + base0 = '#F8F8F2', + base01 = '#6272A4', + base02 = '#21222C', + base03 = '#282A36', + base04 = '#21222C', + cyan = '#8BE9FD', + diag_error = '#FF5555', + diag_hint = '#8BE9FD', + diag_info = '#8BE9FD', + diag_success = '#50FA7B', + diag_warning = '#FFB86C', + git_added = '#50FA7B', + git_modified = '#FFB86C', + git_removed = '#FF5555', + green = '#50FA7A', + orange = '#FFB86C', + pink = '#FF79C6', + purple = '#BD93F9', + red = '#FF5555', + shade_add = '#2E4940', + shade_change = '#483F3E', + shade_cyan = '#374754', + shade_error = '#48303B', + shade_green = '#2E4940', + shade_hint = '#374754', + shade_info = '#374754', + shade_orange = '#483F3E', + shade_pink = '#5E3E5A', + shade_purple = '#3E3A53', + shade_red = '#48303B', + shade_warning = '#483F3E', + shade_yellow = '#464943', + yellow = '#F1FA8C', +} diff --git a/lua/dracula/palettes/init.lua b/lua/dracula/palettes/init.lua deleted file mode 100644 index 47b0426..0000000 --- a/lua/dracula/palettes/init.lua +++ /dev/null @@ -1,41 +0,0 @@ -local colors = { - fg = '#f8f8f2', - bg = '#282a36', - bgdark = '#21222c', - currentline = '#44475a', - selection = '#44475a', - comment = '#6272a4', - cyan = '#8be9fd', - green = '#50fa7b', - orange = '#ffb86c', - pink = '#ff79c6', - purple = '#bd93f9', - red = '#ff5555', - yellow = '#f1fa8c', - cursor_fg = '#282a36', - cursor_bg = '#f8f8f2', - sign_add = '#50fa7b', - sign_change = '#ffb866', - sign_delete = '#ff5555', - error = '#ff555b', - warning = '#ffb866', - info = '#8be9fd', - hint = '#8be9fd', - other = '#bd93f9', - blended_orange = '#483F3E', - blended_red = '#48303B', - blended_cyan = '#374754', - blended_green = '#2E4940', - blended_yellow = '#464943', - blended_purple = '#3E3A53', - blended_pink = '#5E3E5A', - blended_add = '#2E4940', - blended_change = '#483F3E', - blended_warning = '#483F3E', - blended_error = '#48303B', - blended_info = '#374754', - blended_hint = '#374754', - blended_other = '#3E3A53', -} - -return colors diff --git a/lua/dracula/palettes/soft.lua b/lua/dracula/palettes/soft.lua deleted file mode 100644 index ba82b97..0000000 --- a/lua/dracula/palettes/soft.lua +++ /dev/null @@ -1,41 +0,0 @@ -local colors = { - fg = '#f8f8f2', - bg = '#282a36', - bgdark = '#262626', - currentline = '#44475a', - selection = '#44475a', - comment = '#7b7f8b', - cyan = '#adf6f6', - green = '#62e884', - orange = '#ffb86c', - pink = '#f286c4', - purple = '#bf9eee', - red = '#ee6666', - yellow = '#e7ee98', - cursor_fg = '#282a36', - cursor_bg = '#f8f8f2', - sign_add = '#62e884', - sign_change = '#ffb866', - sign_delete = '#ee6666', - error = '#ee6666', - warning = '#ffb866', - info = '#97e1f1', - hint = '#97e1f1', - other = '#bf9eee', - blended_orange = '#483F3E', - blended_red = '#46333D', - blended_cyan = '#394552', - blended_green = '#314742', - blended_yellow = '#454745', - blended_purple = '#3F3B52', - blended_pink = '#5B415A', - blended_add = '#314742', - blended_change = '#483F3E', - blended_warning = '#483F3E', - blended_error = '#46333D', - blended_info = '#394552', - blended_hint = '#394552', - blended_other = '#3F3B52', -} - -return colors diff --git a/lua/dracula/theme.lua b/lua/dracula/theme.lua deleted file mode 100644 index d98e225..0000000 --- a/lua/dracula/theme.lua +++ /dev/null @@ -1,585 +0,0 @@ -local hl = vim.api.nvim_set_hl -local theme = {} - -theme.set_highlights = function(c) - -- highlights - hl(0, 'Normal', { fg = c.fg, bg = c.bg }) - hl(0, 'SignColumn', { fg = 'NONE', bg = c.bg }) - hl(0, 'MsgArea', { link = 'Normal' }) - hl(0, 'ModeMsg', { fg = c.fg, bg = c.bg, bold = true }) - hl(0, 'MsgSeparator', { fg = c.fg, bg = c.bg, bold = true }) - hl(0, 'SpellBad', { fg = c.error, bg = 'NONE', underline = true }) - hl(0, 'SpellCap', { fg = c.info, bg = 'NONE', underline = true }) - hl(0, 'SpellLocal', { fg = c.warning, bg = 'NONE', underline = true }) - hl(0, 'SpellRare', { fg = c.other, bg = 'NONE', underline = true }) - hl(0, 'NormalNC', { link = 'Normal' }) - hl(0, 'Pmenu', { link = 'NormalFloat' }) - hl(0, 'PmenuSel', { fg = 'NONE', bg = c.selection }) - hl(0, 'WildMenu', { fg = 'NONE', bg = c.bg, bold = true }) - hl(0, 'CursorLineNr', { fg = c.pink, bg = c.bg }) - hl(0, 'Comment', { fg = c.comment, bg = 'NONE', italic = true }) - hl(0, 'Folded', { fg = c.comment, bg = c.selection }) - hl(0, 'FoldColumn', { fg = c.fg, bg = c.bg }) - hl(0, 'LineNr', { fg = c.comment, bg = c.bg }) - hl(0, 'FloatBorder', { fg = c.comment, bg = c.bgdark }) - hl(0, 'Whitespace', { fg = c.bg, bg = 'NONE' }) - hl(0, 'WinSeparator', { fg = c.comment, bg = c.bgdark }) - hl(0, 'VertSplit', { link = 'WinSeparator' }) - hl(0, 'CursorLine', { fg = 'NONE', bg = c.currentline }) - hl(0, 'CursorColumn', { link = 'CursorLine' }) - hl(0, 'ColorColumn', { fg = 'NONE', bg = c.bgdark }) - hl(0, 'NormalFloat', { fg = c.fg, bg = c.bgdark }) - hl(0, 'Visual', { fg = 'NONE', bg = c.selection }) - hl(0, 'VisualNOS', { link = 'Visual' }) - hl(0, 'WarningMsg', { fg = c.warning, bg = c.bg }) - hl(0, 'DiffAdd', { fg = c.sign_add, bg = 'NONE', reverse = true }) - hl(0, 'DiffChange', { fg = c.sign_change, bg = 'NONE', reverse = true }) - hl(0, 'DiffDelete', { fg = c.sign_delete, bg = 'NONE', reverse = true }) - hl(0, 'QuickFixLine', { fg = 'NONE', bg = c.selection, bold = true }) - hl(0, 'PmenuSbar', { link = 'NormalFloat' }) - hl(0, 'PmenuThumb', { fg = 'NONE', bg = c.pink }) - hl(0, 'MatchWord', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'MatchParen', { fg = c.hint, bg = c.bg, underline = true }) - hl(0, 'MatchWordCur', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'MatchParenCur', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'Cursor', { fg = c.cursor_fg, bg = c.cursor_bg }) - hl(0, 'lCursor', { fg = c.cursor_fg, bg = c.cursor_bg }) - hl(0, 'CursorIM', { fg = c.cursor_fg, bg = c.cursor_bg }) - hl(0, 'TermCursor', { fg = c.cursor_fg, bg = c.cursor_bg }) - hl(0, 'TermCursorNC', { fg = c.cursor_fg, bg = c.cursor_bg }) - hl(0, 'Conceal', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Directory', { fg = c.purple, bg = 'NONE' }) - hl(0, 'SpecialKey', { fg = c.purple, bg = 'NONE', bold = true }) - hl(0, 'Title', { fg = c.cyan, bg = 'NONE', bold = true }) - hl(0, 'ErrorMsg', { fg = c.error, bg = c.blended_error }) - hl(0, 'Search', { link = 'Visual' }) - hl(0, 'IncSearch', { fg = c.cyan, bg = c.blended_cyan, bold = true }) - hl(0, 'Substitute', { link = 'IncSearch' }) - hl(0, 'MoreMsg', { fg = c.cyan, bg = 'NONE', bold = true }) - hl(0, 'Question', { fg = c.cyan, bg = 'NONE', bold = true }) - hl(0, 'EndOfBuffer', { fg = c.bg, bg = 'NONE' }) - hl(0, 'NonText', { fg = c.comment, bg = 'NONE' }) - hl(0, 'Variable', { fg = c.fg, bg = 'NONE' }) - hl(0, 'String', { fg = c.yellow, bg = 'NONE' }) - hl(0, 'Character', { fg = c.yellow, bg = 'NONE' }) - hl(0, 'Constant', { fg = c.purple, bg = 'NONE' }) - hl(0, 'Number', { fg = c.purple, bg = 'NONE' }) - hl(0, 'Boolean', { fg = c.purple, bg = 'NONE' }) - hl(0, 'Float', { link = 'Number' }) - hl(0, 'Identifier', { fg = c.green, bg = 'NONE' }) - hl(0, 'Function', { link = 'Identifier' }) - hl(0, 'Operator', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Type', { fg = c.cyan, bg = 'NONE', italic = true }) - hl(0, 'StorageClass', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Structure', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Typedef', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Keyword', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Statement', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Conditional', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Repeat', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Label', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Exception', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Include', { fg = c.pink, bg = 'NONE' }) - hl(0, 'PreProc', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Define', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Macro', { fg = c.pink, bg = 'NONE' }) - hl(0, 'PreCondit', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Special', { fg = c.pink, bg = 'NONE' }) - hl(0, 'SpecialChar', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Tag', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'Debug', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Delimiter', { fg = c.fg, bg = 'NONE' }) - hl(0, 'SpecialComment', { fg = c.pink, bg = 'NONE' }) - hl(0, 'Underlined', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'Bold', { fg = 'NONE', bg = 'NONE', bold = true }) - hl(0, 'Italic', { fg = 'NONE', bg = 'NONE', italic = true }) - hl(0, 'Ignore', { fg = c.purple, bg = c.bg, bold = true }) - hl(0, 'Todo', { fg = c.cyan, bg = 'NONE', bold = true }) - hl(0, 'Error', { fg = c.error, bg = 'NONE', bold = true }) - hl(0, 'TabLine', { fg = c.comment, bg = c.bg }) - hl(0, 'TabLineSel', { link = 'Normal' }) - hl(0, 'TabLineFill', { fg = 'NONE', bg = c.bg }) - - -- TreeSitter - hl(0, '@comment', { link = 'Comment' }) - hl(0, '@comment.documentation', { link = 'Comment' }) - hl(0, '@comment.error', { fg = c.error, bg = c.blended_error }) - hl(0, '@comment.warning', { fg = c.warning, bg = c.blended_warning }) - hl(0, '@comment.todo', { fg = c.info, bg = c.blended_info }) - hl(0, '@comment.note', { fg = c.other, bg = c.blended_other }) - hl(0, '@error', { link = 'Error' }) - hl(0, '@operator', { fg = c.pink, bg = 'NONE' }) - hl(0, '@punctuation.delimiter', { fg = c.fg, bg = 'NONE' }) - hl(0, '@punctuation.delimiter.cpp', { fg = c.pink, bg = 'NONE' }) - hl(0, '@punctuation.delimiter.yaml', { fg = c.pink, bg = 'NONE' }) - hl(0, '@punctuation.bracket', { fg = c.pink, bg = 'NONE' }) - hl(0, '@punctuation.special', { fg = c.pink, bg = 'NONE' }) - hl(0, '@string', { fg = c.yellow, bg = 'NONE' }) - hl(0, '@string.regex', { fg = c.red, bg = 'NONE' }) - hl(0, '@string.escape', { fg = c.pink, bg = 'NONE' }) - hl(0, '@string.special', { fg = c.pink, bg = 'NONE' }) - hl(0, '@character', { fg = c.yellow, bg = 'NONE' }) - hl(0, '@character.special', { fg = c.pink, bg = 'NONE' }) - hl(0, '@function', { link = 'Function' }) - hl(0, '@function.builtin', { link = '@function' }) - hl(0, '@function.call', { link = '@function' }) - hl(0, '@method', { link = '@function' }) - hl(0, '@method.call', { link = '@function' }) - hl(0, '@constructor', { fg = c.pink, bg = 'NONE' }) - hl(0, '@constructor.c_sharp', { link = '@type' }) - hl(0, '@constructor.php', { link = '@type' }) - hl(0, '@variable.parameter', { fg = c.orange, bg = 'NONE', italic = true }) - hl(0, '@boolean', { fg = c.purple, bg = 'NONE' }) - hl(0, '@number', { fg = c.purple, bg = 'NONE' }) - hl(0, '@float', { fg = c.purple, bg = 'NONE' }) - hl(0, '@label.json', { fg = c.cyan, bg = 'NONE' }) - hl(0, '@label.ruby', { link = '@variable.builtin' }) - hl(0, '@exception', { link = 'Exception' }) - hl(0, '@type', { link = 'Type' }) - hl(0, '@type.dart', { link = '@type' }) - hl(0, '@type.builtin', { fg = c.cyan, bg = 'NONE', italic = true }) - hl(0, '@type.builtin.cpp', { fg = c.pink, bg = 'NONE', italic = true }) - hl(0, '@type.definition', { link = 'Type' }) - hl(0, '@type.qualifier', { fg = c.pink, bg = 'NONE' }) - hl(0, '@storageclass', { fg = c.pink, bg = 'NONE' }) - hl(0, '@attribute', { fg = c.green, bg = 'NONE', italic = true }) - hl(0, '@field', { fg = c.fg, bg = 'NONE' }) - hl(0, '@field.yaml', { fg = c.cyan, bg = 'NONE' }) - hl(0, '@property', { link = '@field' }) - hl(0, '@property.css', { fg = c.cyan, bg = 'NONE' }) - hl(0, '@variable', { fg = c.fg, bg = 'NONE' }) - hl(0, '@variable.builtin', { fg = c.purple, bg = 'NONE', italic = true }) - hl(0, '@variable.global.ruby', { link = '@constant' }) - hl(0, '@constant', { fg = c.purple, bg = 'NONE' }) - hl(0, '@constant.builtin', { fg = c.purple, bg = 'NONE' }) - hl(0, '@constant.macro', { fg = c.purple, bg = 'NONE' }) - hl(0, '@namespace', { fg = c.fg, bg = 'NONE' }) - hl(0, '@symbol', { fg = c.purple, bg = 'NONE' }) - hl(0, '@markup.heading', { link = 'Title' }) - hl(0, '@markup.italic', { fg = c.green, bg = 'NONE', italic = true }) - hl(0, '@markup.strikethrough', { fg = c.error, bg = 'NONE', strikethrough = true }) - hl(0, '@markup.quote', { link = 'Comment' }) - hl(0, '@markup.math', { link = 'Operator' }) - hl(0, '@markup.link', { fg = c.cyan, bg = 'NONE', underline = true }) - hl(0, '@markup.link.label', { fg = c.cyan, bg = 'NONE', underline = true }) - hl(0, '@markup.link.url', { fg = c.cyan, bg = 'NONE' }) - hl(0, '@markup.raw', { link = 'Comment' }) - hl(0, '@markup.list', { fg = c.purple, bg = 'NONE' }) - hl(0, '@markup.list.checked', { fg = c.green, bg = 'NONE' }) - hl(0, '@markup.list.unchecked', { fg = c.purple, bg = 'NONE' }) - hl(0, '@diff.plus', { fg = c.sign_add, bg = 'NONE' }) - hl(0, '@diff.minus', { fg = c.sign_delete, bg = 'NONE' }) - hl(0, '@diff.delta', { fg = c.sign_change, bg = 'NONE' }) - hl(0, '@tag', { fg = c.pink, bg = 'NONE' }) - hl(0, '@tag.attribute', { fg = c.green, bg = 'NONE' }) - hl(0, '@tag.delimiter', { fg = c.fg, bg = 'NONE' }) - - -- Semantic - hl(0, '@lsp.type.namespace', { link = '@namespace' }) - hl(0, '@lsp.type.type', { link = '@type' }) - hl(0, '@lsp.type.typeParameter', { link = '@type' }) - hl(0, '@lsp.type.class', { link = '@type' }) - hl(0, '@lsp.type.enum', { link = '@type' }) - hl(0, '@lsp.type.interface', { link = '@type' }) - hl(0, '@lsp.type.struct', { link = 'Structure' }) - hl(0, '@lsp.type.parameter', { link = '@variable.parameter' }) - hl(0, '@lsp.type.variable', { link = '@variable' }) - hl(0, '@lsp.type.variable.lua', { fg = 'NONE', bg = 'NONE' }) - hl(0, '@lsp.type.property', { link = '@property' }) - hl(0, '@lsp.type.enumMember', { link = '@constant' }) - hl(0, '@lsp.type.function', { link = '@function' }) - hl(0, '@lsp.type.method', { link = '@method' }) - hl(0, '@lsp.type.macro', { link = '@macro' }) - hl(0, '@lsp.type.decorator', { link = '@function' }) - hl(0, '@lsp.typemod.variable.defaultLibrary', { link = '@constant' }) - hl(0, '@lsp.typemod.parameter.readyonly', { link = 'Italic' }) - hl(0, '@lsp.typemod.variable.readonly', { link = '@constant' }) - hl(0, '@lsp.typemod.variable.global', { link = '@constant' }) - hl(0, '@lsp.typemod.keyword.documentation', { link = '@keyword' }) - hl(0, '@lsp.typemod.class.documentation', { link = '@type' }) - hl(0, '@lsp.typemod.property.readonly', { link = '@constant' }) - - -- Whichkey - hl(0, 'WhichKey', { fg = c.fg, bg = 'NONE' }) - hl(0, 'WhichKeySeparator', { fg = c.pink, bg = 'NONE' }) - hl(0, 'WhichKeyGroup', { fg = c.green, bg = 'NONE' }) - hl(0, 'WhichKeyDesc', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'WhichKeyFloat', { link = 'NormalFloat' }) - - -- Git - hl(0, 'SignAdd', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'SignChange', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'SignDelete', { fg = c.sign_delete, bg = 'NONE' }) - hl(0, 'GitSignsAdd', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'GitSignsChange', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'GitSignsDelete', { fg = c.sign_delete, bg = 'NONE' }) - hl(0, 'GitSignsAddInline', { fg = c.green, bg = c.blended_green }) - hl(0, 'GitSignsChangeInline', { fg = c.orange, bg = c.blended_orange }) - hl(0, 'GitSignsDeleteInline', { fg = c.red, bg = c.blended_red }) - - -- Illuminate - hl(0, 'illuminatedWord', { fg = 'NONE', bg = c.selection }) - hl(0, 'illuminatedCurWord', { link = 'illuminatedWord' }) - hl(0, 'IlluminatedWordText', { link = 'illuminatedWord' }) - hl(0, 'IlluminatedWordRead', { link = 'illuminatedWord' }) - hl(0, 'IlluminatedWordWrite', { link = 'illuminatedWord' }) - - -- LSP - hl(0, 'LspDiagnosticsDefaultError', { fg = c.error, bg = 'NONE' }) - hl(0, 'LspDiagnosticsDefaultWarning', { fg = c.warning, bg = 'NONE' }) - hl(0, 'LspDiagnosticsDefaultInformation', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsDefaultInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsDefaultHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'LspDiagnosticsVirtualTextError', { fg = c.error, bg = 'NONE' }) - hl(0, 'LspDiagnosticsVirtualTextWarning', { fg = c.warning, bg = 'NONE' }) - hl(0, 'LspDiagnosticsVirtualTextInformation', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsVirtualTextInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsVirtualTextHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'LspDiagnosticsFloatingError', { fg = c.error, bg = 'NONE' }) - hl(0, 'LspDiagnosticsFloatingWarning', { fg = c.warning, bg = 'NONE' }) - hl(0, 'LspDiagnosticsFloatingInformation', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsFloatingInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsFloatingHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'DiagnosticHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'DiagnosticInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'DiagnosticError', { fg = c.error, bg = 'NONE' }) - hl(0, 'DiagnosticOther', { fg = c.other, bg = 'NONE' }) - hl(0, 'DiagnosticVirtualTextHint', { fg = c.hint, bg = c.blended_hint }) - hl(0, 'DiagnosticVirtualTextInfo', { fg = c.info, bg = c.blended_info }) - hl(0, 'DiagnosticVirtualTextWarn', { fg = c.warning, bg = c.blended_warning }) - hl(0, 'DiagnosticVirtualTextError', { fg = c.error, bg = c.blended_error }) - hl(0, 'DiagnosticFloatingHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'DiagnosticFloatingInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'DiagnosticFloatingWarn', { fg = c.warning, bg = 'NONE' }) - hl(0, 'DiagnosticFloatingError', { fg = c.error, bg = 'NONE' }) - hl(0, 'DiagnosticUnderlineHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'DiagnosticUnderlineInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'DiagnosticUnderlineWarn', { fg = c.warning, bg = 'NONE' }) - hl(0, 'DiagnosticUnderlineError', { fg = c.error, bg = 'NONE' }) - hl(0, 'DiagnosticSignError', { fg = c.error, bg = 'NONE' }) - hl(0, 'DiagnosticSignWarning', { fg = c.warning, bg = 'NONE' }) - hl(0, 'DiagnosticSignInformation', { fg = c.info, bg = 'NONE' }) - hl(0, 'DiagnosticSignInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'DiagnosticSignHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'DiagnosticSignOther', { fg = c.other, bg = 'NONE' }) - hl(0, 'LspDiagnosticsSignError', { fg = c.error, bg = 'NONE' }) - hl(0, 'LspDiagnosticsSignWarning', { fg = c.warning, bg = 'NONE' }) - hl(0, 'LspDiagnosticsSignInformation', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsSignInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsSignHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'LspDiagnosticsError', { fg = c.error, bg = 'NONE' }) - hl(0, 'LspDiagnosticsWarning', { fg = c.warning, bg = 'NONE' }) - hl(0, 'LspDiagnosticsInformation', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsInfo', { fg = c.info, bg = 'NONE' }) - hl(0, 'LspDiagnosticsHint', { fg = c.hint, bg = 'NONE' }) - hl(0, 'LspDiagnosticsUnderlineError', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'LspDiagnosticsUnderlineWarning', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'LspDiagnosticsUnderlineInformation', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'LspDiagnosticsUnderlineInfo', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'LspDiagnosticsUnderlineHint', { fg = 'NONE', bg = 'NONE', underline = true }) - hl(0, 'LspReferenceRead', { fg = 'NONE', bg = c.selection }) - hl(0, 'LspReferenceText', { fg = 'NONE', bg = c.selection }) - hl(0, 'LspReferenceWrite', { fg = 'NONE', bg = c.selection }) - - -- LspSaga - hl(0, 'SagaNormal', { link = 'NormalFloat' }) - hl(0, 'SagaWinbarModule', { link = '@namespace' }) - hl(0, 'SagaWinbarInterface', { link = '@type' }) - hl(0, 'SagaWinbarConstructor', { link = '@constructor' }) - hl(0, 'SagaWinbarStruct', { link = '@structure' }) - hl(0, 'SagaWinbarObject', { link = '@field' }) - hl(0, 'SagaWinbarUnit', { link = '@number' }) - hl(0, 'SagaWinbarFile', { fg = c.fg, bg = 'NONE' }) - hl(0, 'SagaWinbarSnippet', { fg = c.fg, bg = 'NONE' }) - hl(0, 'SagaWinbarText', { link = '@string' }) - hl(0, 'SagaWinbarTypeAlias', { link = '@type' }) - hl(0, 'SagaWinbarEvent', { link = '@function' }) - hl(0, 'SagaWinbarParameter', { link = '@parameter' }) - hl(0, 'SagaWinbarKey', { link = '@keyword' }) - hl(0, 'SagaWinbarValue', { fg = c.fg, bg = 'NONE' }) - hl(0, 'SagaWinbarMacro', { link = 'Macro' }) - hl(0, 'SagaWinbarNumber', { link = '@number' }) - hl(0, 'SagaWinbarConstant', { link = '@constant' }) - hl(0, 'SagaWinbarFunction', { link = '@function' }) - hl(0, 'SagaWinbarEnum', { link = '@type' }) - hl(0, 'SagaWinbarField', { link = '@field' }) - hl(0, 'SagaWinbarProperty', { link = '@property' }) - hl(0, 'SagaWinbarMethod', { link = '@method' }) - hl(0, 'SagaWinbarClass', { link = '@type' }) - hl(0, 'SagaWinbarFolder', { link = 'Directory' }) - hl(0, 'SagaWinbarPackage', { link = 'Directory' }) - hl(0, 'SagaWinbarStaticMethod', { link = '@method' }) - hl(0, 'SagaWinbarTypeParameter', { link = '@type' }) - hl(0, 'SagaWinbarEnumMember', { link = '@constant' }) - hl(0, 'SagaWinbarOperator', { link = '@operator' }) - hl(0, 'SagaWinbarNull', { link = '@constant' }) - hl(0, 'SagaWinbarNamespace', { link = '@namespace' }) - hl(0, 'SagaWinbarArray', { link = '@keyword' }) - hl(0, 'SagaWinbarBoolean', { link = '@boolean' }) - hl(0, 'SagaWinbarString', { link = '@string' }) - hl(0, 'SagaWinbarVariable', { link = '@variable' }) - hl(0, 'SagaWinbarFilename', { fg = c.fg, bg = 'NONE' }) - hl(0, 'SagaWinbarFolderName', { fg = c.fg, bg = 'NONE' }) - hl(0, 'SagaWinbarFileIcon', { link = 'Directory' }) - hl(0, 'SagaWinbarSep', { fg = c.pink, bg = 'NONE' }) - - -- Telescope - hl(0, 'TelescopeTitle', { fg = c.cyan, bg = c.blended_cyan }) - hl(0, 'TelescopeNormal', { link = 'NormalFloat' }) - hl(0, 'TelescopeSelection', { fg = c.fg, bg = c.selection }) - hl(0, 'TelescopeSelectionCaret', { fg = c.pink, bg = c.selection }) - hl(0, 'TelescopeMatching', { link = 'IncSearch' }) - hl(0, 'TelescopeBorder', { link = 'WinSeparator' }) - - -- NvimTree - hl(0, 'NvimTreeRootFolder', { link = 'Directory' }) - hl(0, 'NvimTreeFolderIcon', { link = 'Directory' }) - hl(0, 'NvimTreeIndentMarker', { link = 'Directory' }) - hl(0, 'NvimTreeNormal', { link = 'NormalFloat' }) - hl(0, 'NvimTreeWinSeparator', { fg = c.bgdark, bg = c.bgdark }) - hl(0, 'NvimTreeVertSplit', { link = 'VertSplit' }) - hl(0, 'NvimTreeFolderName', { fg = c.fg, bg = 'NONE' }) - hl(0, 'NvimTreeOpenedFolderName', { link = 'Directory' }) - hl(0, 'NvimTreeEmptyFolderName', { fg = c.purple, bg = 'NONE', italic = true }) - hl(0, 'NvimTreeGitIgnored', { fg = c.comment, bg = 'NONE', italic = true }) - hl(0, 'NvimTreeEndOfBuffer', { fg = c.bgdark, bg = 'NONE' }) - hl(0, 'NvimTreeCursorLine', { link = 'CursorLine' }) - hl(0, 'NvimTreeGitStaged', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'NvimTreeGitNew', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'NvimTreeGitRenamed', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'NvimTreeGitDeleted', { fg = c.sign_delete, bg = 'NONE' }) - hl(0, 'NvimTreeGitMerge', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'NvimTreeGitDirty', { fg = c.sign_change, bg = 'NONE' }) - - -- NeoTree - hl(0, 'NeoTreeNormal', { link = 'NormalFloat' }) - hl(0, 'NeoTreeNormalNC', { link = 'NormalFloat' }) - hl(0, 'NeoTreeEndOfBuffer', { fg = c.bgdark, bg = 'NONE' }) - hl(0, 'NeoTreeRootName', { link = 'Directory' }) - hl(0, 'NeoTreeFileName', { fg = c.fg, bg = 'NONE' }) - hl(0, 'NeoTreeFileNameOpened', { fg = c.purple, bg = 'NONE', bold = true }) - hl(0, 'NeoTreeFloatBorder', { link = 'WinSeparator' }) - hl(0, 'NeoTreeFloatTitle', { link = 'Title' }) - hl(0, 'NeoTreeGitAdded', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'NeoTreeGitConflict', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'NeoTreeGitDeleted', { fg = c.sign_delete, bg = 'NONE' }) - hl(0, 'NeoTreeGitIgnored', { fg = c.comment, bg = 'NONE', italic = true }) - hl(0, 'NeoTreeGitModified', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'NeoTreeGitUnstaged', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'NeoTreeGitUntracked', { fg = c.sign_change, bg = 'NONE' }) - hl(0, 'NeoTreeGitStaged', { fg = c.sign_add, bg = 'NONE' }) - hl(0, 'NeoTreeIndentMarker', { fg = c.blended_purple, bg = 'NONE' }) - - -- Dap - hl(0, 'DapUINormal', { link = 'NormalFloat' }) - - -- StatusLine - hl(0, 'StatusLine', { fg = c.fg, bg = c.bgdark }) - hl(0, 'StatusLineNC', { fg = c.bgdark, bg = c.bgdark }) - hl(0, 'StatusLineSeparator', { fg = c.bgdark, bg = 'NONE' }) - hl(0, 'StatusLineTerm', { fg = c.bgdark, bg = 'NONE' }) - hl(0, 'StatusLineTermNC', { fg = c.bgdark, bg = 'NONE' }) - - -- Dashboard - hl(0, 'DashboardHeader', { fg = c.red, bg = 'NONE' }) - hl(0, 'DashboardCenter', { fg = c.fg, bg = 'NONE' }) - hl(0, 'DashboardFooter', { fg = c.comment, bg = 'NONE' }) - hl(0, 'DashboardProjectTitle', { link = 'Title' }) - hl(0, 'DashboardProjectTitleIcon', { link = 'Title' }) - hl(0, 'DashboardProjectIcon', { fg = c.purple, bg = 'NONE' }) - hl(0, 'DashboardMruTitle', { link = 'Title' }) - hl(0, 'DashboardMruIcon', { link = 'Title' }) - hl(0, 'DashboardFiles', { fg = c.fg, bg = 'NONE' }) - hl(0, 'DashboardShotCutIcon', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'DashboardDesc', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'DashboardKey', { fg = c.purple, bg = 'NONE' }) - hl(0, 'DashboardIcon', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'DashboardShotCut', { fg = c.purple, bg = 'NONE' }) - - -- Cmp - hl(0, 'CmpItemAbbrDeprecated', { fg = c.comment, bg = 'NONE', strikethrough = true }) - hl(0, 'CmpItemAbbrMatch', { link = 'IncSearch' }) - hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'IncSearch' }) - hl(0, 'CmpItemKindText', { link = '@string' }) - hl(0, 'CmpItemKindMethod', { link = '@method' }) - hl(0, 'CmpItemKindFunction', { link = '@function' }) - hl(0, 'CmpItemKindConstructor', { link = '@constructor' }) - hl(0, 'CmpItemKindField', { link = '@field' }) - hl(0, 'CmpItemKindVariable', { link = '@variable' }) - hl(0, 'CmpItemKindClass', { link = '@type' }) - hl(0, 'CmpItemKindInterface', { link = '@type' }) - hl(0, 'CmpItemKindModule', { link = '@namespace' }) - hl(0, 'CmpItemKindProperty', { link = '@property' }) - hl(0, 'CmpItemKindUnit', { link = '@number' }) - hl(0, 'CmpItemKindValue', { link = '@string' }) - hl(0, 'CmpItemKindEnum', { link = '@type' }) - hl(0, 'CmpItemKindKeyword', { link = '@keyword' }) - hl(0, 'CmpItemKindSnippet', { link = '@keyword' }) - hl(0, 'CmpItemKindColor', { fg = c.orange, bg = 'NONE' }) - hl(0, 'CmpItemKindFile', { fg = c.fg, bg = 'NONE' }) - hl(0, 'CmpItemKindReference', { link = '@text.reference' }) - hl(0, 'CmpItemKindFolder', { link = 'Directory' }) - hl(0, 'CmpItemKindEnumMember', { link = '@constant' }) - hl(0, 'CmpItemKindConstant', { link = '@constant' }) - hl(0, 'CmpItemKindStruct', { link = 'Structure' }) - hl(0, 'CmpItemKindEvent', { link = '@function' }) - hl(0, 'CmpItemKindOperator', { link = '@operator' }) - hl(0, 'CmpItemKindTypeParameter', { link = '@type' }) - - -- Navic - hl(0, 'NavicIconsFile', { fg = c.fg, bg = 'NONE' }) - hl(0, 'NavicIconsModule', { link = '@namespace' }) - hl(0, 'NavicIconsNamespace', { link = '@namespace' }) - hl(0, 'NavicIconsPackage', { link = 'Directory' }) - hl(0, 'NavicIconsClass', { link = '@type' }) - hl(0, 'NavicIconsMethod', { link = '@method' }) - hl(0, 'NavicIconsProperty', { link = '@property' }) - hl(0, 'NavicIconsField', { link = '@field' }) - hl(0, 'NavicIconsConstructor', { link = '@constructor' }) - hl(0, 'NavicIconsEnum', { link = '@type' }) - hl(0, 'NavicIconsInterface', { link = '@type' }) - hl(0, 'NavicIconsFunction', { link = '@function' }) - hl(0, 'NavicIconsVariable', { link = '@Variable' }) - hl(0, 'NavicIconsConstant', { link = '@constant' }) - hl(0, 'NavicIconsString', { link = '@string' }) - hl(0, 'NavicIconsNumber', { link = '@number' }) - hl(0, 'NavicIconsBoolean', { link = '@boolean' }) - hl(0, 'NavicIconsArray', { link = '@keyword' }) - hl(0, 'NavicIconsObject', { link = '@keyword' }) - hl(0, 'NavicIconsKey', { link = '@keyword' }) - hl(0, 'NavicIconsNull', { link = '@constant' }) - hl(0, 'NavicIconsEnumMember', { link = '@constant' }) - hl(0, 'NavicIconsStruct', { link = 'Structure' }) - hl(0, 'NavicIconsEvent', { link = '@function' }) - hl(0, 'NavicIconsOperator', { link = '@operator' }) - hl(0, 'NavicIconsTypeParameter', { link = '@type' }) - hl(0, 'NavicText', { link = '@text' }) - hl(0, 'NavicSeparator', { link = '@keyword' }) - - -- Notify - hl(0, 'NotifyBackground', { link = 'NormalFloat' }) - hl(0, 'NotifyERRORBorder', { fg = c.error, bg = 'NONE' }) - hl(0, 'NotifyWARNBorder', { fg = c.warning, bg = 'NONE' }) - hl(0, 'NotifyINFOBorder', { fg = c.info, bg = 'NONE' }) - hl(0, 'NotifyDEBUGBorder', { fg = c.comment, bg = 'NONE' }) - hl(0, 'NotifyTRACEBorder', { fg = c.other, bg = 'NONE' }) - hl(0, 'NotifyERRORIcon', { fg = c.error, bg = 'NONE' }) - hl(0, 'NotifyWARNIcon', { fg = c.warning, bg = 'NONE' }) - hl(0, 'NotifyINFOIcon', { fg = c.info, bg = 'NONE' }) - hl(0, 'NotifyDEBUGIcon', { fg = c.comment, bg = 'NONE' }) - hl(0, 'NotifyTRACEIcon', { fg = c.other, bg = 'NONE' }) - hl(0, 'NotifyERRORTitle', { fg = c.error, bg = 'NONE' }) - hl(0, 'NotifyWARNTitle', { fg = c.warning, bg = 'NONE' }) - hl(0, 'NotifyINFOTitle', { fg = c.info, bg = 'NONE' }) - hl(0, 'NotifyDEBUGTitle', { fg = c.comment, bg = 'NONE' }) - hl(0, 'NotifyTRACETitle', { fg = c.other, bg = 'NONE' }) - hl(0, 'NotifyERRORBody', { link = 'NormalFloat' }) - hl(0, 'NotifyWARNBody', { link = 'NormalFloat' }) - hl(0, 'NotifyINFOBody', { link = 'NormalFloat' }) - hl(0, 'NotifyDEBUGBody', { link = 'NormalFloat' }) - hl(0, 'NotifyTRACEBody', { link = 'NormalFloat' }) - - -- Neorg - hl(0, '@neorg.headings.1.title', { fg = c.orange, bg = 'NONE' }) - hl(0, '@neorg.headings.2.title', { fg = c.cyan, bg = 'NONE' }) - hl(0, '@neorg.headings.3.title', { fg = c.green, bg = 'NONE' }) - hl(0, '@neorg.headings.4.title', { fg = c.yellow, bg = 'NONE' }) - hl(0, '@neorg.headings.5.title', { fg = c.red, bg = 'NONE' }) - hl(0, '@neorg.headings.6.title', { fg = c.purple, bg = 'NONE' }) - hl(0, '@neorg.headings.1.prefix', { link = '@neorg.headings.1.title' }) - hl(0, '@neorg.headings.2.prefix', { link = '@neorg.headings.2.title' }) - hl(0, '@neorg.headings.3.prefix', { link = '@neorg.headings.3.title' }) - hl(0, '@neorg.headings.4.prefix', { link = '@neorg.headings.4.title' }) - hl(0, '@neorg.headings.5.prefix', { link = '@neorg.headings.5.title' }) - hl(0, '@neorg.headings.6.prefix', { link = '@neorg.headings.6.title' }) - hl(0, '@neorg.lists.ordered.1.prefix', { link = '@neorg.headings.1.title' }) - hl(0, '@neorg.lists.ordered.2.prefix', { link = '@neorg.headings.2.title' }) - hl(0, '@neorg.lists.ordered.3.prefix', { link = '@neorg.headings.3.title' }) - hl(0, '@neorg.lists.ordered.4.prefix', { link = '@neorg.headings.4.title' }) - hl(0, '@neorg.lists.ordered.5.prefix', { link = '@neorg.headings.5.title' }) - hl(0, '@neorg.lists.ordered.6.prefix', { link = '@neorg.headings.5.title' }) - hl(0, '@neorg.lists.unordered.1.prefix', { link = '@neorg.lists.ordered.1.prefix' }) - hl(0, '@neorg.lists.unordered.2.prefix', { link = '@neorg.lists.ordered.2.prefix' }) - hl(0, '@neorg.lists.unordered.3.prefix', { link = '@neorg.lists.ordered.3.prefix' }) - hl(0, '@neorg.lists.unordered.4.prefix', { link = '@neorg.lists.ordered.4.prefix' }) - hl(0, '@neorg.lists.unordered.5.prefix', { link = '@neorg.lists.ordered.5.prefix' }) - hl(0, '@neorg.lists.unordered.6.prefix', { link = '@neorg.lists.ordered.6.prefix' }) - hl(0, '@neorg.links.file', { link = '@text.uri' }) - - -- IndentBlankLine - hl(0, 'IndentBlanklineChar', { fg = c.blended_purple, bg = 'NONE' }) - hl(0, 'IndentBlanklineContextChar', { fg = c.blended_pink, bg = 'NONE' }) - hl(0, 'IndentBlanklineSpaceChar', { fg = c.purple, bg = 'NONE' }) - hl(0, 'IndentBlanklineContextSpaceChar', { fg = c.pink, bg = 'NONE' }) - - -- Hop - hl(0, 'HopNextKey', { fg = c.pink, bg = 'NONE', bold = true }) - hl(0, 'HopNextKey1', { fg = c.cyan, bg = 'NONE', bold = true }) - hl(0, 'HopUnmatched', { fg = c.comment, bg = 'NONE' }) - - -- Lazy - hl(0, 'LazyH1', { fg = c.purple, bg = c.blended_purple }) - hl(0, 'LazyButtonActive', { link = 'LazyH1' }) - - -- BufferLine - hl(0, 'BufferLineSeparator', { fg = c.bgdark, bg = c.bgdark }) - hl(0, 'BufferLineSeparatorSelected', { fg = c.bgdark, bg = c.bg }) - hl(0, 'BufferLineBufferSelected', { fg = c.purple, bg = 'NONE', bold = true }) - hl(0, 'BufferLineFill', { fg = 'NONE', bg = c.bgdark }) - hl(0, 'BufferLineIndicatorSelected', { fg = c.purple, bg = 'NONE' }) - - -- SymbolsOutline - hl(0, 'FocusedSymbol', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'SymbolsOutlineConnector', { fg = c.comment, bg = 'NONE' }) - - -- MiniCursor - hl(0, 'MiniCursorword', { fg = 'NONE', bg = c.selection }) - - -- MiniCompletion - hl(0, 'MiniCompletionActiveParameter', { link = '@paramter' }) - - -- MiniJump - hl(0, 'MiniJump2dSpot', { fg = c.pink, bg = c.blended_pink }) - hl(0, 'MiniJump2dSpotUnique', { fg = c.purple, bg = c.blended_purple }) - - -- MiniIndent - hl(0, 'MiniIndentscopeSymbol', { fg = c.blended_pink, bg = 'NONE' }) - hl(0, 'MiniIndentscopeSymbolOff', { fg = 'NONE', bg = 'NONE' }) - - -- MiniMap - hl(0, 'MiniMapNormal', { fg = c.comment, bg = c.bgdark }) - hl(0, 'MiniMapSymbolCount', { fg = c.purple, bg = 'NONE' }) - hl(0, 'MiniMapSymbolLine', { fg = c.pink, bg = 'NONE' }) - hl(0, 'MiniMapSymbolView', { fg = c.bgdark, bg = 'NONE' }) - - -- MiniStatusLine - hl(0, 'MiniStatuslineModeNormal', { fg = c.bg, bg = c.purple }) - hl(0, 'MiniStatuslineModeInsert', { fg = c.bg, bg = c.green }) - hl(0, 'MiniStatuslineModeVisual', { fg = c.bg, bg = c.yellow }) - hl(0, 'MiniStatuslineModeReplace', { fg = c.bg, bg = c.red }) - hl(0, 'MiniStatuslineModeCommand', { fg = c.purple, bg = c.blended_purple }) - hl(0, 'MiniStatuslineDevinfo', { fg = c.fg, bg = c.comment }) - hl(0, 'MiniStatuslineFileinfo', { fg = c.fg, bg = c.comment }) - - -- MiniTabLine - hl(0, 'MiniTablineCurrent', { fg = c.fg, bg = c.comment }) - hl(0, 'MiniTablineVisible', { fg = c.fg, bg = c.comment }) - hl(0, 'MiniTablineHidden', { fg = c.comment, bg = c.bg }) - hl(0, 'MiniTablineModifiedCurrent', { link = 'MiniTabLineCurrent' }) - hl(0, 'MiniTablineModifiedVisible', { link = 'MiniTablineVisible' }) - hl(0, 'MiniTablineModifiedHidden', { link = 'MiniTablineHidden' }) - hl(0, 'MiniTablineFill', { link = 'NormalFloat' }) - hl(0, 'MiniTablineTabpagesection', { link = 'NormalFloat' }) - - -- MiniStarter - hl(0, 'MiniStarterCurrent', { link = 'CursorLine' }) - hl(0, 'MiniStarterHeader', { fg = c.red, bg = 'NONE' }) - hl(0, 'MiniStarterFooter', { fg = c.comment, bg = 'NONE' }) - hl(0, 'MiniStarterItem', { fg = c.fg, bg = 'NONE' }) - hl(0, 'MiniStarterItemBullet', { fg = c.cyan, bg = 'NONE' }) - hl(0, 'MiniStarterItemPrefix', { fg = c.cyan, bg = c.blended_cyan, bold = true }) - hl(0, 'MiniStarterSection', { link = 'Title' }) - hl(0, 'MiniStarterQuery', { fg = c.red, bg = c.blended_red, bold = true }) -end - -return theme diff --git a/lua/dracula/utils.lua b/lua/dracula/utils.lua index 6a9715b..1f152fa 100644 --- a/lua/dracula/utils.lua +++ b/lua/dracula/utils.lua @@ -1,113 +1,23 @@ -local M = {} - -function M.get_hl(group_name) - local group = vim.api.nvim_get_hl(0, { name = group_name, link = false }) - - if type(group) == 'table' then - return group +local function to_hex(decimal) + if type(decimal) ~= 'number' then + return decimal end - - return nil + local hex = string.format('#%06x', decimal) + return hex:upper() end -function M.update_highlight_groups(groups) - if not groups then - return +local function nvim_get_hl(name) + local output = vim.api.nvim_get_hl(0, { name = name, link = false }) + + local t = {} + + for key, value in pairs(output) do + t[key] = to_hex(value) end - for group_name, val in pairs(groups) do - local group_val = M.get_hl(group_name) - - if type(group_val) == 'table' then - local value = vim.tbl_extend('force', group_val, val) - - vim.api.nvim_set_hl(0, group_name, value) - end - end + return t end -local function hsl_to_rgb(h, s, l) - local r, g, b = 0, 0, 0 - - if s == 0 then - r, g, b = l, l, l - else - local function hue_to_rgb(p, q, t) - if t < 0 then - t = t + 1 - end - if t > 1 then - t = t - 1 - end - if t < 1 / 6 then - return p + (q - p) * 6 * t - end - if t < 1 / 2 then - return q - end - if t < 2 / 3 then - return p + (q - p) * (2 / 3 - t) * 6 - end - return p - end - - local q = l < 0.5 and l * (1 + s) or l + s - l * s - local p = 2 * l - q - - r = hue_to_rgb(p, q, h + 1 / 3) - g = hue_to_rgb(p, q, h) - b = hue_to_rgb(p, q, h - 1 / 3) - end - - return math.floor(r * 255 + 0.5), math.floor(g * 255 + 0.5), math.floor(b * 255 + 0.5) -end - -local function rgb_to_hsl(r, g, b) - r, g, b = r / 255, g / 255, b / 255 - - local maxval = math.max(r, g, b) - local minval = math.min(r, g, b) - - local h, s, l = 0, 0, (maxval + minval) / 2 - - if maxval ~= minval then - local d = maxval - minval - s = l > 0.5 and d / (2 - maxval - minval) or d / (maxval + minval) - - if maxval == r then - h = (g - b) / d + (g < b and 6 or 0) - elseif maxval == g then - h = (b - r) / d + 2 - else - h = (r - g) / d + 4 - end - - h = h / 6 - end - - return h, s, l -end - -function M.reduce_saturation(color, amount) - -- remove "#" prefix if present - color = color:gsub('^#', '') - - -- split the color into its red, green, and blue components - local r = tonumber(color:sub(1, 2), 16) - local g = tonumber(color:sub(3, 4), 16) - local b = tonumber(color:sub(5, 6), 16) - - -- convert the RGB color to HSL - local h, s, l = rgb_to_hsl(r, g, b) - - -- reduce the saturation by the specified amount - s = s * (1 - amount / 100) - - -- convert the HSL color back to RGB - r, g, b = hsl_to_rgb(h, s, l) - - -- convert the RGB color back to hexadecimal - return string.format('#%02x%02x%02x', r, g, b) -end - -return M +return { + nvim_get_hl = nvim_get_hl, +} diff --git a/lua/lualine/themes/dracula.lua b/lua/lualine/themes/dracula.lua deleted file mode 100644 index a6625ab..0000000 --- a/lua/lualine/themes/dracula.lua +++ /dev/null @@ -1,35 +0,0 @@ -local dracula = require 'dracula' -local colors = dracula.colors - -return { - normal = { - a = { bg = colors.purple, fg = colors.bg, gui = 'bold' }, - b = { bg = colors.comment, fg = colors.fg }, - c = { bg = colors.bgdark, fg = colors.fg }, - }, - insert = { - a = { bg = colors.green, fg = colors.bg, gui = 'bold' }, - b = { bg = colors.comment, fg = colors.fg }, - c = { bg = colors.bgdark, fg = colors.fg }, - }, - visual = { - a = { bg = colors.yellow, fg = colors.bg, gui = 'bold' }, - b = { bg = colors.comment, fg = colors.fg }, - c = { bg = colors.bgdark, fg = colors.fg }, - }, - replace = { - a = { bg = colors.red, fg = colors.bg, gui = 'bold' }, - b = { bg = colors.comment, fg = colors.fg }, - c = { bg = colors.bgdark, fg = colors.fg }, - }, - command = { - a = { bg = colors.blended_purple, fg = colors.purple, gui = 'bold' }, - b = { bg = colors.comment, fg = colors.fg }, - c = { bg = colors.bgdark, fg = colors.fg }, - }, - inactive = { - a = { bg = colors.bgdark, fg = colors.fg, gui = 'bold' }, - b = { bg = colors.comment, fg = colors.fg }, - c = { bg = colors.bgdark, fg = colors.fg }, - }, -} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..bcee9b5 --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +{pkgs ? import {}}: +pkgs.mkShell { + nativeBuildInputs = with pkgs.buildPackages; [luajitPackages.vusted stylua]; +} \ No newline at end of file diff --git a/tests/load_spec.lua b/tests/load_spec.lua new file mode 100644 index 0000000..fd117eb --- /dev/null +++ b/tests/load_spec.lua @@ -0,0 +1,29 @@ +local nvim_get_hl = require('dracula.utils').nvim_get_hl + +describe('dracula.load', function() + setup(function() + vim.cmd.colorscheme 'dracula' + end) + + test('name', function() + local expected = 'dracula' + assert.equal(expected, vim.g.colors_name) + end) + + test('palette', function() + local colors = require 'dracula.palette' + assert.True(type(colors) == 'table') + end) + + test('set highlight', function() + local string = nvim_get_hl 'String' + local colors = require 'dracula.palette' + local expected = colors.yellow + assert.equal(expected, string.fg) + end) + + test('default config', function() + local config = require 'dracula.config' + assert.True(type(config) == 'table') + end) +end) diff --git a/tests/setup_spec.lua b/tests/setup_spec.lua new file mode 100644 index 0000000..5f2ee34 --- /dev/null +++ b/tests/setup_spec.lua @@ -0,0 +1,44 @@ +local nvim_get_hl = require('dracula.utils').nvim_get_hl +local colors = require 'dracula.palette' + +describe('dracula.setup', function() + setup(function() + require('dracula').setup { + transparent = true, + on_colors = function() + return { + yellow = '#ffffff', + } + end, + on_highlight = function() + return { + Type = { bg = '#ffffff' }, + } + end, + } + vim.cmd 'colorscheme dracula' + end) + + test('transparent', function() + local normal = nvim_get_hl 'Normal' + assert.falsy(normal.bg) + end) + + test('on_colors', function() + local expected = nvim_get_hl('Function').fg + assert.True(expected ~= colors.yellow) + end) + + test('on_highlight', function() + local user_group = nvim_get_hl 'Type' + local expected = { fg = colors.cyan, bg = '#FFFFFF' } + assert.are.same(expected, user_group) + end) + + test('plugins', function() + local treesitter = nvim_get_hl '@variable' + print(vim.inspect(treesitter), 'treesitter') + assert.equals(colors.base0, treesitter.fg) + assert.True(colors.base0 == treesitter.fg) + end) +end)