@@ -98,6 +98,7 @@ local function show_commit()
9898 })
9999end
100100
101+ local git_log_stdout_cache = {}
101102local function openLogBuffer ()
102103 vim .cmd ([[
103104 edit git://log
@@ -109,9 +110,20 @@ local function openLogBuffer()
109110 setl bufhidden=wipe
110111 setf git-log
111112 ]] )
113+
114+ bufnr = vim .api .nvim_get_current_buf ()
115+ vim .api .nvim_create_autocmd (' BufReadCmd' , {
116+ buffer = bufnr ,
117+ callback = function ()
118+ vim .api .nvim_buf_set_option (bufnr , ' modifiable' , true )
119+ vim .api .nvim_buf_set_lines (bufnr , 0 , - 1 , false , git_log_stdout_cache [bufnr ] or {})
120+ vim .api .nvim_buf_set_option (bufnr , ' modifiable' , false )
121+ vim .cmd .syntax (' on' )
122+ end ,
123+ })
124+
112125 -- nnoremap <buffer><silent> <Cr> :call <SID>show_commit()<CR>
113126 -- nnoremap <buffer><silent> q :call <SID>close_log_win()<CR>
114- bufnr = vim .fn .bufnr ()
115127 vim .api .nvim_buf_set_keymap (bufnr , ' n' , ' q' , ' ' , {
116128 callback = close_log_win ,
117129 })
@@ -135,6 +147,8 @@ local function on_stdout(id, data)
135147 vim .api .nvim_buf_set_lines (bufnr , - 1 , - 1 , false , data )
136148 end
137149 vim .api .nvim_buf_set_option (bufnr , ' modifiable' , false )
150+
151+ git_log_stdout_cache [bufnr ] = vim .api .nvim_buf_get_lines (bufnr , 0 , - 1 , false )
138152end
139153
140154local function on_stderr (id , data )
@@ -151,7 +165,7 @@ function M.run(argv)
151165 table.insert (cmd , vim .fn .expand (' %' ))
152166 else
153167 for _ , v in ipairs (argv ) do
154- if v == ' --decorate' then
168+ if v == ' --decorate' then
155169 cmd [5 ] = ' --pretty=' .. git_log_pretty2
156170 end
157171 table.insert (cmd , v )
0 commit comments