Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
saidelike opened this issue Jan 19, 2024 · 3 comments
Open

Comments

@saidelike
Copy link

saidelike commented Jan 19, 2024

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.

@AndreasArvidsson
Copy link
Owner

AndreasArvidsson commented Jan 19, 2024

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

@saidelike
Copy link
Author

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: ...

@AndreasArvidsson
Copy link
Owner

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants