From 25e664d9f2eaa81720e48ad6b90c1f9804032dc9 Mon Sep 17 00:00:00 2001 From: philw Date: Fri, 28 Mar 2025 10:50:22 +0100 Subject: Enable colorscheme changes --- init.lua | 91 +++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/init.lua b/init.lua index 44564b2..8db2d6f 100644 --- a/init.lua +++ b/init.lua @@ -118,6 +118,57 @@ local function setup_autopairs() ) end end +function set_highlights() + local highlights = { + {"GitGutterAdd", {bg = "none"}}, + {"GitGutterDelete", {bg = "none"}}, + {"GitGutterChange", {bg = "none"}}, + {"GitGutterChangeAdd", {bg = "none"}}, + {"GitGutterChangeDelete", {bg = "none"}}, + {"NonText", {fg = "none"}}, + {"EndOfBuffer", {fg = "none", bg = "none"}}, +-- {"Normal", {bg = "none"}}, + {"SignColumn", {bg = "none"}}, + {"StatusLine", {bg = "none", fg = "none"}}, + {"StatusLineNc", {bg = "none", fg = "none"}}, + {"NvimTreeWinSeparator", {fg = "none"}}, + {"CursorColumn", {fg = "none"}}, + {"CursorLine", {bg = "none"}}, + {"VertSplit", {bg = "none"}}, + {"DiagnosticError", {bg = "none"}}, + {"DiagnosticWarn", {bg = "none"}}, + {"DiagnosticInfo", {bg = "none"}}, + {"DiagnosticHint", {bg = "none"}}, + {"Pmenu", {bg = "none"}}, + {"DiagnosticVirtualTextError", {bg = "none"}}, + {"DiagnosticVirtualTextWarn", {bg = "none"}}, + {"DiagnosticVirtualTextInfo", {bg = "none"}}, + {"DiagnosticVirtualTextHint", {bg = "none"}}, + {"LspFloatWinNormal", {bg = "none"}}, + {"NormalFloat", {bg = "none"}}, + {"LineNr", {bg = "none"}}, + {"DiagnosticVirtualError", {bg = "none"}}, + {"DiagnosticVirtualWarn", {bg = "none"}}, + {"DiagnosticVirtualInfo", {bg = "none"}}, + {"DiagnosticVirtualHint", {bg = "none"}} +} + +for _, hl in ipairs(highlights) do + vim.api.nvim_set_hl(0, hl[1], hl[2]) + end + +end + + +vim.o.background = "dark" +function color_mode() + if vim.o.background == "dark" then + vim.o.background = "light" + else + vim.o.background = "dark" + end + set_highlights() + end setup_autopairs() @@ -179,7 +230,6 @@ require("lazy").setup({ }, }) -vim.o.background = "dark" vim.cmd('colorscheme gruvbox') require("colorizer").setup() @@ -221,43 +271,7 @@ for lsp, settings in pairs(lsp_servers) do ) end -local highlights = { - {"GitGutterAdd", {bg = "none"}}, - {"GitGutterDelete", {bg = "none"}}, - {"GitGutterChange", {bg = "none"}}, - {"GitGutterChangeAdd", {bg = "none"}}, - {"GitGutterChangeDelete", {bg = "none"}}, - {"NonText", {fg = "none"}}, - {"EndOfBuffer", {fg = "none", bg = "none"}}, --- {"Normal", {bg = "none"}}, - {"SignColumn", {bg = "none"}}, - {"StatusLine", {bg = "none", fg = "none"}}, - {"StatusLineNc", {bg = "none", fg = "none"}}, - {"NvimTreeWinSeparator", {fg = "none"}}, - {"CursorColumn", {fg = "none"}}, - {"CursorLine", {bg = "none"}}, - {"VertSplit", {bg = "none"}}, - {"DiagnosticError", {bg = "none"}}, - {"DiagnosticWarn", {bg = "none"}}, - {"DiagnosticInfo", {bg = "none"}}, - {"DiagnosticHint", {bg = "none"}}, - {"Pmenu", {bg = "none"}}, - {"DiagnosticVirtualTextError", {bg = "none"}}, - {"DiagnosticVirtualTextWarn", {bg = "none"}}, - {"DiagnosticVirtualTextInfo", {bg = "none"}}, - {"DiagnosticVirtualTextHint", {bg = "none"}}, - {"LspFloatWinNormal", {bg = "none"}}, - {"NormalFloat", {bg = "none"}}, - {"LineNr", {bg = "none"}}, - {"DiagnosticVirtualError", {bg = "none"}}, - {"DiagnosticVirtualWarn", {bg = "none"}}, - {"DiagnosticVirtualInfo", {bg = "none"}}, - {"DiagnosticVirtualHint", {bg = "none"}} -} - -for _, hl in ipairs(highlights) do - vim.api.nvim_set_hl(0, hl[1], hl[2]) -end +set_highlights() vim.g.mapleader = " " @@ -276,3 +290,4 @@ keymap.set("n", "f", "Telescope find_files") keymap.set("n", "g", "Telescope live_grep") keymap.set("n", "d", vim.lsp.buf.definition, opts) keymap.set("n", "k", vim.lsp.buf.hover, opts) +keymap.set('n', 'r', color_mode, {desc = "Change mode light/dark"}) -- cgit v1.2.3