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

Allow triggering without trigger characters #61

Open
jemag opened this issue Dec 11, 2022 · 11 comments
Open

Allow triggering without trigger characters #61

jemag opened this issue Dec 11, 2022 · 11 comments

Comments

@jemag
Copy link

jemag commented Dec 11, 2022

I would like to be able to replace the default <C-x><C-f> with cmp with path source. However this will not trigger because of the currently configured trigger characters.

Basically I would like to do something like:

vim.keymap.set("i", "<c-x><c-f>", function()
  require("cmp").complete({
    config = {
      sources = {
        {
          name = "path",
          keyword_length = 0,
          keyword_pattern = ".*?",
          trigger_characters = {}
        },
      },
    },
  })
end)

However it does not seem to trigger, despite the empty trigger_characters

@cherti
Copy link

cherti commented Oct 9, 2023

It would be amazing if we could just trigger filepath completions without mandating a leading / or .
This is often very useful for processing scripts that operate on relative paths which can just start with the folder name or the filename rightout, which currently forces xplicit typing of two additional characters ('./') or typing, completing and removing a character afterwards. it would be cool if completion could just happen right away once a character is typed as other path completion sources do it as well.

just adding the entire alphabet to the trigger characters seems to not do the trick, though, I just tried that. I haven't had the chance to look into the lua-code more deeply, so @hrsh7th , if you have any pointers on how to fix that it would be very cool. :)

@tummetott
Copy link

when you look in to the source, the keyword pattern is also hard coded into a path regex. Changing the keyword pattern might not be possible with this plugin. I was trying to understand the regex for a while but i don't get it. I think we need the help of @hrsh7th for this. I'm also very keen on triggering path completion with just a shortcut and nothing else

@hrsh7th
Copy link
Owner

hrsh7th commented Oct 13, 2023

We would like to add an option to make the leading slash non-required.

However, with my English skills, I can't think of a good option name. Any ideas?

@tummetott
Copy link

tummetott commented Oct 13, 2023

My intuition tells me that i would not want a new option for this. We already have trigger_characters. Is it possible to change to code in a way that the path source is triggered when trigger_characters = {} or trigger_characters = nil? and we would probably also have to adjust keyword_pattern.

If a new option is necessary, I would suggest to call it: always_trigger = true or trigger_with_keymap = true

@GitMurf
Copy link

GitMurf commented Feb 6, 2024

any update on this? or any workarounds people have come up with?

@GitMurf
Copy link

GitMurf commented Feb 6, 2024

Ok this is weird. This PR from a couple years ago seems to do exactly what we all want... triggers the paths from starting quote (" or ') instead of requiring ./ or ../

I wonder what happened? did this decision get later reverted?

#16

@tummetott
Copy link

Unfortunately no updates. I got used to trigger it with ./ and then later I was deleting the ./ again ... not nice though

@eekhof
Copy link

eekhof commented Mar 30, 2024

I would also be highly interested in this, but I can't get it to work with changing trigger characters sadly

@Hexa3333
Copy link

Thought i was the only one who disliked having to trigger it with ./. I've tried many workarounds but none worked. Any relevant updates ?

@shurensha
Copy link

i need this too

@shurensha
Copy link

i tried making other trigger characters like @ work but was unable to. but i was able to get " and ' working to suggest cwd completions

https://github.com/shurensha/cmp-path/blob/main/lua/cmp_path/init.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants