From c70f3ec15a8d50d322b659fbcc711bcd9c5e0a2e Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Thu, 19 May 2022 01:26:07 -0700 Subject: [PATCH] add toggle lsp diagnostic --- nvim/init.vim | 11 ++++++----- nvim/keybindings.vim | 3 +++ nvim/lua/toggle_lsp_diagnostics.lua | 11 +++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 nvim/lua/toggle_lsp_diagnostics.lua diff --git a/nvim/init.vim b/nvim/init.vim index 073d2e0..37132f1 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -181,18 +181,19 @@ if has('nvim') source ~/.config/nvim/plugin-confs/github-theme.lua source ~/.config/nvim/plugin-confs/onedarkpro.lua + source ~/.config/nvim/lua/toggle_lsp_diagnostics.lua + " makes fzf match colorscheme (I think) augroup fzf_preview - autocmd! - autocmd User fzf_preview#rpc#initialized call s:fzf_preview_settings() " fzf_preview#remote#initialized or fzf_preview#coc#initialized + autocmd! + autocmd User fzf_preview#rpc#initialized call s:fzf_preview_settings() augroup END function! s:fzf_preview_settings() abort - let g:fzf_preview_command = 'COLORTERM=truecolor ' . g:fzf_preview_command - let g:fzf_preview_grep_preview_cmd = 'COLORTERM=truecolor ' . g:fzf_preview_grep_preview_cmd + let g:fzf_preview_command = 'COLORTERM=truecolor ' . g:fzf_preview_command + let g:fzf_preview_grep_preview_cmd = 'COLORTERM=truecolor ' . g:fzf_preview_grep_preview_cmd endfunction " make terminal not have line numbers autocmd TermOpen * setlocal nonumber norelativenumber - else source ~/.vim/keybindings.vim diff --git a/nvim/keybindings.vim b/nvim/keybindings.vim index 94f7f5f..e9532bd 100644 --- a/nvim/keybindings.vim +++ b/nvim/keybindings.vim @@ -128,3 +128,6 @@ nnoremap xl TroubleToggle loclist nnoremap xq TroubleToggle quickfix nnoremap xw TroubleToggle workspace_diagnostics nnoremap xx TroubleToggle + +nmap y "+ +vmap y "+ diff --git a/nvim/lua/toggle_lsp_diagnostics.lua b/nvim/lua/toggle_lsp_diagnostics.lua new file mode 100644 index 0000000..4c042c4 --- /dev/null +++ b/nvim/lua/toggle_lsp_diagnostics.lua @@ -0,0 +1,11 @@ +local diagnostics_active = true +local toggle_diagnostics = function() + diagnostics_active = not diagnostics_active + if diagnostics_active then + vim.diagnostic.show() + else + vim.diagnostic.hide() + end +end + +vim.keymap.set('n', 'td', toggle_diagnostics)