@@ -137,12 +137,21 @@ function this.normalize_list(arr, word)
137137 if # arr == 0 then return arr end
138138 local ret = {}
139139 for index , value in ipairs (arr ) do
140- table.insert (ret , {
141- word = arr [index ],
142- abbr = arr [index ],
143- kind = vim .g .easycomplete_kindflag_cmdline ,
144- menu = vim .g .easycomplete_menuflag_cmdline ,
145- })
140+ if type (value ) == " table" then
141+ table.insert (ret , {
142+ word = value [" word" ],
143+ abbr = value [" abbr" ],
144+ kind = value [" kind" ],
145+ menu = value [" menu" ],
146+ })
147+ else
148+ table.insert (ret , {
149+ word = arr [index ],
150+ abbr = arr [index ],
151+ kind = vim .g .easycomplete_kindflag_cmdline ,
152+ menu = vim .g .easycomplete_menuflag_cmdline ,
153+ })
154+ end
146155 end
147156 return vim .fn [' easycomplete#util#CompleteMenuFilter' ](ret , word , 500 )
148157end
@@ -209,11 +218,11 @@ this.REG_CMP_HANDLER = {
209218 get_cmp_items = function ()
210219 local typing_path = vim .fn [' easycomplete#sources#directory#TypingAPath' ]()
211220 -- TODO 这里还需要再调试
212- console (typing_path .isPath )
213- if typing_path .isPath == 0 then
221+ if typing_path .is_path == 0 then
214222 return {}
215223 else
216- return vim .fn [' easycomplete#sources#directory#GetDirAndFiles' ](typing_path , typing_path .fname )
224+ local ret = vim .fn [' easycomplete#sources#directory#GetDirAndFiles' ](typing_path , typing_path .fname )
225+ return ret
217226 end
218227 end
219228
249258function this .do_complete ()
250259 local word = this .get_typing_word ()
251260 local matched_pattern = false
252- ---- -------------------- for debug ------------------------
253- -- local logggg_cmd = vim.fn.getcmdline()
254- -- local logggg_al = {}
255- ---- -------------------------------------------------------
256261 for index , item in ipairs (this .REG_CMP_HANDLER ) do
257- ---- -------------------- for debug ------------------------
258- -- logggg_al[#logggg_al + 1] = logggg_cmd .. "|" .. item.pattern .. "|" .. tostring(this.cmd_match(item.pattern))
259- -- --------------------------------------------------------
260262 if this .cmd_match (item .pattern ) then
261263 local start_col = vim .fn .getcmdpos () - this .calculate_sign_and_linenr_width () - # word
262264 cmdline_start_cmdpos = vim .fn .getcmdpos () - # word
@@ -273,28 +275,9 @@ function this.do_complete()
273275 break
274276 end
275277 end
276- ---- -------------------- for debug ------------------------
277- -- this.pum_complete(1, this.normalize_list(logggg_al, ""))
278- -- do return end
279- ---- -------------------------------------------------------
280278 if matched_pattern == false then
281279 this .pum_close ()
282280 end
283- do return end
284- ---- ---------------------------------------
285- -- local word = this.get_typing_word()
286- -- if word == "" then
287- -- this.pum_close()
288- -- else
289- -- local start_col = vim.fn.getcmdpos() - this.calculate_sign_and_linenr_width() - #word
290- -- cmdline_start_cmdpos = vim.fn.getcmdpos() - #word
291- -- local menu_items = this.get_cmp_items()
292- -- if menu_items == nil or #menu_items == 0 then
293- -- this.pum_close()
294- -- else
295- -- this.pum_complete(start_col, this.normalize_list(menu_items, word))
296- -- end
297- -- end
298281end
299282
300283-- 获得所有command list
0 commit comments