-
Notifications
You must be signed in to change notification settings - Fork 187
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
(mini.misc) Add support for restoring the cursor #198
(mini.misc) Add support for restoring the cursor #198
Conversation
5a99ca9
to
c0fbb87
Compare
Hi! First of all, thanks for taking time to write this. It would be even better if you created an issue to discuss it first (as said in CONTRIBUTING.md). Second, could you clarify the purpose and scope of this proposed module? Is it a slightly polished version of the autocommand from Third, it is a strong opinion of mine that no Edit: for reference, this was already discussed earlier |
I thought before opening an issue I could also create a MR. I wanted to play with mini.nvim anyway :-) So this was an exercise learning the code ... About the plugin: By default if you open a file with neovim, the cursor is positioned always at line 1 column 1 (1,1). If you have the plugin loaded and lets assume you jump to line 60 and move the cursor to column 5 (60, 5). Now you close nvim and open the file again with nvim. With the plugin loaded the cursor will be positioned back on line 60 and column 5 (60, 5). It is last position were you left the file. The information about the position where you left a file is stored in shada (see The plugin is an enhanced version of the |
Sure, I can understand this motivation :) Would be nice following the guidelines, though.
OK, I see. Having in mind comments about no I am not opposed to having this as a part of 'mini.misc', though. Along the lines of
I now understand why I've never found this functionality useful... I am using sessions 99% of the time, and they restore this information automatically. |
You really do not want the 'cursor goto' for |
If we are talking about a module - no, any filetype/buftype related disabling is done only through If we are talking about 'mini.misc' |
c0fbb87
to
617a4fc
Compare
I've added it to MiniMisc.setup() but I can move it to |
c8fc799
to
a85c3bf
Compare
a85c3bf
to
c8d58f0
Compare
I've fixed the last issues, added more code comments and improved documentation. |
a974fc7
to
5a1693f
Compare
5a1693f
to
871f5f4
Compare
0bc3443
to
1459792
Compare
Looks like we can't test the
|
2181a73
to
4270047
Compare
9ac61b8
to
9c809c4
Compare
I think, I have covered everything with tests now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for many comments. This does look very good, only many small optimizations needed.
And general request: please use more explicit test case names describing what should work correctly. Like:
- Instead of
['nocenter']
-['respects `opts.center`']
. - Instead of
['file']
-['works in general file']
.
I don't see |
I'll probably add some kind of summary for all interesting 'mini.misc' functions when this one is done. |
ccff7bb
to
e8e4590
Compare
I've taken a quick look. Seems to be nothing major to change. Still some small-ish code style issues, but I think I'll fix them myself during merge. Thanks! I'll take closer look, probably, the day after tomorrow. |
Thanks for all the help! |
367723d
to
adcc386
Compare
What it does: - When reopening a file, this will make sure the cursor is placed back to the position where you left before. - This implements :help restore-cursor in a nicer way. - Creates autocommand for |BufReadPre| and |FileType| event with |MiniMisc.restore_cursor|
…ne argument. The column will default to 0.
adcc386
to
e7be11a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work!
I'll merge this in separate branch and will polish the rest myself (like not modifying the commonly used set_cursor()
helper). Of course, you'll be credited as initial author.
@cryptomilk, I've polished it and merged into Couple of differences that I made:
Thanks again for going forward with this! |
@echasnovski You're welcome. I've rebased my branch which implements the autocmd using vim.api.nvim_create_augroup() here: https://github.com/cryptomilk/mini.nvim/tree/mini.restore_cursor_lua |
What it does:
:help restore-cursor
in a nicer way.This is still work in progress. However I wanted to ask if you would be fine integrating this.