Skip to content

Commit

Permalink
✨ Turn off modification in git hover
Browse files Browse the repository at this point in the history
Mapping <Leader>g to git hover
  • Loading branch information
Nguyen-Hoang-Nam committed Dec 4, 2021
1 parent 0937871 commit eac8e95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lua/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ map('n', '<Leader>o', [[:lua require('telescope.builtin').buffers()<CR>]], cmd_o
map('n', '<Leader>t', [[:lua require('telescope.builtin').lsp_document_diagnostics()<CR>]], cmd_options)
map('n', '<Leader>p', [[:lua require('telescope.builtin').find_files()<CR>]], cmd_options)
map('n', '<Leader>a', [[<Cmd>lua require('telescope.builtin').lsp_code_actions()<CR>]], cmd_options)
map('n', '<Leader>g', [[:lua require('telescope.builtin').symbols{ sources = {'gitmoji'} }<CR>]], cmd_options)
map('n', '<Leader>e', [[:lua require('telescope.builtin').symbols{ sources = {'emoji'} }<CR>]], cmd_options)
map('n', '<Leader>e', [[:lua require('telescope.builtin').symbols{ sources = {'gitmoji'} }<CR>]], cmd_options)
map('n', '<Leader>g', [[<Cmd>lua require("utils.core").git_hover()<CR>]], cmd_options)
-- map('n', '<Leader>e', [[:lua require('telescope.builtin').symbols{ sources = {'emoji'} }<CR>]], cmd_options)

map('n', '<Leader>1', [[:lua require('jdtls.dap').setup_dap_main_class_configs()<CR>]], cmd_options)
map('n', '<Leader>2', [[:lua require'dap'.continue()<CR>]], cmd_options)
Expand Down
7 changes: 5 additions & 2 deletions lua/utils/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ function M.git_hover()

local message = blame.message
local count_line = 0
for line in string.gmatch(message, '[^\n]+') do
for line in string.gmatch(message, '([^\n]*)(\n?)') do
if count_line == 0 then
table.insert(texts, 'Summary: ' .. line)
table.insert(texts, '')
count_line = count_line + 1
else
table.insert(texts, line)
Expand Down Expand Up @@ -112,6 +111,10 @@ function M.git_hover()
api.nvim_buf_set_lines(buf, 0, #texts, false, texts)

api.nvim_buf_set_keymap(buf, 'n', 'q', ':close<CR>', { silent = true, nowait = true, noremap = true })

api.nvim_buf_set_option(buf, 'buftype', 'nofile')
api.nvim_buf_set_option(buf, 'bufhidden', 'delete')
api.nvim_buf_set_option(buf, 'modifiable', false)
end

return M

0 comments on commit eac8e95

Please sign in to comment.