diff --git a/highlight.go b/highlight.go index 91f52fb..e3f9fb0 100644 --- a/highlight.go +++ b/highlight.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "io" + "os" "regexp" "strings" ) @@ -17,9 +18,16 @@ const ( ansiInlineCode = "\033[33m" ansiBlockQuote = "\033[36m" ansiListMarker = "\033[36m" - ansiLineBg = "\033[40m" ansiReset = "\033[0m" ) +var ansiLineBg = func() string { + switch os.Getenv("NOTESIUM_FINDER_THEME") { + case "light": + return "\033[48;5;7m" + default: + return "\033[40m" + } +}() var ( reBold = regexp.MustCompile(`\*\*(.*?)\*\*`) reBoldAlt = regexp.MustCompile(`__(.*?)__`) diff --git a/notesium.go b/notesium.go index 9bc46d2..770a932 100644 --- a/notesium.go +++ b/notesium.go @@ -341,6 +341,15 @@ func notesiumFinder(dir string, opts finderOptions) { log.Fatal(err) } + theme := os.Getenv("NOTESIUM_FINDER_THEME") + var fzfColor string + switch theme { + case "light": + fzfColor = "bg:15,bg+:7,fg:241,fg+:241,hl:4,hl+:2,pointer:9,info:6" + default: + fzfColor = "bg:8,bg+:0,fg:12,fg+:12,hl:11,hl+:3,pointer:9,info:3" + } + optsFzf := []string{ "--ansi", "--exact", @@ -353,7 +362,7 @@ func notesiumFinder(dir string, opts finderOptions) { "--pointer=>", "--delimiter=:", "--with-nth=3..", - "--color=bg:8,bg+:0,fg:12,fg+:12,hl:11,hl+:3,pointer:9,info:3", + fmt.Sprintf("--color=%s", fzfColor), fmt.Sprintf("--prompt=%s> ", opts.prompt), } diff --git a/vim/plugin/notesium.vim b/vim/plugin/notesium.vim index 08cc48c..78626d7 100644 --- a/vim/plugin/notesium.vim +++ b/vim/plugin/notesium.vim @@ -45,6 +45,9 @@ let $NOTESIUM_DIR = notesium#get_notesium_dir() if has('nvim') function! notesium#finder(config) abort + " Set light or dark theme + let $NOTESIUM_FINDER_THEME = &background + " Prepare command let l:cmd = g:notesium_bin . ' finder ' . get(a:config, 'options', '') let l:cmd .= ' -- ' . get(a:config, 'input', '') @@ -106,6 +109,9 @@ if has('nvim') else function! notesium#finder(config) abort + " Set light or dark theme + let $NOTESIUM_FINDER_THEME = &background + " Prepare the command let l:cmd = g:notesium_bin . ' finder ' . get(a:config, 'options', '') let l:cmd .= ' -- ' . get(a:config, 'input', '') @@ -155,12 +161,12 @@ command! -nargs=* NotesiumInsertLink \ 'input': 'list ' . join(map(split(), 'shellescape(v:val)'), ' '), \ 'options': '--prompt=NotesiumInsertLink', \ 'callback': function('notesium#finder_callback_insertlink'), - \ 'window': (&columns > 79 ? g:notesium_window_small : g:notesium_window) }) + \ 'window': (&columns > 89 ? g:notesium_window_small : g:notesium_window) }) command! -nargs=* NotesiumList \ call notesium#finder({ \ 'input': 'list ' . join(map(split(), 'shellescape(v:val)'), ' '), - \ 'options': '--prompt=NotesiumList' . (&columns > 79 ? ' --preview' : ''), + \ 'options': '--prompt=NotesiumList' . (&columns > 89 ? ' --preview' : ''), \ 'callback': function('notesium#finder_callback_editfile'), \ 'window': g:notesium_window }) @@ -170,14 +176,14 @@ command! -bang -nargs=* NotesiumLinks \ let s:args = . (!empty(s:filename) ? ' ' . s:filename : '') | \ call notesium#finder({ \ 'input': 'links ' . join(map(split(s:args), 'shellescape(v:val)'), ' '), - \ 'options': '--prompt=NotesiumLinks' . (&columns > 79 ? ' --preview' : ''), + \ 'options': '--prompt=NotesiumLinks' . (&columns > 89 ? ' --preview' : ''), \ 'callback': function('notesium#finder_callback_editfile'), \ 'window': g:notesium_window }) command! -nargs=* NotesiumLines \ call notesium#finder({ \ 'input': 'lines ' . join(map(split(), 'shellescape(v:val)'), ' '), - \ 'options': '--prompt=NotesiumLines' . (&columns > 79 ? ' --preview' : ''), + \ 'options': '--prompt=NotesiumLines' . (&columns > 89 ? ' --preview' : ''), \ 'callback': function('notesium#finder_callback_editfile'), \ 'window': g:notesium_window })