telescope-gitignore.nvim is a Telescope extension that allows you to browse and select .gitignore templates from the official github/gitignore repository.
Features:
- Browse gitignore templates from GitHub's official collection
- Preview template content before selection
- Works offline with cached templates
- Customizable selection behavior
- Automatic caching for performance
{
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'llawn/telescope-gitignore.nvim',
'nvim-tree/nvim-web-devicons',
},
config = function()
require("telescope").load_extension("gitignore")
end
}
-- Add plugins to your config
vim.pack.add({
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/nvim-telescope/telescope.nvim",
"https://github.com/llawn/telescope-gitignore.nvim",
"https://github.com/nvim-tree/nvim-web-devicons",
})
-- Setup telescope and load extension
require("telescope").setup({})
require("telescope").load_extension("gitignore")- telescope.nvim
- plenary.nvim
- nvim-web-devicons
curlcommand-line tool (for fetching templates from GitHub)
local telescope = require('telescope')
telescope.setup({
extensions = {
gitignore = {
cache_dir = vim.fn.stdpath("data") .. "/telescope-gitignore",
github_api_url = "https://api.github.com/repos/github/gitignore/contents/",
notifications = true,
prompt_title = "Gitignore Templates",
offline_prompt_title = "Gitignore Templates (Offline)",
on_select = function(name, content)
-- Custom behavior when template is selected
local path = vim.fn.getcwd() .. "/.gitignore"
local f = io.open(path, "a+")
if f then
f:write("\n" .. content .. "\n")
f:close()
else
vim.notify("Error: Unable to write to .gitignore", vim.log.levels.ERROR)
end
end,
},
}
})
-- --- Keybindings ---
vim.keymap.set('n', '<leader>fgt', telescope.extensions.gitignore.gitignore, { desc = 'Gitignore Templates' })| Option | Default | Description |
|---|---|---|
cache_dir |
vim.fn.stdpath("data") .. "/telescope-gitignore" |
Directory to cache downloaded templates |
github_api_url |
"https://api.github.com/repos/github/gitignore/contents/" |
GitHub API URL for templates |
notifications |
true |
Show notifications when templates are added |
prompt_title |
"Gitignore Templates" |
Title for the telescope picker |
offline_prompt_title |
"Gitignore Templates (Offline)" |
Title when offline |
on_select |
function(name, content) |
Callback when template is selected |
| Command | Description |
|---|---|
:Gitignore |
Open the gitignore template picker |
:Telescope gitignore |
Alternative command to open the picker |
- Online Mode: Fetches available templates from GitHub's gitignore repository API
- Caching: Downloaded templates are cached locally for offline use
- Preview: Shows template content in a preview pane before selection
- Offline Mode: Falls back to cached templates when network is unavailable
- Custom Actions: Configurable callback function for template selection behavior
This plugin uses an asynchronous "push-based" architecture to ensure that Neovim never freezes while fetching data from GitHub when using curl.
- Run
:Gitignoreor:Telescope gitignore - Search for a template (e.g., "Node", "Python", "Go")
- Preview the template content in the right pane
- Press
<Enter>to add it to your project's.gitignorefile
MIT License - see LICENSE
