AndreasArvidsson/andreas-talon-vscode

feature request: jump to definition for user action (ctx -> module)

Opened this issue · 3 comments

hover or go definition of a user defined action defined in a context to jump to a definition in a module

for instance for go_back:

@ctx.action_class("user")
class UserActions:
    def go_back():
        //...

    def go_forward():
        //...

we would find all the definitions and find this:

@mod.action_class
class Actions:
    def go_back():
        """Navigate back"""
        actions.key("alt-left")

    def go_forward():
        """Navigate forward"""
        actions.key("alt-right")

The main advantage is if there are multiple definitions. And also compared a workspace search where we find all the occurrences so lots of other contexts, we don't jump directly to definitions.

Definitions on action calls in a py file already works, but user.go_back is not the same action as browser.go_back

I removed the browser.go_back code that was confusing the discussion. If you can re-read what I asked for, hopefully it makes sense. It is about going from ctx.go_back() to mod.go_back()

Another example is for a Talon defined action app.tab_previous so going from

@ctx.action_class("app")
class AppActions:
    # Switch to previous tab for this window
    def tab_previous():
        actions.key("ctrl-shift-tab")

to C:\Program Files\Talon\Lib\site-packages\talon\scripting\core\app.pyi:

class AppActions:
    ...
    def tab_previous() -> None: ...

That is more like references then go to definition, but I get it.

Your last example is probably not going to happen since I'm not reading any files outside of the user workspace. This would involve actually building a proper lsp instead of the on demand regex solution I have now.