diff options
| author | nsfisis <nsfisis@gmail.com> | 2021-12-04 11:04:56 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2021-12-04 11:04:56 +0900 |
| commit | b8d14f4f60fd6a4aa21fdc3d22a9ccf9dcb4398f (patch) | |
| tree | aab38a795f19f1d9912e099809997c5bc83ad64d | |
| parent | d257fe2d3a2fa0b899ca47b07378c0d7a8582db6 (diff) | |
| download | dotfiles-b8d14f4f60fd6a4aa21fdc3d22a9ccf9dcb4398f.tar.gz dotfiles-b8d14f4f60fd6a4aa21fdc3d22a9ccf9dcb4398f.tar.zst dotfiles-b8d14f4f60fd6a4aa21fdc3d22a9ccf9dcb4398f.zip | |
neovim: port colorscheme to Lua
| -rw-r--r-- | .config/nvim/colors/ocean.lua | 265 | ||||
| -rw-r--r-- | .config/nvim/colors/ocean.vim | 263 | ||||
| -rw-r--r-- | .config/nvim/init.lua | 10 |
3 files changed, 270 insertions, 268 deletions
diff --git a/.config/nvim/colors/ocean.lua b/.config/nvim/colors/ocean.lua new file mode 100644 index 0000000..55b3ccb --- /dev/null +++ b/.config/nvim/colors/ocean.lua @@ -0,0 +1,265 @@ +vim.cmd('hi clear') +vim.g.colors_name = 'ocean' + + + +-- Color palette {{{1 + +local palette +if vim.o.background == 'dark' then + palette = { + NONE = 'NONE', + fg = '#b1b1c8', + bg = '#101020', + blue = '#6e6eff', + blue_bg = '#202050', + blue2 = '#70b0ff', + comment = '#8686bf', + cursor = '#5b5bb6', + gray = '#353535', + gray2 = '#202020', + green = '#c4e088', + green_bg = '#204020', + orange = '#deab52', + orange2 = '#ff7100', + red = '#a65f49', + red_bg = '#402020', + selection = '#303060', + yellow = '#a68f49', + yellow2 = '#a89562', + yellow3 = '#5c5241', + } +else + palette = { + NONE = 'NONE', + fg = '#203050', + bg = '#f5f5ff', + blue = '#6e6eff', + blue_bg = '#202050', + blue2 = '#6f8fff', + comment = '#a0a0e0', + cursor = '#5b5bb6', + gray = '#bebebe', + gray2 = '#171717', + green = '#6f9226', + green_bg = '#204020', + orange = '#e79230', + orange2 = '#ff7100', + red = '#d77253', + red_bg = '#402020', + selection = '#f0f0d0', + yellow = '#cba224', + yellow2 = '#af8e29', + yellow3 = '#c6b683', + } +end + + + +-- Semantic highlight group {{{1 + +local function hl(group_name, guifg, guibg, attr) + vim.cmd(('hi! ocean%s guifg=%s guibg=%s gui=%s cterm=%s'):format( + group_name, + palette[guifg], + palette[guibg], + attr, + attr) + ) +end + + + +hl('AnalysisError', 'red', 'NONE', 'underline') +hl('AnalysisWarning', 'yellow2', 'NONE', 'underline') +hl('Cursor', 'fg', 'cursor', 'NONE') +hl('DecorationBold', 'NONE', 'NONE', 'bold') +hl('DecorationUnderlined', 'NONE', 'NONE', 'underline') +hl('DiffAdd', 'NONE', 'blue_bg', 'NONE') +hl('DiffChange', 'NONE', 'green_bg', 'NONE') +hl('DiffDelete', 'NONE', 'red_bg', 'NONE') +hl('DiffText', 'NONE', 'green_bg', 'underline') +hl('Error', 'red', 'NONE', 'NONE') +hl('Hidden', 'bg', 'bg', 'NONE') +hl('Normal', 'fg', 'bg', 'NONE') +hl('Prompt', 'comment', 'NONE', 'bold') +hl('Search', 'bg', 'yellow3', 'NONE') +hl('Special', 'red', 'NONE', 'NONE') +hl('SpecialKey', 'gray', 'NONE', 'NONE') +hl('SyntaxComment', 'comment', 'NONE', 'NONE') +hl('SyntaxCommentSpecial', 'fg', 'NONE', 'bold') +hl('SyntaxConstant', 'red', 'NONE', 'NONE') +hl('SyntaxIdentifier', 'green', 'NONE', 'NONE') +hl('SyntaxStatement', 'blue', 'NONE', 'bold') +hl('SyntaxStatement2', 'blue', 'NONE', 'NONE') +hl('SyntaxString', 'yellow', 'NONE', 'NONE') +hl('SyntaxType', 'blue2', 'NONE', 'NONE') +hl('Title', 'orange', 'NONE', 'NONE') +hl('UiCompletion', 'fg', 'gray', 'NONE') +hl('UiSelection', 'NONE', 'selection', 'NONE') +hl('UiStatusLine', 'fg', 'gray', 'NONE') +hl('UiStatusLineModeCommand', 'bg', 'blue', 'bold') +hl('UiStatusLineModeInsert', 'bg', 'green', 'bold') +hl('UiStatusLineModeNormal', 'bg', 'blue', 'bold') +hl('UiStatusLineModeOperator', 'bg', 'blue', 'bold') +hl('UiStatusLineModeOther', 'bg', 'blue', 'bold') +hl('UiStatusLineModeReplace', 'bg', 'red', 'bold') +hl('UiStatusLineModeTerminal', 'bg', 'blue', 'bold') +hl('UiStatusLineModeVisual', 'bg', 'orange', 'bold') +hl('UiStatusLineNC', 'comment', 'gray2', 'NONE') +hl('UiTabLine', 'fg', 'gray', 'NONE') +hl('UiTabLineNC', 'comment', 'bg', 'NONE') +hl('UiTarget', 'orange2', 'NONE', 'underline') +hl('Warning', 'yellow2', 'NONE', 'NONE') + + + +-- Highlight link {{{1 + +local function link(from, to) + vim.cmd(('hi! link %s ocean%s'):format(from, to)) +end + + + +-- :sort /, \+/ + +-- Vim builtins {{{2 + +link('SpellBad', 'AnalysisError') +link('SpellCap', 'AnalysisError') +link('SpellLocal', 'AnalysisWarning') +link('SpellRare', 'AnalysisWarning') +link('Cursor', 'Cursor') +link('CursorIM', 'Cursor') +link('Underlined', 'DecorationUnderlined') +link('DiffAdd', 'DiffAdd') +link('DiffChange', 'DiffChange') +link('DiffDelete', 'DiffDelete') +link('DiffText', 'DiffText') +link('Error', 'Error') +link('ErrorMsg', 'Error') +link('EndOfBuffer', 'Hidden') +link('MatchParen', 'Hidden') +link('CursorLineNr', 'Normal') +link('Normal', 'Normal') +link('MoreMsg', 'Prompt') +link('Question', 'Prompt') +link('IncSearch', 'Search') +link('Search', 'Search') +link('Special', 'Special') +link('NonText', 'SpecialKey') +link('SpecialKey', 'SpecialKey') +link('Comment', 'SyntaxComment') +link('Folded', 'SyntaxComment') +link('ModeMsg', 'SyntaxComment') +link('SpecialComment', 'SyntaxCommentSpecial') +link('Todo', 'SyntaxCommentSpecial') +link('Constant', 'SyntaxConstant') +link('Identifier', 'SyntaxIdentifier') +link('Statement', 'SyntaxStatement') +link('Operator', 'SyntaxStatement2') +link('PreProc', 'SyntaxStatement2') +link('Character', 'SyntaxString') +link('String', 'SyntaxString') +link('Directory', 'SyntaxType') +link('Type', 'SyntaxType') +link('Title', 'Title') +link('WildMenu', 'Title') +link('PMenu', 'UiCompletion') +link('PMenuSbar', 'UiCompletion') +link('PMenuThumb', 'UiCompletion') +link('CursorColumn', 'UiSelection') +link('CursorLine', 'UiSelection') +link('FoldColumn', 'UiSelection') +link('LineNr', 'UiSelection') +link('PMenuSel', 'UiSelection') +link('SignColumn', 'UiSelection') +link('Visual', 'UiSelection') +link('ColorColumn', 'UiSelection') +link('VertSplit', 'UiStatusLine') +link('WarningMsg', 'Warning') + + +-- 'statusline' and 'tabline' {{{2 + +-- Cited from ':h hl-StatusLineNC': +-- > Note: if this is equal to "StatusLine" Vim will use "^^^" in +-- > the status line of the current window. +link('StatusLine', 'UiStatusLine') +link('StatusLineNC', 'UiStatusLineNC') +link('statusLineModeNormal', 'UiStatusLineModeNormal') +link('statusLineModeInsert', 'UiStatusLineModeInsert') +link('statusLineModeVisual', 'UiStatusLineModeVisual') +link('statusLineModeOperator', 'UiStatusLineModeOperator') +link('statusLineModeReplace', 'UiStatusLineModeReplace') +link('statusLineModeCommand', 'UiStatusLineModeCommand') +link('statusLineModeTerminal', 'UiStatusLineModeTerminal') +link('statusLineModeOther', 'UiStatusLineModeOther') + + +link('TabLineSel', 'UiTabLine') +link('TabLine', 'UiTabLineNC') +link('TabLineFill', 'Hidden') + + +-- Third-party plugins {{{2 + +link('YankRoundRegion', 'UiSelection') + +link('OperatorSandwichAdd', 'UiSelection') +link('OperatorSandwichBuns', 'UiSelection') +link('OperatorSandwichChange', 'UiSelection') +link('OperatorSandwichDelete', 'UiSelection') + +link('HopNextKey', 'UiTarget') +link('HopNextKey1', 'UiTarget') +link('HopNextKey2', 'UiTarget') + + +-- File types {{{2 + +-- c {{{3 + +link('cOctalZero', 'Constant') + +-- cpp {{{3 + +link('cppRawStringDelimiter', 'SyntaxString') + +-- html {{{3 + +link('htmlEndTag', 'SyntaxStatement2') +link('htmlTag', 'SyntaxStatement2') +link('htmlTagName', 'SyntaxStatement2') + +-- php {{{3 + +link('phpParent', 'Normal') +link('phpOperator', 'Normal') +link('phpRelation', 'Normal') +link('phpDocTags', 'SyntaxCommentSpecial') +link('phpSpecialFunction', 'SyntaxIdentifier') + +-- ruby {{{3 + +link('rubyDataDirective', 'SyntaxStatement2') +link('rubyStringDelimiter', 'SyntaxString') + +-- sh {{{3 + +link('shQuote', 'SyntaxString') +link('shDerefSimple', 'SyntaxIdentifier') +link('shDerefVar', 'SyntaxIdentifier') + + + + + +-- Utilities {{{1 + +vim.cmd([[ +command! -bar + \ OceanGetHighlightGroupName + \ echo synIDattr(synID(line('.'), col('.'), v:false), 'name') +]]) diff --git a/.config/nvim/colors/ocean.vim b/.config/nvim/colors/ocean.vim deleted file mode 100644 index 3158b7e..0000000 --- a/.config/nvim/colors/ocean.vim +++ /dev/null @@ -1,263 +0,0 @@ -scriptencoding utf-8 - - -hi clear -let g:colors_name = 'ocean' - - - -" Color palette {{{1 - -if &background ==# 'dark' - let s:palette = { - \ 'NONE': 'NONE', - \ 'fg': '#b1b1c8', - \ 'bg': '#101020', - \ 'blue': '#6e6eff', - \ 'blue-bg': '#202050', - \ 'blue2': '#70b0ff', - \ 'comment': '#8686bf', - \ 'cursor': '#5b5bb6', - \ 'gray': '#353535', - \ 'gray2': '#202020', - \ 'green': '#c4e088', - \ 'green-bg': '#204020', - \ 'orange': '#deab52', - \ 'orange2': '#ff7100', - \ 'red': '#a65f49', - \ 'red-bg': '#402020', - \ 'selection': '#303060', - \ 'yellow': '#a68f49', - \ 'yellow2': '#a89562', - \ 'yellow3': '#5c5241', - \ } -else - let s:palette = { - \ 'NONE': 'NONE', - \ 'fg': '#203050', - \ 'bg': '#f5f5ff', - \ 'blue': '#6e6eff', - \ 'blue-bg': '#202050', - \ 'blue2': '#6f8fff', - \ 'comment': '#a0a0e0', - \ 'cursor': '#5b5bb6', - \ 'gray': '#bebebe', - \ 'gray2': '#171717', - \ 'green': '#6f9226', - \ 'green-bg': '#204020', - \ 'orange': '#e79230', - \ 'orange2': '#ff7100', - \ 'red': '#d77253', - \ 'red-bg': '#402020', - \ 'selection': '#f0f0d0', - \ 'yellow': '#cba224', - \ 'yellow2': '#af8e29', - \ 'yellow3': '#c6b683', - \ } -endif - - - -" Semantic highlight group {{{1 - -function! s:hl(group_name, guifg, guibg, attr) abort - execute printf('hi! ocean%s guifg=%s guibg=%s gui=%s cterm=%s', - \ a:group_name, - \ s:palette[a:guifg], - \ s:palette[a:guibg], - \ a:attr, - \ a:attr) -endfunction - - -call s:hl('AnalysisError', 'red', 'NONE', 'underline') -call s:hl('AnalysisWarning', 'yellow2', 'NONE', 'underline') -call s:hl('Cursor', 'fg', 'cursor', 'NONE') -call s:hl('DecorationBold', 'NONE', 'NONE', 'bold') -call s:hl('DecorationUnderlined', 'NONE', 'NONE', 'underline') -call s:hl('DiffAdd', 'NONE', 'blue-bg', 'NONE') -call s:hl('DiffChange', 'NONE', 'green-bg', 'NONE') -call s:hl('DiffDelete', 'NONE', 'red-bg', 'NONE') -call s:hl('DiffText', 'NONE', 'green-bg', 'underline') -call s:hl('Error', 'red', 'NONE', 'NONE') -call s:hl('Hidden', 'bg', 'bg', 'NONE') -call s:hl('Normal', 'fg', 'bg', 'NONE') -call s:hl('Prompt', 'comment', 'NONE', 'bold') -call s:hl('Search', 'bg', 'yellow3', 'NONE') -call s:hl('Special', 'red', 'NONE', 'NONE') -call s:hl('SpecialKey', 'gray', 'NONE', 'NONE') -call s:hl('SyntaxComment', 'comment', 'NONE', 'NONE') -call s:hl('SyntaxCommentSpecial', 'fg', 'NONE', 'bold') -call s:hl('SyntaxConstant', 'red', 'NONE', 'NONE') -call s:hl('SyntaxIdentifier', 'green', 'NONE', 'NONE') -call s:hl('SyntaxStatement', 'blue', 'NONE', 'bold') -call s:hl('SyntaxStatement2', 'blue', 'NONE', 'NONE') -call s:hl('SyntaxString', 'yellow', 'NONE', 'NONE') -call s:hl('SyntaxType', 'blue2', 'NONE', 'NONE') -call s:hl('Title', 'orange', 'NONE', 'NONE') -call s:hl('UiCompletion', 'fg', 'gray', 'NONE') -call s:hl('UiSelection', 'NONE', 'selection', 'NONE') -call s:hl('UiStatusLine', 'fg', 'gray', 'NONE') -call s:hl('UiStatusLineModeCommand', 'bg', 'blue', 'bold') -call s:hl('UiStatusLineModeInsert', 'bg', 'green', 'bold') -call s:hl('UiStatusLineModeNormal', 'bg', 'blue', 'bold') -call s:hl('UiStatusLineModeOperator', 'bg', 'blue', 'bold') -call s:hl('UiStatusLineModeOther', 'bg', 'blue', 'bold') -call s:hl('UiStatusLineModeReplace', 'bg', 'red', 'bold') -call s:hl('UiStatusLineModeTerminal', 'bg', 'blue', 'bold') -call s:hl('UiStatusLineModeVisual', 'bg', 'orange', 'bold') -call s:hl('UiStatusLineNC', 'comment', 'gray2', 'NONE') -call s:hl('UiTabLine', 'fg', 'gray', 'NONE') -call s:hl('UiTabLineNC', 'comment', 'bg', 'NONE') -call s:hl('UiTarget', 'orange2', 'NONE', 'underline') -call s:hl('Warning', 'yellow2', 'NONE', 'NONE') - -delfunction! s:hl - - - -" Highlight link {{{1 - -" :sort /hi! link \w\+ \+/ - -" Vim builtins {{{2 - -hi! link SpellBad oceanAnalysisError -hi! link SpellCap oceanAnalysisError -hi! link SpellLocal oceanAnalysisWarning -hi! link SpellRare oceanAnalysisWarning -hi! link Cursor oceanCursor -hi! link CursorIM oceanCursor -hi! link Underlined oceanDecorationUnderlined -hi! link DiffAdd oceanDiffAdd -hi! link DiffChange oceanDiffChange -hi! link DiffDelete oceanDiffDelete -hi! link DiffText oceanDiffText -hi! link Error oceanError -hi! link ErrorMsg oceanError -hi! link EndOfBuffer oceanHidden -hi! link MatchParen oceanHidden -hi! link CursorLineNr oceanNormal -hi! link Normal oceanNormal -hi! link PMenu oceanUiCompletion -hi! link PMenuSbar oceanUiCompletion -hi! link PMenuThumb oceanUiCompletion -hi! link MoreMsg oceanPrompt -hi! link Question oceanPrompt -hi! link IncSearch oceanSearch -hi! link Search oceanSearch -hi! link CursorColumn oceanUiSelection -hi! link CursorLine oceanUiSelection -hi! link FoldColumn oceanUiSelection -hi! link LineNr oceanUiSelection -hi! link PMenuSel oceanUiSelection -hi! link SignColumn oceanUiSelection -hi! link Visual oceanUiSelection -hi! link Special oceanSpecial -hi! link NonText oceanSpecialKey -hi! link SpecialKey oceanSpecialKey -hi! link VertSplit oceanUiStatusLine -hi! link Comment oceanSyntaxComment -hi! link Folded oceanSyntaxComment -hi! link ModeMsg oceanSyntaxComment -hi! link SpecialComment oceanSyntaxCommentSpecial -hi! link Todo oceanSyntaxCommentSpecial -hi! link Constant oceanSyntaxConstant -hi! link Identifier oceanSyntaxIdentifier -hi! link Statement oceanSyntaxStatement -hi! link Operator oceanSyntaxStatement2 -hi! link PreProc oceanSyntaxStatement2 -hi! link Character oceanSyntaxString -hi! link String oceanSyntaxString -hi! link Directory oceanSyntaxType -hi! link Type oceanSyntaxType -hi! link Title oceanTitle -hi! link WildMenu oceanTitle -hi! link ColorColumn oceanUiSelection -hi! link WarningMsg oceanWarning - - -" 'statusline' and 'tabline' {{{2 - -" Cited from ':h hl-StatusLineNC': -" > Note: if this is equal to "StatusLine" Vim will use "^^^" in -" > the status line of the current window. -hi! link StatusLine oceanUiStatusLine -hi! link StatusLineNC oceanUiStatusLineNC -hi! link statusLineModeNormal oceanUiStatusLineModeNormal -hi! link statusLineModeInsert oceanUiStatusLineModeInsert -hi! link statusLineModeVisual oceanUiStatusLineModeVisual -hi! link statusLineModeOperator oceanUiStatusLineModeOperator -hi! link statusLineModeReplace oceanUiStatusLineModeReplace -hi! link statusLineModeCommand oceanUiStatusLineModeCommand -hi! link statusLineModeTerminal oceanUiStatusLineModeTerminal -hi! link statusLineModeOther oceanUiStatusLineModeOther - - -hi! link TabLineSel oceanUiTabLine -hi! link TabLine oceanUiTabLineNC -hi! link TabLineFill oceanHidden - - -" Third-party plugins {{{2 - -hi! link YankRoundRegion oceanUiSelection - -hi! link OperatorSandwichAdd oceanUiSelection -hi! link OperatorSandwichBuns oceanUiSelection -hi! link OperatorSandwichChange oceanUiSelection -hi! link OperatorSandwichDelete oceanUiSelection - -hi! link HopNextKey oceanUiTarget -hi! link HopNextKey1 oceanUiTarget -hi! link HopNextKey2 oceanUiTarget - - -" File types {{{2 - -" c {{{3 - -hi! link cOctalZero oceanConstant - -" cpp {{{3 - -hi! link cppRawStringDelimiter oceanSyntaxString - -" html {{{3 - -hi! link htmlEndTag oceanSyntaxStatement2 -hi! link htmlTag oceanSyntaxStatement2 -hi! link htmlTagName oceanSyntaxStatement2 - -" php {{{3 - -hi! link phpParent oceanNormal -hi! link phpOperator oceanNormal -hi! link phpRelation oceanNormal -hi! link phpDocTags oceanSyntaxCommentSpecial -hi! link phpSpecialFunction oceanSyntaxIdentifier - -" ruby {{{3 - -hi! link rubyDataDirective oceanSyntaxStatement2 -hi! link rubyStringDelimiter oceanSyntaxString - - - - - -" sh {{{3 - -hi! link shQuote oceanSyntaxString -hi! link shDerefSimple oceanSyntaxIdentifier -hi! link shDerefVar oceanSyntaxIdentifier - - - - - -" Utilities {{{1 - -command! -bar - \ OceanGetHighlightGroupName - \ echo synIDattr(synID(line('.'), col('.'), v:false), 'name') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 6ec1ff1..135550f 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1150,12 +1150,12 @@ command! -bar -range=% vim.cmd([[ try - colorscheme ocean + colorscheme ocean catch - " Loading colorscheme failed. - " The color scheme, "desert", is one of the built-in ones. Probably, it - " will be loaded without any errors. - colorscheme desert + " Loading colorscheme failed. + " The color scheme, "desert", is one of the built-in ones. Probably, it + " will be loaded without any errors. + colorscheme desert endtry ]]) |
