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

Support xref in emacs #431

Open
omajid opened this issue Mar 17, 2018 · 1 comment
Open

Support xref in emacs #431

omajid opened this issue Mar 17, 2018 · 1 comment

Comments

@omajid
Copy link

omajid commented Mar 17, 2018

Emacs includes a consistent way to look up (cross reference) identifiers: https://www.gnu.org/software/emacs/manual/html_node/emacs/Xref.html

It would be great if, instead of omnisharp-specific commands like omnisharp-go-to-definition and omnisharp-find-usages, we could delegate to xref and it's standard keybindings across modes.

A simple implementation might be somthing like this:

(add-hook 'xref-backend-functions 'omnisharp--xref-backend)

(defun omnisharp--xref-backend () (when omnisharp-mode 'omnisharp))

(cl-defmethod xref-backend-definitions ((_backend (eql omnisharp)) symbol)
  (omnisharp--xref-find-definitions symbol))

(defun omnisharp---xref-definitions (symbol)
  "Return definitions for symbol."
  ...
  (xref-make ""
             (xref-make-file-location
              (omnisharp--get-filename response)
              (cdr (assoc 'Line json-result))

I tried implementing omnisharp---xref-definitions, but it seems a bit tricky to mix the sync-style behaviour that xref expects from the async style omnisharp generally uses.

@andyleejordan
Copy link
Contributor

For what it's worth, I have bound:

  :bind (:map omnisharp-mode-map
              ([remap xref-find-definitions] . omnisharp-go-to-definition)
              ([remap xref-find-references] . omnisharp-find-usages)
              ;; `xref-pop-marker-stack' works as expected.)

To get xref-like behaviors.

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

No branches or pull requests

3 participants