init.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. local M = {}
  2. M.config = function()
  3. local status_ok, fterm = pcall(require, "FTerm")
  4. if not status_ok then
  5. return
  6. end
  7. fterm.setup {
  8. dimensions = {
  9. height = 0.8,
  10. width = 0.8,
  11. x = 0.5,
  12. y = 0.5,
  13. },
  14. border = "single", -- or 'double'
  15. }
  16. -- Create LazyGit Terminal
  17. local term = require "FTerm.terminal"
  18. local lazy = term:new():setup {
  19. cmd = "lazygit",
  20. dimensions = {
  21. height = 0.9,
  22. width = 0.9,
  23. x = 0.5,
  24. y = 0.3,
  25. },
  26. }
  27. local function is_installed(exe)
  28. return vim.fn.executable(exe) == 1
  29. end
  30. -- Use this to toggle gitui in a floating terminal
  31. function _G.__fterm_lazygit()
  32. if is_installed "lazygit" ~= true then
  33. print "Please install lazygit. Check documentation for more information"
  34. return
  35. end
  36. lazy:toggle()
  37. end
  38. -- Map esc to exit inside lazygit
  39. vim.api.nvim_exec([[
  40. function LazyGitNativation()
  41. echom &filetype
  42. if &filetype ==# 'FTerm'
  43. tnoremap <Esc> q
  44. tnoremap <C-v><Esc> <Esc>
  45. endif
  46. endfunction
  47. ]], false)
  48. end
  49. return M