Skip to content

Commit

Permalink
Feat/telescope collections keymaps (#1303)
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]>

* revert: local cmp changes.

* fix: update alpha-nvim config.

* chore: update doc strings

Signed-off-by: Jint-lzxy <[email protected]>

* Update lua/modules/configs/ui/alpha.lua

Co-authored-by: jint_lzxy_ <[email protected]>
Signed-off-by: Mohu <[email protected]>

* Update lua/modules/configs/ui/alpha.lua

Co-authored-by: jint_lzxy_ <[email protected]>
Signed-off-by: Mohu <[email protected]>

* Update lua/modules/configs/ui/alpha.lua

Co-authored-by: jint_lzxy_ <[email protected]>
Signed-off-by: Mohu <[email protected]>

* Update lua/modules/configs/ui/alpha.lua

Co-authored-by: jint_lzxy_ <[email protected]>
Signed-off-by: Mohu <[email protected]>

* Update lua/modules/configs/ui/alpha.lua

Co-authored-by: jint_lzxy_ <[email protected]>
Signed-off-by: Mohu <[email protected]>

* feat: update dotstutor.

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

* feat: correct several minor issues

Signed-off-by: Jint-lzxy <[email protected]>

* chore: cleanup

Signed-off-by: Jint-lzxy <[email protected]>

* feat!: mnemonic keymaps

Signed-off-by: Jint-lzxy <[email protected]>

---------

Signed-off-by: ayamir <[email protected]>
Signed-off-by: Jint-lzxy <[email protected]>
Signed-off-by: Mohu <[email protected]>
Co-authored-by: CharlesChiuGit <[email protected]>
Co-authored-by: Jint-lzxy <[email protected]>
  • Loading branch information
3 people authored Jun 21, 2024
1 parent 3bf00f0 commit 6c59c16
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 86 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: Find files"),
["n|<leader>fp"] = map_callback(function()
require("search").open({ collection = "pattern" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Find patterns"),
["v|<leader>fs"] = map_cu("Telescope grep_string")
:with_noremap()
:with_silent()
:with_desc("tool: Find word under cursor"),
["n|<leader>fg"] = map_callback(function()
require("search").open({ collection = "git" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Locate Git objects"),
["n|<leader>fd"] = map_callback(function()
require("search").open({ collection = "dossier" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Retrieve dossiers"),
["n|<leader>fm"] = map_callback(function()
require("search").open({ collection = "misc" })
end)
:with_noremap()
:with_silent()
:with_desc("tool: Miscellaneous"),

-- Plugin: dap
["n|<F6>"] = map_callback(function()
Expand Down
27 changes: 19 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 using filenames
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 using patterns
pattern = {
initial_tab = 1,
tabs = {
{
Expand All @@ -50,6 +58,7 @@ return function()
},
},
},
-- Search Git objects (branches, commits)
git = {
initial_tab = 1,
tabs = {
Expand Down Expand Up @@ -79,15 +88,10 @@ return function()
},
},
},
workspace = {
-- Retrieve dossiers
dossier = {
initial_tab = 1,
tabs = {
{
name = "Buffers",
tele_func = function()
builtin.buffers()
end,
},
{
name = "Sessions",
tele_func = function()
Expand All @@ -108,6 +112,7 @@ return function()
},
},
},
-- Miscellaneous
misc = {
initial_tab = 1,
tabs = {
Expand All @@ -117,6 +122,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 f",
icons.documents.FileFind .. "Find files",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f d",
icons.ui.FolderWithHeart .. "Retrieve dossiers",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f p",
icons.documents.Word .. "Find patterns",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f g",
icons.git.Git .. "Locate Git objects",
leader,
nil,
{ noremap = true, silent = true, nowait = true }
),
button(
"space f m",
icons.misc.Ghost .. "Miscellaneous artifacts",
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 @@ -62,9 +62,11 @@ local data = {
Default = "",
File = "",
Files = "",
FileFind = "󰈞",
FileTree = "󰙅",
Import = "",
Symlink = "",
Word = "",
},
git = {
Add = "",
Expand Down
57 changes: 29 additions & 28 deletions tutor/dots.tutor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Welcome to the nvimdots Tutor

Nvimdots is a [neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease
Nvimdots is a [Neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease
of use. It provides the ability to work with text files yet feels like you are
working within an IDE environment.

Expand Down Expand Up @@ -64,7 +64,7 @@ Consequently, this segment of the status line provides insight into the context
your cursor position. It's important to note that this feature relies on LSP, so it
is disabled if the corresponding LSP is not attached to the current buffer.

You can press `<leader>li`{normal} to check LSP info. Upon doing so, you will notice that
You can press `<leader>`{normal}`l`{normal}`i`{normal} to check LSP info. Upon doing so, you will notice that
there are two active clients attached to this buffer.

Now, press [go](go) to toggle the code outline, which displays all symbols defined in
Expand All @@ -85,32 +85,33 @@ to the next topic, which covers the basic workflow.

# Lesson 1.2: FIND AND SEARCH

Nvimdots utilizes [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) as the primary fuzzy finder. It offers numerous
features for finding and searching. To open the file finder under the current
working directory, press `<leader>ff`{normal}. Then, input the keyword you wish to find and use
`<C-p>`{normal} and `<C-n>`{normal} to navigate up and down the list of results. You can preview the
content of the selected file in the right window and press `<Enter>`{normal} to open it
in a new buffer.

Nvimdots also provide several additional search features. One commonly used keymap is
`<leader>fr`{normal}, especially if you frequently edit files across different projects. This
command lists files you have previously opened and sorts them by "frecency," a
concept similar to that used in Firefox's address bar. This feature utilizes "Lua
Bytecode" to permanently store the key-value pairs of file paths and their "frecency"
values at **~/.local/share/nvim/file_frecency.bin**.

You can press `<leader>fw`{normal} to search for a word in the current working directory. This
feature utilizes [ripgrep](https://github.com/BurntSushi/ripgrep) for searching, allowing you to use it naturally as you would
with ripgrep.

Nvimdots also provides project management features and integrates them seamlessly
with telescope. Press `<leader>fp`{normal} to open the recent project list. Please refrain from
quitting this interface; instead, you can add the current working directory to the
project list by pressing `<C-a>`{normal}, and remove it by pressing `<C-d>`{normal}. Typically, the
current working directory corresponds to the project directory, which is identified
by LSP and patterns such as *.git/*. However, you have the flexibility to set your own
patterns. Consequently, the project directory will automatically change when you
switch to another buffer whose file belongs to a different project.
Nvimdots utilizes [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) as the primary fuzzy finder, offering numerous
features for efficient finding and searching. To access the "file finder collection"
within the current working directory, press `<leader>`{normal}`f`{normal}`f`{normal}. Subsequently, enter the
desired keyword and use `<C-p>`{normal} and `<C-n>`{normal} to navigate through the list of results. The
content of the selected file can be previewed in the adjacent window, and pressing
`<Enter>`{normal} will open it in a new buffer. Additionally, `<Tab>`{normal} and `<S-Tab>`{normal} allow you to
switch between various tabs to locate files with different properties. For instance,
the "Frecency" and "Oldfiles" tabs enable searches based on the most frequently and
recently opened files, respectively, while the "Buffers" tab facilitates searches
among currently opened buffers.

For pattern searches within the current working directory, press `<leader>`{normal}`f`{normal}`p`{normal}. This
functionality leverages [ripgrep](https://github.com/BurntSushi/ripgrep) for its search capabilities, making it as intuitive
to use as ripgrep itself. As with the "file finder collection", `<Tab>`{normal} and `<S-Tab>`{normal} can
be used to cycle through the search tabs. The "Word under cursor" tab displays all
instances of the word located under the current cursor position.

Nvimdots also offers comprehensive dossier management, seamlessly integrated with
Telescope. Press `<leader>`{normal}`f`{normal}`d`{normal} to access the recent dossiers list. The first tab
presents the currently saved sessions; select a session and press `<CR>`{normal} to restore
the corresponding session. The second tab lists various projects. Instead of exiting
this interface, you can add the current working directory to the project list by
pressing `<C-a>`{normal}, and remove it by pressing `<C-d>`{normal}. Generally, the current working
directory corresponds to the current project's directory, identified by the LSP or
patterns such as *.git/*. You can also define your own patterns. Consequently, the
current working directory will automatically switch when you move to another buffer
containing a file from a different project.

# Lesson 1.3: EDIT AND FORMAT

Expand Down

0 comments on commit 6c59c16

Please sign in to comment.