-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
d78c93a
commit 26d7603
Showing
13 changed files
with
467 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @gorillamoe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- ignore-for-release | ||
categories: | ||
- title: Breaking Changes 💥 | ||
labels: | ||
- breaking-change | ||
- title: Documentation 📚 | ||
labels: | ||
- documentation | ||
- title: Exciting New Features ✨ | ||
labels: | ||
- enhancement | ||
- title: Bug Fixes 🐛 | ||
labels: | ||
- bug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
jobs: | ||
create-release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up env | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Create Release | ||
run: ./scripts/release.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
stds.nvim = { | ||
read_globals = { "jit" }, | ||
} | ||
|
||
std = "lua51+nvim" | ||
|
||
read_globals = { | ||
"vim", | ||
} | ||
|
||
globals = { | ||
"vim.g", | ||
"vim.b", | ||
"vim.w", | ||
"vim.o", | ||
"vim.bo", | ||
"vim.wo", | ||
"vim.go", | ||
"vim.env", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version: | ||
./scripts/set-version.sh $(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,58 @@ | ||
<div align="center"> | ||
|
||
 | ||
|
||
# tafuta.nvim | ||
A tiny 🤏🏾, wrapper around ripgrep, for making search 🔍 blazingly fast ⚡ and easy to use 👌🏾 in your favorite editor 🥰. | ||
|
||
 | ||
[](https://github.com/mistweaverco/tafuta.nvim/releases/latest) | ||
|
||
[Install](#install) • [Usage](#usage) | ||
|
||
<p></p> | ||
|
||
A tiny 🤏 wrapper around ripgrep for | ||
making search 🔍 blazingly fast ⚡ and | ||
easy to use 👌 in your favorite editor 🥰. | ||
|
||
Tafuta is swahili for "search". | ||
|
||
It allows you to search for text in your project. | ||
|
||
<p></p> | ||
|
||
</div> | ||
|
||
## Install | ||
|
||
> [!WARNING] | ||
> Requires Neovim 0.10.0+ | ||
Via [lazy.nvim](https://github.com/folke/lazy.nvim): | ||
|
||
### Configuration | ||
|
||
```lua | ||
require('lazy').setup({ | ||
-- blazingly fast ⚡ search 🔍 | ||
{ | ||
'mistweaverco/tafuta.nvim', | ||
cmd = { "Tf" }, | ||
config = function() | ||
-- Setup is required, even if you don't pass any options | ||
require('tafuta').setup({ | ||
-- The user command to run the search e.g. `:Tf <query>` | ||
user_command = "Tf", | ||
-- rg options, a lua table of options to pass to rg | ||
rg_options = nil, | ||
}) | ||
end, | ||
}, | ||
}) | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
:Tf <search-term> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local M = {} | ||
|
||
M.defaults = { | ||
-- The user command to run the search e.g. `:Tf <query>` | ||
user_command = "Tf", | ||
} | ||
|
||
M.options = {} | ||
|
||
M.setup = function(config) | ||
M.options = vim.tbl_deep_extend("force", M.defaults, config or {}) | ||
end | ||
|
||
M.get = function() | ||
return M.options | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local M = {} | ||
|
||
M.VERSION = "1.0.0" | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
local GLOBALS = require("tafuta.globals") | ||
local CONFIG = require("tafuta.config") | ||
local M = {} | ||
|
||
local rg_installed = vim.fn.executable("rg") == 1 | ||
|
||
local async_run = vim.schedule_wrap(function(res) | ||
local code = res.code | ||
if code == 0 then | ||
local matches = vim.split(res.stdout, "\n", { trimempty = true }) | ||
if vim.tbl_isempty(matches) then | ||
vim.notify("❌ no match", vim.log.levels.INFO, { title = "Tafuta" }) | ||
return | ||
end | ||
vim.fn.setqflist({}, "r", { | ||
title = "Tafuta results (" .. #matches .. ")", | ||
lines = matches, | ||
}) | ||
vim.cmd("copen") | ||
elseif code == 1 then | ||
vim.notify("❌ no match", vim.log.levels.INFO, { title = "Tafuta" }) | ||
else | ||
vim.notify("💀 error occurred", vim.log.levels.ERROR, { title = "Tafuta" }) | ||
end | ||
end) | ||
|
||
local search = function(search_query) | ||
local search_command = { "rg", "--vimgrep" } | ||
local rg_options = CONFIG.get().rg_options | ||
if rg_options ~= nil then | ||
for _, option in ipairs(rg_options) do | ||
table.insert(search_command, option) | ||
end | ||
end | ||
table.insert(search_command, search_query) | ||
vim.system(search_command, { text = true }, async_run) | ||
end | ||
|
||
M.setup = function(config) | ||
CONFIG.setup(config) | ||
local user_command = CONFIG.get().user_command | ||
if user_command ~= nil then | ||
vim.api.nvim_create_user_command(user_command, function(a) | ||
if a.args == "" then | ||
vim.notify("❌ No search query provided", vim.log.levels.INFO, { title = "Tafuta" }) | ||
return | ||
end | ||
M.run(a.args) | ||
end, { | ||
nargs = "?", | ||
desc = "Tf, blazingly fast ⚡ search 🔍 using ripgrep 🦀", | ||
}) | ||
end | ||
end | ||
|
||
M.run = function(search_query) | ||
if not rg_installed then | ||
vim.notify("❌ ripgrep not found on the system", vim.log.levels.WARN, { title = "Tafuta" }) | ||
return | ||
end | ||
if search_query == nil then | ||
search_query = vim.fn.input("Search: ") | ||
end | ||
search(search_query) | ||
end | ||
|
||
M.version = function() | ||
local neovim_version = vim.fn.execute("version") | ||
vim.notify( | ||
"Tafuta version: " .. GLOBALS.VERSION .. "\n\n" .. "Neovim version: " .. neovim_version, | ||
"info", | ||
{ title = "Tafuta" } | ||
) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
GH_TAG="v$VERSION" | ||
|
||
set_version() { | ||
./scripts/set-version.sh | ||
} | ||
|
||
check_git_dirty() { | ||
if [[ -n $(git status -s) ]]; then | ||
echo "Working directory is dirty. Please commit or stash your changes before releasing." | ||
exit 1 | ||
fi | ||
} | ||
|
||
do_gh_release() { | ||
echo "Creating new release $GH_TAG" | ||
gh release create --generate-notes "$GH_TAG" | ||
} | ||
|
||
boot() { | ||
set_version | ||
check_git_dirty | ||
do_gh_release | ||
} | ||
|
||
boot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
update_lua_globals_version() { | ||
local tmp | ||
tmp=$(mktemp) | ||
sed -e "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" ./lua/tafuta/globals/init.lua > "$tmp" && mv "$tmp" ./lua/tafuta/globals/init.lua | ||
} | ||
|
||
update_lua_globals_version |