From 2aa32074585f93b20149ce3cc21040b0a89662dc Mon Sep 17 00:00:00 2001 From: babchoo Date: Thu, 6 Jan 2022 12:55:32 +0900 Subject: [PATCH] Make colors customizable --- README.md | 46 ++++++++++++++++++++++++++++++------ lua/dracula/init.lua | 55 +++++++++++++++++++++++--------------------- 2 files changed, 68 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 9ddefc7..2e1ea2d 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,17 @@

Dracula colorscheme for NEOVIM written in Lua

- ![TypeScript and NvimTree](./assets/1.png) ![Lua](./assets/2.png) ## ✔️ Requirements + - Neovim >= 0.5.0 - Treesitter (optional) ## #️ Supported Plugins + - [LSP](https://github.com/neovim/nvim-lspconfig) - [Treesitter](https://github.com/nvim-treesitter/nvim-treesitter) - [nvim-compe](https://github.com/hrsh7th/nvim-compe) @@ -28,15 +29,16 @@ Install via package manager - ```lua - -- Using Packer: - use 'Mofiqul/dracula.nvim' - ``` +```lua +-- Using Packer: +use 'Mofiqul/dracula.nvim' +``` ```vim " Using Vim-Plug: Plug 'Mofiqul/dracula.nvim' ``` + ## 🚀 Usage ```lua @@ -50,14 +52,15 @@ colorscheme dracula ``` If you are using [`lualine`](https://github.com/hoob3rt/lualine.nvim), you can also enable the provided theme: + > Make sure to set theme as 'dracula-nvim' as dracula already exists in lualine built in themes ```lua require('lualine').setup { options = { - -- ... + -- ... theme = 'dracula-nvim' - -- ... + -- ... } }' ``` @@ -65,7 +68,33 @@ require('lualine').setup { ## 🔧 Configuration If you're using lua + ```lua +-- customize dracula color palette +vim.g.dracula_colors = { + bg = "#282A36", + fg = "#F8F8F2", + selection = "#44475A", + comment = "#6272A4", + red = "#FF5555", + orange = "#FFB86C", + yellow = "#F1FA8C", + green = "#50fa7b", + purple = "#BD93F9", + cyan = "#8BE9FD", + pink = "#FF79C6", + bright_red = "#FF6E6E", + bright_green = "#69FF94", + bright_yellow = "#FFFFA5", + bright_blue = "#D6ACFF", + bright_magenta = "#FF92DF", + bright_cyan = "#A4FFFF", + bright_white = "#FFFFFF", + menu = "#21222C", + visual = "#3E4452", + gutter_fg = "#4B5263", + nontext = "#3B4048", +} -- show the '~' characters after the end of buffers vim.g.dracula_show_end_of_buffer = true -- use transparent background @@ -75,6 +104,7 @@ vim.g.dracula_lualine_bg_color = "#44475a" ``` The same works in viml + ```vim " show the '~' characters after the end of buffers let g:dracula_show_end_of_buffer = 1 @@ -85,9 +115,11 @@ let g:dracula_lualine_bg_color = "#44475a" ``` ## 🎨 Importing colors for other usage + ```lua require('dracula').colors() ``` + This will return the folowing table ![colors](./assets/colors.png) diff --git a/lua/dracula/init.lua b/lua/dracula/init.lua index 097d3f7..74bd543 100644 --- a/lua/dracula/init.lua +++ b/lua/dracula/init.lua @@ -2,33 +2,36 @@ local M = {} +local DEFAULT_COLORS = { + bg = "#282A36", + fg = "#F8F8F2", + selection = "#44475A", + comment = "#6272A4", + red = "#FF5555", + orange = "#FFB86C", + yellow = "#F1FA8C", + green = "#50fa7b", + purple = "#BD93F9", + cyan = "#8BE9FD", + pink = "#FF79C6", + bright_red = "#FF6E6E", + bright_green = "#69FF94", + bright_yellow = "#FFFFA5", + bright_blue = "#D6ACFF", + bright_magenta = "#FF92DF", + bright_cyan = "#A4FFFF", + bright_white = "#FFFFFF", + menu = "#21222C", + visual = "#3E4452", + gutter_fg = "#4B5263", + nontext = "#3B4048", + white = "#ABB2BF", +} + +local colors = vim.tbl_deep_extend('force', DEFAULT_COLORS, vim.g.dracula_colors or {}) + M.colors = function() - return { - bg = "#282A36", - fg = "#F8F8F2", - selection = "#44475A", - comment = "#6272A4", - red = "#FF5555", - orange = "#FFB86C", - yellow = "#F1FA8C", - green = "#50fa7b", - purple = "#BD93F9", - cyan = "#8BE9FD", - pink = "#FF79C6", - bright_red = "#FF6E6E", - bright_green = "#69FF94", - bright_yellow = "#FFFFA5", - bright_blue = "#D6ACFF", - bright_magenta = "#FF92DF", - bright_cyan = "#A4FFFF", - bright_white = "#FFFFFF", - menu = "#21222C", - visual = "#3E4452", - gutter_fg = "#4B5263", - nontext = "#3B4048", - white = "#ABB2BF", - black = "#191A21" - } + return colors end M.apply_term_colors = function(colors) -- 2.30.2