Skip to content

Commit 320f883

Browse files
committed
beautify code
1 parent 0ad89a5 commit 320f883

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

lua/easycomplete/cmdline.lua

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ local console = util.console
33
local normal_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST0123456789#$_"
44
-- cmdline_start_cmdpos 是不带偏移量的,偏移量只给 pum 定位用
55
local cmdline_start_cmdpos = 0
6-
local zizz_flag = 0
7-
local zizz_timer = vim.loop.new_timer()
86
local completeopt = vim.o.completeopt
97
local this = {}
108

@@ -58,14 +56,14 @@ end
5856

5957
function this.select_next()
6058
vim.fn['easycomplete#pum#next']()
61-
this.zizz()
59+
util.zizz()
6260
local new_whole_word = this.get_tab_returing_opword()
6361
return new_whole_word
6462
end
6563

6664
function this.select_prev()
6765
vim.fn['easycomplete#pum#prev']()
68-
this.zizz()
66+
util.zizz()
6967
local new_whole_word = this.get_tab_returing_opword()
7068
return new_whole_word
7169
end
@@ -153,7 +151,7 @@ function this.cmdline_handler(keys, key_str)
153151
if vim.g.easycomplete_cmdline_pattern == "" then
154152
return
155153
end
156-
if this.zizzing() then return end
154+
if util.zizzing() then return end
157155
local cmdline = vim.fn.getcmdline()
158156
cmdline_start_cmdpos = 0
159157
if string.byte(key_str) == 9 then
@@ -266,25 +264,6 @@ function this.get_completion_type()
266264
return cmd_type
267265
end
268266

269-
function this.zizz()
270-
if zizz_flag > 0 then
271-
zizz_timer:stop()
272-
zizz_flag = 0
273-
end
274-
zizz_timer:start(30, 0, function()
275-
zizz_flag = 0
276-
end)
277-
zizz_flag = 1
278-
end
279-
280-
function this.zizzing()
281-
if zizz_flag == 1 then
282-
return true
283-
else
284-
return false
285-
end
286-
end
287-
288267
this.commands_type = {
289268
-- File completion
290269
edit = 'file',

lua/easycomplete/util.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
local util = {}
2+
local zizz_flag = 0
3+
local zizz_timer = vim.loop.new_timer()
24
local async_timer = vim.loop.new_timer()
35
local async_timer_counter = 0
46

7+
function util.zizz()
8+
if zizz_flag > 0 then
9+
zizz_timer:stop()
10+
zizz_flag = 0
11+
end
12+
zizz_timer:start(30, 0, function()
13+
zizz_flag = 0
14+
end)
15+
zizz_flag = 1
16+
end
17+
18+
function util.zizzing()
19+
if zizz_flag == 1 then
20+
return true
21+
else
22+
return false
23+
end
24+
end
25+
526
function util.get_servers()
627
if not util.nvim_installer_installed() then
728
return nil

0 commit comments

Comments
 (0)