Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the usage of VenvSelect on smaller screens #139

Open
rodhash opened this issue Jun 7, 2024 · 7 comments
Open

Improve the usage of VenvSelect on smaller screens #139

rodhash opened this issue Jun 7, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request regexp branch

Comments

@rodhash
Copy link

rodhash commented Jun 7, 2024

Hi

New version looks very very nice, thanks and kudos

This isn't an issue per se, but I noticed that the type (or source) shows up only when I have my terminal in full screen .. this isn't visible when I have my temrinal in normal size or snapped to the left / right of my monitor..

Is this expected? I find this piece of info very nice to have but most of the time I'm not using the terminal in full screen.

image
@linux-cultist
Copy link
Owner

I agree, it would be nice if the UI could take into account screen size and adapt to it. I would like it to be visible even when the terminal is snapped to a side, at least on most normal resolutions.

Let me see if I can make the UI a bit smarter, it's a good idea. :)

@linux-cultist linux-cultist changed the title types / source information Scale the UI so the search type is visible in half terminal width on normal resolutions Jun 7, 2024
@linux-cultist linux-cultist added enhancement New feature or request regexp branch labels Jun 7, 2024
@linux-cultist
Copy link
Owner

Update the plugin now and see if it looks better?

@linux-cultist linux-cultist self-assigned this Jun 7, 2024
@tranbinh1604
Copy link

CleanShot 2024-06-07 at 22 10 18

mine after updated, I can not see the right project folder at all, also don't know which one to activate

@linux-cultist
Copy link
Owner

linux-cultist commented Jun 7, 2024

Its because you have so long paths and the window is smaller so it doesnt really fit.

You can replace the entire first part of your results with something much shorter by adding a callback function that gets called by VenvSelect for each result it finds. Here is an example you can put in your config to play with.

Dont forget to set the option at the end to actually call the function too. :)

  {
    "linux-cultist/venv-selector.nvim",
    dependencies = {
      "neovim/nvim-lspconfig",
      { "nvim-telescope/telescope.nvim", branch = "0.1.x", dependencies = { "nvim-lua/plenary.nvim" } },
      "mfussenegger/nvim-dap",
      "mfussenegger/nvim-dap-python",
    },
    lazy = false,
    branch = "regexp",
    config = function()
   
      local function shorter_name(filename)
        -- Define replacements as key-value pairs
        local replacements = {
          ["/Users/binhtt/Library/Mobile Documents/com~apple~CloudDocs/Coding"] = ".../Coding",
        }

        -- Loop through the table and replace each found path with its specific replacement
        for path, replacement in pairs(replacements) do
          filename = string.gsub(filename, path, replacement)
        end

        return filename
      end

      require("venv-selector").setup {
        settings = {
          options = {
            on_telescope_result_callback = shorter_name,
          },
        },
      }
    end,
    keys = {
      { ",v", "<cmd>VenvSelect<cr>" },
    },
  },

@linux-cultist
Copy link
Owner

I should probably add some built-in way to limit the result length as well. Normally its much more useful to see the end of the path rather than the beginning of the path, if there is not enough space to show it all.

@linux-cultist linux-cultist changed the title Scale the UI so the search type is visible in half terminal width on normal resolutions Improve the usage of VenvSelect on smaller screens Jun 8, 2024
@rodhash
Copy link
Author

rodhash commented Jun 8, 2024

Thanks for the prompt feedback .. 2 things:

  1. I've updated my plugin to the latest version but I see no change regarding the placement of the type:
image

For me it still showing up only when full screen.

  1. I liked the callback idea but it seems to not be working for me however I managed to shorten my path using a little bit of sed:
          search = {
            venvs = {
              command = "fd python$ ~/venv -I -L -E /proc | sed 's/.*venv/foobar/g'",
              type = "pyenv"
            },
...
image

With paths shortened I still can't see the type .. it shows up only with terminal in full screen

@linux-cultist
Copy link
Owner

linux-cultist commented Jun 8, 2024

I even tested the code above, it worked fine for me (but different path or course). It's possible that the tilde characters in the paths are not liked by lua though. If I had to guess, it's something like that. Using sed works but it will be slower.

The actual column where the type shows up is set to a specific width so I guess it's outside of the terminal width if it doesnt show up. Maybe a good idea to make this configurable in a setting since it doesn't seem like the telescope viewer can adapt the column width dynamically.

If you had a setting where you could set a number where the column would start, you could find a setting that works for you in the end.

I will experiment a bit with this later. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request regexp branch
Projects
None yet
Development

No branches or pull requests

3 participants