Skip to content

Commit 5076325

Browse files
committed
saving code
1 parent 1894c7e commit 5076325

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

autoload/easycomplete/sources/directory.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
function! easycomplete#sources#directory#completor(opt, ctx)
33
let l:typing_path = s:TypingAPath(a:ctx)
4-
if !l:typing_path.isPath
4+
if !l:typing_path.is_path
55
call easycomplete#complete(a:opt['name'], a:ctx, a:ctx['startcol'], [])
66
return v:true
77
endif
@@ -191,11 +191,11 @@ function! s:TypingAPath(...)
191191
" 排除掉输入注释的情况
192192
" 因为如果输入'//'紧跟<Tab>不应该出<C-X><C-U><C-N>出补全菜单
193193
if len(fpath) == 0 || match(prefx,"\\(\\/\\/\\|\\/\\*\\)") >= 0
194-
let pathDict.isPath = 0
194+
let pathDict.is_path = 0
195195
elseif fpath == "/"
196-
let pathDict.isPath = 0
196+
let pathDict.is_path = 0
197197
else
198-
let pathDict.isPath = 1
198+
let pathDict.is_path = 1
199199
endif
200200

201201
return pathDict

lua/easycomplete/cmdline.lua

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
148157
end
@@ -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

@@ -249,14 +258,7 @@ end
249258
function 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
298281
end
299282

300283
-- 获得所有command list

0 commit comments

Comments
 (0)