Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lua/peek/app.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local config = require('peek.config')
local util = require('peek.util')

local chansend = vim.fn.chansend
local concat = table.concat
Expand All @@ -25,11 +26,18 @@ local function message(chunks)
end, chunks))
end

function module.setup()
function module.setup(cfg)
local cfg = cfg or {}
local sep = vim.loop.os_uname().sysname:match('Windows') and '\\' or '/'
local theme = cfg['theme'] or config.get('theme')

if cfg['auto_os_theme'] or config.get('auto_os_theme') then
theme = util.get_color_scheme()
end

local args = {
'--logfile=' .. string.format('%s%speek.log', vim.fn.stdpath('log'), sep),
'--theme=' .. config.get('theme'),
'--theme=' .. theme,
'--app=' .. vim.json.encode(config.get('app')),
}

Expand Down
1 change: 1 addition & 0 deletions lua/peek/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local config = {
close_on_bdelete = true,
syntax = true,
theme = 'dark',
auto_os_theme = false,
update_on_change = true,
throttle_at = 200000,
throttle_time = 'auto',
Expand Down
3 changes: 2 additions & 1 deletion lua/peek/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ local function get_buf_content(bufnr)
return concat(nvim_buf_get_lines(bufnr, 0, -1, false), '\n'):gsub('%s*$', '')
end

local function open(bufnr)
local function open(bufnr, cfg)
app.setup(cfg)
augroup = nvim_create_augroup('PeekActiveAugroup', { clear = true })

app.init(function()
Expand Down
19 changes: 19 additions & 0 deletions lua/peek/util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local M = {}

local function get_color_scheme()
local color_scheme = 'light'
local system = vim.loop.os_uname().sysname
if system == 'Darwin' then
if vim.fn.executable('defaults') ~= 0 then
local appleInterfaceStyle = vim.fn.system({ 'defaults', 'read', '-g', 'AppleInterfaceStyle' })
if appleInterfaceStyle:find('Dark') then
color_scheme = 'dark'
end
end
end

return color_scheme
end

M.get_color_scheme = get_color_scheme
return M