Make colors customizable
authorbabchoo <babchoo@protonmail.com>
Thu, 6 Jan 2022 03:55:32 +0000 (12:55 +0900)
committerbabchoo <babchoo@protonmail.com>
Thu, 6 Jan 2022 04:19:37 +0000 (13:19 +0900)
README.md
lua/dracula/init.lua

index 9ddefc71a271e88169ce5ad76b9f0b0fe2d9e0b3..2e1ea2dc7062b7d8abdd6e6b7cc1ccb87196f662 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,16 +2,17 @@
 
 <p align="center"><a href="https://draculatheme.com/">Dracula</a> colorscheme for <a href="https://neovim.io/">NEOVIM</a> written in Lua</p>
 
-
 ![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)
 
 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)
index 097d3f7404edb083c68800c1837d06fea7116a5e..74bd543275b939673adc0e7d27dcd2028cc71e27 100644 (file)
@@ -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)