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

Path source: path completion not working on Windows #612

Open
2 tasks done
marovira opened this issue Dec 17, 2024 · 2 comments
Open
2 tasks done

Path source: path completion not working on Windows #612

marovira opened this issue Dec 17, 2024 · 2 comments
Labels
backlog Likely not getting to it anytime soon bug Something isn't working sources Specific source provider or the system as a whole

Comments

@marovira
Copy link

marovira commented Dec 17, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

In Windows, path completion doesn't work when a path starts with a drive letter, e.g. C:/.
To reproduce:

  • Open nvim on an empty buffer in Windows.
  • Enter C:/ and see that no path completion sources are shown.

Note: behaviour is the same if C:\ is used instead.

Using nvim-cmp with cmp-async-path works correctly as shown below
image

And this is blink:
image

Relevant configuration

{
        "saghen/blink.cmp",
        lazy = false,
        dependencies = {
            { "saghen/blink.compat", lazy = true, config = true },
            { "f3fora/cmp-spell" },
            { "hrsh7th/cmp-omni" },
        },
        version = "v0.*",
        opts = {
            keymap = {
                preset = "enter",
                ["<Tab>"] = { "select_next", "fallback" },
                ["<S-Tab>"] = { "select_prev", "fallback" },
            },
            completion = {
                list = {
                    selection = "auto_insert",
                },
                documentation = { auto_show = true },
            },
            signature = { enabled = true },
            sources = {
                completion = {
                    enabled_providers = { "lsp", "path", "buffer" },
                },
            },
        },
    },

neovim version

NVIM v0.10.2

blink.cmp version: branch, tag, or commit

v0.76

@marovira marovira added the bug Something isn't working label Dec 17, 2024
@Saghen Saghen added sources Specific source provider or the system as a whole backlog Likely not getting to it anytime soon labels Dec 17, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 17, 2024

I'm on Linux so if someone on Windows could take a look at this, it'd be much appreciated

@bstaint
Copy link

bstaint commented Dec 18, 2024

diff --git a/lua/blink/cmp/sources/path/lib.lua b/lua/blink/cmp/sources/path/lib.lua
index a54c257..8f5f0da 100644
--- a/lua/blink/cmp/sources/path/lib.lua
+++ b/lua/blink/cmp/sources/path/lib.lua
@@ -40,6 +40,10 @@ function lib.dirname(path_regex, get_cwd, context)
     accept = accept and (not prefix:match('^[%s/]*$') or not lib.is_slash_comment())    
     if accept then return vim.fn.resolve('/' .. dirname) end
   end
+  local driver = prefix:match('(%a:)[/\\]$')
+  if driver then
+    return vim.fn.resolve(driver .. '/' .. dirname)
+  end
   return nil
 end

https://codeberg.org/FelipeLema/cmp-async-path/src/commit/d6d1ffa2075039632a2d71e8fa139818e15ac757/lua/cmp_async_path/init.lua#L196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Likely not getting to it anytime soon bug Something isn't working sources Specific source provider or the system as a whole
Projects
None yet
Development

No branches or pull requests

3 participants