diff --git a/nvim/after/ftplugin/diff.vim b/nvim/after/ftplugin/diff.vim new file mode 100644 index 0000000..ab49c88 --- /dev/null +++ b/nvim/after/ftplugin/diff.vim @@ -0,0 +1 @@ +setlocal nofoldenable foldmethod=manual diff --git a/nvim/after/ftplugin/markdown.vim b/nvim/after/ftplugin/markdown.vim index 5408829..f5408c0 100644 --- a/nvim/after/ftplugin/markdown.vim +++ b/nvim/after/ftplugin/markdown.vim @@ -2,9 +2,10 @@ source :h/text.vim let s:src_file = expand('%') let s:out_file = s:src_file.'.html' -let &l:makeprg = 'markdown2htmldoc '.shellescape(s:src_file).' '.shellescape(s:out_file) +let &l:makeprg = 'markdown2htmldoc' for s:arg in get(g:, 'dotfiles_markdown2htmldoc_options', []) let &l:makeprg .= ' '.shellescape(s:arg) endfor +let &l:makeprg .= ' -- '.shellescape(s:src_file).' '.shellescape(s:out_file) nnoremap Open %.html diff --git a/nvim/after/ftplugin/sass.vim b/nvim/after/ftplugin/sass.vim new file mode 100644 index 0000000..6e88f83 --- /dev/null +++ b/nvim/after/ftplugin/sass.vim @@ -0,0 +1 @@ +source :h/scss.vim diff --git a/nvim/after/ftplugin/scss.vim b/nvim/after/ftplugin/scss.vim index 94b3fea..9d5f7f1 100644 --- a/nvim/after/ftplugin/scss.vim +++ b/nvim/after/ftplugin/scss.vim @@ -1 +1,9 @@ source :h/css.vim + +let s:src_file = expand('%') +let s:out_file = s:src_file.'.css' +let &l:makeprg = 'sass' +for s:arg in get(g:, 'dotfiles_dart_sass_options', []) + let &l:makeprg .= ' '.shellescape(s:arg) +endfor +let &l:makeprg .= ' -- '.shellescape(s:src_file).':'.shellescape(s:out_file) diff --git a/nvim/colors/dotfiles.vim b/nvim/colors/dotfiles.vim index a48e3af..bea107b 100644 --- a/nvim/colors/dotfiles.vim +++ b/nvim/colors/dotfiles.vim @@ -5,7 +5,8 @@ execute 'source' fnameescape(g:dotfiles_dir.'/colorschemes/out/vim.vim') - if !&termguicolors && exists('$_COLORSCHEME_TERMINAL') + let s:is_gui_color = !has('win32') && !has('win64') && !has('win32unix') && has('termguicolors') && &termguicolors + if s:is_gui_color && exists('$_COLORSCHEME_TERMINAL') set notermguicolors endif @@ -25,39 +26,45 @@ endfunction let s:colors = g:dotfiles_colorscheme_base16_colors - function s:hi(group, fg, bg, attr, guisp) - let args = '' + function s:hi(group, fg, bg, attr, sp) + let fg = {} + let bg = {} + let attr = 'NONE' + let sp = {} if a:fg isnot '' let fg = s:is_number(a:fg) ? s:colors[a:fg] : {'gui': a:fg, 'cterm': a:fg} - let args .= ' guifg=' . fg.gui . ' ctermfg=' . fg.cterm endif if a:bg isnot '' let bg = s:is_number(a:bg) ? s:colors[a:bg] : {'gui': a:bg, 'cterm': a:bg} - let args .= ' guibg=' . bg.gui . ' ctermbg=' . bg.cterm endif if a:attr isnot '' - let args .= ' gui=' . a:attr . ' cterm=' . a:attr + let attr = a:attr endif - if a:guisp isnot '' - let guisp = s:is_number(a:guisp) ? s:colors[a:guisp].gui : a:guisp - let args .= ' guisp=' . guisp + if a:sp isnot '' + let sp = s:is_number(a:sp) ? s:colors[a:sp] : {'gui': a:sp, 'cterm': a:sp} endif - exec 'hi' a:group args + exec 'hi' a:group + \ 'guifg='.get(fg, 'gui', 'NONE') 'ctermfg='.get(fg, 'cterm', 'NONE') + \ 'guibg='.get(bg, 'gui', 'NONE') 'ctermbg='.get(bg, 'cterm', 'NONE') + \ 'gui='.(attr) 'cterm='.(attr) + \ 'guisp='.get(sp, 'gui', 'NONE') endfunction " }}} " General syntax highlighting {{{ - call s:hi('Normal', 0x5, 0x0, '', '') - call s:hi('Italic', 0xE, '', 'italic', '') - call s:hi('Bold', 0xA, '', 'bold', '') - call s:hi('Underlined', 0x8, '', 'underline', '') - call s:hi('Title', 0xD, '', 'NONE', '') + " TODO: `hi clear` ? + + call s:hi('Normal', 0x5, 0x0, '', '') + call s:hi('Italic', 0xE, '', 'italic', '') + call s:hi('Bold', 0xA, '', 'bold', '') + call s:hi('Underlined', 0x8, '', 'underline', '') + call s:hi('Title', 0xD, '', '', '') hi! link Directory Title - call s:hi('Conceal', 0xC, 'NONE', '', '') - call s:hi('NonText', 0x3, '', '', '') + call s:hi('Conceal', 0xC, '', '', '') + call s:hi('NonText', 0x3, '', '', '') hi! link SpecialKey Special - call s:hi('MatchParen', 'fg', 0x3, '', '') + call s:hi('MatchParen', 'fg', 0x3, '', '') call s:hi('Keyword', 0xE, '', '', '') hi! link Statement Keyword @@ -78,7 +85,7 @@ hi! link SpecialComment Comment call s:hi('Todo', 'bg', 0xA, 'bold', '') call s:hi('Function', 0xD, '', '', '') - call s:hi('Identifier', 0x8, '', 'none', '') + call s:hi('Identifier', 0x8, '', '', '') hi! link Variable Identifier " call s:hi('Include', 0xF, '', '', '') hi! link Include Keyword @@ -88,30 +95,30 @@ hi! link Delimiter NONE call s:hi('Special', 0xC, '', '', '') call s:hi('Tag', 0xA, '', '', '') - call s:hi('Type', 0xA, '', 'none', '') + call s:hi('Type', 0xA, '', '', '') hi! link Typedef Type " }}} " User interface {{{ - call s:hi('Error', 'bg', 0x8, '', '') - call s:hi('ErrorMsg', 0x8, 'NONE', '', '') - call s:hi('WarningMsg', 0x9, 'NONE', '', '') - call s:hi('TooLong', 0x8, '', '', '') - call s:hi('Debug', 0x8, '', '', '') + call s:hi('Error', 'bg', 0x8, '', '') + call s:hi('ErrorMsg', 0x8, '', '', '') + call s:hi('WarningMsg', 0x9, '', '', '') + call s:hi('TooLong', 0x8, '', '', '') + call s:hi('Debug', 0x8, '', '', '') hi! link CocErrorSign Error - call s:hi('CocWarningSign', 'bg', 0xA, '', '') - call s:hi('CocInfoSign', 'bg', 0xD, '', '') + call s:hi('CocWarningSign', 'bg', 0xA, '', '') + call s:hi('CocInfoSign', 'bg', 0xD, '', '') hi! link CocHintSign CocInfoSign - call s:hi('CocFadeOut', 0x3, '', '', '') + call s:hi('CocFadeOut', 0x3, '', '', '') hi! link CocMarkdownLink Underlined call s:hi('FoldColumn', 0xC, 0x1, '', '') call s:hi('Folded', 0x3, 0x1, '', '') - call s:hi('IncSearch', 0x1, 0x9, 'none', '') - call s:hi('Search', 0x1, 0xA, '', '') + call s:hi('IncSearch', 0x1, 0x9, '', '') + call s:hi('Search', 0x1, 0xA, '', '') hi! link Substitute Search call s:hi('ModeMsg', 0xB, '', '', '') @@ -120,7 +127,7 @@ call s:hi('Visual', '', 0x2, '', '') call s:hi('WildMenu', 0x1, 'fg', '', '') - call s:hi('CursorLine', '', 0x1, 'none', '') + call s:hi('CursorLine', '', 0x1, '', '') hi! link CursorColumn CursorLine call s:hi('ColorColumn', '', 0x1, '', '') call s:hi('LineNr', 0x3, 0x1, '', '') @@ -128,7 +135,7 @@ call s:hi('QuickFixLine', '', 0x2, '', '') call s:hi('SignColumn', 0x3, 0x1, '', '') - call s:hi('StatusLine', 0x4, 0x1, 'none', '') + call s:hi('StatusLine', 0x4, 0x1, '', '') call s:hi('StatusLineNC', 0x3, 0x1, '', '') call s:hi('VertSplit', 0x2, 0x2, '', '') call s:hi('TabLine', 0x3, 0x1, '', '') @@ -142,13 +149,12 @@ hi! link ctrlsfLnumMatch ctrlsfMatch let s:spell_fg = s:is_kitty ? '' : 'bg' - let s:spell_bg = s:is_kitty ? 'NONE' : '' let s:spell_attr = s:is_kitty ? 'undercurl' : '' - call s:hi('SpellBad', s:spell_fg, s:spell_bg, s:spell_attr, 0x8) - call s:hi('SpellLocal', s:spell_fg, s:spell_bg, s:spell_attr, 0xC) - call s:hi('SpellCap', s:spell_fg, s:spell_bg, s:spell_attr, 0xD) - call s:hi('SpellRare', s:spell_fg, s:spell_bg, s:spell_attr, 0xE) - unlet s:is_kitty s:spell_fg s:spell_bg s:spell_attr + call s:hi('SpellBad', s:spell_fg, s:is_kitty ? '' : 0x8, s:spell_attr, 0x8) + call s:hi('SpellLocal', s:spell_fg, s:is_kitty ? '' : 0xC, s:spell_attr, 0xC) + call s:hi('SpellCap', s:spell_fg, s:is_kitty ? '' : 0xD, s:spell_attr, 0xD) + call s:hi('SpellRare', s:spell_fg, s:is_kitty ? '' : 0xE, s:spell_attr, 0xE) + unlet s:spell_fg s:spell_attr call s:hi('Sneak', 'bg', 0xB, 'bold', '') hi! link SneakScope Visual diff --git a/nvim/init.vim b/nvim/init.vim index a1911ba..fbbb72a 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -63,8 +63,17 @@ if exists(':Sleuth') " shiftwidth to the unreasonable value picked above, which vim-sleuth " internally compares with its local `s:default_shiftwidth`, sees that both " are the same, and proceeds to execute the indent detection algorithm. - " Boom, my work here is done. - autocmd BufEnter * let &l:shiftwidth = s:fake_default_shiftwidth | Sleuth + " ALSO Note how I'm not using `BufEnter` as vim-sleuth does because + " apparently `BufWinEnter` leads to better compatibility with the + " indentLine plugin and potentially less useless invocations (see the note + " about window splits in the docs for this event). Oh, one last thing: + " vim-sleuth forgets to assign the tabstop options, which I have to do as + " well. But anyway, boom, my work here is done. + autocmd BufWinEnter * + \ let &l:shiftwidth = s:fake_default_shiftwidth + \| Sleuth + \| let &l:tabstop = &l:shiftwidth + \| let &l:softtabstop = &l:shiftwidth augroup END " HACK: In case you are wondering why I'm using Polyglot's bundled vim-sleuth diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 70ba62e..5a81cec 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -15,8 +15,8 @@ set commentstring=//%s function SetIndent(expandtab, shiftwidth) let &l:expandtab = a:expandtab let &l:shiftwidth = str2nr(a:shiftwidth) - let &l:tabstop = &shiftwidth - let &l:softtabstop = &shiftwidth + let &l:tabstop = &l:shiftwidth + let &l:softtabstop = &l:shiftwidth endfunction command -nargs=1 Indent call SetIndent(1, ) command -nargs=1 IndentTabs call SetIndent(0, ) diff --git a/nvim/plugin/interface.vim b/nvim/plugin/interface.vim index 11671da..8e357ce 100644 --- a/nvim/plugin/interface.vim +++ b/nvim/plugin/interface.vim @@ -123,6 +123,8 @@ endif nnoremap Helptags nnoremap f Files nnoremap b Buffers + " + let $FZF_DEFAULT_OPTS = '--color=16' let g:fzf_layout = { 'down': '~40%' } let g:fzf_preview_window = ['right:noborder', 'ctrl-/'] " }}} diff --git a/script-resources/colortest.awk b/script-resources/colortest.awk index cf66228..6f87514 100644 --- a/script-resources/colortest.awk +++ b/script-resources/colortest.awk @@ -14,20 +14,24 @@ BEGIN { print ""; } -function print_color(color) { - printf "\033[48;5;%sm \033[0m", color +function print_color(color, idx) { + if (OPT_COLOR_CODES) { + printf "\033[1;30;48;5;%sm %02X \033[0m", color, idx; + } else { + printf "\033[48;5;%sm \033[0m", color; + } } function test_standard_colors() { print "16 standard colors:"; - for (color = 0; color < 16; color += 1) print_color(color); + for (color = 0; color < 16; color += 1) print_color(color, color); print ""; } function test_base16_colorscheme() { print "base16 colorscheme:"; split("0 18 19 8 20 7 21 15 1 16 3 2 6 4 5 17", colors, " "); - for (i = 1; i <= length(colors); i++) print_color(colors[i]); + for (i = 1; i <= length(colors); i++) print_color(colors[i], i - 1); print ""; } @@ -39,7 +43,8 @@ function test_6x6x6_cube() { for (row = 0; row < 6; row++) { for (block_x = 0; block_x < block_grid_w; block_x++) { for (col = 0; col < 6; col++) { - print_color(16 + col + 6*row + 6*6*block_x + block_grid_w*6*6*block_y); + color = col + 6*row + 6*6*block_x + block_grid_w*6*6*block_y + print_color(16 + color, color); } } print ""; @@ -50,7 +55,7 @@ function test_6x6x6_cube() { function test_grayscale() { print "grayscale from black to white in 24 steps:"; for (color = 0; color < 24; color += 1) { - print_color(16 + 6*6*6 + color) + print_color(16 + 6*6*6 + color, color) } print ""; } diff --git a/scripts/colortest b/scripts/colortest index 99f0f4b..9f5bc94 100755 --- a/scripts/colortest +++ b/scripts/colortest @@ -1,6 +1,6 @@ #!/bin/sh -set -e +set -eu script_dir="$(dirname "$0")" diff --git a/scripts/colortest2 b/scripts/colortest2 index 9b685c6..8a439ff 100755 --- a/scripts/colortest2 +++ b/scripts/colortest2 @@ -1,6 +1,6 @@ #!/bin/sh -set -e +set -eu script_dir="$(dirname "$0")" cols="$(tput cols)" diff --git a/scripts/colortest3 b/scripts/colortest3 new file mode 100755 index 0000000..84a2cef --- /dev/null +++ b/scripts/colortest3 @@ -0,0 +1,7 @@ +#!/bin/sh + +set -eu + +script_dir="$(dirname "$0")" + +exec awk -v OPT_COLOR_CODES=1 -f "${script_dir}/../script-resources/colortest.awk" diff --git a/zsh/env.zsh b/zsh/env.zsh index eca6fb0..baf1882 100644 --- a/zsh/env.zsh +++ b/zsh/env.zsh @@ -31,3 +31,6 @@ export JQ_COLORS="${(j.:.)jq_colors}" unset jq_colors export HOMEBREW_NO_AUTO_UPDATE=1 + +# https://github.com/junegunn/fzf/blob/764316a53d0eb60b315f0bbcd513de58ed57a876/src/tui/tui.go#L496-L515 +export FZF_DEFAULT_OPTS="--color=16"