diff options
| author | Mike Vink <mike.vink@stater.nl> | 2023-05-08 13:57:54 +0200 |
|---|---|---|
| committer | Mike Vink <mike.vink@stater.nl> | 2023-05-08 13:57:54 +0200 |
| commit | 69126b821f73124527d520d301155f4fc80684ce (patch) | |
| tree | d5b4ceb71bb2e93a5a4dcc62b56e039ef6e38408 | |
| parent | d92dc4ca304bf175f3440b617b67b7791a9c0749 (diff) | |
fixup completion of Worktree
| -rw-r--r-- | fnl/conf/init.fnl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fnl/conf/init.fnl b/fnl/conf/init.fnl index 00ac7a8..8a6bce1 100644 --- a/fnl/conf/init.fnl +++ b/fnl/conf/init.fnl @@ -45,7 +45,7 @@ (local git-worktree (require :git-worktree)) (git-worktree.setup {:change_directory_command :tcd :update_on_change true - :autopush false}) + :autopush true}) (fn append [tbl item] (table.insert tbl item) @@ -78,6 +78,13 @@ [[:worktree path] [:HEAD commit] [:branch branch]] (branch:gsub :refs/heads/ "")))) +(fn list-branches [] + (local pbranch (io.popen "git branch --list -r --format \"%(refname)\"")) + (icollect [_ ref (ipairs (icollect [line (pbranch:lines)] + (line:gsub :refs/remotes/.+/ "")))] + (if (not (= ref :HEAD)) + ref))) + (vim.api.nvim_create_user_command :Worktree (fn [ctx] (match ctx.fargs @@ -98,7 +105,9 @@ (local cmdline-tokens (vim.split cmdline " ")) (match cmdline-tokens + [:Worktree :create & rest] (list-branches) [:Worktree :switch & rest] (list-worktrees) + [:Worktree :delete & rest] (list-worktrees) [:Worktree & rest] [:create :switch :delete]))}) |
