view plugins/hghelp/hghelp.vim @ 7:34930197e9d4

Updating hg diff tool. Adding support for global searching
author Luka Sitas <lsitas@avatarasoftware.com>
date Thu, 30 Oct 2025 13:45:31 -0400
parents 3017fd33ad8b
children 9c80955f0c6e
line wrap: on
line source

let g:hg_format_command = ""


function! s:CommitWithFormat()
  wa
  if exists("g:hg_format_command") && !empty(g:hg_format_command)
    execute '!'.g:hg_format_command
  endif
  execute '!hg addremove && hg commit'
endfunction

function! s:OpenHgDiff(file)
  let l:current_file = a:file !=# '' ? a:file : expand('%')
  let l:filetype = &filetype
  let l:temp_file = tempname()
  let l:command = 'hg cat -r . ' . l:current_file . ' > ' . l:temp_file
  let result = system(l:command . ' 2>&1')
  execute 'tabe ' . l:temp_file
  execute 'setfiletype' l:filetype
  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile 
  execute 'vert diffsplit' l:current_file
endfunction

command HGDiff call s:OpenHgDiff(expand('%'))
command Commit call s:CommitWithFormat()

map <C-k> :Commit<CR>
nnoremap <Leader>df :HGDiff<CR>