From ad5ea9ebebab82a574944414719cff54b8fd317c Mon Sep 17 00:00:00 2001 From: ecosse3 Date: Fri, 10 Jun 2022 18:40:52 +0200 Subject: [PATCH 1/2] feat: add LazyGitFilterCurrentFile command --- lua/lazygit.lua | 7 +++++++ plugin/lazygit.vim | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 1e634eb..7a773a1 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -82,6 +82,12 @@ local function lazygitfilter(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 os = fn.substitute(fn.system('uname'), '\n', '', '') @@ -115,6 +121,7 @@ end return { lazygit = lazygit, lazygitfilter = lazygitfilter, + lazygitfiltercurrentfile = lazygitfiltercurrentfile, lazygitconfig = lazygitconfig, project_root_dir = project_root_dir, } diff --git a/plugin/lazygit.vim b/plugin/lazygit.vim index 7655ff4..2722161 100644 --- a/plugin/lazygit.vim +++ b/plugin/lazygit.vim @@ -27,6 +27,8 @@ command! LazyGit lua require'lazygit'.lazygit() command! LazyGitFilter lua require'lazygit'.lazygitfilter() +command! LazyGitFilterCurrentFile lua require'lazygit'.lazygitfiltercurrentfile() + command! LazyGitConfig lua require'lazygit'.lazygitconfig() """""""""""""""""""""""""""""""""""""""""""""""""""""" From 5845162ae8c32edc0533861c70e331f01c577618 Mon Sep 17 00:00:00 2001 From: ecosse3 Date: Fri, 10 Jun 2022 18:57:33 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8e01c31..7def5b6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,18 @@ 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 +``` + +Open buffer commits with `lazygit` directly from vim in floating window. + +```vim +:LazyGitFilterCurrentFile +``` + **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`.