Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 10 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,24 @@ An advanced git search extension for `Telescope` and `fzf-lua`.

Search your git history by commit message, content and author in Neovim

## 🖥️ Usage
## 🚀 Usage

- [Demo](https://www.youtube.com/watch?v=bO0uYLlHtYo)
[Demo](https://www.youtube.com/watch?v=bO0uYLlHtYo)

### 📖 Open a picker
- __📖 Open a picker__

#### 🔭 Telescope
`:AdvancedGitSearch` or `:AdvancedGitSearch {command}`

```vim
:Telescope advanced_git_search {function_name}
```

> or in lua

```lua
require('telescope').extensions.advanced_git_search.{function_name}()
```

> or through another Telescope picker

execute `:AdvancedGitSearch`, choose your picker and press `<CR>`

#### 🧎 fzf-lua

```lua
require('advanced_git_search.fzf').{function_name}()
```

> or through another picker

execute `:AdvancedGitSearch`, choose your picker and press `<CR>`
- __🔎 Enter a query__

### 🔎 Enter a query
Your usual search experience. See the individual commands for the grep behaviour.

Your usual search experience. See the individual commands for the grep behaviour.
- __✏️ Further search on commit author with `@`__

### ✏️ Further search on commit author with `@`

The prompt is split on `@`. Everything following the `@` is the pattern for
The prompt is split on `@`. Everything following the `@` is the pattern for
the author name.

## ⚡️Commands
## ⚡️ Commands

### 1. search_log_content -- Search in repo log content

Expand Down Expand Up @@ -95,34 +71,7 @@ selected lines

_Grep behaviour_: filter on commit message.

#### How to use

> _This workaround only applies when you use the following command. (Telescope)_
>
> ```vim
> :Telescope advanced_git_search diff_commit_line
> ```

First you have to select the lines in visual mode, then go back to normal
mode and execute this command.
To make a bit easier, you can wrap it in a user command and define a keybind:

```lua
vim.api.nvim_create_user_command(
"DiffCommitLine",
"lua require('telescope').extensions.advanced_git_search.diff_commit_line()",
{ range = true }
)

vim.api.nvim_set_keymap(
"v",
"<leader>dcl",
":DiffCommitLine<CR>",
{ noremap = true }
)
```

> No extra setup is needed when you use `:AdvancedGitSearch`.
> Use `:'<,'>AdvancedGitSearch diff_commit_line` (with a visual range).

#### _Keymaps_

Expand Down
23 changes: 3 additions & 20 deletions lua/advanced_git_search/fzf/init.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
local M = {}
local config = require("advanced_git_search.utils.config")
local setup = require("advanced_git_search.utils.setup")

M.setup = function(opts)
config.setup(opts)

vim.api.nvim_create_user_command(
"AdvancedGitSearch",
"lua require('advanced_git_search.fzf').show_custom_functions()",
{ range = true }
)
local pickers = require("advanced_git_search.fzf.pickers")
setup.setup_user_command(pickers)
end

M.search_log_content =
require("advanced_git_search.fzf.pickers").search_log_content

M.search_log_content_file =
require("advanced_git_search.fzf.pickers").search_log_content_file

M.diff_commit_line = require("advanced_git_search.fzf.pickers").diff_commit_line

M.diff_commit_file = require("advanced_git_search.fzf.pickers").diff_commit_file

M.diff_branch_file = require("advanced_git_search.fzf.pickers").diff_branch_file

M.show_custom_functions =
require("advanced_git_search.fzf.pickers").show_custom_functions

return M
29 changes: 29 additions & 0 deletions lua/advanced_git_search/utils/setup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local M = {}

M.setup_user_command = function(pickers)
vim.api.nvim_create_user_command("AdvancedGitSearch", function(opt)
local f = opt.fargs[1]

if f == nil then
pickers.show_custom_functions()
else
pickers[f]()
end
end, {
range = true,
nargs = "?",
complete = function(_)
local completion_list = {}
local n = 0
for k, _ in pairs(pickers) do
if k ~= "show_custom_functions" then
n = n + 1
completion_list[n] = k
end
end
return completion_list
end,
})
end

return M
7 changes: 2 additions & 5 deletions lua/telescope/_extensions/advanced_git_search.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
local pickers = require("advanced_git_search.telescope.pickers")
local config = require("advanced_git_search.utils.config")
local setup = require("advanced_git_search.utils.setup")

return require("telescope").register_extension({
setup = function(ext_config, _)
config.setup(ext_config)

vim.api.nvim_create_user_command(
"AdvancedGitSearch",
"lua require('telescope').extensions.advanced_git_search.show_custom_functions()",
{ range = true }
)
setup.setup_user_command(pickers)
end,
exports = pickers,
})