Fixes completion of files with spaces and adds file type identifier#56
Fixes completion of files with spaces and adds file type identifier#56haorenW1025 merged 5 commits intonvim-lua:masterfrom
Conversation
|
I've found a weird issue though, sometimes the return type will be |
|
Maybe use a metatable to prevent from getting nil value? Something like this local fileTypesMap = setmetatable({
['f'] = "(file)",
['d'] = "(dir)",
['c'] = "(char)",
['l'] = "(link)",
['b'] = "(block)",
['p'] = "(pipe)",
['s'] = "(socket)"
}, {__index = function()
return ''
end
}) |
|
Using suggested metatable solved the issue but even that i will get two empty words in complete_items list. I will look at it later. |
|
I did notice there is some weird stuff in completion list in that case, and when I'm using for _, val in ipairs(M.items) do
if fileTypesMap[val.t] then goto continue end
local score = score_func(prefix, val.name)
if score < #prefix/3 or #prefix == 0 then
table.insert(complete_items, {
word = val.name,
kind = 'Path ' .. fileTypesMap[val.t],
score = score,
icase = 1,
dup = 1,
empty = 1,
})
end
::continue::
end |
|
I rewrote directory listing using uv fs_scandir function. It is working better now. And it should also work on another platforms(win?). But there is still little problem with completion of items with spaces. Try create this directory structure |
|
Hmm I make some test and I think the cause is this line local textMatch = vim.fn.match(line_to_cursor, '\\f*$')I use the vim built-in matching function to match the file name structure, but it can't recognize file name with spaces. Maybe we have to rewrite this. |
|
I think I'll merged this first since using |
Related issue: #55