Skip to content

virtual_env

Zeioth edited this page May 26, 2024 · 4 revisions

You can add this component to the statusline section of heirline opts.

require("heirline-components.all").component.virtual_env()

It displays a indicator when a virtual_env is enabled in the current working directory. screenshot_2024-02-23_18-53-51_526956578

Available providers

These are the available providers for this component and its options.

virtual_env = { icon = { kind = "Environment", padding = { right = 1 } } },       -- icon to display.
surround = {
  separator = "right",                                                            -- where to add the separator.
  color = "virtual_env_bg",                                                       -- you can set a custom background color, for example "#444444".
  condition = require("heirline-components.all").condition.has_virtual_env        -- a function that determines when to display the component.
},
on_click = {                                                                      -- on click, allow selecting virtual env.
  name = "heirline_virtual_env",
  callback = function()
   if is_available("venv-selector.nvim") then
      vim.schedule(vim.cmd.VenvSelect)
    end
  end,
},
hl = hl.get_attributes("virtual_env"),                                            -- you can specify your own highlight group here.

For example you could change the text displayed when treesitter is enabled

component.virtual_env({ virtual_env = { icon = { kind = "MyIcon" } } })

Clone this wiki locally