{"action":"created","issue":{"url":"https://api.github.com/repos/proofit404/anaconda-mode/issues/309","repository_url":"https://api.github.com/repos/proofit404/anaconda-mode","labels_url":"https://api.github.com/repos/proofit404/anaconda-mode/issues/309/labels{/name}","comments_url":"https://api.github.com/repos/proofit404/anaconda-mode/issues/309/comments","events_url":"https://api.github.com/repos/proofit404/anaconda-mode/issues/309/events","html_url":"https://github.com/proofit404/anaconda-mode/issues/309","id":339236178,"node_id":"MDU6SXNzdWUzMzkyMzYxNzg=","number":309,"title":"Better goto definition","user":{"login":"valignatev","id":7038954,"node_id":"MDQ6VXNlcjcwMzg5NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7038954?v=4","gravatar_id":"","url":"https://api.github.com/users/valignatev","html_url":"https://github.com/valignatev","followers_url":"https://api.github.com/users/valignatev/followers","following_url":"https://api.github.com/users/valignatev/following{/other_user}","gists_url":"https://api.github.com/users/valignatev/gists{/gist_id}","starred_url":"https://api.github.com/users/valignatev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valignatev/subscriptions","organizations_url":"https://api.github.com/users/valignatev/orgs","repos_url":"https://api.github.com/users/valignatev/repos","events_url":"https://api.github.com/users/valignatev/events{/privacy}","received_events_url":"https://api.github.com/users/valignatev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-08T15:51:02Z","updated_at":"2018-07-11T03:02:59Z","closed_at":null,"author_association":"NONE","body":"Hi there! As David Halter [said](https://github.com/davidhalter/jedi/issues/570#issuecomment-97892003),\r\n\r\n>  \"goto_definitions is an important function, because it gives you access to the type inference. But it's probably not the goto function IDE's want\"\r\n\r\nWhat I want to propose is using jedi's `goto_assignment` with `follow_imports=True` for definition function either as a fallback, or as a full replacement. Consider this project layout:\r\n```\r\n# project root\r\n.\r\n- foo.py\r\n- bar.py\r\n```\r\nfoo.py:\r\n```python\r\na = (1, 2, 3, 4)\r\n```\r\nbar.py\r\n```python\r\nfrom foo import a\r\nb = a[0]\r\n```\r\n\r\nIf in `bar.py` I'll try to go to `a` definition, anaconda-mode will say `\"tuple is defined in compiled module\"` which is expected considering how anaconda-mode uses Jedi, but it's definitely not what user wants and expects. Related issues in this repo: #205, #214.\r\nRelated discussions in jedi/jedi-vim repo: https://github.com/davidhalter/jedi/issues/570, https://github.com/davidhalter/jedi-vim/issues/348.\r\n\r\nI played a bit with anaconda-mode sources and found out, that `goto_assignments` with import following solves this problem. Paths we might choose:\r\n1) Falling back to `goto_assignments` if `goto_definitions` fails.\r\nPros: don't have to change user-facing API\r\nCons: potential speed reduction since two operations are performed one after another in case of builtin type\r\n2) A new function, something like `anaconda-mode-find-definitions-dwim` which will use jedi's assignments with import following.\r\nPros: intuitive\r\nCons: might cause user's confusion, has to be documented\r\n3) Replace `goto_definition` call with `goto_assignments(follow_imports=True)` call.\r\nPros: same as in 1) and 2)\r\nCons: inconsistent with Jedi. Is it an issue?\r\n\r\njedi-vim switched from somewhere in between 1) and 2) to 2) and 3), check [this](https://github.com/davidhalter/jedi-vim/pull/808/files) PR.\r\n\r\nI'll open a PR with a fallback option to continue the discussion. What do you think? Are you generally in favor of such change? If so, which option do you prefer?"},"comment":{"url":"https://api.github.com/repos/proofit404/anaconda-mode/issues/comments/404029788","html_url":"https://github.com/proofit404/anaconda-mode/issues/309#issuecomment-404029788","issue_url":"https://api.github.com/repos/proofit404/anaconda-mode/issues/309","id":404029788,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDAyOTc4OA==","user":{"login":"valignatev","id":7038954,"node_id":"MDQ6VXNlcjcwMzg5NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7038954?v=4","gravatar_id":"","url":"https://api.github.com/users/valignatev","html_url":"https://github.com/valignatev","followers_url":"https://api.github.com/users/valignatev/followers","following_url":"https://api.github.com/users/valignatev/following{/other_user}","gists_url":"https://api.github.com/users/valignatev/gists{/gist_id}","starred_url":"https://api.github.com/users/valignatev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valignatev/subscriptions","organizations_url":"https://api.github.com/users/valignatev/orgs","repos_url":"https://api.github.com/users/valignatev/repos","events_url":"https://api.github.com/users/valignatev/events{/privacy}","received_events_url":"https://api.github.com/users/valignatev/received_events","type":"User","site_admin":false},"created_at":"2018-07-11T03:02:59Z","updated_at":"2018-07-11T03:02:59Z","author_association":"NONE","body":"Thanks for the fast response!\r\n\r\n> I don't want to lose goto assignments as it is today. I use it to go to the import statement and edit import itself.\r\n\r\nI don't want to do anything with current goto_assignments as well, all I'm saying is for current goto_definition.\r\nRegarding your suggestion, I think this might be confusing for users. While technically it makes sense, users expect action to be called \"goto definition\". Also, `C-u` is one additional keystroke (yeah, user might rebind that, but it's one extra hassle).\r\n\r\nWhat downsides do you see in replacing current goto_definition implementation with goto_assignments with following imports? This way, anaconda's public interface won't be changed."}}
{"actor":{"display_login":"valignatev"}}