From d4bb45b28db238e9888d38de10530fd0fa7baaca Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 12 Apr 2022 22:14:46 +0800 Subject: [PATCH] fix(lang#c): fix `g d` key binding close https://github.com/SpaceVim/SpaceVim/issues/4544 --- autoload/SpaceVim/layers/lang/c.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/c.vim b/autoload/SpaceVim/layers/lang/c.vim index 739c4412b..ebe08ebce 100644 --- a/autoload/SpaceVim/layers/lang/c.vim +++ b/autoload/SpaceVim/layers/lang/c.vim @@ -463,7 +463,13 @@ endfunction " local function: go_to_declaration {{{ function! s:go_to_declaration() abort if !SpaceVim#layers#lsp#check_filetype(&ft) - execute "norm! g\" + try + exe 'ts' expand('') + catch /^Vim\%((\a\+)\)\=:E426/ + echohl WarningMsg + echo 'tag not found: ' . expand('') + echohl NONE + endtry else call SpaceVim#lsp#go_to_declaration() endif @@ -473,7 +479,13 @@ endfunction " local function: go_to_def {{{ function! s:go_to_def() abort if !SpaceVim#layers#lsp#check_filetype(&ft) - execute "norm! g\" + try + exe 'ts' expand('') + catch /^Vim\%((\a\+)\)\=:E426/ + echohl WarningMsg + echo 'tag not found: ' . expand('') + echohl NONE + endtry else call SpaceVim#lsp#go_to_def() endif