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

Global settings via projectionist_heuristics #55

Open
blueyed opened this issue Aug 13, 2015 · 5 comments
Open

Global settings via projectionist_heuristics #55

blueyed opened this issue Aug 13, 2015 · 5 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Aug 13, 2015

I am wondering if and how global settings are supported.

The following seems to work, but it is unclear if that's the way to go:

let g:projectionist_heuristics = {
    …
    \ "*": {
    \   "*.c": { "alternate": "{}.h" },
    \ },
    \ }

It would be nice to have this documented (in case it is supported).
I can prepare a PR in that case.

@tpope
Copy link
Owner

tpope commented Aug 13, 2015

That eliminates the ability to tell where the root of your project is so I don't recommend it. I think the solution in this case would be to install a.vim or whatever. Other than alternates I don't think any features make sense to enable globally?

@wincent
Copy link

wincent commented Jul 9, 2021

(Arriving here years later via a Google search...)

@blueyed: I used the '*' trick for a long time and it worked for me for years. Then one day, I did some profiling with --startuptime and realized that ProjectionistDetect() was adding 80ms to my startup time (teh horror!). Turns out I have a lot of projections, and if I opened Vim in a directory like /a/b/c/d/e it was adding the projections for every level: /a/b/c/d/e, /a/b/c/d, /a/b/c, /a/b, /a, and even /. Basically a combinatorial explosion.

Whoops!

So I switched to defining real root markers (not *) and that got the startup cost down to around 16ms in a typical case (less when none of the markers match), which is quite reasonable given the number of projections I have. So I think the "real" solution here is to just be very disciplined and come up with real root markers even if you have to be creative about it in some cases. If you have a fast enough machine you might not care, but I like to make startup feel as "instant" as possible.

@razamatan
Copy link

to solve for the "root" of the project, why not borrow ctrlp's solution to look for standard vcs metadata dirs?

@tpope
Copy link
Owner

tpope commented Aug 7, 2021

I have always found that approach to be naive and limiting. Not all projects use vcs, and not all vcs repositories are projects. But if you're okay with that limitation, you can use a key like .git/|.hg/|... to match ctrp's root behavior.

@razamatan
Copy link

what is .projections.json but yet another project metadata system? :)

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

4 participants