neovim: Follow GNOME theme

This commit is contained in:
Sijmen 2022-12-17 17:38:48 +01:00
parent 65d0f5acba
commit 64da4c43ce
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
1 changed files with 15 additions and 2 deletions

View File

@ -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", "<C-b>", ":NvimTreeToggle<CR>", { 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))