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

Setting initial mode of CtrlPLastMode? #620

Open
ChristianTackeGSI opened this issue May 4, 2023 · 2 comments
Open

Setting initial mode of CtrlPLastMode? #620

ChristianTackeGSI opened this issue May 4, 2023 · 2 comments

Comments

@ChristianTackeGSI
Copy link

I like CtrlPLastMode! But in a new editing session, it starts out with the default Files mode, which I (currently) use rarely. I use Buffer first and then MRU. So I would like to set the initial mode of LastMode to Buffer. Is this possuble?

I even tried things like call ctrlp#switchtype(0), call ctrlp#setlines(0), or call ctrlp#call("s:setlines_pre", -1). But they either fail with an error or set the mode of the next LastMode invocation somewhat wrong.

@tacahiroy
Copy link
Member

Currently, the plugin doesn't provide a way of changing the default mode for the CtrlPLastMode. Also, there is no API to update the ControlP mode triggered last time.

But to achieve the goal, you can implement your version of CtrlPLastMode like this:

function! s:my_last_mode(argv) abort
   let s:lm = get(s:, 'lm', 'buf')
   cal ctrlp#init(s:lm, { 'args':  a:argv })
   let s:lm = -1
endfunction
com! -n=? MyLastMode cal <SID>my_last_mode(<q-args>)

Hope this helps.

@ChristianTackeGSI
Copy link
Author

This seems to work nicely for me! Thanks!

Could this be added to some docs? Maybe as an example on how to customize things? (Or is it already and I missed it?)

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

2 participants