cjodo / convert.nvim

A plugin to do unit conversions for you.
45 stars 1 forks source link

Convert all #10

Closed briot closed 3 months ago

briot commented 3 months ago

Hello, It would be nice to have a new function to convert all in a file (given two units). For instance, convert all "#aabbcc" to hsl, or something. I imagine there would be a menu to select the origin unit (which would also act as documentation showing all possible units supported by your plugin), then a second one for the target unit. Thank you Emmanuel

cjodo commented 3 months ago

Yea I agree that would be nice to have! I'll work on this right away.

Thanks!

cjodo commented 3 months ago

@briot !! A first working implementation of this can be found in https://github.com/cjodo/convert.nvim/tree/feature/convert-all. Check it out if you'd like :) Thanks again, I've got some great ideas from this!

cjodo commented 3 months ago

@briot It isn't as specific as you suggested to convert every instace of #aabbcc to hsl but instead it converts all hex to rgb, px to rem and so on.

briot commented 3 months ago

"all hex to rgb" is great, what I was looking for. I must say I haven't understood how to use the two-column popup window to select units though. Pressing or doesn't move me to the next column ? Also, I am not sure whether this works on the selected region ("mode=v"). I think it would be nice (but in this case we should add the corresponding key binding to the README example).

Sorry for asking ever more :-)

cjodo commented 3 months ago

At the moment, this doesn't work with a selected region. This can be a feature in the future, but a long ways out. Adressing your problem with the menu, Pressing enter does nothing? be careful with replies that support md, sometimes it hides characters like "< CR >"

briot commented 3 months ago

Running the command, I get the two-column popup window. I can then move the cursor up and down to select a unit, then press . This moves the cursor to the top of the first column, and I can't move it anymore. Pressing a second time closes the dialog, but does nothing.

cjodo commented 3 months ago

can you please send me your configuration?

briot commented 3 months ago

Just for convert.nvim, it is basically the one in the README file

     {
        --  Converting CSS units
        'cjodo/convert.nvim',
        dependencies = {
            'MunifTanjim/nui.nvim'
        },
        keys = {
            { "<leader>nn", "<cmd>ConvertFindNext<CR>",
               desc = "Find next convertable unit" },
            { "<leader>nc", "<cmd>ConvertFindCurrent<CR>",
               desc = "Find convertable unit in current line" },
            { "<leader>na", "<cmd>ConvertAll<CR>",
               desc = "Convert all of a specified unit" },
            { "<leader>na", "<cmd>ConvertAll<CR>",
               desc = "Convert all of a specified unit", mode="v" },
        },
    },

If you want the whole vim configuration (which is fairly extensive), you can find it on github at https://github.com/briot/dotfiles/tree/master/.config/nvim/lua/plugins

cjodo commented 3 months ago

@briot Weird. The cursor itself after pressing enter stays at the top of the left box but the cursor bg highlight is able to move in the right box. It is still able to convert all for me.

https://github.com/user-attachments/assets/0885f6f2-083f-4f01-b790-a0b9e2029136

It's good to note that you can't convert size to color units and vice versa, maybe that's causing the trouble.

Let me know if this helps and thanks again for your feedback, Curtis.

briot commented 3 months ago

I think it might be a colorscheme issue. Indeed, convert all seems to work (though right now I am selecting at random since I don't see what I am doing :-). Using colorscheme default doesn't help though. I'll investigate

cjodo commented 3 months ago

@briot The newest update sets the bg and fg of the cursorline, so you shouldn't be having the contrast issue depending what colorscheme you use

briot commented 3 months ago

Hello, I have updated, but I am still not seeing the background colors. I had spent a bit of time this week-end looking at the nui sources trying to understand which colors they use, but no success. This is really strange

cjodo commented 3 months ago

What colorscheme are you using?