1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 21:10:05 +08:00

feat(git): complete :Git branch

This commit is contained in:
Eric Wong 2024-03-31 15:47:50 +08:00
parent 18f2edc395
commit cbc3f5e50c
3 changed files with 12 additions and 1 deletions

View File

@ -24,6 +24,10 @@ if has('nvim-0.9.0')
function! git#branch#detect() abort
lua require('git.command.branch').detect()
endfunction
function! git#branch#complete(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("git.command.branch").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')

View File

@ -1,5 +1,5 @@
*git.txt* Git support in vim
Wang Shidong *git*
Wang Shidong & Mattes Groeger *git*
==============================================================================
CONTENTS *git-contents*

View File

@ -146,4 +146,11 @@ function M.run(argv)
end
end
function M.complete(arglead, cmdline, cursorpos)
if vim.startswith(arglead, '-') then
return table.concat({'-d', '-D'}, '\n')
end
return table.concat(vim.fn.map(vim.fn.systemlist('git branch --no-merged'), 'trim(v:val)'), '\n')
end
return M