feat: customize symbols for the diagnostics component (#112)
This commit is contained in:
parent
1c44781835
commit
7115aa8f8b
|
@ -198,7 +198,7 @@ All of these options can also be specifically set to all supported components, f
|
|||
##### Available global options
|
||||
Option | Default | Behaviour | Supported components
|
||||
:------: | :------: | :----------: | :-----:
|
||||
icons_enabled | true | Displays icons on components You should have powerline supported fonts to see icons properly. | branch, fileformat, filetype, location
|
||||
icons_enabled | true | Displays icons on components You should have nerd-fonts supported fonts to see icons properly. | branch, fileformat, filetype, location, diagnostics
|
||||
padding | 1 | Adds padding to the left and right of components | all
|
||||
left_padding | 1 | Adds padding to the left of components | all
|
||||
right_padding | 1 | Adds padding to the right of components | all
|
||||
|
@ -229,6 +229,7 @@ sections | `{'error', 'warn', 'info'}` | displays diagnostics of defined severit
|
|||
color_error | `DiffDelete` foreground color | changes diagnostic's error section foreground color | color in `#rrggbb` format
|
||||
color_warn | `DiffText` foreground color | changes diagnostic's warn section foreground color | color in `#rrggbb` format
|
||||
color_info | `Normal` foreground color | changes diagnostic's info section foreground color | color in `#rrggbb` format
|
||||
symbols | `{error = ' ', warn = ' ', info = ' '}` or `{error = 'E:', warn = 'W:', info = 'I:'}` | changes diagnostic's info section foreground color | table containing one or more symbols for levels |
|
||||
|
||||
* `filename` component options
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ Default options act as default for all components
|
|||
icons_enabled (Default: true)
|
||||
|
||||
Displays icons on components
|
||||
You should have powerline supported fonts to see
|
||||
You should have nerd-fonts supported fonts to see
|
||||
icons properly.
|
||||
Suported by branch, fileformat, filetype, location
|
||||
|
||||
|
@ -296,6 +296,21 @@ List of options are given below.
|
|||
changes diagnostic's info section foreground color
|
||||
color in #rrggbb format
|
||||
|
||||
• symbols
|
||||
(icons_enabled: true -> {error = ' ', warn = ' ', info = ' '})
|
||||
(icons_enabled: false -> {error = 'E:', warn = 'W:', info = 'I:'})
|
||||
changes diagnostic's symbol characters. You can set one or more symbols
|
||||
for each level.
|
||||
>
|
||||
{
|
||||
'diagnostics',
|
||||
symbols = {
|
||||
-- set the error symbol and use defaults for warn and info.
|
||||
error = '!!',
|
||||
},
|
||||
}
|
||||
<
|
||||
|
||||
• filename~
|
||||
• file_status (true)
|
||||
Whether to display filemodified status in filename
|
||||
|
|
|
@ -43,20 +43,16 @@ local function get_diagnostics(sources)
|
|||
end
|
||||
|
||||
local function diagnostics(options)
|
||||
local symbols
|
||||
if options.icons_enabled then
|
||||
symbols = {
|
||||
error = ' ', -- xf659
|
||||
warn = ' ', -- xf529
|
||||
info = ' ', -- xf7fc
|
||||
}
|
||||
else
|
||||
symbols = {
|
||||
error = 'E:',
|
||||
warn = 'W:',
|
||||
info = 'I:'
|
||||
}
|
||||
end
|
||||
local default_symbols = options.icons_enabled and {
|
||||
error = ' ', -- xf659
|
||||
warn = ' ', -- xf529
|
||||
info = ' ', -- xf7fc
|
||||
} or {
|
||||
error = 'E:',
|
||||
warn = 'W:',
|
||||
info = 'I:'
|
||||
}
|
||||
options.symbols = vim.tbl_extend('force', default_symbols, options.symbols or {})
|
||||
if options.sources == nil then
|
||||
print('no sources for diagnostics configured')
|
||||
return ''
|
||||
|
@ -109,13 +105,13 @@ local function diagnostics(options)
|
|||
end
|
||||
for _, section in ipairs(options.sections) do
|
||||
if data[section] ~= nil and data[section] > 0 then
|
||||
table.insert(result, colors[section]..symbols[section]..data[section])
|
||||
table.insert(result, colors[section]..options.symbols[section]..data[section])
|
||||
end
|
||||
end
|
||||
else
|
||||
for _, section in ipairs(options.sections) do
|
||||
if data[section] ~= nil and data[section] > 0 then
|
||||
table.insert(result,symbols[section]..data[section])
|
||||
table.insert(result,options.symbols[section]..data[section])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue