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

Relative paths in the Projects section of the Alpha Plugin. #1

Open
Fausto-Korpsvart opened this issue Jul 22, 2023 · 4 comments
Open

Comments

@Fausto-Korpsvart
Copy link

Greetings, @sho-87

Well, I came across your dotfiles in the theme sharing section of the Alpha Dashboard Plugin, I was looking for a way to add the Project section to my theme and when I saw your theme and setup it looked pretty cool, very clean, and it's that way of adding the Projects that I would like to set it up.

You know, I used elements from your setup to add this section and everything works fine, but the problem I've noticed is that the projects added to Telescope shows the full path in Alpha, which makes the text in the Alpha layout overflow.

The question is: Is there any way to make it show a relative path instead of the full path? Something like in the MRU section, which shows truncated paths.

Thanks in advance, and thanks for posting your theme, I found your setup very helpful.

@sho-87
Copy link
Owner

sho-87 commented Jul 22, 2023

@Fausto-Korpsvart I'm not sure about relative vs absolute paths - I had a lot of troubling figuring that part out. But truncated paths are not too hard:

image

The relevant part of my dotfiles would be here: https://github.com/sho-87/dotfiles/blob/master/nvim/lua/plugins/modules/alpha.lua#L124-L140

L124: get my list of recent projects from telescope plugin
L133: set the max number of characters I want to display to avoid overflowing
L136: this bit is the key to truncating paths. I use the plenary plugin to control which parts of the path I want to shorten, for example, shorten(1, { -2, -1 }) means shorten everything down to 1 character, but exclude the last 2 directories in the path

@Fausto-Korpsvart
Copy link
Author

@Fausto-Korpsvart I'm not sure about relative vs absolute paths - I had a lot of troubling figuring that part out. But truncated paths are not too hard:

image

The relevant part of my dotfiles would be here: https://github.com/sho-87/dotfiles/blob/master/nvim/lua/plugins/modules/alpha.lua#L124-L140

L124: get my list of recent projects from telescope plugin L133: set the max number of characters I want to display to avoid overflowing L136: this bit is the key to truncating paths. I use the plenary plugin to control which parts of the path I want to shorten, for example, shorten(1, { -2, -1 }) means shorten everything down to 1 character, but exclude the last 2 directories in the path

Hi again, @sho-87.

OK, I understand better the Plenary part, but I still can't get the result, I have placed the code as you have in your configuration and I still have the full path in the Projects.

This is what happens.
alpha-project-section

Or is it something I have to configure in the Telescope Project Plugin?
If so, could you explain a little bit how to configure it? Because I haven't configured the base_dirs part yet.

@sho-87
Copy link
Owner

sho-87 commented Jul 22, 2023

from your paths it looks like youre on linux, which uses a different path separator than on windows (which is what im using).

so I think you'll need to tinker with the regular expressions on L134 an ensure that display_path is printing what you expect

I would also throw in a few prints for plenary_path.new(display_path):shorten(1, { -2, -1 }) to check if plenary is actually correctly shortening the path outside of the alpha plugin

I remember it took me a lot of trial an error to get this path thing working

@Fausto-Korpsvart
Copy link
Author

Yes, thanks, actually, I thought about that, as I noticed that in the Telescope Project Plugin the path you have assigned references the Windows paths, so I thought that in Alpha I should reassign those paths to make them work on Linux, when I have a bit of time I will do that.

And I've also had to do some trial and error on various plugins, and it's great when you finally get it right.

Thank you very much for your answers, have a good time.

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