1
0

2 Коммитууд 936522a847 ... a5b2a07904

Эзэн SHA1 Мессеж Огноо
  Thomas Dy a5b2a07904 bin: add git-amend-last 3 долоо хоног өмнө
  Thomas Dy 7b2776ac9f nixpkgs/neovim: use telescope as vim.ui.select 3 долоо хоног өмнө

+ 9 - 0
.config/nixpkgs/neovim/config/lua/user/plugins/telescope.lua

@@ -4,6 +4,7 @@ local telescope_actions = require('telescope.actions')
 local telescope_builtin = require('telescope.builtin')
 local telescope_pickers = require('telescope.pickers')
 local telescope_finders = require('telescope.finders')
+local telescope_themes = require('telescope.themes')
 local telescope_previewers = require('telescope.previewers')
 local telescope_putils = require('telescope.previewers.utils')
 local telescope_conf = require('telescope.config').values
@@ -102,11 +103,19 @@ telescope.setup({
       mappings = commit_mappings,
     },
   },
+  extensions = {
+    ['ui-select'] = {
+      telescope_themes.get_dropdown({})
+    }
+  }
 })
 
 -- use native sorter for better performance
 telescope.load_extension('fzf')
 
+-- use telescope for vim.ui.select
+telescope.load_extension('ui-select')
+
 -- custom picker to fallback to files if no git
 local function project_files()
   local ok = pcall(telescope_builtin.git_files, { show_untracked = true })

+ 4 - 0
.config/nixpkgs/neovim/plugins/sources.json

@@ -88,5 +88,9 @@
   "mawkler/demicolon.nvim": {
     "rev": "42eaf79845b777d3608b134f283d97ce44c87e82",
     "sha256": "19jmf8pkcyc6yfd45xb8hk6rnksanqmbqf3alwr5axgrr9xm2rsh"
+  },
+  "nvim-telescope/telescope-ui-select.nvim": {
+    "rev": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2",
+    "sha256": "1cgi4kmq99ssx97nnriff5674cjfvc3qsw62nx3iz0xqc6d4s631"
   }
 }

+ 40 - 0
.local/bin/git-amend-last

@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+# This essentially makes the current commit empty so you can see the full diff
+# of the commit to be amended.
+#
+# This allows something similar to "Amend Last Commit" of git gui.
+
+set -euo pipefail
+
+old_commit=$(git rev-parse HEAD)
+
+git-fmt() {
+  git show -s --format="$1"
+}
+
+title=$(git-fmt %s)
+message=$(git-fmt %B)
+
+GIT_AUTHOR_NAME=$(git-fmt %an)
+GIT_AUTHOR_EMAIL=$(git-fmt %ae)
+GIT_AUTHOR_DATE=$(git-fmt %aD)
+GIT_COMMITTER_NAME=$(git-fmt %cn)
+GIT_COMMITTER_EMAIL=$(git-fmt %ce)
+GIT_COMMITTER_DATE=$(git-fmt %cD)
+
+export \
+  GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE \
+  GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE
+
+git reset --soft HEAD~1
+new_commit=$(git commit-tree -p HEAD 'HEAD^{tree}' -m "$message")
+
+git update-ref -m "amend-last: $title" HEAD "$new_commit"
+
+# If we're rebasing, git stores the current commit in rebase-merge/amend to
+# know whether --continue should result in an amend. If we don't update this,
+# --continue will complain that we have unstaged changes instead.
+if git rev-parse -q --verify rebase-merge/amend; then
+  git update-ref rebase-merge/amend "$new_commit" "$old_commit"
+fi