navigator.lua/lua/navigator/lspclient/highlight.lua

77 lines
3.0 KiB
Lua
Raw Normal View History

2021-04-19 02:56:32 +00:00
local M = {}
2022-06-01 15:41:26 +00:00
-- local log = require('navigator.util').log
2021-04-19 02:56:32 +00:00
local api = vim.api
2022-07-27 04:36:29 +00:00
local cmd_group = api.nvim_create_augroup('NGHiGroup', {})
2021-04-19 02:56:32 +00:00
-- lsp sign          ﮻         ﯭ        ﳀ  
function M.diagnositc_config_sign()
if M.configed then
return
end
local icons = _NgConfigValues.icons
2022-02-17 11:21:34 +00:00
local sign_name = 'NavigatorLightBulb'
if vim.fn.sign_getdefined(sign_name).text == nil then
2022-02-17 11:21:34 +00:00
vim.fn.sign_define(sign_name, { text = icons.code_action_icon, texthl = 'LspDiagnosticsSignHint' })
2022-02-17 11:21:34 +00:00
sign_name = 'NavigatorCodeLensLightBulb'
vim.fn.sign_define(sign_name, { text = icons.code_lens_action_icon, texthl = 'LspDiagnosticsSignHint' })
end
2022-02-17 11:21:34 +00:00
local e, w, i, h = icons.diagnostic_err, icons.diagnostic_warn, icons.diagnostic_info, icons.diagnostic_hint
local t = vim.fn.sign_getdefined('DiagnosticSignWarn')
if vim.tbl_isempty(t) or t[1].text == 'W ' and icons.icons == true then
vim.fn.sign_define('DiagnosticSignError', { text = e, texthl = 'DiagnosticError', linehl = '', numhl = '' })
vim.fn.sign_define('DiagnosticSignWarn', { text = w, texthl = 'DiagnosticWarn', linehl = '', numhl = '' })
vim.fn.sign_define('DiagnosticSignInfo', { text = i, texthl = 'DiagnosticInfo', linehl = '', numhl = '' })
vim.fn.sign_define('DiagnosticSignHint', { text = h, texthl = 'DiagnosticHint', linehl = '', numhl = '' })
2022-02-17 11:21:34 +00:00
t = vim.fn.sign_getdefined('DiagnosticSignWarn')
end
M.configed = true
2021-04-19 02:56:32 +00:00
end
local colors = {
{ '#aefe00', '#aede00', '#aebe00', '#4e7efe' },
{ '#ff00e0', '#df00e0', '#af00e0', '#fedefe' },
{ '#1000ef', '#2000df', '#2000cf', '#f0f040' },
{ '#d8a8a3', '#c8a8a3', '#b8a8a3', '#4e2c33' },
{ '#ffa724', '#efa024', '#dfa724', '#0040ff' },
{ '#afdc2b', '#09dc4b', '#08d04b', '#ef4f8f' },
}
2021-04-19 02:56:32 +00:00
function M.add_highlight()
-- lsp system default
api.nvim_set_hl(0, 'DiagnosticUnderlineError', { link = 'SpellBad', default = true })
api.nvim_set_hl(0, 'DiagnosticUnderlineWarning', { link = 'SpellRare', default = true })
api.nvim_set_hl(0, 'DiagnosticUnderlineInformation', { link = 'SpellRare', default = true })
api.nvim_set_hl(0, 'DiagnosticUnderlineHint', { link = 'SpellRare', default = true })
api.nvim_set_hl(0, 'NGPreviewTitle', { link = 'Title', default = true })
2022-07-27 04:36:29 +00:00
api.nvim_set_hl(0, 'LspReferenceRead', { default = true, bold = true, ctermfg = 'Yellow', underline = true })
api.nvim_set_hl(0, 'LspReferenceText', { default = true, bold = true, ctermfg = 'White', underline = true })
api.nvim_set_hl(
0,
'LspReferenceWrite',
{ default = true, bold = true, italic = true, ctermfg = 'Magenta', underdouble = true }
)
2021-05-29 11:08:30 +00:00
for i = 1, #colors do
for j = 1, 3 do
2022-07-27 04:36:29 +00:00
local hlg = string.format('NGHiReference_%i_%i', i, j) -- , colors[i][j], colors[i][4]
api.nvim_set_hl(0, hlg, { fg = colors[i][j], bg = colors[i][4], default = true })
2021-05-29 11:08:30 +00:00
end
end
2021-04-19 02:56:32 +00:00
end
2022-07-27 04:36:29 +00:00
api.nvim_create_autocmd('ColorScheme', {
group = cmd_group,
pattern = '*',
callback = function()
M.add_highlight()
end,
})
2021-04-19 02:56:32 +00:00
return M