vim: move custom highlights to colorscheme config()
This commit is contained in:
parent
afdda2d4f3
commit
2498e73c10
6 changed files with 50 additions and 52 deletions
|
@ -1,15 +1,9 @@
|
||||||
local util = require'fs.util'
|
local nmap = require'fs.util'.nmap
|
||||||
local nmap = util.nmap
|
|
||||||
local colors = util.colors()
|
|
||||||
local highlight = util.highlight
|
|
||||||
|
|
||||||
local config = function()
|
local config = function()
|
||||||
vim.g.indent_blankline_enabled = false
|
require'indent_blankline'.setup { enabled = false }
|
||||||
|
|
||||||
require'indent_blankline'.setup()
|
|
||||||
|
|
||||||
highlight('IndentBlanklineChar') { fg = colors.base01 }
|
|
||||||
|
|
||||||
|
-- show/hide indent guides
|
||||||
nmap { '<leader>si', '<cmd>:IndentBlanklineToggle<cr>' }
|
nmap { '<leader>si', '<cmd>:IndentBlanklineToggle<cr>' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
local util = require'fs.util'
|
local nmap = require'fs.util'.nmap
|
||||||
local nmap = util.nmap
|
|
||||||
local colors = util.colors()
|
|
||||||
local highlight = util.highlight
|
|
||||||
|
|
||||||
-- helper to set vim.g options that will be moved to setup() later
|
-- helper to set vim.g options that will be moved to setup() later
|
||||||
local function set_globals(tbl)
|
local function set_globals(tbl)
|
||||||
|
@ -41,15 +38,6 @@ local config = function()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
highlight('NvimTreeSpecialFile') { fg = colors.base2 }
|
|
||||||
highlight('NvimTreeIndentMarker') { fg = colors.base01 }
|
|
||||||
highlight('NvimTreeGitStaged') { fg = colors.green }
|
|
||||||
highlight('NvimTreeGitRenamed') { fg = colors.yellow }
|
|
||||||
highlight('NvimTreeGitNew') { fg = colors.yellow }
|
|
||||||
highlight('NvimTreeGitDirty') { fg = colors.yellow }
|
|
||||||
highlight('NvimTreeGitDeleted') { fg = colors.orange }
|
|
||||||
highlight('NvimTreeGitMerge') { fg = colors.red }
|
|
||||||
|
|
||||||
nmap { '<c-n>', '<cmd>NvimTreeToggle<cr>' }
|
nmap { '<c-n>', '<cmd>NvimTreeToggle<cr>' }
|
||||||
nmap { '<leader>n', '<cmd>NvimTreeFindFileToggle<cr>' }
|
nmap { '<leader>n', '<cmd>NvimTreeFindFileToggle<cr>' }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
local util = require'fs.util'
|
local nmap = require'fs.util'.nmap
|
||||||
local nmap = util.nmap
|
|
||||||
local colors = util.colors()
|
|
||||||
local highlight = util.highlight
|
|
||||||
|
|
||||||
local setup = function()
|
local setup = function()
|
||||||
vim.g.better_whitespace_filetypes_blacklist = {
|
vim.g.better_whitespace_filetypes_blacklist = {
|
||||||
|
@ -10,8 +7,6 @@ local setup = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = function()
|
local config = function()
|
||||||
highlight('ExtraWhitespace') { fg = colors.orange, bg = colors.orange }
|
|
||||||
|
|
||||||
-- fix whitespace
|
-- fix whitespace
|
||||||
nmap { '<leader>w', '<cmd>StripWhitespace<cr>' }
|
nmap { '<leader>w', '<cmd>StripWhitespace<cr>' }
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,41 @@ local util = require'fs.util'
|
||||||
local C = util.colors()
|
local C = util.colors()
|
||||||
local highlight = util.highlight
|
local highlight = util.highlight
|
||||||
|
|
||||||
|
local additional_highlights = {
|
||||||
|
-- Override the colorscheme for these ones:
|
||||||
|
Normal = { bg = 'NONE' }, -- transparent background
|
||||||
|
NonText = { fg = C.base02, attrs = 'NONE' }, -- very subtle EOL symbols
|
||||||
|
Whitespace = { fg = C.orange }, -- listchars
|
||||||
|
SpellBad = { fg = C.yellow }, -- spelling mistakes
|
||||||
|
QuickFixLine = { fg = C.yellow, bg = C.base02 }, -- selected quickfix item
|
||||||
|
CursorLineNr = { fg = C.yellow, attrs = 'NONE' }, -- current line number
|
||||||
|
|
||||||
|
-- Trailing whitespace, from 'ntpeters/vim-better-whitespace':
|
||||||
|
ExtraWhitespace = { fg = C.orange, bg = C.orange },
|
||||||
|
|
||||||
|
-- Indentation guids, from 'lukas-reineke/indent-blankline.nvim':
|
||||||
|
IndentBlanklineChar = { fg = C.base01 },
|
||||||
|
|
||||||
|
-- Virtual colorcolumn, from 'lukas-reineke/virt-column.nvim':
|
||||||
|
VirtColumn = { fg = C.base02, bg = C.base03, attrs = 'NONE' },
|
||||||
|
|
||||||
|
-- Colors for 'kyazdani42/nvim-tree.lua':
|
||||||
|
NvimTreeSpecialFile = { fg = C.base2 },
|
||||||
|
NvimTreeIndentMarker = { fg = C.base01 },
|
||||||
|
NvimTreeGitStaged = { fg = C.green },
|
||||||
|
NvimTreeGitRenamed = { fg = C.yellow },
|
||||||
|
NvimTreeGitNew = { fg = C.yellow },
|
||||||
|
NvimTreeGitDirty = { fg = C.yellow },
|
||||||
|
NvimTreeGitDeleted = { fg = C.orange },
|
||||||
|
NvimTreeGitMerge = { fg = C.red },
|
||||||
|
}
|
||||||
|
|
||||||
local config = function()
|
local config = function()
|
||||||
vim.cmd [[silent! colorscheme solarized]]
|
vim.cmd [[silent! colorscheme solarized]]
|
||||||
|
|
||||||
highlight('Normal') { bg = 'NONE' } -- transparent background
|
for group, hl in pairs(additional_highlights) do
|
||||||
highlight('NonText') { fg = C.base02, attrs = 'NONE' } -- subtle EOL symbols
|
highlight(group, hl)
|
||||||
highlight('Whitespace') { fg = C.orange } -- listchars
|
end
|
||||||
highlight('SpellBad') { fg = C.yellow }
|
|
||||||
highlight('QuickFixLine') { fg = C.yellow, bg = C.base02 } -- selected quickfix item
|
|
||||||
highlight('CursorLineNr') { fg = C.yellow, attrs = 'NONE' } -- current line number
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return { config = config }
|
return { config = config }
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
local util = require'fs.util'
|
local nmap = require'fs.util'.nmap
|
||||||
local nmap = util.nmap
|
|
||||||
local colors = util.colors()
|
|
||||||
local highlight = util.highlight
|
|
||||||
|
|
||||||
local toggle = function()
|
local toggle = function()
|
||||||
if vim.o.colorcolumn == '' then
|
if vim.o.colorcolumn == '' then
|
||||||
|
@ -14,9 +11,8 @@ end
|
||||||
local config = function()
|
local config = function()
|
||||||
require'virt-column'.setup { char = '│' }
|
require'virt-column'.setup { char = '│' }
|
||||||
|
|
||||||
highlight('VirtColumn') { fg = colors.base02, attrs = 'NONE' }
|
-- show/hide virtual colorcolumn
|
||||||
|
nmap { '<leader>sc', [[<cmd>lua require'fs.config.virt-column'.toggle()<cr>]] }
|
||||||
nmap { '<leader>sc', '<cmd>lua require"fs.config.virt-column".toggle()<cr>' }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return { config = config, toggle = toggle }
|
return { config = config, toggle = toggle }
|
||||||
|
|
|
@ -58,19 +58,18 @@ M.colors = function(gui)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Usage example:
|
-- Usage example:
|
||||||
-- highlight('Test2') { fg = C.yellow, bg = C.base02 }
|
-- highlight('Test2', { fg = C.yellow, bg = C.base02 })
|
||||||
M.highlight = function(name)
|
M.highlight = function(group, highlights)
|
||||||
return function(tbl)
|
local kind = vim.opt.termguicolors:get() and 'gui' or 'cterm'
|
||||||
local kind = vim.opt.termguicolors:get() and 'gui' or 'cterm'
|
|
||||||
|
|
||||||
local parts = {}
|
local parts = {}
|
||||||
for k, v in pairs(tbl) do
|
for k, v in pairs(highlights) do
|
||||||
if k == 'attrs' then k = '' end
|
if k == 'attrs' then k = '' end
|
||||||
table.insert(parts, kind .. k .. '=' .. v)
|
table.insert(parts, kind .. k .. '=' .. v)
|
||||||
end
|
|
||||||
|
|
||||||
vim.cmd('highlight ' .. name .. ' ' .. vim.fn.join(parts, ' '))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local cmd = 'highlight ' .. group .. ' ' .. vim.fn.join(parts, ' ')
|
||||||
|
vim.cmd(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Add table
Reference in a new issue