Skip to content
Merged
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
10 changes: 9 additions & 1 deletion highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io"
"os"
"regexp"
"strings"
)
Expand All @@ -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(`__(.*?)__`)
Expand Down
11 changes: 10 additions & 1 deletion notesium.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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),
}

Expand Down
14 changes: 10 additions & 4 deletions vim/plugin/notesium.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down Expand Up @@ -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', '')
Expand Down Expand Up @@ -155,12 +161,12 @@ command! -nargs=* NotesiumInsertLink
\ 'input': 'list ' . join(map(split(<q-args>), '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(<q-args>), '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 })

Expand All @@ -170,14 +176,14 @@ command! -bang -nargs=* NotesiumLinks
\ let s:args = <q-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(<q-args>), '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 })

Expand Down