@@ -51,7 +51,6 @@ M.getCompletionItems = function(prefix, score_func)
5151 })
5252 end
5353 end
54- -- print(vim.inspect(complete_items))
5554 return complete_items
5655end
5756
@@ -63,26 +62,19 @@ M.triggerFunction = function(_, _, _, manager)
6362 local pos = api .nvim_win_get_cursor (0 )
6463 local line = api .nvim_get_current_line ()
6564 local line_to_cursor = line :sub (1 , pos [2 ])
66- local textMatch = vim .fn .match (line_to_cursor , ' \\ f*$' )
67- local keyword = line_to_cursor :sub (textMatch + 1 )
65+ local keyword = line_to_cursor :match (" [^%s\" ].*" )
6866 if keyword ~= ' /' then
69- keyword = keyword :match (" %s*(%S+)%w*/.*$" )
67+ -- TODO rewrite this
68+ local index = string.len (keyword ) - string.find (keyword :reverse (), ' /' ) + 1
69+ keyword = string.sub (keyword , 1 , index )
70+ -- keyword = keyword:match("%s*(%S+)%w*/.*$")
7071 end
72+
7173 local path = vim .fn .expand (' %:p:h' )
7274 if keyword ~= nil then
73- -- dealing with special case in matching
74- if keyword == " /" and line :sub (pos [2 ], pos [2 ]) then
75- path = keyword
76- goto continue
77- elseif string.sub (keyword , 1 , 1 ) == " \" " or string.sub (keyword , 1 , 1 ) == " '" then
78- keyword = string.sub (keyword , 2 , # keyword )
79- end
80-
8175 local expanded_keyword = vim .fn .glob (keyword )
8276 local home = vim .fn .expand (" $HOME" )
83- if expanded_keyword == ' /' then
84- goto continue
85- elseif expanded_keyword ~= nil and expanded_keyword ~= ' /' then
77+ if expanded_keyword ~= nil and string.find (expanded_keyword , ' %.' ) == nil then
8678 path = expanded_keyword
8779 else
8880 path = vim .fn .expand (' %:p:h' )
@@ -91,7 +83,6 @@ M.triggerFunction = function(_, _, _, manager)
9183 end
9284
9385 :: continue::
94- path = path .. ' /'
9586 M .items = {}
9687 vim .loop .fs_scandir (path , onDirScanned )
9788end
0 commit comments