diff --git a/.luacheckrc b/.luacheckrc index e67ca30..02d32c2 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,3 +1,2 @@ -globals = { - "vim", -} +globals = {"vim"} +max_comment_line_length = false diff --git a/CHANGELOG.md b/CHANGELOG.md index a9749ee..e0a23a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,14 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- `Linting` Github Action init -- `Makefile, .lua-format, .luacheckrc` init -- format .lua code with (lua-format)[https://github.com/Koihik/LuaFormatter] -- `kitty` tabs color changed +- **Warning** on `vim.g` configuration +- Configure plugin in lua using `require('onedark').setup({})` **[fix monsonjeremy/onedark.nvim#5]** +- Minimal config example added inside [README.md#minimal](./README.md#minimal) +- Linting Github Action init +- Format .lua code with [lua-format](https://github.com/Koihik/LuaFormatter) +- **kitty tab** colors are changed +- Init: `Makefile, .lua-format, .luacheckrc` ### Changed +- Removed function `require('onedark').colorscheme()` +- Colorscheme **autoload removed** from `colors/onedark.vim` - **VertSplit** & **Inactive StatusLine** `fg` color changed to `bg_visual` +- StatusLine bug note inside [README.md#usage](./README.md#-usage) +- Configuration docs updated inside [README.md#configuration](./README.md#-configuration) ## [v0.0.1] - 14 June 2021 diff --git a/README.md b/README.md index 916da9b..44271ac 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,19 @@ +

- onedark.nvim + onedark.nvim +
+ Atom's iconic One Dark theme for Neovim, written in Lua

+

- Atom's iconic One Dark theme for Neovim, written in Lua -

- -

- De-attach fork of monsonjeremy/onedark.nvim + + + monsonjeremy/onedark.nvim + + + GitHub Action Linting +

## ✨ Features @@ -63,16 +69,18 @@ Enable the colorscheme: ```vim " Vim Script -colorscheme onedark +lua require('onedark').setup() ``` ```lua -- Lua -vim.cmd[[colorscheme onedark]] +require('onedark').setup() ``` To enable the `onedark` theme for `Lualine`, simply specify it in your lualine settings: +> **📝 NOTE:** Set `lualine` configuration **before** `onedark`. + ```lua require('lualine').setup { options = { @@ -92,42 +100,48 @@ To enable the `onedark` colorscheme for `Lightline`: let g:lightline = {'colorscheme': 'onedark'} ``` +```lua +-- Lua +vim.g.lightline = {colorscheme = "onedark"} +``` + ## ⚙️ Configuration -> ❗️ configuration needs to be set **BEFORE** loading the color scheme with `colorscheme onedark` - -| Option | Default | Description | -| -------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| onedark_italic_comments | `true` | Make comments italic | -| onedark_italic_keywords | `true` | Make keywords italic | -| onedark_italic_functions | `false` | Make functions italic | -| onedark_italic_variables | `false` | Make variables and identifiers italic | -| onedark_transparent | `false` | Enable this to disable setting the background color | -| onedark_hide_inactive_statusline | `false` | Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. | -| onedark_sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` | -| onedark_dark_sidebar | `true` | Sidebar like windows like `NvimTree` get a darker background | -| onedark_dark_float | `true` | Float windows like the lsp diagnostics windows get a darker background. | -| onedark_colors | `{}` | You can override specific color groups to use other groups or a hex color | +| Option | Default | Description | +| ---------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| commentStyle | `italic` | Highlight style for comments (check `:help highlight-args` for options) | +| keywordStyle | `italic` | Highlight style for keywords (check `:help highlight-args` for options) | +| functionStyle | `NONE` | Highlight style for functions (check `:help highlight-args` for options) | +| variableStyle | `NONE` | Highlight style for variables and identifiers (check `:help highlight-args` for options) | +| transparent | `false` | Enable this to disable setting the background color | +| hideInactiveStatusline | `false` | Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. | +| sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `{"qf", "vista_kind", "terminal", "packer"}` | +| darkSidebar | `true` | Sidebar like windows like `NvimTree` get a darker background | +| darkFloat | `true` | Float windows like the lsp diagnostics windows get a darker background. | +| colors | `{}` | You can override specific color groups to use other groups or a hex color | ```lua -- Example config in Lua -vim.g.onedark_italic_functions = true -vim.g.onedark_sidebars = { "qf", "vista_kind", "terminal", "packer" } - --- Change the "hint" color to the "orange" color, and make the "error" color bright red -vim.g.onedark_colors = { hint = "orange", error = "#ff0000" } +require("onedark").setup({ + functionStyle = "italic", + sidebars = {"qf", "vista_kind", "terminal", "packer"}, --- Load the colorscheme -vim.cmd[[colorscheme onedark]] + -- Change the "hint" color to the "orange" color, and make the "error" color bright red + colors = {hint = "orange", error = "#ff0000"} +}) ``` ```vim " Example config in VimScript -let g:onedark_italic_functions = 1 -let g:onedark_sidebars = [ "qf", "vista_kind", "terminal", "packer" ] - -" Load the colorscheme -colorscheme onedark +lua << EOF +require("onedark").setup({ + functionStyle = "italic", + sidebars = {"qf", "vista_kind", "terminal", "packer"}, + + -- Change the "hint" color to the "orange" color, and make the "error" color bright red + colors = {hint = "orange", error = "#ff0000"} +}) +EOF ``` ### Making `undercurls` work properly in **Tmux** @@ -143,7 +157,7 @@ set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{25 ## 🌈 Extras -> To generate the configs `:luafile /lua/onedark/extra/init.lua` +> To generate the configs `make extra` Extra color configs for **Kitty**, and **Alacritty** can be found in [extras](extras/). To use them, refer to their respective documentation. @@ -167,11 +181,14 @@ Extra color configs for **Kitty**, and **Alacritty** can be found in [extras](ex ### Normal -``` -vim.g.onedark_italic_comments = false -vim.g.onedark_italic_keywords = false -vim.g.onedark_italic_functions = false -vim.g.onedark_italic_variables = false +```lua +require("onedark").setup({ + commentStyle = "NONE", + keywordStyle = "NONE", + functionStyle = "NONE", + variableStyle = "NONE" + -- ... your onedark config +}) ```

@@ -180,17 +197,35 @@ vim.g.onedark_italic_variables = false ### Italic -``` -vim.g.onedark_italic_comments = true -vim.g.onedark_italic_keywords = true -vim.g.onedark_italic_functions = true -vim.g.onedark_italic_variables = true +```lua +require("onedark").setup({ + commentStyle = "italic", + keywordStyle = "italic", + functionStyle = "italic", + variableStyle = "italic" + -- ... your onedark config +}) ```

Italic fonts

+### Minimal + +```lua +require("onedark").setup({ + hideInactiveStatusline = true, + darkSidebar = false, + darkFloat = false + -- ... your onedark config +}) +``` + +

+ Minimal +

+ ### Telescope

@@ -204,8 +239,6 @@ vim.g.onedark_italic_variables = true - [Wallpaper](https://hdqwalls.com/big-sur-4k-wallpaper) - [dotfiles](https://github.com/ful1e5/dotfiles) - - ## Support @@ -217,7 +250,6 @@ vim.g.onedark_italic_variables = true Follow me on **[Twitter](https://twitter.com/ful1e5)** -

(◣_◢)

diff --git a/colors/onedark.vim b/colors/onedark.vim index 982b367..b6e5be8 100644 --- a/colors/onedark.vim +++ b/colors/onedark.vim @@ -5,5 +5,3 @@ lua package.loaded['onedark.theme'] = nil lua package.loaded['onedark.colors'] = nil lua package.loaded['onedark.util'] = nil lua package.loaded['onedark.config'] = nil - -lua require('onedark').colorscheme() diff --git a/extras/alacritty_onedark_.yml b/extras/alacritty_onedark_.yml index 90dabd4..d6697b5 100644 --- a/extras/alacritty_onedark_.yml +++ b/extras/alacritty_onedark_.yml @@ -30,5 +30,3 @@ colors: indexed_colors: - { index: 16, color: '0xd19a66' } - { index: 17, color: '0xf65866' } - - \ No newline at end of file diff --git a/extras/kitty_onedark_.conf b/extras/kitty_onedark_.conf index 5ba9e7e..bf1fdf4 100644 --- a/extras/kitty_onedark_.conf +++ b/extras/kitty_onedark_.conf @@ -1,40 +1,39 @@ - # onedark colors for Kitty - - background #282c34 - foreground #abb2bf - selection_background #393f4a - selection_foreground #abb2bf - url_color #98c379 - cursor #abb2bf - - # Tabs - active_tab_background #61afef - active_tab_foreground #282c34 - inactive_tab_background #abb2bf - inactive_tab_foreground #282c34 - #tab_bar_background #20232A - - # normal - color0 #20232A - color1 #e86671 - color2 #98c379 - color3 #e0af68 - color4 #61afef - color5 #c678dd - color6 #56b6c2 - color7 #798294 - - # bright - color8 #5c6370 - color9 #e86671 - color10 #98c379 - color11 #e0af68 - color12 #61afef - color13 #c678dd - color14 #56b6c2 - color15 #abb2bf - - # extended colors - color16 #d19a66 - color17 #f65866 - \ No newline at end of file +# onedark colors for Kitty + +background #282c34 +foreground #abb2bf +selection_background #393f4a +selection_foreground #abb2bf +url_color #98c379 +cursor #abb2bf + +# Tabs +active_tab_background #61afef +active_tab_foreground #282c34 +inactive_tab_background #abb2bf +inactive_tab_foreground #282c34 +#tab_bar_background #20232A + +# normal +color0 #20232A +color1 #e86671 +color2 #98c379 +color3 #e0af68 +color4 #61afef +color5 #c678dd +color6 #56b6c2 +color7 #798294 + +# bright +color8 #5c6370 +color9 #e86671 +color10 #98c379 +color11 #e0af68 +color12 #61afef +color13 #c678dd +color14 #56b6c2 +color15 #abb2bf + +# extended colors +color16 #d19a66 +color17 #f65866 diff --git a/lua/lualine/themes/onedark.lua b/lua/lualine/themes/onedark.lua index 564c297..ef53531 100644 --- a/lua/lualine/themes/onedark.lua +++ b/lua/lualine/themes/onedark.lua @@ -1,5 +1,5 @@ -local config = require("onedark.config") -local colors = require("onedark.colors").setup(config) +local configModule = require("onedark.config") +local colors = require("onedark.colors").setup(configModule.config) local onedark = {} diff --git a/lua/onedark/colors.lua b/lua/onedark/colors.lua index 11643ef..ff0dc5c 100644 --- a/lua/onedark/colors.lua +++ b/lua/onedark/colors.lua @@ -1,17 +1,16 @@ local util = require("onedark.util") +local configModule = require("onedark.config") local M = {} ---@param config Config ---@return ColorScheme function M.setup(config) - config = config or require("onedark.config") + config = config or configModule.config -- Color Palette ---@class ColorScheme - local colors = {} - - colors = { + local colors = { none = "NONE", bg = "#282c34", bg2 = "#21252b", diff --git a/lua/onedark/config.lua b/lua/onedark/config.lua index 2a419c7..ee051d6 100644 --- a/lua/onedark/config.lua +++ b/lua/onedark/config.lua @@ -1,14 +1,23 @@ ---@class Config local config +local vimConfig = false + -- shim vim for kitty and other generators vim = vim or {g = {}, o = {}} local function opt(key, default) key = "onedark_" .. key - if vim.g[key] == nil then return default end - if vim.g[key] == 0 then return false end - return vim.g[key] + if vim.g[key] == nil then + return default + else + vimConfig = true + if vim.g[key] == 0 then + return false + else + return vim.g[key] + end + end end config = { @@ -26,4 +35,17 @@ config = { transform_colors = false } -return config +---@param userConfig Config +local function applyConfiguration(userConfig) + for key, value in pairs(userConfig) do + if value ~= nil then + if config[key] ~= nil then + config[key] = value + else + error("ful1e5/onedark: Option " .. key .. " does not exist") -- luacheck: ignore + end + end + end +end + +return {config = config, vimConfig = vimConfig, applyConfiguration = applyConfiguration} diff --git a/lua/onedark/extra/alacritty.lua b/lua/onedark/extra/alacritty.lua index 6272a1b..090f583 100644 --- a/lua/onedark/extra/alacritty.lua +++ b/lua/onedark/extra/alacritty.lua @@ -1,9 +1,10 @@ local util = require("onedark.util") +local configModule = require("onedark.config") local M = {} function M.alacritty(config) - config = config or require("onedark.config") + config = config or configModule.config config.transform_colors = true local colors = require("onedark.colors").setup(config) @@ -45,8 +46,7 @@ colors: indexed_colors: - { index: 16, color: '${orange}' } - { index: 17, color: '${red1}' } - - ]], alacrittyColors) +]], alacrittyColors) return alacritty end diff --git a/lua/onedark/extra/init.lua b/lua/onedark/extra/init.lua index d87608d..4998608 100644 --- a/lua/onedark/extra/init.lua +++ b/lua/onedark/extra/init.lua @@ -1,6 +1,6 @@ package.path = "./lua/?/init.lua;./lua/?.lua" -local config = require("onedark.config") +local configModule = require("onedark.config") local function write(str, fileName) print("[write] extra/" .. fileName) @@ -12,5 +12,5 @@ end local extras = {kitty = "conf", alacritty = "yml"} for extra, ext in pairs(extras) do local plugin = require("onedark.extra." .. extra) - write(plugin[extra](config), extra .. "_onedark_" .. "." .. ext) + write(plugin[extra](configModule.config), extra .. "_onedark_" .. "." .. ext) end diff --git a/lua/onedark/extra/kitty.lua b/lua/onedark/extra/kitty.lua index 8451102..c755893 100644 --- a/lua/onedark/extra/kitty.lua +++ b/lua/onedark/extra/kitty.lua @@ -1,53 +1,54 @@ local util = require("onedark.util") +local configModule = require("onedark.config") local M = {} function M.kitty(config) - config = config or require("onedark.config") + config = config or configModule.config config.transform_colors = true local colors = require("onedark.colors").setup(config) local kitty = util.template([[ - # onedark colors for Kitty - - background ${bg} - foreground ${fg} - selection_background ${bg_visual} - selection_foreground ${fg} - url_color ${green} - cursor ${fg} - - # Tabs - active_tab_background ${blue} - active_tab_foreground ${bg} - inactive_tab_background ${fg} - inactive_tab_foreground ${bg} - #tab_bar_background ${black} - - # normal - color0 ${black} - color1 ${red} - color2 ${green} - color3 ${yellow} - color4 ${blue} - color5 ${purple} - color6 ${cyan} - color7 ${fg_dark} - - # bright - color8 ${fg_gutter} - color9 ${red} - color10 ${green} - color11 ${yellow} - color12 ${blue} - color13 ${purple} - color14 ${cyan} - color15 ${fg} - - # extended colors - color16 ${orange} - color17 ${red1} - ]], colors) +# onedark colors for Kitty + +background ${bg} +foreground ${fg} +selection_background ${bg_visual} +selection_foreground ${fg} +url_color ${green} +cursor ${fg} + +# Tabs +active_tab_background ${blue} +active_tab_foreground ${bg} +inactive_tab_background ${fg} +inactive_tab_foreground ${bg} +#tab_bar_background ${black} + +# normal +color0 ${black} +color1 ${red} +color2 ${green} +color3 ${yellow} +color4 ${blue} +color5 ${purple} +color6 ${cyan} +color7 ${fg_dark} + +# bright +color8 ${fg_gutter} +color9 ${red} +color10 ${green} +color11 ${yellow} +color12 ${blue} +color13 ${purple} +color14 ${cyan} +color15 ${fg} + +# extended colors +color16 ${orange} +color17 ${red1} +]], colors) return kitty end diff --git a/lua/onedark/init.lua b/lua/onedark/init.lua index 82f681d..9752b2e 100644 --- a/lua/onedark/init.lua +++ b/lua/onedark/init.lua @@ -1,10 +1,21 @@ local util = require("onedark.util") local theme = require("onedark.theme") +local configModule = require("onedark.config") -local M = {} +local function setup(userConfig) + -- Warning, If config set inside 'vim.g' + if configModule.vimConfig then + vim.schedule(function() + vim.api.nvim_err_writeln( + [[ful1e5/onedark: onedark will stop supporting vimscript soon, change your config to lua or wrap it around lua << EOF ... EOF]]) -- luacheck: ignore + end) + end -function M.colorscheme() - util.load(theme.setup()) + -- Applying user configuration + if userConfig then configModule.applyConfiguration(userConfig) end + + -- Load colorscheme + util.load(theme.setup(configModule.config)) end -return M +return {setup = setup} diff --git a/lua/onedark/theme.lua b/lua/onedark/theme.lua index 8799ec8..2d612d2 100644 --- a/lua/onedark/theme.lua +++ b/lua/onedark/theme.lua @@ -1,12 +1,13 @@ local util = require("onedark.util") local colors = require("onedark.colors") +local configModule = require("onedark.config") local M = {} ---@param config Config ---@return Theme function M.setup(config) - config = config or require("onedark.config") + config = config or configModule.config ---@class Theme local theme = {} @@ -14,7 +15,7 @@ function M.setup(config) theme.colors = colors.setup(config) local c = theme.colors - theme.base = { + theme.base = { -- luacheck: ignore Comment = {fg = c.fg_gutter, style = config.commentStyle}, -- any comment ColorColumn = {bg = c.bg_visual}, -- used for the columns set with 'colorcolumn' Conceal = {fg = c.fg_gutter}, -- placeholder characters substituted for concealed text (see 'conceallevel') @@ -325,7 +326,7 @@ function M.setup(config) theme.base.StatusLineNC = inactive -- LuaLine - for _, section in ipairs({"a", "b", "c"}) do + for _, section in pairs({"a", "b", "c"}) do theme.plugins["lualine_" .. section .. "_inactive"] = inactive end end