diff options
| author | Robert Günzler <r@gnzler.io> | 2026-02-10 12:32:48 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-02-10 12:41:25 +0100 |
| commit | 63feeb9f369fc6176e85c1c2d8fcc863caad1946 (patch) | |
| tree | 41cd5d2d1ec36e74e464caab722cc9b460153f04 /.vim/plugin/darkmode.lua | |
| parent | 5bd0a4aca65ecb9818ef1285982d160b6b6ff665 (diff) | |
start new
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.vim/plugin/darkmode.lua')
| -rw-r--r-- | .vim/plugin/darkmode.lua | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/.vim/plugin/darkmode.lua b/.vim/plugin/darkmode.lua deleted file mode 100644 index 6ffd06f..0000000 --- a/.vim/plugin/darkmode.lua +++ /dev/null @@ -1,47 +0,0 @@ --- this plugin registers registers and autocommand that switches colorschemes on UIEnter based on --- the system's preference for dark/light mode - -local state = { enabled = true } - -if not state.enabled then - return -end - -local set_darkmode = function(enabled) - if enabled then - vim.opt.background = 'dark' - vim.cmd.colorscheme(vim.g.darkmode_colorscheme_dark or 'default') - else - vim.opt.background = 'light' - vim.cmd.colorscheme(vim.g.darkmode_colorscheme_light or 'default') - end -end - --- returns if system is configured to use darkmode -local discover = function() - require('plenary.job') - :new({ - command = 'porta', - args = { 'settings', 'org.freedesktop.appearance', 'color-scheme' }, - enable_recording = true, - on_exit = vim.schedule_wrap(function(job, exitcode) - local darkmode_enabled = true - local res = job:result() - if exitcode == 0 and #res then - darkmode_enabled = not (res[1] == 'prefer-light') - end - set_darkmode(darkmode_enabled) - end), - }) - :start() -end - --- setup autogroup -local aug = vim.api.nvim_create_augroup('darkmode', { clear = true }) - --- setup color-scheme detection via desktop portal apis -vim.api.nvim_create_autocmd({ 'UIEnter', 'VimResume' }, { callback = discover, group = aug }) -vim.api.nvim_create_autocmd({ 'Signal' }, { pattern = 'SIGUSR1', callback = discover, group = aug }) - --- fix ColorColumn not being defined -vim.api.nvim_set_hl(0, 'ColorColumn', { link = 'CursorColumn', force = true }) |