<commit_before>" vim: set ts=4 sw=4 tw=78 noet :
"======================================================================
"
" config.vim - 
"
" Created by skywind on 2022/09/07
" Last Modified: 2022/09/07 16:42:08
"
"======================================================================


"----------------------------------------------------------------------
" default config
"----------------------------------------------------------------------
let s:default_config = {
			\ 'icon_separator': '=>',
			\ 'icon_group': '+',
			\ 'icon_breadcrumb': '>',
			\ 'max_height': 20,
			\ 'min_height': 5,
			\ 'padding': [2, 0, 2, 0],
			\ 'spacing': 3,
			\ 'position': 'bottom',
			\ 'splitmod': '',
			\ }


"----------------------------------------------------------------------
" get config
"----------------------------------------------------------------------
function! starter#config#get(opts, key) abort
	if type(a:opts) == v:t_dict
		let opts = a:opts
	elseif type(a:opts) == v:t_none
		let opts = get(g:, 'quickui_starter', {})
	endif
	return get(opts, a:key, s:default_config[a:key])
endfunc


"----------------------------------------------------------------------
" visit tree node
"----------------------------------------------------------------------
function! starter#config#visit(keymap, path) abort
	let keymap = a:keymap
	let path = a:path
	if type(keymap) == v:t_none || type(path) == v:t_none
		return v:none
	endif
	for key in path
		if type(keymap) == v:t_func
			let keymap = call(keymap, [])
		endif
		if !has_key(keymap, key)
			return v:none
		endif
		let keymap = keymap[key]
	endfor
	return keymap
endfunc


"----------------------------------------------------------------------
" compile keymap into ctx
"----------------------------------------------------------------------
function! starter#config#compile(keymap, opts) abort
	let keymap = a:keymap
	let opts = a:opts
	let ctx = {}
	let ctx.items = {}
	let ctx.keys = []
	let ctx.strlen_key = 1
	let ctx.strlen_txt = 8
	for key in keylist
		if key == '' || key == 'name'
			continue
		endif
		let key_char = starter#charname#translate(key)
		if type(key_char) == v:t_none
			continue
		endif
		let ctx.keys += [key]
		let item = {}
		let item.key = key
		let item.key_char = key_char
		let item.key_display = starter#charname#display(key)
		let item.cmd = ''
		let item.text = ''
		let item.child = 0
		let ctx.items[key] = item
		let value = keymap[keyname]
		if type(value) == v:t_func
			value = call(value, [])
		endif
		if type(value) == v:t_str
			let item.cmd = value
			let item.text = value
		elseif type(value) == v:t_list
			let item.cmd = (len(value) > 0)? value[0] : ''
			let item.text = (len(value) > 1)? value[1] : ''
		elseif type(value) == v:t_dict
			let item.child = 1
			let item.text = get(value, 'name', '...')
		endif
		if len(item.key) > ctx.strlen_key
			let ctx.strlen_key = len(item.key)
		endif
		if len(item.text) > ctx.strlen_txt
			let ctx.strlen_text = len(item.text)
		endif
	endfor
	call sort(ctx.keys)
	return ctx
endfunc


<commit_msg>update files<commit_after>" vim: set ts=4 sw=4 tw=78 noet :
"======================================================================
"
" config.vim - 
"
" Created by skywind on 2022/09/07
" Last Modified: 2022/09/07 16:42:08
"
"======================================================================


"----------------------------------------------------------------------
" default config
"----------------------------------------------------------------------
let s:default_config = {
			\ 'icon_separator': '=>',
			\ 'icon_group': '+',
			\ 'icon_breadcrumb': '>',
			\ 'max_height': 20,
			\ 'min_height': 5,
			\ 'padding': [2, 0, 2, 0],
			\ 'spacing': 3,
			\ 'position': 'bottom',
			\ 'splitmod': '',
			\ }


"----------------------------------------------------------------------
" get config
"----------------------------------------------------------------------
function! starter#config#get(opts, key) abort
	if type(a:opts) == v:t_dict
		let opts = a:opts
	elseif type(a:opts) == v:t_none
		let opts = get(g:, 'quickui_starter', {})
	endif
	return get(opts, a:key, s:default_config[a:key])
endfunc


"----------------------------------------------------------------------
" visit tree node
"----------------------------------------------------------------------
function! starter#config#visit(keymap, path) abort
	let keymap = a:keymap
	let path = a:path
	if type(keymap) == v:t_none || type(path) == v:t_none
		return v:none
	endif
	for key in path
		if type(keymap) == v:t_func
			let keymap = call(keymap, [])
		endif
		if !has_key(keymap, key)
			return v:none
		endif
		let keymap = keymap[key]
	endfor
	return keymap
endfunc


"----------------------------------------------------------------------
" compile keymap into ctx
"----------------------------------------------------------------------
function! starter#config#compile(keymap, opts) abort
	let keymap = a:keymap
	let opts = a:opts
	let ctx = {}
	let ctx.items = {}
	let ctx.keys = []
	let ctx.strlen_key = 1
	let ctx.strlen_txt = 8
	for key in keylist
		if key == '' || key == 'name'
			continue
		endif
		let key_char = starter#charname#translate(key)
		if type(key_char) == v:t_none
			continue
		endif
		let ctx.keys += [key]
		let item = {}
		let item.key = key
		let item.key_char = key_char
		let item.key_display = starter#charname#display(key)
		let item.cmd = ''
		let item.text = ''
		let item.child = 0
		let ctx.items[key] = item
		let value = keymap[keyname]
		if type(value) == v:t_func
			value = call(value, [])
		endif
		if type(value) == v:t_str
			let item.cmd = value
			let item.text = value
		elseif type(value) == v:t_list
			let item.cmd = (len(value) > 0)? value[0] : ''
			let item.text = (len(value) > 1)? value[1] : ''
		elseif type(value) == v:t_dict
			let item.child = 1
			let item.text = get(value, 'name', '...')
		endif
		if len(item.key) > ctx.strlen_key
			let ctx.strlen_key = len(item.key)
		endif
		if len(item.text) > ctx.strlen_txt
			let ctx.strlen_text = len(item.text)
		endif
	endfor
	call sort(ctx.keys)
	return ctx
endfunc


{'fraction_non_alphanumeric': 0.3476268412438625, 'fraction_numerical': 0.013747954173486088, 'mean_word_length': 1.734228187919463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5600509', 'n_tokens_mistral': 2191, 'n_tokens_neox': 1938, 'n_words': 477}