forked from rafi/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgina.lua
More file actions
101 lines (76 loc) · 2.94 KB
/
gina.lua
File metadata and controls
101 lines (76 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
-- plugin: gina.vim
-- :h gina.txt
-- see: https://github.com/lambdalisue/gina.vim
-- rafi settings
local command_alias = vim.fn['gina#custom#command#alias']
local command_option = vim.fn['gina#custom#command#option']
local custom_execute = vim.fn['gina#custom#execute']
local action_alias = vim.fn['gina#custom#action#alias']
-- Commands
--
-- status
command_option('status', '-s')
command_option('status', '-b')
-- log
command_option('log', '--graph')
command_option('log', '-M')
-- lg (log --all)
command_alias('log', 'lg')
command_option('lg', '--all')
command_option('lg', '-M')
-- commit
command_option('commit', '--opener', 'below vnew')
command_option('commit', '-v|--verbose')
command_option('/\\%(status\\|commit\\)', '-u|--untracked-files')
-- Look 'n Feel
--
local winwidth = vim.fn.winwidth(0)
local width_half = winwidth / 2
local width_quarter = winwidth / 4
-- command_option('/\v(status|branch|ls|grep|changes)', '--opener', 'botright 10split')
-- command_option('/\v(blame|diff|log)', '--opener', 'tabnew')
-- Blame
command_option('blame', '--width', '40')
vim.g['gina#command#blame#formatter#format'] = '%au: %su%=on %ti %ma%in'
vim.g['gina#command#blame#formatter#separator'] = '… '
vim.g['gina#command#blame#formatter#current_mark'] = '>'
vim.g['gina#command#blame#formatter#timestamp_months'] = 3
vim.g['gina#command#blame#formatter#timestamp_format1'] = '%d %b'
vim.g['gina#command#blame#formatter#timestamp_format2'] = '%d/%b/%Y'
-- Open in vertical split
command_option('/\\%(branch\\|changes\\|grep\\)',
'--opener', 'vsplit')
-- Open in bottom horizontal split
command_option('/\\%(log\\|reflog\\)',
'--opener', 'below new')
-- log - Move to bottom
custom_execute('log',
'wincmd J | execute "resize" &previewheight | setlocal winfixheight')
-- changes/ls - Fixed window, half-size
custom_execute('/\\%(changes\\|ls\\)',
'vertical resize ' .. width_half .. ' | setlocal winfixwidth')
-- branch - Fixed window, quarter-size
custom_execute(
'/\\%(branch\\)',
'vertical resize ' .. width_quarter .. ' | setlocal winfixwidth')
-- Mappings
--
local opts = {noremap = 1, silent = 1}
-- local nowait = {noremap = 1, silent = 1, nowait = 1}
local nmap = vim.fn['gina#custom#mapping#nmap']
-- Alias 'p'/'dp' globally
action_alias('/.*', 'dp', 'diff:preview')
nmap('/.*', 'dp', ":<C-u>call gina#action#call('dp')<CR>", opts)
-- nmap('/.*', 'p', ":<C-u>call gina#action#call('preview')<CR>", nowait)
-- Preview commits
action_alias('/\\%(blame\\|log\\)', 'preview', 'show:commit:preview')
nmap('status', 'go', '<Plug>(gina-status-browse)')
-- Echo chunk info with K
nmap('blame', 'K', '<Plug>(gina-blame-echo)')
nmap('blame', 'p', '<cmd>call v:lua.gina_popup("Gina show HEAD --opener=split")<CR>', opts)
-- Blame mappings
vim.g['gina#command#blame#use_default_mappings'] = 0
nmap('blame', '<Return>', '<Plug>(gina-blame-open)')
nmap('blame', '<Backspace>', '<Plug>(gina-blame-back)')
nmap('blame', '<C-r>', '<Plug>(gina-blame-C-L)')
-- vim: set ts=2 sw=0 tw=80 noet :