A simple plugin to simplify searching for code on Github Code Search.
In normal
mode, searches for the word under the cursor.
In visual
mode, searches for the selected text.
2023-03-20.18-09-00.mp4
{
'thenbe/csgithub.nvim',
keys = {
{
'<leader>fege',
function()
local csgithub = require('csgithub')
local url = csgithub.search({
includeFilename = false,
includeExtension = true,
})
csgithub.open(url)
end,
mode = { 'v', 'n' },
desc = 'Search Github (extension)',
},
{
'<leader>fegf',
function()
local csgithub = require('csgithub')
local url = csgithub.search({
includeFilename = true,
includeExtension = true,
})
csgithub.open(url)
end,
mode = { 'v', 'n' },
desc = 'Search Github (filename)',
},
},
}
This plugin does not set any keymaps, so you'll need to set some on your own. The snippet above is how I have mine set up, and includes two keymaps:
- A keymap that searches in files that have the same extension (e.g.
*.nix
,*.lua
). - A keymap for searching in files that have the exact same filename. This is useful when the file lacks intellisense and you can't quite remember the exact syntax (e.g.
.gitconfig
,.npmrc
,flake.nix
,kitty.conf
).