feat(diagnostics): add header + icon
This commit is contained in:
parent
4de9c237fa
commit
d634483030
4 changed files with 37 additions and 39 deletions
|
@ -9,12 +9,9 @@ local signs = {
|
||||||
Info = icons.info .. ' ',
|
Info = icons.info .. ' ',
|
||||||
}
|
}
|
||||||
|
|
||||||
local t = vim.fn.sign_getdefined('DiagnosticSignWarn')
|
for type, icon in pairs(signs) do
|
||||||
if vim.tbl_isempty(t) then
|
local hl = 'DiagnosticSign' .. type
|
||||||
for type, icon in pairs(signs) do
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
||||||
local hl = 'DiagnosticSign' .. type
|
|
||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set up vim.diagnostics
|
-- set up vim.diagnostics
|
||||||
|
@ -25,9 +22,10 @@ vim.diagnostic.config(vim.tbl_deep_extend('force', {
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
float = {
|
float = {
|
||||||
header = false,
|
|
||||||
source = 'always',
|
|
||||||
border = config.border,
|
border = config.border,
|
||||||
|
focusable = false,
|
||||||
|
header = { icons.debug .. ' Diagnostics:', 'Normal' },
|
||||||
|
source = 'always',
|
||||||
},
|
},
|
||||||
virtual_text = {
|
virtual_text = {
|
||||||
spacing = 4,
|
spacing = 4,
|
||||||
|
|
|
@ -2,34 +2,7 @@ local cmp = require('cmp')
|
||||||
local utils = require('cosmic-ui.utils')
|
local utils = require('cosmic-ui.utils')
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
local config = require('cosmic.config')
|
local config = require('cosmic.config')
|
||||||
|
local icons = require('cosmic.theme.icons')
|
||||||
local kind_icons = {
|
|
||||||
Text = '',
|
|
||||||
Method = 'm',
|
|
||||||
Function = '',
|
|
||||||
Constructor = '',
|
|
||||||
Field = '',
|
|
||||||
Variable = '',
|
|
||||||
Class = '',
|
|
||||||
Interface = '',
|
|
||||||
Module = '',
|
|
||||||
Property = '',
|
|
||||||
Unit = '',
|
|
||||||
Value = '',
|
|
||||||
Enum = '',
|
|
||||||
Keyword = '',
|
|
||||||
Snippet = '',
|
|
||||||
Color = '',
|
|
||||||
File = '',
|
|
||||||
Reference = '',
|
|
||||||
Folder = '',
|
|
||||||
EnumMember = '',
|
|
||||||
Constant = '',
|
|
||||||
Struct = '',
|
|
||||||
Event = '',
|
|
||||||
Operator = '',
|
|
||||||
TypeParameter = '',
|
|
||||||
}
|
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
@ -99,7 +72,7 @@ local default_cmp_opts = {
|
||||||
formatting = {
|
formatting = {
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
-- Kind icons
|
-- Kind icons
|
||||||
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
|
vim_item.kind = string.format('%s %s', icons.kind_icons[vim_item.kind], vim_item.kind)
|
||||||
vim_item.menu = ({
|
vim_item.menu = ({
|
||||||
nvim_lsp = '[lsp]',
|
nvim_lsp = '[lsp]',
|
||||||
luasnip = '[snip]',
|
luasnip = '[snip]',
|
||||||
|
|
|
@ -17,8 +17,8 @@ require('todo-comments').setup(vim.tbl_deep_extend('force', {
|
||||||
},
|
},
|
||||||
colors = {
|
colors = {
|
||||||
error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' },
|
error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' },
|
||||||
warning = { 'DiagnosticWarning', 'WarningMsg', '#FBBF24' },
|
warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' },
|
||||||
info = { 'DiagnosticInformation', '#2563EB' },
|
info = { 'DiagnosticInfo', '#2563EB' },
|
||||||
hint = { 'DiagnosticHint', '#10B981' },
|
hint = { 'DiagnosticHint', '#10B981' },
|
||||||
default = { 'Identifier', '#7C3AED' },
|
default = { 'Identifier', '#7C3AED' },
|
||||||
},
|
},
|
||||||
|
|
|
@ -52,6 +52,33 @@ local icons = {
|
||||||
symlink = '',
|
symlink = '',
|
||||||
symlink_open = '',
|
symlink_open = '',
|
||||||
},
|
},
|
||||||
|
kind_icons = {
|
||||||
|
Text = '',
|
||||||
|
Method = 'm',
|
||||||
|
Function = '',
|
||||||
|
Constructor = '',
|
||||||
|
Field = '',
|
||||||
|
Variable = '',
|
||||||
|
Class = '',
|
||||||
|
Interface = '',
|
||||||
|
Module = '',
|
||||||
|
Property = '',
|
||||||
|
Unit = '',
|
||||||
|
Value = '',
|
||||||
|
Enum = '',
|
||||||
|
Keyword = '',
|
||||||
|
Snippet = '',
|
||||||
|
Color = '',
|
||||||
|
File = '',
|
||||||
|
Reference = '',
|
||||||
|
Folder = '',
|
||||||
|
EnumMember = '',
|
||||||
|
Constant = '',
|
||||||
|
Struct = '',
|
||||||
|
Event = '',
|
||||||
|
Operator = '',
|
||||||
|
TypeParameter = '',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return icons
|
return icons
|
||||||
|
|
Loading…
Add table
Reference in a new issue