linux-cultist / venv-selector.nvim

Allows selection of python virtual environment from within neovim
MIT License
378 stars 40 forks source link

Telescope callback not working as intended #136

Closed sho-87 closed 4 weeks ago

sho-87 commented 1 month ago

Just updated to the new version and everything works great, but I cant figure out how to get the telescope callback to work. This is my config:

opts = {
      settings = {
        hooks = { hooks.pyright_hook },
        options = {
          enable_default_searches = true,
          enable_cached_venvs = true,
          activate_venv_in_terminal = true,
          set_environment_variables = true,
          show_telescope_search_type = true,
          notify_user_on_venv_activation = false,
          on_venv_activate_callback = nil,
          on_telescope_result_callback = shorten_path, -- not working
        },
      },
    }

my shorten_path function looks like this, but it seems other variations dont work either (eg simply returning "hello"):

local function shorten_path(filename)
  local pattern
  if utils.is_windows() then
    pattern = "[^\\]+"
  else
    pattern = "[^/]+"
  end

  local parts = {}
  for part in string.gmatch(filename, pattern) do
    table.insert(parts, part)
  end
  local last_parts = table.concat(parts, "\\", #parts - 3, #parts)
  return last_parts
end
linux-cultist commented 4 weeks ago

Hi,

This was a stupid bug caused by changing the telescope results to be real time. The telescope viewer was showing the path to the python all the time, and didnt show the result name. The result name was always changed by the callback function but you couldnt see it because of the bug.

Update the plugin and it should work. :)

sho-87 commented 4 weeks ago

perfect, thanks!