From 8064cf355ac78d5ea06ee27112f839f0f8fdf347 Mon Sep 17 00:00:00 2001 From: Matt Leong Date: Fri, 29 Oct 2021 14:18:05 -0700 Subject: [PATCH] feat(config): full vim.diagnostic config settings --- lua/cosmic/config/config.lua | 7 +++++-- lua/cosmic/config/init.lua | 17 +++++++++++++++-- lua/cosmic/lsp/diagnostics.lua | 13 +------------ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lua/cosmic/config/config.lua b/lua/cosmic/config/config.lua index ca9991c..bd4a83b 100644 --- a/lua/cosmic/config/config.lua +++ b/lua/cosmic/config/config.lua @@ -4,6 +4,7 @@ local config = {} +-- statusline settings config.statusline = { main_icon = '★', } @@ -29,12 +30,13 @@ config.lsp = { -- set to false to disable rename notification rename_notification = false, + -- see :h vim.diagnostic.config for all diagnostic configuration options diagnostic = { - -- disable diagnostic virtual text (see :h vim.diagnostic.config for all options) + -- disable diagnostic virtual text virtual_text = false, - -- disable diagnostic signs (see :h vim.diagnostic.config for all options) + -- disable diagnostic signs signs = false, -- enable diagnostic update on insert @@ -70,6 +72,7 @@ config.lsp = { -- specifc to efm, e.g. 'eslint', 'prettier', 'stylua' disable_formatters = {'eslint'}, }, + }, } diff --git a/lua/cosmic/config/init.lua b/lua/cosmic/config/init.lua index d80a8c9..8fec7ea 100644 --- a/lua/cosmic/config/init.lua +++ b/lua/cosmic/config/init.lua @@ -30,9 +30,17 @@ local default_config = { lsp = { format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',} rename_notification = true, + -- vim.diagnostic.config settiings diagnostic = { + underline = true, signs = true, update_in_insert = false, + severity_sort = true, + float = { + show_header = false, + source = 'always', + border = 'single', + }, virtual_text = { spacing = 4, source = 'always', @@ -49,10 +57,15 @@ local default_config = { }, }, servers = { + -- override lsp server options + --[[ rust_analyzer = { + opts = {} + }, ]] + -- enable/disable server + formatting + -- rust_analyzer = true, -- enable non-default servers (todo: support for custom server configs) eslint = { format = false, - }, -- enable/disable server + formatting - -- rust_analyzer = true, -- enable non-default servers (todo: support for custom server configs) + }, efm = { format = true, -- true or false disable_formatters = { 'eslint' }, -- e.g. 'eslint', 'prettier', 'stylua' diff --git a/lua/cosmic/lsp/diagnostics.lua b/lua/cosmic/lsp/diagnostics.lua index 8253db7..3fb0e17 100644 --- a/lua/cosmic/lsp/diagnostics.lua +++ b/lua/cosmic/lsp/diagnostics.lua @@ -3,18 +3,7 @@ local icons = require('cosmic.core.theme.icons') local M = {} function M.init() - vim.diagnostic.config({ - underline = true, - update_in_insert = config.lsp.diagnostic.update_in_insert, - virtual_text = config.lsp.diagnostic.virtual_text, - signs = config.lsp.diagnostic.signs, - severity_sort = true, - float = { - show_header = false, - source = 'always', - border = 'single', - }, - }) + vim.diagnostic.config(config.lsp.diagnostic) local function do_diagnostic_signs() local signs = {