yegappan / mru

Most Recently Used (MRU) Vim Plugin
Other
259 stars 48 forks source link

Fetaure request: Add option to set vim's alternate file to the first entry in the MRU list at startup #49

Closed mroavi closed 2 years ago

mroavi commented 2 years ago

My feature request is to add an option that enables setting vim's alternate file to the first entry in the MRU list at startup. I don't understand why vim doesn't provide an option to remember the alternate file. Not even using Sessions. Let me know what you think.

mroavi commented 2 years ago

Here is an initial idea. This is still missing the check of whether the option is set:

" plugin/mru.vim

...

" Load the MRU list on plugin startup
call s:MRU_LoadList()

" Set the first entry in MRU list as alternate file 
let s:MRU_file = s:MRU_files[0]
call bufadd(s:MRU_file)
let @# = s:MRU_file

...

This implementation does not add the buffer to the buffer list. We would need to decide whether we would like that to happen or not.

yegappan commented 2 years ago

This is a good idea. I will make this a configurable option (default is disabled). I will push a change for this.

yegappan commented 2 years ago

This is addressed by f30ba874a996fdcb5e4ec6060d7cefe6ff247055.

mroavi commented 2 years ago

I noticed that the new patch does not work with nvim because of this check:

&& (v:version >= 802 || has('patch-8.1.1610'))

It does work fine if removed. Could you adapt it to support nvim as well?

yegappan commented 2 years ago

I have pushed a commit to check for nvim also. Can you try that out?

mroavi commented 2 years ago

Works great now. Thanks.