Skip to content

Commit

Permalink
Feat/telescope collections keymaps (#1299)
Browse files Browse the repository at this point in the history
* feat(telescope): add some new plugins for `search.nvim`

* fixup: correct alpha-nvim config.

* feat: more resonable keymap, add notify to misc.

Signed-off-by: ayamir <[email protected]>

---------

Signed-off-by: ayamir <[email protected]>
Co-authored-by: ayamir <[email protected]>
  • Loading branch information
CharlesChiuGit and ayamir authored Jun 20, 2024
1 parent 4e614a3 commit 93c06cd
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 78 deletions.
38 changes: 36 additions & 2 deletions lua/keymap/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,46 @@ local plug_map = {
:with_noremap()
:with_silent()
:with_desc("tool: Toggle command panel"),
["n|<leader>f"] = map_callback(function()
["n|<leader>fc"] = map_callback(function()
_telescope_collections(require("telescope.themes").get_dropdown())
end)
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope"),
:with_desc("tool: Open Telescope (collections)"),
["n|<leader>ff"] = map_callback(function()
require("search").open({ collection = "file" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope (file)"),
["n|<leader>fw"] = map_callback(function()
require("search").open({ collection = "word" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope (word)"),
["v|<leader>fs"] = map_cu("Telescope grep_string")
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope (selected)"),
["n|<leader>fg"] = map_callback(function()
require("search").open({ collection = "git" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope (git)"),
["n|<leader>fr"] = map_callback(function()
require("search").open({ collection = "rootdir" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope (rootdir)"),
["n|<leader>fm"] = map_callback(function()
require("search").open({ collection = "misc" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Open Telescope (misc)"),

-- Plugin: dap
["n|<F6>"] = map_callback(function()
Expand Down
35 changes: 15 additions & 20 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,28 +162,23 @@ return function()
{ name = "nvim_lsp", max_item_count = 350 },
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "path" },
{ name = "treesitter" },
{ name = "spell" },
{ name = "tmux" },
{ name = "orgmode" },
{
name = "buffer",
option = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end,
},
},
{ name = "latex_symbols" },
{ name = "copilot" },
-- { name = "path" },
-- { name = "treesitter" },
-- { name = "spell" },
-- { name = "tmux" },
-- { name = "orgmode" },
-- {
-- name = "buffer",
-- option = {
-- get_bufnrs = function()
-- return vim.api.nvim_list_bufs()
-- end,
-- },
-- },
-- { name = "latex_symbols" },
-- { name = "copilot" },
-- { name = "codeium" },
-- { name = "cmp_tabnine" },
},
experimental = {
ghost_text = {
hl_group = "Whitespace",
},
},
})
end
26 changes: 18 additions & 8 deletions lua/modules/configs/tool/search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ return function()

require("modules.utils").load_plugin("search", {
collections = {
-- Search by file name
file = {
initial_tab = 1,
tabs = {
Expand All @@ -30,9 +31,16 @@ return function()
builtin.oldfiles()
end,
},
{
name = "Buffers",
tele_func = function()
builtin.buffers()
end,
},
},
},
live_grep = {
-- Search by word
word = {
initial_tab = 1,
tabs = {
{
Expand All @@ -50,6 +58,7 @@ return function()
},
},
},
-- Search by git (branches, commits)
git = {
initial_tab = 1,
tabs = {
Expand Down Expand Up @@ -79,15 +88,10 @@ return function()
},
},
},
workspace = {
-- Search by rootdir name
rootdir = {
initial_tab = 1,
tabs = {
{
name = "Buffers",
tele_func = function()
builtin.buffers()
end,
},
{
name = "Sessions",
tele_func = function()
Expand Down Expand Up @@ -117,6 +121,12 @@ return function()
builtin.colorscheme({ enable_preview = true })
end,
},
{
name = "Notify",
tele_func = function()
extensions.notify.notify()
end,
},
{
name = "Undo History",
tele_func = function()
Expand Down
97 changes: 49 additions & 48 deletions lua/modules/configs/ui/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,55 +39,56 @@ return function()
end

local leader = " "
local icons = {
documents = require("modules.utils.icons").get("documents", true),
git = require("modules.utils.icons").get("git", true),
ui = require("modules.utils.icons").get("ui", true),
misc = require("modules.utils.icons").get("misc", true),
}

dashboard.section.buttons.val = {
button("space f c", " Scheme change", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
require("telescope.builtin").colorscheme()
end,
}),
button("space f r", " File frecency", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
require("telescope").extensions.frecency.frecency({})
end,
}),
button("space f e", "󰋚 File history", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
require("telescope.builtin").oldfiles()
end,
}),
button("space f p", " Project find", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
require("telescope").extensions.projects.projects({})
end,
}),
button("space f f", "󰈞 File find", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
require("telescope.builtin").find_files()
end,
}),
button("space f w", " Word find", leader, nil, {
noremap = true,
silent = true,
nowait = true,
callback = function()
require("telescope.builtin").live_grep()
end,
}),
button(
"space f c",
icons.misc.Neovim .. "Telescope collections",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f g",
icons.git.Git .. "Telescope git",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f w",
icons.ui.FolderWithHeart .. "Telescope workspace",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f f",
icons.documents.FileFind .. "Telescope file",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f l",
icons.documents.Word .. "Telescope live_grep",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f m",
icons.misc.Ghost .. "Telescope misc",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
}
dashboard.section.buttons.opts.hl = "AlphaButtons"

Expand Down
2 changes: 2 additions & 0 deletions lua/modules/utils/icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ local data = {
File = "",
Files = "",
FileTree = "󰙅",
FileFind = "󰈞",
Word = "",
Import = "",
Symlink = "",
},
Expand Down

0 comments on commit 93c06cd

Please sign in to comment.