Update Telescope mappings
This commit is contained in:
parent
de117a56e2
commit
6b0773eb77
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
* Update Telescope keymaps to be more like the ones in <https://github.com/nvim-lua/kickstart.nvim>.
|
||||||
* Update Harpoon keymaps and include keymaps to remove a single file and clear all files.
|
* Update Harpoon keymaps and include keymaps to remove a single file and clear all files.
|
||||||
* Update Telescope to ignore more files and directories by default.
|
* Update Telescope to ignore more files and directories by default.
|
||||||
* Replace `christoomey/vim-tmux-navigator` with `alexghergh/nvim-tmux-navigation`.
|
* Replace `christoomey/vim-tmux-navigator` with `alexghergh/nvim-tmux-navigation`.
|
||||||
|
|
|
@ -99,6 +99,7 @@ end
|
||||||
|
|
||||||
function M.find_all_files()
|
function M.find_all_files()
|
||||||
local opts = {
|
local opts = {
|
||||||
|
file_ignore_patterns = { ".direnv", ".git" },
|
||||||
no_ignore = true,
|
no_ignore = true,
|
||||||
prompt_title = "All Files",
|
prompt_title = "All Files",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
TelescopeMapArgs = TelescopeMapArgs or {}
|
TelescopeMapArgs = TelescopeMapArgs or {}
|
||||||
|
|
||||||
local telescope = require "telescope"
|
|
||||||
|
|
||||||
local telescope_mapper = function(key, f, options, buffer)
|
local telescope_mapper = function(key, f, options, buffer)
|
||||||
local map_key = vim.api.nvim_replace_termcodes(key .. f, true, true, true)
|
local map_key = vim.api.nvim_replace_termcodes(key .. f, true, true, true)
|
||||||
|
|
||||||
|
@ -22,37 +20,53 @@ local telescope_mapper = function(key, f, options, buffer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
telescope_mapper("<leader>fb", "buffers")
|
-- Based on https://github.com/nvim-lua/kickstart.nvim
|
||||||
telescope_mapper("<leader>fd", "find_files")
|
-- TODO: refactor telescope_mapper and add descriptions.
|
||||||
telescope_mapper("<leader>fD", "find_all_files")
|
telescope_mapper("<leader>/", "current_buf") -- [/] Fuzzily search in current buffer
|
||||||
telescope_mapper("<leader>fe", "file_browser")
|
telescope_mapper("<leader><leader>", "buffers") -- [ ] Find existing buffers
|
||||||
telescope_mapper("<leader>ff", "current_buf")
|
telescope_mapper("<leader>s.", "oldfiles") -- '[S]earch Recent Files ("." for repeat)
|
||||||
telescope_mapper("<leader>fg", "git_files")
|
telescope_mapper("<leader>sF", "find_all_files") -- [S]earch all [F]iles
|
||||||
telescope_mapper("<leader>fh", "help_tags")
|
telescope_mapper("<leader>sb", "file_browser") -- [S]earch using the File [B]rowser
|
||||||
telescope_mapper("<leader>fl", "live_grep")
|
telescope_mapper("<leader>sf", "find_files") -- [S]earch [F]iles
|
||||||
telescope_mapper("<leader>fo", "oldfiles")
|
telescope_mapper("<leader>sg", "git_files") -- [S]earch [G]it Files
|
||||||
|
telescope_mapper("<leader>sh", "help_tags") -- [S]earch [H]elp
|
||||||
|
telescope_mapper("<leader>sl", "live_grep") -- [S]earch using [L]ive grep
|
||||||
|
telescope_mapper("<leader>sp", "grep_prompt") -- [S]earch using grep [P]rompt
|
||||||
|
|
||||||
local builtin = require "telescope.builtin"
|
local builtin = require "telescope.builtin"
|
||||||
|
local telescope = require "telescope"
|
||||||
|
|
||||||
local nmap = require("opdavies.keymap").nmap
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
nmap {
|
nmap {
|
||||||
"<leader>fw",
|
"<leader>s/",
|
||||||
|
function()
|
||||||
|
builtin.live_grep {
|
||||||
|
grep_open_files = true,
|
||||||
|
prompt_title = "Live Grep in Open Files",
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
{ desc = "[S]earch [/] in Open Files" },
|
||||||
|
}
|
||||||
|
|
||||||
|
nmap {
|
||||||
|
"<leader>sw",
|
||||||
function()
|
function()
|
||||||
local word = vim.fn.expand "<cword>"
|
local word = vim.fn.expand "<cword>"
|
||||||
builtin.grep_string { search = word }
|
builtin.grep_string { search = word }
|
||||||
end,
|
end,
|
||||||
|
{ desc = "[S]earch for the current [W]ord" },
|
||||||
}
|
}
|
||||||
|
|
||||||
nmap {
|
nmap {
|
||||||
"<leader>fW",
|
"<leader>sW",
|
||||||
function()
|
function()
|
||||||
local word = vim.fn.expand "<cWORD>"
|
local word = vim.fn.expand "<cWORD>"
|
||||||
builtin.grep_string { search = word }
|
builtin.grep_string { search = word }
|
||||||
end,
|
end,
|
||||||
|
{ desc = "[S]earch for the current [W]ord object" },
|
||||||
}
|
}
|
||||||
|
|
||||||
telescope_mapper("<leader>gp", "grep_prompt")
|
|
||||||
|
|
||||||
telescope_mapper("<leader>ds", "lsp_document_symbols")
|
telescope_mapper("<leader>ds", "lsp_document_symbols")
|
||||||
telescope_mapper("<leader>dl", "diagnostics")
|
telescope_mapper("<leader>dl", "diagnostics")
|
||||||
|
|
||||||
|
|
Reference in a new issue