summary refs log tree commit diff
path: root/.vim/plugin/colorscheme.lua
blob: 240737e3b0c2092e3a2ac4e538b2b69189bc16ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
vim.opt.background = 'dark'

-- setup color-scheme detection via desktop portal apis
vim.api.nvim_create_autocmd('UIEnter', {
  once = true,
  callback = function()
    local job = require('plenary.job'):new({
      command = 'porta',
      args = { 'settings', 'org.freedesktop.appearance', 'color-scheme' },
      enable_recording = true,
    })
    local res, exitcode = job:sync()
    if exitcode == 0 and #res == 1 then
      if res[1] == 'prefer-light' then
        vim.opt.background = 'light'
      else
        vim.opt.background = 'dark'
      end
    end
  end,
})

vim.api.nvim_set_hl(0, 'ColorColumn', { link = 'CursorColumn', force = true })