From d6344830308290edb9b7359eecc4996c99dcee25 Mon Sep 17 00:00:00 2001 From: Matt Leong Date: Sun, 19 Dec 2021 20:38:14 -0800 Subject: [PATCH] feat(diagnostics): add header + icon --- lua/cosmic/lsp/diagnostics.lua | 14 +++++----- lua/cosmic/plugins/nvim-cmp/init.lua | 31 ++--------------------- lua/cosmic/plugins/todo-comments/init.lua | 4 +-- lua/cosmic/theme/icons.lua | 27 ++++++++++++++++++++ 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/lua/cosmic/lsp/diagnostics.lua b/lua/cosmic/lsp/diagnostics.lua index 8cf2cea..0e743af 100644 --- a/lua/cosmic/lsp/diagnostics.lua +++ b/lua/cosmic/lsp/diagnostics.lua @@ -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, diff --git a/lua/cosmic/plugins/nvim-cmp/init.lua b/lua/cosmic/plugins/nvim-cmp/init.lua index febaad3..a382158 100644 --- a/lua/cosmic/plugins/nvim-cmp/init.lua +++ b/lua/cosmic/plugins/nvim-cmp/init.lua @@ -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]', diff --git a/lua/cosmic/plugins/todo-comments/init.lua b/lua/cosmic/plugins/todo-comments/init.lua index 0c4a98b..84c9331 100644 --- a/lua/cosmic/plugins/todo-comments/init.lua +++ b/lua/cosmic/plugins/todo-comments/init.lua @@ -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' }, }, diff --git a/lua/cosmic/theme/icons.lua b/lua/cosmic/theme/icons.lua index fe7b1ce..206d7ec 100644 --- a/lua/cosmic/theme/icons.lua +++ b/lua/cosmic/theme/icons.lua @@ -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