Merge pull request #16 from sudoforge/10/relative-paths-without-a-leading-slash

feat: support relative paths without a leading forward slash
This commit is contained in:
hrsh7th 2021-11-29 12:22:52 +09:00 committed by GitHub
commit e30d3fdee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
local cmp = require'cmp'
local NAME_REGEX = '\\%([^/\\\\:\\*?<>\'"`\\|]\\)'
local PATH_REGEX = vim.regex(([[\%(/PAT\+\)*/\zePAT*$]]):gsub('PAT', NAME_REGEX))
local PATH_REGEX = vim.regex(([[\%([/"\']PAT\+\)*[/"\']\zePAT*$]]):gsub('PAT', NAME_REGEX))
local source = {}
@ -14,7 +14,7 @@ source.new = function()
end
source.get_trigger_characters = function()
return { '/', '.' }
return { '/', '.', '"', '\'' }
end
source.get_keyword_pattern = function()
@ -56,7 +56,7 @@ source._dirname = function(self, params)
if prefix:match('%.%./$') then
return vim.fn.resolve(buf_dirname .. '/../' .. dirname)
end
if prefix:match('%./$') then
if (prefix:match('%./$') or prefix:match('"$') or prefix:match('\'$')) then
return vim.fn.resolve(buf_dirname .. '/' .. dirname)
end
if prefix:match('~/$') then