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

Jumping between classes? #38

Open
goodboy opened this issue Jan 3, 2017 · 7 comments
Open

Jumping between classes? #38

goodboy opened this issue Jan 3, 2017 · 7 comments

Comments

@goodboy
Copy link
Contributor

goodboy commented Jan 3, 2017

In the docs you write:

In Python, ]m, ]M, [m, and [M are available to move to def or               
class blocks.  They are analogous to what's described in various-motions,   
except the part about braces.

I understood this as [M/]M would move the same as [[/]] normally do without the plugin installed?

Maybe i'm misunderstanding but how does one jump between top level definitions?

@tweekmonster
Copy link
Owner

There isn't a way to jump between top level blocks. As mentioned in #37, you can disable the maps for [[ and ]] to retain the maps set by the builtin ftplugin.

I understood this as [M/]M would move the same as [[/]] normally do without the plugin installed?

No. Without this plugin or the builtin ftplugin, [[ and ]] moves between { (open curly braces) without respect to their purpose. [m and ]m moves between { for methods/classes, and [M and ]M moves between } for methods/classes.

I felt that the builtin ftplugin's maps and the ones set by the python-mode plugin broke the meaning of these maps as explained in the docs. To me, it seemed like these maps were only added because there wasn't a meaningful way to jump between block boundaries. There aren't many languages where these maps are overridden in the builtin runtime scripts and I didn't like the inconsistency.

@goodboy
Copy link
Contributor Author

goodboy commented Jan 4, 2017

@tweekmonster I like your thinking regarding how [[ and ]] should work in a braceless language.

So then my question is whether having a way to jump between top level blocks is something that is useful?

I personally miss it.

@tweekmonster
Copy link
Owner

So then my question is whether having a way to jump between top level blocks is something that is useful?

I think it's useful and I'm open to suggestions. You also got @blueyed's support, so that's something I can't ignore 😉

I've been getting by by using FZF's tag search. There's a discussion about the motions in #1 if it helps. After I got the sense that I made the scope of this plugin too big, I stopped adding new maps since there's only so many keys available.

I thought about adding [0 and ]0 as a "jump to block at first column" but thought it wasn't exactly ergonomic. Maybe it's better than nothing? I also thought about using <leader>[ and <leader>], but still has the ergonomic issue.

Whatever it is, it could do what the builtin ftplugin is doing since this feature wouldn't require block parsing.

Off topic: I'm now thinking I should rewrite the parser since I have a much better understanding of how python scripts are parsed by the interpreter now.

@goodboy
Copy link
Contributor Author

goodboy commented Jan 4, 2017

After I got the sense that I made the scope of this plugin too big, I stopped adding new maps since there's only so many keys available.

Well then maybe you can accept #39 :)

@tweekmonster after thinking a bit more I'm starting to lean towards it not being a top level block jump but rather an actual class or type (other langs) jump. I agree that tags should be used where possible but sometimes it's handy between classes to get a feel for how things are organized especially since often classes the the main topic of interest with non-method helper functions surrounding them.

In terms of ergonomics I'm actually mostly partial to having the secondary key be on the lhs (querty of course) when using [ and ]. So I'd be partial to [s (section) or [t (top or type?).

@tweekmonster
Copy link
Owner

Well then maybe you can accept #39

It's been reviewed 😜

So I'd be partial to [s (section) or [t (top or type?).

I actually wanted to use [t and ]t, but it's in use by unimpaired which may as well be builtin with how much its recommended to new users.

[s and ]s could be used if there's a rule that states that it only works when spell is disabled. Another possibility is using ( and ) since I can't think of the last time that I found sentence motions useful in Python.

@goodboy
Copy link
Contributor Author

goodboy commented Jan 5, 2017

@tweekmonster hmm. I really like using () but my concern would be with how it translates to other braceless languages...

Also maybe I'm blind, but where is unimpaired.vim using [t?

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

No branches or pull requests

3 participants