From d3c04107bf23cd75b04a180f78a422a6d00c3d26 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 1 Mar 2022 15:32:03 +0100 Subject: [PATCH] home: vim: move diagnostics config to 'on_attach' --- home/vim/lua/ambroisie/utils.lua | 22 ++++++++++++++++++++++ home/vim/plugin/settings/diagnostics.vim | 20 -------------------- 2 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 home/vim/plugin/settings/diagnostics.vim diff --git a/home/vim/lua/ambroisie/utils.lua b/home/vim/lua/ambroisie/utils.lua index 2b502a4..7b1322b 100644 --- a/home/vim/lua/ambroisie/utils.lua +++ b/home/vim/lua/ambroisie/utils.lua @@ -18,6 +18,28 @@ end -- @param client native client configuration -- @param bufnr int? buffer number of the attched client M.on_attach = function(client, bufnr) + -- Diagnostics + vim.diagnostic.config({ + -- Disable virtual test next to affected regions + virtual_text = false, + -- Show diagnostics signs + signs = true, + -- Underline offending regions + underline = true, + -- Do not bother me in the middle of insertion + update_in_insert = false, + -- Show highest severity first + severity_sort = true, + }) + + vim.cmd([[ + augroup DiagnosticsHover + autocmd! * + " Show diagnostics on "hover" + autocmd CursorHold,CursorHoldI lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"}) + augroup END + ]]) + -- Format on save if client.resolved_capabilities.document_formatting then vim.cmd([[ diff --git a/home/vim/plugin/settings/diagnostics.vim b/home/vim/plugin/settings/diagnostics.vim deleted file mode 100644 index 6b5e0ba..0000000 --- a/home/vim/plugin/settings/diagnostics.vim +++ /dev/null @@ -1,20 +0,0 @@ -lua << EOF -vim.diagnostic.config({ - -- Disable virtual test next to affected regions - virtual_text = false, - -- Show diagnostics signs - signs = true, - -- Underline offending regions - underline = true, - -- Do not bother me in the middle of insertion - update_in_insert = false, - -- Show highest severity first - severity_sort = true, -}) -EOF - -augroup DiagnosticsHover - autocmd! - " Show diagnostics on "hover" - autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"}) -augroup END