hrsh7th / cmp-path

nvim-cmp source for path
MIT License
628 stars 60 forks source link

how to ignore the root of the system #68

Open Manix80 opened 1 year ago

Manix80 commented 1 year ago

hi,

is it possible not to display the root of the system? for example: /sys ...

when I type / I automatically get the root.

in the doc there is the option "get_cwd" but I don't know how to do it.

the best would be to be able to display the current directory.

I have the same configuration as here: https://github.com/sar/cmp.nvim#setup

with the exception that I added this:

cmp.setup({
...
  sources = cmp.config.sources({
    ...
    { name = "path" },
    ...
  )}
...
})

thanks

liquiddandruff commented 1 year ago

Yeah, at the moment using default configs this is causing :e <anything> to hang for 1 minute on WSL2, it's finding things like random DLLs from IDK where. Need to make this configurable otherwise it's not usable atm.

From looking at the source it doesn't appear there's a way to do this through the existing options atm.

Edit: nvm, this seems to be a cmp-cmdline issue:

  -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources(
    {
      { name = 'path' }
    })
    -- {
    --   { name = 'cmdline' }
    -- })
  })

above doesn't freeze when I do :e /, everything works and I get path completions.

But when I enable cmdline, then :e <anything> lags.

  -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources(
    {
      { name = 'path' }
    },
    {
      { name = 'cmdline' }
    })
  })

EDIT: OK actually my cwd was in system32 for some reason (thanks wsl) so that's why cmp-path was picking up all these DLLs. It's not a global search afterall; user error, please ignore 😅. Still it shouldn't block this hard though, but I guess that's an issue with cmp-cmdline

Manix80 commented 1 year ago

I haven't found a solution for this problem, which isn't a problem in fact, just a habit to get into and be a little more careful with a "/".

NullVoxPopuli commented 1 year ago

I just ran in to this and had to disable cmp-path -- I thought neovim was freezing whenever I typed a comment (// or /*) -- or a self-closing element (<br />) -- or ever just / in the middle of a sentence (this / related-this)