Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

nugu/neovim.nu

Raw
use palette.nu

const tui = {
	debug: 16
	error: 1
	info: 6
	warning: 3

	content_normal: 7
	content_backdrop: 0
	content_accent: 5
	content_minor: 8
	content_focus: 2
	content_unfocus: 22
	content_important_global: 12
	content_important_local: 4

	ui_normal: 17
	ui_backdrop: 18
	ui_accent: 13
	ui_minor: 19
	ui_focus: 20
	ui_unfocus: 21
	ui_important_global: 15
	ui_important_local: 14
}

const slots = [
	[0 'palette.content.backdrop']
	[1 'palette.error']
	[2 'palette.content.focus']
	[3 'palette.warning']
	[4 'palette.content.important_local']
	[5 'palette.content.accent']
	[6 'palette.info']
	[7 'palette.content.normal']
	[8 'palette.content.minor']
	[12 'palette.content.important_global']
	[13 'palette.ui.accent']
	[14 'palette.ui.important_local']
	[15 'palette.ui.important_global']
	[16 'palette.debug']
	[17 'palette.ui.normal']
	[18 'palette.ui.backdrop']
	[19 'palette.ui.minor']
	[20 'palette.ui.focus']
	[21 'palette.ui.unfocus']
	[22 'palette.content.unfocus']
]

def pick [theme path: string] {
	mut value = $theme
	for key in ($path | split row '.') {
		$value = ($value | get $key)
	}
	$value
}

def gui [mode: string] {
	let theme = palette nugu $mode
	$slots | each {|slot|
		let index = $slot.0
		let path = $slot.1
		$"\t\t[($index)] = '(pick $theme $path)',"
	}
}

export def theme [] {
	let lines = [
		'return {'
		"\ttui = {"
		...($tui | transpose key value | each {|row| $"\t\t($row.key) = ($row.value)," })
		"\t},"
		"\tdark = {"
		...(gui dark)
		"\t},"
		"\tlight = {"
		...(gui light)
		"\t},"
		'}'
	]
	($lines | str join (char nl)) + (char nl)
}