1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 23:50:04 +08:00

feat(git): implement lua complete for git-tag

This commit is contained in:
Eric Wong 2024-12-17 17:30:08 +08:00
parent a0b86e67e8
commit 3ffa25addc
2 changed files with 85 additions and 72 deletions

View File

@ -6,6 +6,11 @@
" :Git tag --list " :Git tag --list
" < " <
if has('nvim-0.9.0')
function! git#tag#complete(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("git.command.tag").complete(vim.api.nvim_eval("a:ArgLead"), vim.api.nvim_eval("a:CmdLine"), vim.api.nvim_eval("a:CursorPos"))')
endfunction
else
let s:JOB = SpaceVim#api#import('job') let s:JOB = SpaceVim#api#import('job')
let s:NT = SpaceVim#api#import('notify') let s:NT = SpaceVim#api#import('notify')
let s:jobid = -1 let s:jobid = -1
@ -91,3 +96,4 @@ function! git#tag#complete(ArgLead, CmdLine, CursorPos) abort
endfunction endfunction
endif

View File

@ -72,7 +72,14 @@ function M.run(argv)
end end
end end
function M.complete(ArgLead, CmdLine, CursorPos) end function M.complete(ArgLead, CmdLine, CursorPos)
local str = string.sub(CmdLine, 1, CursorPos)
if vim.regex([[^Git\s\+tag\s\+-\+$]]):match_str(str) then
return table.concat({'--list'}, '\n')
else
return ''
end
end
return M return M