From 64da4c43ce6e961567789a943cfc1b4f06850b77 Mon Sep 17 00:00:00 2001 From: Sijmen Date: Sat, 17 Dec 2022 17:38:48 +0100 Subject: [PATCH] neovim: Follow GNOME theme --- common/nvim.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/common/nvim.lua b/common/nvim.lua index 73d1fc4..ee4e806 100644 --- a/common/nvim.lua +++ b/common/nvim.lua @@ -2,8 +2,6 @@ local opt = vim.opt local g = vim.g vim.cmd [[ - colorscheme onehalflight - if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif @@ -146,3 +144,18 @@ cmp.setup { require("leap").add_default_mappings() vim.api.nvim_set_keymap("n", "", ":NvimTreeToggle", { noremap = true, silent = true }) + +local update_theme = function() + local file = io.popen("dconf read /org/gnome/desktop/interface/color-scheme") + local theme = file:read("*all") + file:close() + + if(string.find(theme, "dark")) then + vim.cmd "colorscheme onehalfdark" + elseif(string.find(theme, "default")) then + vim.cmd "colorscheme onehalflight" + end +end + +update_theme() +vim.loop.new_timer():start(0, 750, vim.schedule_wrap(update_theme))