2021-07-06 19:40:10 +02:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.config = function()
|
2021-07-07 01:15:37 +02:00
|
|
|
local status_ok, fterm = pcall(require, "FTerm")
|
|
|
|
if not status_ok then
|
|
|
|
return
|
|
|
|
end
|
2021-07-06 19:40:10 +02:00
|
|
|
|
2021-07-07 01:15:37 +02:00
|
|
|
fterm.setup {
|
|
|
|
dimensions = {
|
|
|
|
height = 0.8,
|
|
|
|
width = 0.8,
|
|
|
|
x = 0.5,
|
|
|
|
y = 0.5,
|
|
|
|
},
|
|
|
|
border = "single", -- or 'double'
|
|
|
|
}
|
2021-07-06 19:40:10 +02:00
|
|
|
|
2021-07-07 01:15:37 +02:00
|
|
|
-- Create LazyGit Terminal
|
|
|
|
local term = require "FTerm.terminal"
|
|
|
|
local lazy = term:new():setup {
|
|
|
|
cmd = "lazygit",
|
|
|
|
dimensions = {
|
|
|
|
height = 0.9,
|
|
|
|
width = 0.9,
|
2021-07-07 03:44:51 +02:00
|
|
|
x = 0.5,
|
|
|
|
y = 0.3,
|
2021-07-07 01:15:37 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local function is_installed(exe)
|
|
|
|
return vim.fn.executable(exe) == 1
|
|
|
|
end
|
2021-07-06 19:40:10 +02:00
|
|
|
|
2021-07-07 01:15:37 +02:00
|
|
|
-- Use this to toggle gitui in a floating terminal
|
|
|
|
function _G.__fterm_lazygit()
|
|
|
|
if is_installed "lazygit" ~= true then
|
|
|
|
print "Please install lazygit. Check documentation for more information"
|
|
|
|
return
|
2021-07-06 19:40:10 +02:00
|
|
|
end
|
2021-07-07 01:15:37 +02:00
|
|
|
lazy:toggle()
|
|
|
|
end
|
2021-07-07 19:51:23 +02:00
|
|
|
|
|
|
|
-- Map esc to exit inside lazygit
|
|
|
|
vim.api.nvim_exec([[
|
|
|
|
function LazyGitNativation()
|
|
|
|
echom &filetype
|
|
|
|
if &filetype ==# 'FTerm'
|
|
|
|
tnoremap <Esc> q
|
|
|
|
tnoremap <C-v><Esc> <Esc>
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
]], false)
|
2021-07-06 19:40:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|