Browse Source

nixpkgs/neovim: refactor GLg off of telescope

telescope search doesn't preserve order which doesn't match the work
flow of git lg -> git show
Thomas Dy 2 weeks ago
parent
commit
9b3d712653

+ 11 - 0
.config/nixpkgs/neovim/overrides/after/syntax/git.vim

@@ -0,0 +1,11 @@
+syn region gitLg start=/\%(^[|\/\\_ ]*\*[|\/\\_ ]\{-\} \%(\x\{4,\}\)\)\@=/ end=/$/ contains=@NoSpell,gitLgHash,gitLgEnd
+syn match gitLgHash /\<\x\{7,\}\>/ contained nextgroup=gitLgDecorate skipwhite
+syn match gitLgDecorate /([^)]*)/ contained
+syn match gitLgEnd /([^)]*) <[^>]*>$/ contains=gitLgAuthor,gitLgDate
+syn match gitLgDate /([^)]*)/ contained
+syn match gitLgAuthor /<[^>]*>/ contained
+
+hi def link gitLgHash gitHash
+hi def link gitLgAuthor gitIdentity
+hi def link gitLgDate gitDate
+hi def link gitLgDecorate gitReference

+ 5 - 7
.config/nixpkgs/neovim/plugins.lua

@@ -144,13 +144,6 @@ local telescope_previewers = require('telescope.previewers')
 local telescope_putils = require('telescope.previewers.utils')
 local telescope_conf = require('telescope.config').values
 
--- arbitrary git log picker
-vim.api.nvim_create_user_command('GLg', function(opts)
-  local git_command = { "git", "log", "--pretty=oneline", "--abbrev-commit" }
-  vim.list_extend(git_command, opts.fargs)
-  telescope_builtin.git_commits({ git_command = git_command })
-end, { nargs = '*', complete = vim.fn['fugitive#LogComplete'] })
-
 -- custom picker to fallback to files if no git
 _G.project_files = function()
   local ok = pcall(telescope_builtin.git_files, { show_untracked = true })
@@ -432,3 +425,8 @@ _G.toggle_end_char = function(char)
     vim.api.nvim_buf_set_text(0, row, -1, row, -1, { char })
   end
 end
+
+-- prettier git log, relies on additional syntax highlights
+vim.api.nvim_create_user_command('GLg', function(opts)
+  vim.cmd("Git ++curwin log --abbrev-commit --graph --pretty='%h %d %s (%cr) <%an>' " .. opts.args)
+end, { nargs = '?', complete = vim.fn['fugitive#LogComplete'] })