From f35711a4f59c92137248ab72817552273a2ae537 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 15 Jun 2021 17:17:12 +0530 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=92=85=20Lua=20code=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .lua-format | 4 ++ lua/onedark/config.lua | 8 +-- lua/onedark/extra/alacritty.lua | 12 ++--- lua/onedark/extra/kitty.lua | 8 +-- lua/onedark/hsluv.lua | 66 +++++++---------------- lua/onedark/util.lua | 95 +++++++++++---------------------- 6 files changed, 60 insertions(+), 133 deletions(-) create mode 100644 .lua-format diff --git a/.lua-format b/.lua-format new file mode 100644 index 0000000..17678ee --- /dev/null +++ b/.lua-format @@ -0,0 +1,4 @@ +column_limit: 90 +indent_width: 2 +single_quote_to_double_quote: true +keep_simple_function_one_line: false diff --git a/lua/onedark/config.lua b/lua/onedark/config.lua index e6bda84..2a419c7 100644 --- a/lua/onedark/config.lua +++ b/lua/onedark/config.lua @@ -6,12 +6,8 @@ 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 + if vim.g[key] == nil then return default end + if vim.g[key] == 0 then return false end return vim.g[key] end diff --git a/lua/onedark/extra/alacritty.lua b/lua/onedark/extra/alacritty.lua index 8d24cc4..6272a1b 100644 --- a/lua/onedark/extra/alacritty.lua +++ b/lua/onedark/extra/alacritty.lua @@ -9,14 +9,10 @@ function M.alacritty(config) local alacrittyColors = {} for k, v in pairs(colors) do - if type(v) == "string" then - alacrittyColors[k] = v:gsub("^#", "0x") - end + if type(v) == "string" then alacrittyColors[k] = v:gsub("^#", "0x") end end - local alacritty = - util.template( - [[ + local alacritty = util.template([[ # onedark Alacritty Colors colors: # Default colors @@ -50,9 +46,7 @@ colors: - { index: 16, color: '${orange}' } - { index: 17, color: '${red1}' } - ]], - alacrittyColors - ) + ]], alacrittyColors) return alacritty end diff --git a/lua/onedark/extra/kitty.lua b/lua/onedark/extra/kitty.lua index 2636b24..60c8fca 100644 --- a/lua/onedark/extra/kitty.lua +++ b/lua/onedark/extra/kitty.lua @@ -7,9 +7,7 @@ function M.kitty(config) config.transform_colors = true local colors = require("onedark.colors").setup(config) - local kitty = - util.template( - [[ + local kitty = util.template([[ # onedark colors for Kitty background ${bg} @@ -49,9 +47,7 @@ function M.kitty(config) # extended colors color16 ${orange} color17 ${red1} - ]], - colors - ) + ]], colors) return kitty end diff --git a/lua/onedark/hsluv.lua b/lua/onedark/hsluv.lua index c5ad61e..86342df 100644 --- a/lua/onedark/hsluv.lua +++ b/lua/onedark/hsluv.lua @@ -18,8 +18,7 @@ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE A NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] -local hsluv = {} +]] local hsluv = {} local hexChars = "0123456789abcdef" @@ -62,9 +61,7 @@ hsluv.max_safe_chroma_for_l = function(l) for i = 1, 6 do local length = distance_line_from_origin(bounds[i]) - if length >= 0 then - min = math.min(min, length) - end + if length >= 0 then min = math.min(min, length) end end return min end @@ -77,18 +74,14 @@ hsluv.max_safe_chroma_for_lh = function(l, h) for i = 1, 6 do local bound = bounds[i] local length = length_of_ray_until_intersect(hrad, bound) - if length >= 0 then - min = math.min(min, length) - end + if length >= 0 then min = math.min(min, length) end end return min end hsluv.dot_product = function(a, b) local sum = 0 - for i = 1, 3 do - sum = sum + a[i] * b[i] - end + for i = 1, 3 do sum = sum + a[i] * b[i] end return sum end @@ -117,10 +110,11 @@ hsluv.xyz_to_rgb = function(tuple) end hsluv.rgb_to_xyz = function(tuple) - local rgbl = {hsluv.to_linear(tuple[1]), hsluv.to_linear(tuple[2]), hsluv.to_linear(tuple[3])} + local rgbl = { + hsluv.to_linear(tuple[1]), hsluv.to_linear(tuple[2]), hsluv.to_linear(tuple[3]) + } return { - hsluv.dot_product(hsluv.minv[1], rgbl), - hsluv.dot_product(hsluv.minv[2], rgbl), + hsluv.dot_product(hsluv.minv[1], rgbl), hsluv.dot_product(hsluv.minv[2], rgbl), hsluv.dot_product(hsluv.minv[3], rgbl) } end @@ -155,9 +149,7 @@ hsluv.xyz_to_luv = function(tuple) varV = 0 end local L = hsluv.y_to_l(Y) - if L == 0 then - return {0, 0, 0} - end + if L == 0 then return {0, 0, 0} end return {L, 13 * L * (varU - hsluv.refU), 13 * L * (varV - hsluv.refV)} end @@ -165,9 +157,7 @@ hsluv.luv_to_xyz = function(tuple) local L = tuple[1] local U = tuple[2] local V = tuple[3] - if L == 0 then - return {0, 0, 0} - end + if L == 0 then return {0, 0, 0} end local varU = U / (13 * L) + hsluv.refU local varV = V / (13 * L) + hsluv.refV local Y = hsluv.l_to_y(L) @@ -185,9 +175,7 @@ hsluv.luv_to_lch = function(tuple) H = 0 else H = math.atan2(V, U) * 180.0 / 3.1415926535897932 - if H < 0 then - H = 360 + H - end + if H < 0 then H = 360 + H end end return {L, C, H} end @@ -203,12 +191,8 @@ hsluv.hsluv_to_lch = function(tuple) local H = tuple[1] local S = tuple[2] local L = tuple[3] - if L > 99.9999999 then - return {100, 0, H} - end - if L < 0.00000001 then - return {0, 0, H} - end + if L > 99.9999999 then return {100, 0, H} end + if L < 0.00000001 then return {0, 0, H} end return {L, hsluv.max_safe_chroma_for_lh(L, H) / 100 * S, H} end @@ -217,12 +201,8 @@ hsluv.lch_to_hsluv = function(tuple) local C = tuple[2] local H = tuple[3] local max_chroma = hsluv.max_safe_chroma_for_lh(L, H) - if L > 99.9999999 then - return {H, 0, 100} - end - if L < 0.00000001 then - return {H, 0, 0} - end + if L > 99.9999999 then return {H, 0, 100} end + if L < 0.00000001 then return {H, 0, 0} end return {H, C / max_chroma * 100, L} end @@ -231,12 +211,8 @@ hsluv.hpluv_to_lch = function(tuple) local H = tuple[1] local S = tuple[2] local L = tuple[3] - if L > 99.9999999 then - return {100, 0, H} - end - if L < 0.00000001 then - return {0, 0, H} - end + if L > 99.9999999 then return {100, 0, H} end + if L < 0.00000001 then return {0, 0, H} end return {L, hsluv.max_safe_chroma_for_l(L) / 100 * S, H} end @@ -244,12 +220,8 @@ hsluv.lch_to_hpluv = function(tuple) local L = tuple[1] local C = tuple[2] local H = tuple[3] - if L > 99.9999999 then - return {H, 0, 100} - end - if L < 0.00000001 then - return {H, 0, 0} - end + if L > 99.9999999 then return {H, 0, 100} end + if L < 0.00000001 then return {H, 0, 0} end return {H, C / hsluv.max_safe_chroma_for_l(L) * 100, L} end diff --git a/lua/onedark/util.lua b/lua/onedark/util.lua index bd5efe0..52823ce 100644 --- a/lua/onedark/util.lua +++ b/lua/onedark/util.lua @@ -13,7 +13,8 @@ local function hexToRgb(hex_str) local pat = "^#(" .. hex .. ")(" .. hex .. ")(" .. hex .. ")$" hex_str = string.lower(hex_str) - assert(string.find(hex_str, pat) ~= nil, "hex_to_rgb: invalid hex_str: " .. tostring(hex_str)) + assert(string.find(hex_str, pat) ~= nil, + "hex_to_rgb: invalid hex_str: " .. tostring(hex_str)) local r, g, b = string.match(hex_str, pat) return {tonumber(r, 16), tonumber(g, 16), tonumber(b, 16)} @@ -44,9 +45,7 @@ end function util.brighten(color, percentage) local hsl = hsluv.hex_to_hsluv(color) local larpSpace = 100 - hsl[3] - if percentage < 0 then - larpSpace = hsl[3] - end + if percentage < 0 then larpSpace = hsl[3] end hsl[3] = hsl[3] + larpSpace * percentage return hsluv.hsluv_to_hex(hsl) end @@ -55,9 +54,7 @@ function util.invertColor(color) if color ~= "NONE" then local hsl = hsluv.hex_to_hsluv(color) hsl[3] = 100 - hsl[3] - if hsl[3] < 40 then - hsl[3] = hsl[3] + (100 - hsl[3]) * 0.3 - end + if hsl[3] < 40 then hsl[3] = hsl[3] + (100 - hsl[3]) * 0.3 end return hsluv.hsluv_to_hex(hsl) end return color @@ -73,26 +70,16 @@ function util.randomColor(color) end function util.getColor(color) - if vim.o.background == "dark" then - return color - end - if not util.colorCache[color] then - util.colorCache[color] = util.invertColor(color) - end + if vim.o.background == "dark" then return color end + if not util.colorCache[color] then util.colorCache[color] = util.invertColor(color) end return util.colorCache[color] end -- local ns = vim.api.nvim_create_namespace("onedark") function util.highlight(group, color) - if color.fg then - util.colorsUsed[color.fg] = true - end - if color.bg then - util.colorsUsed[color.bg] = true - end - if color.sp then - util.colorsUsed[color.sp] = true - end + if color.fg then util.colorsUsed[color.fg] = true end + if color.bg then util.colorsUsed[color.bg] = true end + if color.sp then util.colorsUsed[color.sp] = true end local style = color.style and "gui=" .. color.style or "gui=NONE" local fg = color.fg and "guifg=" .. util.getColor(color.fg) or "guifg=NONE" @@ -146,9 +133,11 @@ function util.autocmds(config) end for _, sidebar in ipairs(config.sidebars) do if sidebar == "terminal" then - vim.cmd([[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]]) + vim.cmd( + [[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]]) else - vim.cmd([[ autocmd FileType ]] .. sidebar .. [[ setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]]) + vim.cmd([[ autocmd FileType ]] .. sidebar .. + [[ setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]]) end end vim.cmd([[augroup end]]) @@ -161,18 +150,13 @@ end ---@param str string template string ---@param table table key value pairs to replace in the string function util.template(str, table) - return (str:gsub( - "($%b{})", - function(w) - return table[w:sub(3, -2)] or w - end - )) + return (str:gsub("($%b{})", function(w) + return table[w:sub(3, -2)] or w + end)) end function util.syntax(syntax) - for group, colors in pairs(syntax) do - util.highlight(group, colors) - end + for group, colors in pairs(syntax) do util.highlight(group, colors) end end ---@param colors ColorScheme @@ -212,22 +196,16 @@ function util.terminal(colors) end function util.light_colors(colors) - if type(colors) == "string" then - return util.getColor(colors) - end + if type(colors) == "string" then return util.getColor(colors) end local ret = {} - for key, value in pairs(colors) do - ret[key] = util.light_colors(value) - end + for key, value in pairs(colors) do ret[key] = util.light_colors(value) end return ret end ---@param theme Theme function util.load(theme) vim.cmd("hi clear") - if vim.fn.exists("syntax_on") then - vim.cmd("syntax reset") - end + if vim.fn.exists("syntax_on") then vim.cmd("syntax reset") end vim.o.termguicolors = true vim.g.colors_name = "onedark" @@ -236,14 +214,11 @@ function util.load(theme) util.syntax(theme.base) -- load syntax for plugins and terminal async - vim.defer_fn( - function() - util.terminal(theme.colors) - util.syntax(theme.plugins) - util.autocmds(theme.config) - end, - 0 - ) + vim.defer_fn(function() + util.terminal(theme.colors) + util.syntax(theme.plugins) + util.autocmds(theme.config) + end, 0) end ---@param config Config @@ -251,17 +226,13 @@ end function util.color_overrides(colors, config) if type(config.colors) == "table" then for key, value in pairs(config.colors) do - if not colors[key] then - error("Color " .. key .. " does not exist") - end + if not colors[key] then error("Color " .. key .. " does not exist") end if string.sub(value, 1, 1) == "#" then -- hex override colors[key] = value else -- another group - if not colors[value] then - error("Color " .. value .. " does not exist") - end + if not colors[value] then error("Color " .. value .. " does not exist") end colors[key] = colors[value] end end @@ -275,17 +246,13 @@ function util.light(brightness) if type(hl[key]) == "number" then local hex = string.format("#%06x", hl[key]) local color = util.invertColor(hex) - if brightness then - color = util.brighten(hex, brightness) - end + if brightness then color = util.brighten(hex, brightness) end table.insert(def, "gui" .. def_key .. "=" .. color) end end if hl_name ~= "" and #def > 0 then for _, style in pairs({"bold", "italic", "underline", "undercurl", "reverse"}) do - if hl[style] then - table.insert(def, "gui=" .. style) - end + if hl[style] then table.insert(def, "gui=" .. style) end end vim.cmd("highlight! " .. hl_name .. " " .. table.concat(def, " ")) @@ -307,9 +274,7 @@ function util.random() end if hl_name ~= "" and #def > 0 then for _, style in pairs({"bold", "italic", "underline", "undercurl", "reverse"}) do - if hl[style] then - table.insert(def, "gui=" .. style) - end + if hl[style] then table.insert(def, "gui=" .. style) end end vim.cmd("highlight! " .. hl_name .. " " .. table.concat(def, " ")) From 029096a996575c81b004c3491bc3cd01ccf5018e Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 15 Jun 2021 17:17:26 +0530 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Make=20?= =?UTF-8?q?development=20easy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lint.yml | 21 +++++++++++++++++++++ .luacheckrc | 3 +++ Makefile | 15 +++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .luacheckrc create mode 100644 Makefile diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0ebdf31 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: Linting + +on: + push: + branches: [main] + pull_request: + +jobs: + build: + name: Luacheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install linter + run: | + sudo apt-get update + sudo apt-get install luarocks + sudo luarocks install luacheck + - name: Lint + run: make lint diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..e67ca30 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,3 @@ +globals = { + "vim", +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c2a192a --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +.DEFAULT_GOAL = check + +onedark_path = lua/onedark +extra_path = $(onedark_path)/extra + +extra: $(extra_path) + @lua $(extra_path)/init.lua + +format: + @for file in `find . -name '*.lua'`;do lua-format $$file -i; done; + +lint: $(onedark_path) + @luacheck $(onedark_path) + +check: format lint From df346d9d68bf043b2b80793cd3ca10b1527efce0 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 15 Jun 2021 17:22:02 +0530 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9A=80=20CI=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lint.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0ebdf31..7c09991 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,8 +2,12 @@ name: Linting on: push: - branches: [main] + branches: [main, dev] pull_request: + paths-ignore: + - "**.md" + - LICENSE + branches: [main] jobs: build: @@ -11,7 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install linter run: | sudo apt-get update From 98abd0f3fe44ee9cb3a72b3e9633e9a1e1df8c0e Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 16 Jun 2021 19:26:38 +0530 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=94=20Kitty=20tab=20color=20change?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++++++ README.md | 21 ++++++++++++++++----- extras/kitty_onedark_.conf | 8 ++++---- lua/onedark/extra/kitty.lua | 8 ++++---- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe8fd7..a9749ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +### 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 + +### Changed + +- **VertSplit** & **Inactive StatusLine** `fg` color changed to `bg_visual` + ## [v0.0.1] - 14 June 2021 ### Added diff --git a/README.md b/README.md index 070e04d..916da9b 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,13 @@ Extra color configs for **Kitty**, and **Alacritty** can be found in [extras](ex ## 📺 Screenshot

- onedark.nvim + onedark.nvim +

+ +### Default + +

+ Default fonts

### Normal @@ -169,7 +175,7 @@ vim.g.onedark_italic_variables = false ```

- Normal fonts + Normal fonts

### Italic @@ -182,18 +188,19 @@ vim.g.onedark_italic_variables = true ```

- Italic fonts + Italic fonts

### Telescope

- Telescope plugin + Telescope plugin

## Useful Links -- [SF Mono Nerd-Font](https://github.com/epk/SF-Mono-Nerd-Font) +- [Kitty](https://sw.kovidgoyal.net/kitty) +- ~[SF Mono Nerd-Font](https://github.com/epk/SF-Mono-Nerd-Font)~ [Ubuntu Mono](https://design.ubuntu.com/font/) - [Wallpaper](https://hdqwalls.com/big-sur-4k-wallpaper) - [dotfiles](https://github.com/ful1e5/dotfiles) @@ -205,6 +212,10 @@ vim.g.onedark_italic_variables = true Buy Me A Coffee +## Self Promotion + +Follow me on **[Twitter](https://twitter.com/ful1e5)** +

diff --git a/extras/kitty_onedark_.conf b/extras/kitty_onedark_.conf index 08bed29..5ba9e7e 100644 --- a/extras/kitty_onedark_.conf +++ b/extras/kitty_onedark_.conf @@ -8,10 +8,10 @@ cursor #abb2bf # Tabs - active_tab_background #282c34 - active_tab_foreground #abb2bf - inactive_tab_background #242b38 - inactive_tab_foreground #5c6370 + active_tab_background #61afef + active_tab_foreground #282c34 + inactive_tab_background #abb2bf + inactive_tab_foreground #282c34 #tab_bar_background #20232A # normal diff --git a/lua/onedark/extra/kitty.lua b/lua/onedark/extra/kitty.lua index 60c8fca..8451102 100644 --- a/lua/onedark/extra/kitty.lua +++ b/lua/onedark/extra/kitty.lua @@ -18,10 +18,10 @@ function M.kitty(config) cursor ${fg} # Tabs - active_tab_background ${bg} - active_tab_foreground ${fg} - inactive_tab_background ${bg_highlight} - inactive_tab_foreground ${fg_gutter} + active_tab_background ${blue} + active_tab_foreground ${bg} + inactive_tab_background ${fg} + inactive_tab_foreground ${bg} #tab_bar_background ${black} # normal