2 2 local map
= require 'std.map' 3 3 local auto
= require 'std.auto' 4 4 local icon
= require 'std.icon' 6 -local diagnostic_icons
= { icon.error, icon.warn, icon.info, icon.hint, }
6 +local diagnostic_icons
= { icon.error, icon.warn, icon.info, icon.hint }
7 7 diagnostic_icons.error
= diagnostic_icons[
1]
8 8 diagnostic_icons.warn
= diagnostic_icons[
2]
9 9 diagnostic_icons.info
= diagnostic_icons[
3]
10 10 diagnostic_icons.hint
= diagnostic_icons[
4]
12 12 local display_name
= {
19 19 local diagnostic
= vim.diagnostic
20 -diagnostic.enable(
false)
20 +diagnostic.enable(
false )
22 22 auto
'disable_diagnostic_initially' {
23 - description =
'Disable Diagnostics initially, when attaching an LSP client to a buffer',
24 - events =
'LspAttach',
25 - command =
function () diagnostic.enable(
false, {
bufnr =
0 } )
end,
23 + description =
'Disable Diagnostics initially, when attaching an LSP client to a buffer',
24 + events =
'LspAttach',
25 + command =
function () diagnostic.enable(
false, {
bufnr =
0 } )
end,
28 28 local diagnostic_format = function ( context )
29 - return string.
format(
'%s: %s', display_name[context.severity], context.message )
29 + return string.
format(
'%s: %s', display_name[context.severity], context.message )
32 32 local prefix_format = function ( context, index, total )
33 - return string.
format(
'%s/%s %s %s ', index, total, context.source, diagnostic_icons[context.severity] ),
34 - 'DiagnosticVirtualText' .. display_name[context.severity]
33 + return string.
format(
'%s/%s %s %s ', index, total, context.source, diagnostic_icons[context.severity] ),
34 + 'DiagnosticVirtualText' .. display_name[context.severity]
37 37 diagnostic.config {
57 57 local sign = function ( options )
58 - vim.fn.sign_define( options.name, {
59 - text = options.text,
60 - texthl = options.name,
58 + vim.fn.sign_define( options.name, {
59 + text = options.text,
60 + texthl = options.name,
67 -sign {
name =
'DiagnosticSignError',
text = diagnostic_icons.error, }
68 -sign {
name =
'DiagnosticSignWarn',
text = diagnostic_icons.warn, }
69 -sign {
name =
'DiagnosticSignHint',
text = diagnostic_icons.hint, }
70 -sign {
name =
'DiagnosticSignInfo',
text = diagnostic_icons.info, }
67 +sign {
name =
'DiagnosticSignError',
text = diagnostic_icons.error }
68 +sign {
name =
'DiagnosticSignWarn',
text = diagnostic_icons.warn }
69 +sign {
name =
'DiagnosticSignHint',
text = diagnostic_icons.hint }
70 +sign {
name =
'DiagnosticSignInfo',
text = diagnostic_icons.info }
74 - description =
'Toggle diagnostics',
75 - category =
'diagnostic',
76 - keys =
'<leader>td',
77 - command =
function ()
78 - if not diagnostic.is_enabled()
then 80 - vim.notify
'Enabling Diagnostics' 82 - diagnostic.enable(
false)
83 - vim.notify
'Disabling Diagnostics' 74 + description =
'Toggle diagnostics',
75 + category =
'diagnostic',
76 + keys =
'<leader>td',
77 + command =
function ()
78 + if not diagnostic.is_enabled()
then 80 + vim.notify
'Enabling Diagnostics' 82 + diagnostic.enable(
false )
83 + vim.notify
'Disabling Diagnostics' 89 - description =
'Show diagnostics under cursor',
90 - category =
'diagnostic',
92 - command = diagnostic.open_float,
89 + description =
'Show diagnostics under cursor',
90 + category =
'diagnostic',
92 + command = diagnostic.open_float,
96 - description =
'Open diagnostics in quickfix list.',
97 - category =
'diagnostic',
99 - command = diagnostic.setqflist,
96 + description =
'Open diagnostics in quickfix list.',
97 + category =
'diagnostic',
99 + command = diagnostic.setqflist,
102 102 local show_diagnostics_in_buffer = function ()
103 - local builtin
= require 'telescope.builtin' 104 - builtin.diagnostics {
bufnr =
0, }
103 + local builtin
= require 'telescope.builtin' 104 + builtin.diagnostics {
bufnr =
0 }
108 - description =
'Show all diagnostics in buffer',
109 - category =
'diagnostic',
111 - command = show_diagnostics_in_buffer,
108 + description =
'Show all diagnostics in buffer',
109 + category =
'diagnostic',
111 + command = show_diagnostics_in_buffer,
114 114 local show_diagnostics_in_workspace = function ()
115 - local builtin
= require 'telescope.builtin' 116 - builtin.diagnostics()
115 + local builtin
= require 'telescope.builtin' 116 + builtin.diagnostics()
120 - description =
'Show all diagnostics in workspace',
121 - category =
'diagnostic',
123 - command = show_diagnostics_in_workspace,
120 + description =
'Show all diagnostics in workspace',
121 + category =
'diagnostic',
123 + command = show_diagnostics_in_workspace,
128 128 local dia = function ( severity, line )
129 - local ns
= vim.api.nvim_create_namespace(
'test' .. tostring( severity ) )
130 - local bufnr
= vim.api.nvim_get_current_buf()
136 - severity = severity,
137 - message =
'This is a test ' .. tostring( severity )
.. ' diagnostic',
129 + local ns
= vim.api.nvim_create_namespace(
'test' .. tostring( severity ) )
130 + local bufnr
= vim.api.nvim_get_current_buf()
136 + severity = severity,
137 + message =
'This is a test ' .. tostring( severity )
.. ' diagnostic',
140 - vim.diagnostic.set( ns, bufnr, { options, } )
141 - vim.diagnostic.show( ns, bufnr, { options, } )
140 + vim.diagnostic.set( ns, bufnr, { options } )
141 + vim.diagnostic.show( ns, bufnr, { options } )
144 144 local send_dia = function ()
145 - dia( vim.diagnostic.severity.ERROR,
1 )
146 - dia( vim.diagnostic.severity.WARN,
2 )
147 - dia( vim.diagnostic.severity.INFO,
3 )
148 - dia( vim.diagnostic.severity.HINT,
4 )
145 + dia( vim.diagnostic.severity.ERROR,
1 )
146 + dia( vim.diagnostic.severity.WARN,
2 )
147 + dia( vim.diagnostic.severity.INFO,
3 )
148 + dia( vim.diagnostic.severity.HINT,
4 )
151 151 vim.g.send_dia
= send_dia