From 5e121d88da8559e0c52074916c6bca49c9cd4736 Mon Sep 17 00:00:00 2001 From: thefux Date: Mon, 21 Feb 2022 20:27:36 +0100 Subject: [PATCH] clean up --- lua/lazygit.lua | 34 +++++-------------- .../_extensions/lazygit_telescope.lua | 6 +--- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index ec2e293..b5f4f83 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -5,7 +5,6 @@ local fn = vim.fn -- store all git repositories visited in this session local lazygit_visited_git_repos = {} local function append_git_repo_path(repo_path) - -- TODO: could be done better :) for _, path in ipairs(lazygit_visited_git_repos) do if path == repo_path then return @@ -36,7 +35,6 @@ end --- Get project_root_dir for git repository local function project_root_dir() - -- always use bash on Unix based systems. local oldshell = vim.o.shell if vim.fn.has('win32') == 0 then @@ -48,7 +46,6 @@ local function project_root_dir() 'cd "' .. fn.fnamemodify(fn.resolve(fn.expand('%:p')), ':h') .. '" && git rev-parse --show-toplevel') local isgitdir = fn.matchstr(gitdir, '^fatal:.*') == '' - -- TODO: not sure the right way to do this if isgitdir then vim.o.shell = oldshell append_git_repo_path(gitdir) @@ -171,36 +168,21 @@ local function lazygit(path) print('Please install lazygit. Check documentation for more information') return end + + open_floating_window() + + local cmd = 'lazygit' + -- set path to the root path + _ = project_root_dir() + if path == nil then if is_symlink() then path = project_root_dir() end - end - open_floating_window() - - -- TODO: this should be configurable and not hardcoded like this - -- this is convinient if you want to carry your lazygit config in a custom location - local function get_nvim_root() - local nvim_root_path = vim.api.nvim_eval('$MYVIMRC') - return nvim_root_path:match("(.*".."\\"..")") - end - local cmd = 'lazygit' - _ = project_root_dir() - - if path ~= nil then + else cmd = cmd .. ' -p ' .. path end - cmd = cmd .. ' -ucf=' .. get_nvim_root() .. '/config/config.yml' - - -- if path ~= nil and not vim.env.GIT_DIR then - -- cmd = cmd .. ' -g "' .. path .. '/.git/"' - -- end - - -- if path ~= nil and not vim.env.GIT_WORK_TREE then - -- cmd = cmd .. ' -w "' .. path .. '"' - -- end - exec_lazygit_command(cmd) end diff --git a/lua/telescope/_extensions/lazygit_telescope.lua b/lua/telescope/_extensions/lazygit_telescope.lua index f3f0957..6ccfb0e 100644 --- a/lua/telescope/_extensions/lazygit_telescope.lua +++ b/lua/telescope/_extensions/lazygit_telescope.lua @@ -1,10 +1,5 @@ -local Path = require("plenary.path") -local Window = require("plenary.window.float") -local strings = require("plenary.strings") local pickers = require("telescope.pickers") local finders = require("telescope.finders") -local actions = require("telescope.actions") -local utils = require("telescope.utils") local action_set = require("telescope.actions.set") local action_state = require("telescope.actions.state") local conf = require("telescope.config").values @@ -24,6 +19,7 @@ end local lazygit_repos = function(opts) local displayer = require("telescope.pickers.entry_display").create { separator = "", + -- TODO: make use of telescope geometry items = { {width = 4}, {width = 55},