emacs-ycmd
emacs-ycmd copied to clipboard
Add option to open definition/... in other window
Something I miss dearly from vim YCM. Not sure what the key bindings should be like (universal argument?), I'm mostly interested in supporting it in spacemacs anyway.
Hi @Kha
Thanks for the suggetions. I am also not sure yet whether we should make this available via prefix-argument (C-u) or add another version of each GoTo function which opens the file in other window (i.e. ycmd-goto-other-window). The latter is usually used for other-window functions, like C-x 4. Also for key bindings this is better. Adding both versions would be also quite convenient. Do you want to work on a patch?
I'm not too acquainted with elisp, but I can try to make the change. I'm specifically interested in adding keybindings for these to spacemacs, so feel free to suggest regular emacs bindings.
I can also have look into this too. The interactive functions need to pass the information whether to open with find-file or find-file-other-window through multiple functions.
Finally figure how to do it :smile: Added this function
(defun split-and-go (file)
(if (not (string= (prin1-to-string file) (prin1-to-string(buffer-file-name)))) (split-window-right-and-focus)) (find-file file) )
and changed ycmd--handle-goto-success to following
(defun ycmd--handle-goto-success (response) "Handle a successfull GoTo RESPONSE." (let* ((is-vector (vectorp response)) (num-items (if is-vector (length response) 1))) (ycmd--save-marker) (when is-vector (setq response (append response nil))) (if (eq 1 num-items) (ycmd--goto-location response 'split-and-go) (ycmd--view response major-mode))))