From 5159722d1fcd368964510543c5aa25467af42f3f Mon Sep 17 00:00:00 2001 From: flw Date: Thu, 18 Jun 2020 17:01:42 +0800 Subject: [PATCH] Add (rust-doc-tab) This should close #150. --- README.md | 1 + autoload/racer.vim | 8 ++++++-- ftplugin/rust_racer.vim | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f9ba2a3..ddf7a6b 100644 --- a/README.md +++ b/README.md @@ -67,5 +67,6 @@ augroup Racer autocmd FileType rust nmap gx (rust-def-vertical) autocmd FileType rust nmap gt (rust-def-tab) autocmd FileType rust nmap gd (rust-doc) + autocmd FileType rust nmap gD (rust-doc-tab) augroup END ``` diff --git a/autoload/racer.vim b/autoload/racer.vim index 5d41977..7185476 100644 --- a/autoload/racer.vim +++ b/autoload/racer.vim @@ -108,7 +108,7 @@ function! s:RacerSplitLine(line) return parts endfunction -function! racer#ShowDocumentation() +function! racer#ShowDocumentation(tab) let winview = winsaveview() " Save the current cursor position " Move to the end of the word for the entire token to search. " Move one char back to avoid moving to the end of the *next* word. @@ -143,7 +143,11 @@ function! racer#ShowDocumentation() " If the __doc__ buffer is open in the current tab, jump to it silent execute (wi+1) . 'wincmd w' else - pedit __doc__ + if a:tab + tab pedit __doc__ + else + pedit __doc__ + endif wincmd P endif diff --git a/ftplugin/rust_racer.vim b/ftplugin/rust_racer.vim index 1019e2c..f53cd20 100644 --- a/ftplugin/rust_racer.vim +++ b/ftplugin/rust_racer.vim @@ -15,6 +15,8 @@ nnoremap (rust-def-vertical) nnoremap (rust-def-tab) \ :tab split:call racer#GoToDefinition() nnoremap (rust-doc) - \ :call racer#ShowDocumentation() + \ :call racer#ShowDocumentation(0) +nnoremap (rust-doc-tab) + \ :call racer#ShowDocumentation(1) setlocal omnifunc=racer#RacerComplete