Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2b30bc9

Browse files
committed
feat(cmd): Add path complete for optional args
1 parent6412719 commit2b30bc9

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

‎lua/packer.lua‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,9 @@ end
954954
-- Completion user plugins
955955
-- Intended to provide completion for PackerUpdate/Sync/Install command
956956
packer.plugin_complete=function(lead,_,_)
957+
ifvim.startswith(lead,'--lockfile=')then
958+
returnrequire('packer.util').path_complete(lead)
959+
end
957960
ifvim.startswith(lead,'-')then
958961
returnvim.tbl_filter(function(name)
959962
returnvim.startswith(name,lead)

‎lua/packer/lockfile.lua‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ local function collect_commits(plugins)
6565
end
6666

6767
lockfile.completion=function(lead,_,_)
68+
ifvim.startswith(lead,'--path=')then
69+
returnrequire("packer.util").path_complete(lead)
70+
end
71+
6872
ifvim.startswith(lead,'-')then
6973
returnvim.tbl_filter(function(name)
7074
returnvim.startswith(name,lead)

‎lua/packer/util.lua‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,44 @@ util.join_paths = function(...)
6464
returntable.concat({... },separator)
6565
end
6666

67+
util.path_complete=function(lead)
68+
localsplit=vim.split(lead,'=')
69+
localcommand,path=split[1]..'=',split[2]
70+
if#path==0then
71+
path='.'
72+
end
73+
path=vim.fs.normalize(path)
74+
75+
localcompletion_list= {}
76+
localis_dir=vim.fn.isdirectory(path)==1
77+
localdirpath=is_dirandpathorvim.fs.dirname(path)
78+
localfilepath=notis_dirandvim.fs.basename(path)
79+
80+
localsep=util.get_separator()
81+
localdir=vim.loop.fs_opendir(dirpath)
82+
83+
localfunctionjoin(d,f)
84+
returnd:sub(#d,#d)==sepandd..ford..sep..f
85+
end
86+
87+
localres=vim.loop.fs_readdir(dir)
88+
whileres~=nildo
89+
for_,entryinipairs(res)do
90+
iffilepaththen
91+
ifvim.startswith(entry.name,filepath)then
92+
completion_list[#completion_list+1]=command..join(dirpath,entry.name)
93+
end
94+
else
95+
completion_list[#completion_list+1]=command..join(dirpath,entry.name)
96+
end
97+
end
98+
res=vim.loop.fs_readdir(dir)
99+
end
100+
101+
vim.loop.fs_closedir(dir)
102+
returncompletion_list
103+
end
104+
67105
util.get_plugin_short_name=function(plugin)
68106
localpath=vim.fn.expand(plugin[1])
69107
localname_segments=vim.split(path,util.get_separator())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp