blink.cmp
blink.cmp copied to clipboard
Path source: path completion not working on Windows
Make sure you have done the following
- [X] I have updated to the latest version of
blink.cmp - [X] 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
And this is blink:
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
I'm on Linux so if someone on Windows could take a look at this, it'd be much appreciated
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