1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1,2 @@
github: [kdheepak]
custom: ['https://donate.stripe.com/8wM9E7bBO9ZsbGUdQR']

View File

@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Description**
<!-- A clear and concise description of what the bug is. -->
**To Reproduce**
Here are the steps to reproduce the behavior using [MINRC](../blob/master/tests/MINRC):
<!--
1. ...
2. ...
3. ...
-->
**Expected behavior**
What is expected to happen:
**Screenshots**
<!-- if applicable -->
**Desktop (please complete the following information):**
- nvim --version:

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2020 Dheepak Krishnamurthy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,274 @@
# lazygit.nvim
Plugin for calling [lazygit](https://github.com/jesseduffield/lazygit) from within neovim.
![](https://user-images.githubusercontent.com/1813121/87866391-79fcfe00-c93e-11ea-94a9-204947de1b39.gif)
See [akinsho/nvim-toggleterm](https://github.com/akinsho/nvim-toggleterm.lua#custom-terminals) or [voldikss/vim-floaterm](https://github.com/voldikss/vim-floaterm) as an alternative to this package.
### Install
Install using [`vim-plug`](https://github.com/junegunn/vim-plug):
```vim
" nvim v0.7.2
Plug 'kdheepak/lazygit.nvim'
```
Install using [`packer.nvim`](https://github.com/wbthomason/packer.nvim):
```lua
-- nvim v0.7.2
use({
"kdheepak/lazygit.nvim",
-- optional for floating window border decoration
requires = {
"nvim-lua/plenary.nvim",
},
})
```
Install using [`lazy.nvim`](https://github.com/folke/lazy.nvim):
```lua
-- nvim v0.8.0
return {
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
-- setting the keybinding for LazyGit with 'keys' is recommended in
-- order to load the plugin when the command is run for the first time
keys = {
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = "LazyGit" }
}
}
```
Feel free to use any plugin manager.
Just remember that if you are not using the latest neovim release, you will need to use [the `nvim-v0.4.3` branch](https://github.com/kdheepak/lazygit.vim/tree/nvim-v0.4.3).
Integration with `nvr` works better on the `main` branch.
You can check what version of `neovim` you have:
```bash
nvim --version
```
### Usage
The following are configuration options and their defaults.
```vim
let g:lazygit_floating_window_winblend = 0 " transparency of floating window
let g:lazygit_floating_window_scaling_factor = 0.9 " scaling factor for floating window
let g:lazygit_floating_window_border_chars = ['╭','─', '╮', '│', '╯','─', '╰', '│'] " customize lazygit popup window border characters
let g:lazygit_floating_window_use_plenary = 0 " use plenary.nvim to manage floating window if available
let g:lazygit_use_neovim_remote = 1 " fallback to 0 if neovim-remote is not installed
let g:lazygit_use_custom_config_file_path = 0 " config file path is evaluated if this value is 1
let g:lazygit_config_file_path = '' " custom config file path
" OR
let g:lazygit_config_file_path = [] " list of custom config file paths
```
```lua
vim.g.lazygit_floating_window_winblend = 0 -- transparency of floating window
vim.g.lazygit_floating_window_scaling_factor = 0.9 -- scaling factor for floating window
vim.g.lazygit_floating_window_border_chars = {'╭','─', '╮', '│', '╯','─', '╰', '│'} -- customize lazygit popup window border characters
vim.g.lazygit_floating_window_use_plenary = 0 -- use plenary.nvim to manage floating window if available
vim.g.lazygit_use_neovim_remote = 1 -- fallback to 0 if neovim-remote is not installed
vim.g.lazygit_use_custom_config_file_path = 0 -- config file path is evaluated if this value is 1
vim.g.lazygit_config_file_path = '' -- custom config file path
-- OR
vim.g.lazygit_config_file_path = {} -- table of custom config file paths
```
Call `:LazyGit` to start a floating window with `lazygit` in the current working directory.
And set up a mapping to call `:LazyGit`:
```vim
" setup mapping to call :LazyGit
nnoremap <silent> <leader>gg :LazyGit<CR>
```
Call `:LazyGitCurrentFile` to start a floating window with `lazygit` in the project root of the current file.
Open the configuration file for `lazygit` directly from vim.
```vim
:LazyGitConfig<CR>
```
If the file does not exist it'll load the defaults for you.
![](https://user-images.githubusercontent.com/1813121/78830902-46721580-79d8-11ea-8809-291b346b6c42.gif)
Open project commits with `lazygit` directly from vim in floating window.
```vim
:LazyGitFilter<CR>
```
Open buffer commits with `lazygit` directly from vim in floating window.
```vim
:LazyGitFilterCurrentFile<CR>
```
**Using neovim-remote**
If you have [neovim-remote](https://github.com/mhinz/neovim-remote) and have configured to use it in neovim, it'll launch the commit editor inside your neovim instance when you use `C` inside `lazygit`.
1. `pip install neovim-remote`
2. Add the following to your `~/.bashrc`:
```bash
if [ -n "$NVIM_LISTEN_ADDRESS" ]; then
alias nvim=nvr -cc split --remote-wait +'set bufhidden=wipe'
fi
```
3. Set `EDITOR` environment variable in `~/.bashrc`:
```bash
if [ -n "$NVIM_LISTEN_ADDRESS" ]; then
export VISUAL="nvr -cc split --remote-wait +'set bufhidden=wipe'"
export EDITOR="nvr -cc split --remote-wait +'set bufhidden=wipe'"
else
export VISUAL="nvim"
export EDITOR="nvim"
fi
```
4. Add the following to `~/.vimrc`:
```vim
if has('nvim') && executable('nvr')
let $GIT_EDITOR = "nvr -cc split --remote-wait +'set bufhidden=wipe'"
endif
```
If you have `neovim-remote` and don't want `lazygit.nvim` to use it, you can disable it using the following configuration option:
```vim
let g:lazygit_use_neovim_remote = 0
```
**Using nvim --listen and nvim --server to edit files in same process**
You can use vanilla nvim server to edit files in the same nvim instance when you use `e` inside `lazygit`.
1. You have to start nvim with the `--listen` parameter. An easy way to ensure this is to use an alias:
```bash
# ~/.bashrc
alias vim='nvim --listen /tmp/nvim-server.pipe'
```
2. You have to modify lazygit to attempt connecting to existing nvim instance on edit:
```yml
# ~/.config/jesseduffield/lazygit/config.yml
os:
editCommand: 'nvim'
editCommandTemplate: '{{editor}} --server /tmp/nvim-server.pipe --remote-tab "$(pwd)/{{filename}}"'
```
### Telescope Plugin
The Telescope plugin is used to track all git repository visited in one nvim session.
![lazygittelplugin](https://user-images.githubusercontent.com/10464534/156933468-c89abee4-6afb-457c-8b02-55b67913aef2.png)
(background image is not included :smirk:)
**Why a telescope Plugin** ?
Assuming you have one or more submodule(s) in your project and you want to commit changes in both the submodule(s)
and the main repo.
Though switching between submodules and main repo is not straight forward.
A solution at first could be:
1. open a file inside the submodule
2. open lazygit
3. do commit
4. then open a file in the main repo
5. open lazygit
6. do commit
That is really annoying.
Instead, you can open it with telescope.
**How to use**
Install using [`packer.nvim`](https://github.com/wbthomason/packer.nvim):
```lua
-- nvim v0.7.2
use({
"kdheepak/lazygit.nvim",
requires = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
},
config = function()
require("telescope").load_extension("lazygit")
end,
})
```
Install using [`lazy.nvim`](https://github.com/folke/lazy.nvim):
```lua
-- nvim v0.8.0
require("lazy").setup({
{
"kdheepak/lazygit.nvim",
dependencies = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim"
},
config = function()
require("telescope").load_extension("lazygit")
end,
},
})
```
Lazy loading `lazygit.nvim` for telescope functionality is not supported. Open an issue if you wish to have this feature.
If you are not using Packer, to load the telescope extension, you have to add this line to your configuration:
```lua
require('telescope').load_extension('lazygit')
```
By default the paths of each repo is stored only when lazygit is triggered.
Though, this may not be convenient, so it possible to do something like this:
```vim
autocmd BufEnter * :lua require('lazygit.utils').project_root_dir()
```
That makes sure that any opened buffer which is contained in a git repo will be tracked.
Once you have loaded the extension, you can invoke the plugin using:
```lua
lua require("telescope").extensions.lazygit.lazygit()
```
### Highlighting groups
| Highlight Group | Default Group | Description |
| ------------------| --------------| -----------------------------------------|
| **LazyGitFloat** | **_Normal_** | Float terminal foreground and background |
| **LazyGitBorder** | **_Normal_** | Float terminal border |

View File

@ -0,0 +1,7 @@
if exists("g:lazygit_opened") && g:lazygit_opened && g:lazygit_use_neovim_remote && executable("nvr")
augroup lazygit_neovim_remote
autocmd!
autocmd BufUnload <buffer> :lua local root = require('lazygit').project_root_dir(); vim.schedule(function() require('lazygit').lazygit(root) end)
autocmd BufUnload <buffer> :let g:lazygit_opened=0
augroup END
end

View File

@ -0,0 +1,170 @@
local open_floating_window = require("lazygit.window").open_floating_window
local project_root_dir = require("lazygit.utils").project_root_dir
local get_root = require("lazygit.utils").get_root
local is_lazygit_available = require("lazygit.utils").is_lazygit_available
local is_symlink = require("lazygit.utils").is_symlink
local open_or_create_config = require("lazygit.utils").open_or_create_config
local fn = vim.fn
LAZYGIT_BUFFER = nil
LAZYGIT_LOADED = false
vim.g.lazygit_opened = 0
local prev_win = -1
local win = -1
local buffer = -1
--- on_exit callback function to delete the open buffer when lazygit exits in a neovim terminal
local function on_exit(job_id, code, event)
if code ~= 0 then
return
end
LAZYGIT_BUFFER = nil
LAZYGIT_LOADED = false
vim.g.lazygit_opened = 0
vim.cmd("silent! :checktime")
if vim.api.nvim_win_is_valid(prev_win) then
vim.api.nvim_win_close(win, true)
vim.api.nvim_set_current_win(prev_win)
prev_win = -1
if vim.api.nvim_buf_is_valid(buffer) and vim.api.nvim_buf_is_loaded(buffer) then
vim.api.nvim_buf_delete(buffer, { force = true })
end
buffer = -1
win = -1
end
end
--- Call lazygit
local function exec_lazygit_command(cmd)
if LAZYGIT_LOADED == false then
-- ensure that the buffer is closed on exit
vim.g.lazygit_opened = 1
vim.fn.termopen(cmd, { on_exit = on_exit })
end
vim.cmd("startinsert")
end
local function lazygitdefaultconfigpath()
-- lazygit -cd gives only the config dir, not the config file, so concat config.yml
return fn.substitute(fn.system("lazygit -cd"), "\n", "", "") .. "/config.yml"
end
local function lazygitgetconfigpath()
local default_config_path = lazygitdefaultconfigpath()
-- if vim.g.lazygit_config_file_path is a table, check if all config files exist
if vim.g.lazygit_config_file_path then
if type(vim.g.lazygit_config_file_path) == "table" then
for _, config_file in ipairs(vim.g.lazygit_config_file_path) do
if fn.empty(fn.glob(config_file)) == 1 then
print("lazygit: custom config file path: '" .. config_file .. "' could not be found. Returning default config")
return default_config_path
end
end
return vim.g.lazygit_config_file_path
elseif fn.empty(fn.glob(vim.g.lazygit_config_file_path)) == 0 then
return vim.g.lazygit_config_file_path
else
print("lazygit: custom config file path: '" .. vim.g.lazygit_config_file_path .. "' could not be found. Returning default config")
return default_config_path
end
else
print("lazygit: custom config file path is not set, option: 'lazygit_config_file_path' is missing")
-- any issue with the config file we fallback to the default config file path
return default_config_path
end
end
--- :LazyGit entry point
local function lazygit(path)
if is_lazygit_available() ~= true then
print("Please install lazygit. Check documentation for more information")
return
end
prev_win = vim.api.nvim_get_current_win()
win, buffer = open_floating_window()
local cmd = "lazygit"
-- set path to the root path
_ = project_root_dir()
if vim.g.lazygit_use_custom_config_file_path == 1 then
local config_path = lazygitgetconfigpath()
if type(config_path) == "table" then
config_path = table.concat(config_path, ",")
end
cmd = cmd .. " -ucf '" .. config_path .. "'" -- quote config_path to avoid whitespace errors
end
if path == nil then
if is_symlink() then
path = project_root_dir()
end
else
if fn.isdirectory(path) then
cmd = cmd .. " -p " .. path
end
end
exec_lazygit_command(cmd)
end
--- :LazyGitCurrentFile entry point
local function lazygitcurrentfile()
local current_dir = vim.fn.expand("%:p:h")
local git_root = get_root(current_dir)
lazygit(git_root)
end
--- :LazyGitFilter entry point
local function lazygitfilter(path)
if is_lazygit_available() ~= true then
print("Please install lazygit. Check documentation for more information")
return
end
if path == nil then
path = project_root_dir()
end
prev_win = vim.api.nvim_get_current_win()
win, buffer = open_floating_window()
local cmd = "lazygit " .. "-f " .. path
exec_lazygit_command(cmd)
end
--- :LazyGitFilterCurrentFile entry point
local function lazygitfiltercurrentfile()
local current_file = vim.fn.expand("%")
lazygitfilter(current_file)
end
--- :LazyGitConfig entry point
local function lazygitconfig()
local config_file = lazygitgetconfigpath()
if type(config_file) == "table" then
vim.ui.select(
config_file,
{ prompt = "select config file to edit" },
function (path)
open_or_create_config(path)
end
)
else
open_or_create_config(config_file)
end
end
return {
lazygit = lazygit,
lazygitcurrentfile = lazygitcurrentfile,
lazygitfilter = lazygitfilter,
lazygitfiltercurrentfile = lazygitfiltercurrentfile,
lazygitconfig = lazygitconfig,
project_root_dir = project_root_dir,
}

View File

@ -0,0 +1,127 @@
local fn = vim.fn
-- store all git repositories visited in this session
local lazygit_visited_git_repos = {}
-- TODO:check if the repo isa git repo
local function append_git_repo_path(repo_path)
if repo_path == nil or not fn.isdirectory(repo_path) then
return
end
for _, path in ipairs(lazygit_visited_git_repos) do
if path == repo_path then
return
end
end
table.insert(lazygit_visited_git_repos, tostring(repo_path))
end
--- Strip leading and lagging whitespace
local function trim(str)
return str:gsub('^%s+', ''):gsub('%s+$', '')
end
local function get_root(cwd)
local status, job = pcall(require, 'plenary.job')
if not status then
return fn.system('git rev-parse --show-toplevel')
end
local gitroot_job = job:new({
'git',
'rev-parse',
'--show-toplevel',
cwd=cwd
})
local path, code = gitroot_job:sync()
if (code ~= 0) then
return nil
end
return table.concat(path, "")
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
vim.o.shell = 'bash'
end
local cwd = vim.loop.cwd()
local root = get_root(cwd)
if root == nil then
vim.o.shell = oldshell
return nil
end
local cmd = string.format('cd "%s" && git rev-parse --show-toplevel', fn.fnamemodify(fn.resolve(fn.expand('%:p')), ':h'), root)
-- try symlinked file location instead
local gitdir = fn.system(cmd)
local isgitdir = fn.matchstr(gitdir, '^fatal:.*') == ''
if isgitdir then
vim.o.shell = oldshell
append_git_repo_path(gitdir)
return trim(gitdir)
end
-- revert to old shell
vim.o.shell = oldshell
local repo_path = fn.getcwd(0, 0)
append_git_repo_path(repo_path)
-- just return current working directory
return repo_path
end
--- Check if lazygit is available
local function is_lazygit_available()
return fn.executable('lazygit') == 1
end
local function is_symlink()
local resolved = fn.resolve(fn.expand('%:p'))
return resolved ~= fn.expand('%:p')
end
local function open_or_create_config(path)
if fn.empty(fn.glob(path)) == 1 then
-- file does not exist
-- check if user wants to create it
local answer = fn.confirm(
"File "
.. path
.. " does not exist.\nDo you want to create the file and populate it with the default configuration?",
"&Yes\n&No"
)
if answer == 2 then
return nil
end
if fn.isdirectory(fn.fnamemodify(path, ":h")) == false then
-- directory does not exist
fn.mkdir(fn.fnamemodify(path, ":h"), "p")
end
vim.cmd("edit " .. path)
vim.cmd([[execute "silent! 0read !lazygit -c"]])
vim.cmd([[execute "normal 1G"]])
else
vim.cmd("edit " .. path)
end
end
return {
get_root = get_root,
project_root_dir = project_root_dir,
lazygit_visited_git_repos = lazygit_visited_git_repos,
is_lazygit_available = is_lazygit_available,
is_symlink = is_symlink,
open_or_create_config = open_or_create_config,
}

View File

@ -0,0 +1,89 @@
local api = vim.api
--- open floating window with nice borders
local function open_floating_window()
local floating_window_scaling_factor = vim.g.lazygit_floating_window_scaling_factor
-- Why is this required?
-- vim.g.lazygit_floating_window_scaling_factor returns different types if the value is an integer or float
if type(floating_window_scaling_factor) == 'table' then
floating_window_scaling_factor = floating_window_scaling_factor[false]
end
local status, plenary = pcall(require, 'plenary.window.float')
if status and vim.g.lazygit_floating_window_use_plenary and vim.g.lazygit_floating_window_use_plenary ~= 0 then
local ret = plenary.percentage_range_window(floating_window_scaling_factor, floating_window_scaling_factor, {winblend=vim.g.lazygit_floating_window_winblend})
return ret.win_id, ret.bufnr
end
local height = math.ceil(vim.o.lines * floating_window_scaling_factor) - 1
local width = math.ceil(vim.o.columns * floating_window_scaling_factor)
local row = math.ceil(vim.o.lines - height) / 2
local col = math.ceil(vim.o.columns - width) / 2
local border_opts = {
style = 'minimal',
relative = 'editor',
row = row - 1,
col = col - 1,
width = width + 2,
height = height + 2,
}
local opts = { style = 'minimal', relative = 'editor', row = row, col = col, width = width, height = height }
local topleft, top, topright, right, botright, bot, botleft, left
local window_chars = vim.g.lazygit_floating_window_border_chars
if type(window_chars) == 'table' and #window_chars == 8 then
topleft, top, topright, right, botright, bot, botleft, left = unpack(window_chars)
else
topleft, top, topright, right, botright, bot, botleft, left = '','', '', '', '','', '', ''
end
local border_lines = { topleft .. string.rep(top, width) .. topright }
local middle_line = left .. string.rep(' ', width) .. right
for _ = 1, height do
table.insert(border_lines, middle_line)
end
table.insert(border_lines, botleft .. string.rep(bot, width) .. botright)
-- create a unlisted scratch buffer for the border
local border_buffer = api.nvim_create_buf(false, true)
-- set border_lines in the border buffer from start 0 to end -1 and strict_indexing false
api.nvim_buf_set_lines(border_buffer, 0, -1, true, border_lines)
-- create border window
local border_window = api.nvim_open_win(border_buffer, true, border_opts)
vim.api.nvim_set_hl(0, "LazyGitBorder", { link = "Normal", default = true })
vim.cmd('set winhl=NormalFloat:LazyGitBorder')
-- create a unlisted scratch buffer
if LAZYGIT_BUFFER == nil or vim.fn.bufwinnr(LAZYGIT_BUFFER) == -1 then
LAZYGIT_BUFFER = api.nvim_create_buf(false, true)
else
LAZYGIT_LOADED = true
end
-- create file window, enter the window, and use the options defined in opts
local win = api.nvim_open_win(LAZYGIT_BUFFER, true, opts)
vim.bo[LAZYGIT_BUFFER].filetype = 'lazygit'
vim.cmd('setlocal bufhidden=hide')
vim.cmd('setlocal nocursorcolumn')
vim.api.nvim_set_hl(0, "LazyGitFloat", { link = "Normal", default = true })
vim.cmd('setlocal winhl=NormalFloat:LazyGitFloat')
vim.cmd('set winblend=' .. vim.g.lazygit_floating_window_winblend)
-- use autocommand to ensure that the border_buffer closes at the same time as the main buffer
local cmd = [[autocmd WinLeave <buffer> silent! execute 'hide']]
vim.cmd(cmd)
cmd = [[autocmd WinLeave <buffer> silent! execute 'silent bdelete! %s']]
vim.cmd(cmd:format(border_buffer))
return win, LAZYGIT_BUFFER
end
return {
open_floating_window = open_floating_window,
}

View File

@ -0,0 +1,93 @@
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local conf = require("telescope.config").values
local lazygit_utils = require("lazygit.utils")
local function open_lazygit(prompt_buf)
local entry = action_state.get_selected_entry()
vim.fn.execute('cd ' .. entry.value)
local cmd = [[lua require"lazygit".lazygit(nil)]]
vim.api.nvim_command(cmd)
vim.cmd('stopinsert')
vim.cmd([[execute "normal i"]])
vim.fn.feedkeys('j')
vim.api.nvim_buf_set_keymap(0, 't', '<Esc>', '<Esc>', {noremap = true, silent = true})
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},
{remaining = true},
},
}
local repos = {}
for _, v in pairs(lazygit_utils.lazygit_visited_git_repos) do
if v == nil then
goto skip
end
local index = #repos + 1
local entry =
{
idx = index,
value = v:gsub("%s", ""),
-- retrieve git repo name
repo_name= v:gsub("%s", ""):match("^.+/(.+)$"),
}
table.insert(repos, index, entry)
::skip::
end
pickers.new(opts or {}, {
prompt_title = "lazygit repos",
finder = finders.new_table {
results = repos,
entry_maker = function(entry)
local make_display = function()
return displayer
{
{entry.idx},
{entry.repo_name},
}
end
return {
value = entry.value,
ordinal = string.format("%s %s", entry.idx, entry.repo_name),
display = make_display,
}
end,
},
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_buf, _)
actions.select_default:replace(function ()
-- for what ever reason any attempt to open an external window (such as lazygit)
-- shall be done after closing the buffer manually
actions.close(prompt_buf)
open_lazygit()
end
)
return true
end
}):find()
end
return require("telescope").register_extension({
exports = {
lazygit = lazygit_repos,
}
})

View File

@ -0,0 +1,60 @@
scriptencoding utf-8
if exists('g:loaded_lazygit_vim') | finish | endif
let s:save_cpo = &cpoptions
set cpoptions&vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""
if !exists('g:lazygit_floating_window_winblend')
let g:lazygit_floating_window_winblend = 0
endif
if !exists('g:lazygit_floating_window_scaling_factor')
let g:lazygit_floating_window_scaling_factor = 0.9
endif
if !exists('g:lazygit_use_neovim_remote')
let g:lazygit_use_neovim_remote = executable('nvr') ? 1 : 0
endif
if exists('g:lazygit_floating_window_corner_chars')
echohl WarningMsg
echomsg "`g:lazygit_floating_window_corner_chars` is deprecated. Please use `g:lazygit_floating_window_border_chars` instead."
echohl None
if !exists('g:lazygit_floating_window_border_chars')
let g:lazygit_floating_window_border_chars = g:lazygit_floating_window_corner_chars
endif
endif
if !exists('g:lazygit_floating_window_border_chars')
let g:lazygit_floating_window_border_chars = ['╭','─', '╮', '│', '╯','─', '╰', '│']
endif
" if lazygit_use_custom_config_file_path is set to 1 the
" lazygit_config_file_path option will be evaluated
if !exists('g:lazygit_use_custom_config_file_path')
let g:lazygit_use_custom_config_file_path = 0
endif
" path to custom config file
if !exists('g:lazygit_config_file_path')
let g:lazygit_config_file_path = ''
endif
command! LazyGit lua require'lazygit'.lazygit()
command! LazyGitCurrentFile lua require'lazygit'.lazygitcurrentfile()
command! LazyGitFilter lua require'lazygit'.lazygitfilter()
command! LazyGitFilterCurrentFile lua require'lazygit'.lazygitfiltercurrentfile()
command! LazyGitConfig lua require'lazygit'.lazygitconfig()
""""""""""""""""""""""""""""""""""""""""""""""""""""""
let &cpoptions = s:save_cpo
unlet s:save_cpo
let g:loaded_lazygit_vim = 1

View File

@ -0,0 +1,22 @@
" If after installing lazygit.vim, you are having trouble getting it to work, try the following minimal vimrc file.
set nocompatible " be iMproved, required
filetype off " required
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.local/share/nvim/plugged')
Plug '~/gitrepos/lazygit.nvim'
" Initialize plugin system
call plug#end()
let mapleader = " "
nnoremap <silent> <leader>lg :LazyGit<CR>
" Save the above to a file `MINRC`, and run `nvim -u MINRC` and type `<leader>lg` in normal mode.