feat(config): add configurable diagnostic settings
This commit is contained in:
parent
3233a424e9
commit
4acead695c
3 changed files with 36 additions and 16 deletions
|
@ -13,6 +13,20 @@ config.lsp = {
|
||||||
-- true/false or table of filetypes {'.ts', '.js',}
|
-- true/false or table of filetypes {'.ts', '.js',}
|
||||||
format_on_save = true,
|
format_on_save = true,
|
||||||
|
|
||||||
|
diagnostic = {
|
||||||
|
-- disable diagnostic virtual text (see :h vim.diagnostic.config for all options)
|
||||||
|
virtual_text = false,
|
||||||
|
|
||||||
|
-- disable diagnostic signs (see :h vim.diagnostic.config for all options)
|
||||||
|
signs = false,
|
||||||
|
|
||||||
|
-- enable diagnostic update on insert
|
||||||
|
update_in_insert = true,
|
||||||
|
|
||||||
|
-- disable underline for diagnostic
|
||||||
|
underline = false,
|
||||||
|
}
|
||||||
|
|
||||||
servers = {
|
servers = {
|
||||||
|
|
||||||
-- enable/disable server + formatting
|
-- enable/disable server + formatting
|
||||||
|
|
|
@ -17,6 +17,24 @@ local default_config = {
|
||||||
},
|
},
|
||||||
lsp = {
|
lsp = {
|
||||||
format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',}
|
format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',}
|
||||||
|
diagnostic = {
|
||||||
|
signs = true,
|
||||||
|
update_in_insert = false,
|
||||||
|
virtual_text = {
|
||||||
|
spacing = 4,
|
||||||
|
source = 'always',
|
||||||
|
severity = {
|
||||||
|
min = vim.diagnostic.severity.HINT,
|
||||||
|
},
|
||||||
|
-- todo: icons for diagnostics?
|
||||||
|
--[[ format = function(diagnostic)
|
||||||
|
if diagnostic.severity == vim.diagnostic.severity.ERROR then
|
||||||
|
return string.format('E: %s', diagnostic.message)
|
||||||
|
end
|
||||||
|
return diagnostic.message
|
||||||
|
end, ]]
|
||||||
|
},
|
||||||
|
},
|
||||||
servers = {
|
servers = {
|
||||||
eslint = {
|
eslint = {
|
||||||
format = false,
|
format = false,
|
||||||
|
|
|
@ -1,25 +1,13 @@
|
||||||
|
local config = require('cosmic.config')
|
||||||
local icons = require('cosmic.core.theme.icons')
|
local icons = require('cosmic.core.theme.icons')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.init()
|
function M.init()
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
underline = true,
|
underline = true,
|
||||||
update_in_insert = false,
|
update_in_insert = config.lsp.diagnostic.update_in_insert,
|
||||||
virtual_text = {
|
virtual_text = config.lsp.diagnostic.virtual_text,
|
||||||
spacing = 4,
|
signs = config.lsp.diagnostic.signs,
|
||||||
source = 'always',
|
|
||||||
severity = {
|
|
||||||
min = vim.diagnostic.severity.HINT,
|
|
||||||
},
|
|
||||||
-- todo: icons for diagnostics?
|
|
||||||
--[[ format = function(diagnostic)
|
|
||||||
if diagnostic.severity == vim.diagnostic.severity.ERROR then
|
|
||||||
return string.format('E: %s', diagnostic.message)
|
|
||||||
end
|
|
||||||
return diagnostic.message
|
|
||||||
end, ]]
|
|
||||||
},
|
|
||||||
signs = true,
|
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
float = {
|
float = {
|
||||||
show_header = false,
|
show_header = false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue