Skip to content

Commit 250e9fd

Browse files
authored
Merge pull request #151 from flw-cn/pr/rust-doc-tab
Add <Plug>(rust-doc-tab)
2 parents 950b78f + 5159722 commit 250e9fd

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ augroup Racer
6767
autocmd FileType rust nmap <buffer> gx <Plug>(rust-def-vertical)
6868
autocmd FileType rust nmap <buffer> gt <Plug>(rust-def-tab)
6969
autocmd FileType rust nmap <buffer> <leader>gd <Plug>(rust-doc)
70+
autocmd FileType rust nmap <buffer> <leader>gD <Plug>(rust-doc-tab)
7071
augroup END
7172
```

autoload/racer.vim

+6-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function! s:RacerSplitLine(line)
108108
return parts
109109
endfunction
110110

111-
function! racer#ShowDocumentation()
111+
function! racer#ShowDocumentation(tab)
112112
let winview = winsaveview() " Save the current cursor position
113113
" Move to the end of the word for the entire token to search.
114114
" Move one char back to avoid moving to the end of the *next* word.
@@ -143,7 +143,11 @@ function! racer#ShowDocumentation()
143143
" If the __doc__ buffer is open in the current tab, jump to it
144144
silent execute (wi+1) . 'wincmd w'
145145
else
146-
pedit __doc__
146+
if a:tab
147+
tab pedit __doc__
148+
else
149+
pedit __doc__
150+
endif
147151
wincmd P
148152
endif
149153

ftplugin/rust_racer.vim

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ nnoremap <silent><buffer> <Plug>(rust-def-vertical)
1515
nnoremap <silent><buffer> <Plug>(rust-def-tab)
1616
\ :tab split<CR>:call racer#GoToDefinition()<CR>
1717
nnoremap <silent><buffer> <Plug>(rust-doc)
18-
\ :call racer#ShowDocumentation()<CR>
18+
\ :call racer#ShowDocumentation(0)<CR>
19+
nnoremap <silent><buffer> <Plug>(rust-doc-tab)
20+
\ :call racer#ShowDocumentation(1)<CR>
1921
2022
setlocal omnifunc=racer#RacerComplete

0 commit comments

Comments
 (0)