emacs-ycmd icon indicating copy to clipboard operation
emacs-ycmd copied to clipboard

Add option to open definition/... in other window

Open Kha opened this issue 9 years ago • 4 comments

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.

Kha avatar Sep 02 '16 20:09 Kha

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?

ptrv avatar Sep 03 '16 22:09 ptrv

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.

Kha avatar Sep 08 '16 01:09 Kha

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.

ptrv avatar Sep 08 '16 07:09 ptrv

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))))

harindu95 avatar Nov 01 '16 17:11 harindu95