AckslD / swenv.nvim

Tiny plugin to quickly switch python virtual environments from within neovim without restarting.
204 stars 29 forks source link

How to use the swenv component in lualine? #11

Closed desilinguist closed 1 year ago

desilinguist commented 1 year ago

Sorry, I am new to neovim so it's not obvious to me how to use the lualine component provided by this plugin? It'd be great if this was in the documentation too.

desilinguist commented 1 year ago

Never mind. It works.

AckslD commented 1 year ago

Happy to hear it worked! :) If you have a snippet you think would be useful for others. Feel free to open a PR to add it to the README.

skolj commented 1 year ago

hey! does the icon work though? I use a jetbrains nerd font and it doesn't seem to render the icon. Is it possible to change the icon through config?

AckslD commented 1 year ago

@skolj, I see I didn't expose any configuration for this but could easily be done. Is that something you would like contribute with :)

skolj commented 1 year ago

Sure, I'd be happy to help! However, it looks like I can use the default icon component option and customize it. But the hardcoded icon and highlight from the swenv component are still there.

This line in my config

image

gives me this result.

image

Do you need help with any changes?

AckslD commented 1 year ago

Maybe the lualine plugin should be restructured, I honestly wasn't fully sure how it should look like so I put the icon directly in the string returned from update_status: https://github.com/AckslD/swenv.nvim/blob/adaa088121d2716611cad814ecc8f0cf73d0cc57/lua/lualine/components/swenv.lua#L19

Maybe only the venv name should be returned and icons etc go into self.options in init? Any thoughts on this?

skolj commented 1 year ago

yeah, that'd be nice I guess. I could move the hardcoded icon to default icon option. Also, do we really need a default highlight?

AckslD commented 1 year ago

Sounds good @skolj, yeah maybe default highlight is not needed indeed and the user can set that instead

skolj commented 1 year ago

Created a PR as discussed :) let me know if anything needs updating.

DanielAndreasen commented 1 year ago

Thanks both to the work on the icon stuff. Can one of you help me the last bit? I prefer no icon. Here is my sections part from the lualine config:

  sections = {
    lualine_a = {'mode'},
    lualine_b = {'branch', 'diff', 'swenv', icon=''},
    lualine_c = {'filename'},
    lualine_x = {'filetype'},
    lualine_y = {'searchcount'},
    lualine_z = {'progress'}
  },

But that does not work.

skolj commented 1 year ago

@DanielAndreasen wrap swenv component in braces, i.e., lualine_b = {'branch', 'diff', { 'swenv', icon='' } },

DanielAndreasen commented 1 year ago

Perfect - thanks for the reply. Works like a charm