feat(diagnostics): add header + icon

This commit is contained in:
Matt Leong 2021-12-19 20:38:14 -08:00
parent 4de9c237fa
commit d634483030
4 changed files with 37 additions and 39 deletions
lua/cosmic
lsp
plugins
nvim-cmp
todo-comments
theme

View file

@ -9,12 +9,9 @@ local signs = {
Info = icons.info .. ' ',
}
local t = vim.fn.sign_getdefined('DiagnosticSignWarn')
if vim.tbl_isempty(t) then
for type, icon in pairs(signs) do
local hl = 'DiagnosticSign' .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
end
for type, icon in pairs(signs) do
local hl = 'DiagnosticSign' .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
end
-- set up vim.diagnostics
@ -25,9 +22,10 @@ vim.diagnostic.config(vim.tbl_deep_extend('force', {
update_in_insert = false,
severity_sort = true,
float = {
header = false,
source = 'always',
border = config.border,
focusable = false,
header = { icons.debug .. ' Diagnostics:', 'Normal' },
source = 'always',
},
virtual_text = {
spacing = 4,

View file

@ -2,34 +2,7 @@ local cmp = require('cmp')
local utils = require('cosmic-ui.utils')
local luasnip = require('luasnip')
local config = require('cosmic.config')
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 icons = require('cosmic.theme.icons')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
@ -99,7 +72,7 @@ local default_cmp_opts = {
formatting = {
format = function(entry, vim_item)
-- 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 = ({
nvim_lsp = '[lsp]',
luasnip = '[snip]',

View file

@ -17,8 +17,8 @@ require('todo-comments').setup(vim.tbl_deep_extend('force', {
},
colors = {
error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' },
warning = { 'DiagnosticWarning', 'WarningMsg', '#FBBF24' },
info = { 'DiagnosticInformation', '#2563EB' },
warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' },
info = { 'DiagnosticInfo', '#2563EB' },
hint = { 'DiagnosticHint', '#10B981' },
default = { 'Identifier', '#7C3AED' },
},

View file

@ -52,6 +52,33 @@ local icons = {
symlink = '',
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