cybu.nvim icon indicating copy to clipboard operation
cybu.nvim copied to clipboard

feat: add an option to make the path `shortened`

Open Dich0tomy opened this issue 2 years ago • 3 comments

Added an option to make the path shortened. image

Dich0tomy avatar Sep 20 '22 22:09 Dich0tomy

Hey, this looks cool, and I'm inclined to merge it with some minor changes. Are you OK with implementing some suggestions, I make, and we merge it then?

ghillb avatar Sep 21 '22 09:09 ghillb

Ofc! Glad you like it.

Dich0tomy avatar Sep 21 '22 09:09 Dich0tomy

Great! I would like to synchronize the looks with the shorten option of telescope. Here are pics for comparison: telescope cybu

Notable differences, telescope (upper image) only uses the relative paths, when shorten is set, adds the first char after an . for a dot directory and per default the / separator is displayed on Linux.

To keep the combination absolute + shorten, one could implement the shorten functionality under a new option key, e.g., style = { shorten_path = true/false } or style = { path_abbreviation = 'shorten'/'default' }, to make it easier to implement another abbreviation variant (like telescope's 'smart') in the future.

I think the last one is a bug, vim.fn.has('win32') returns "0" on Linux, which is truthy in Lua.

ghillb avatar Sep 21 '22 10:09 ghillb

If I understand you correctly, you want to:

  1. have an option to make the path relative and absolute
  2. make some minor changes (fixes, naming, change the location of the functions, etc.)

If that's so - I'll surely do the second, but I think that adding an option for relative and absolute path is for another PR.

Dich0tomy avatar Sep 26 '22 10:09 Dich0tomy

It'd be lovely if you could try that PR locally because I'm not in a position right now to try it on linux, but I believe it should work no problem.

Dich0tomy avatar Sep 26 '22 10:09 Dich0tomy

Yes, I will do it soon.

Regarding 1: It is probably a minor misunderstanding, what I meant, was to keep the current style = {path = "relative", -- absolute, relative, tail} option and to introduce a new option (e.g.: style = { path_abbreviation = 'shorten'/'default' }) for the new functionality. This yields the possibility to shorten relative AND absolute paths, and chance to introduce new abbreviation options easier in the future without breaking changes and could be probably done in relatively few lines of code.

ghillb avatar Sep 26 '22 10:09 ghillb

Oh, that actually makes sense. How about instead of path_abbrievation = 'shorten'/'default' - path_abbrievation = 'shorten'/'none' or even shorten_path = true/false?

Dich0tomy avatar Sep 26 '22 11:09 Dich0tomy

path_abbrevation = 'shorten'/'none' sounds good to me (in case there will be another abbreviation scheme in the future, this will prevent breaking changes)

ghillb avatar Sep 26 '22 11:09 ghillb

It'd be lovely if you could try that PR locally because I'm not in a position right now to try it on linux, but I believe it should work no problem.

Yes, it works fine now on Linux, and the improvements you made look good too.

ghillb avatar Sep 26 '22 19:09 ghillb

It should be good now.

Dich0tomy avatar Sep 27 '22 17:09 Dich0tomy

Fixed it.

But oof, don't mind the commit name, I changed them to abbreviation, not abbrevation, just a typo in the commit :(.

Dich0tomy avatar Sep 27 '22 19:09 Dich0tomy

Oh man! Right. Really sorry, I'm a bit dizzy. Hope it's all good now, thanks for your suggestions.

Dich0tomy avatar Sep 27 '22 19:09 Dich0tomy