Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GoDef without split in current buffer #1003

Closed
oryband opened this issue Aug 11, 2016 · 11 comments · Fixed by #1083
Closed

Add GoDef without split in current buffer #1003

oryband opened this issue Aug 11, 2016 · 11 comments · Fixed by #1083

Comments

@oryband
Copy link

oryband commented Aug 11, 2016

I'm trying to use :GoDef and it's shortcuts to jump to definition while staying in the same buffer window, without splitting the buffer or opening a new tab.

I've set let g:go_def_reuse_buffer = 1 but this doesn't seem to do anything.

Configuration

Add here your current configuration and additional information that might be
useful, such as:

.vim [master] λ vim --version
Alias tip: vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun  9 2016 09:35:51)
Included patches: 1-1910
Compiled by Arch Linux
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
+balloon_eval    +float           +mouse_urxvt     +tcl/dyn
+browse          +folding         +mouse_xterm     +termguicolors
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+channel         +gettext         -mzscheme        +textobjects
+cindent         -hangul_input    +netbeans_intg   +timers
+clientserver    +iconv           +packages        +title
+clipboard       +insert_expand   +path_extra      +toolbar
+cmdline_compl   +job             +perl/dyn        +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua/dyn         +rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      +startuptime     +xsmp_interact
+eval            +mouse_dec       +statusline      +xterm_clipboard
+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lieee -lm
  • vim-go version: ecac655
  • go version:
.vim [master] λ go version
go version go1.6.2 linux/amd64
@fatih
Copy link
Owner

fatih commented Sep 4, 2016

Hi @oryband

Did you tried gd ? It jumps in the same buffer. What exactly is the problem here?

@oryband
Copy link
Author

oryband commented Sep 4, 2016

If gd is the same like :GoToDef, than there's a bug where sometimes the go-to-definition command opens in a split window even though reuse buffer is turned on.

The reason I'm using GoToDef is becaues I have a key binding which calls a function that calls the go-to function per filetype:

function! GoToDef()
    if &ft == 'go'
        execute 'GoDef'
    elseif &ft == 'javascript'
        execute 'TernDef'
    else
        execute 'YcmCompleter GoTo'
    endif
endfunction
nnoremap <leader>] :call GoToDef()<CR>

@fatih
Copy link
Owner

fatih commented Sep 4, 2016

Did you just called gd ? What happens in that case.

@oryband
Copy link
Author

oryband commented Sep 4, 2016

I'll verify if this also happens with gd and get back to you.

On Sun, Sep 4, 2016 at 6:51 PM Fatih Arslan notifications@github.com
wrote:

Did you just called gd ? What happens in that case.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1003 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAHCuw-qcItxkyczICyzby3dYr2MDT3Mks5qmuj2gaJpZM4JiBep
.

Ory Band - אורי בנד

oryband@gmail.com
OryBand.com http://oryband.com

@jasonkeene
Copy link
Contributor

@fatih I'm running c63c798 and noticed this as well. When I use gd or :GoDef often it will open the file in a new split. I disabled all other plugins to make sure this wasn't a conflicting plugin. Here is all the stuff in my .vimrc related to vim-go:

let g:go_fmt_command = "goimports"
let g:go_autodetect_gopath = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_auto_type_info = 1
let g:go_auto_sameids = 1
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
let g:go_metalinter_autosave = 1
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
let g:go_metalinter_deadline = "5s"
let g:go_list_type = "quickfix"

" vim-go command shortcuts
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>t <Plug>(go-test)
autocmd FileType go nmap <leader>a <Plug>(go-alternate-edit)
autocmd FileType go nmap <leader>d :GoDeclsDir<CR>
autocmd FileType go nmap <leader>g <Plug>(go-generate)

" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
  let l:file = expand('%')
  if l:file =~# '^\f\+_test\.go$'
    call go#cmd#Test(0, 1)
  elseif l:file =~# '^\f\+\.go$'
    call go#cmd#Build(0)
  endif
endfunction

autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>

function! s:toggle_coverage()
    call go#coverage#BufferToggle(!g:go_jump_to_error)
    highlight ColorColumn ctermbg=235
    highlight NonText ctermfg=239
    highlight SpecialKey ctermfg=239
    highlight goSameId term=bold cterm=bold ctermbg=250 ctermfg=239
endfunction

autocmd FileType go nmap <leader>c :<C-u>call <SID>toggle_coverage()<CR>

@svanharmelen
Copy link
Contributor

Both myself and a few colleagues share the same experience. It's not a 100% consistent, so it sometimes it opens in the current buffer and sometimes it opens a new split.

We're using au FileType go nmap <leader>d <Plug>(go-def) to call godef...

@torkelo
Copy link

torkelo commented Sep 27, 2016

same problem here, sometimes it opens in the current buffer and sometimes it opens a new split.

@torkelo
Copy link

torkelo commented Oct 14, 2016

this is super frustrating, anyone found a workaround?

@svanharmelen
Copy link
Contributor

I noticed it (in my case at least) does a split when my source file isn't saved, and it replaces the current buffer when the source file is saved... So since I know that it feels less weird 😉

@fatih
Copy link
Owner

fatih commented Oct 14, 2016

As @svanharmelen (thanks for the clue) said it was due something we added at #944. I've removed that case as I think there shouldn't be a case for modified flags. Pull the latest master and let me know how it works.

@jasonkeene
Copy link
Contributor

Thanks @fatih I'll let you know if I run into it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants