Compare commits
3 commits
d925f8ca0d
...
4e38fd5de1
Author | SHA1 | Date | |
---|---|---|---|
4e38fd5de1 | |||
edbec9b0d5 | |||
eddd7452d4 |
8 changed files with 104 additions and 91 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
local keymap = require("fschauen.plugins.telescope").keymap
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"2kabhishek/nerdy.nvim",
|
"2kabhishek/nerdy.nvim",
|
||||||
|
|
||||||
|
@ -8,11 +10,7 @@ return {
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
},
|
},
|
||||||
|
|
||||||
keys = function()
|
keys = {
|
||||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
keymap { "i", "<cmd>Nerdy<cr>", desc = "Nerd [i]cons" },
|
||||||
local lhs, desc = helper.lhs, helper.description
|
},
|
||||||
return {
|
|
||||||
{ lhs("i"), "<cmd>Nerdy<cr>", desc = desc("Nerd [i]cons") },
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,13 @@ return {
|
||||||
|
|
||||||
local dismiss_notifications = function() require("notify").dismiss() end
|
local dismiss_notifications = function() require("notify").dismiss() end
|
||||||
|
|
||||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
local keymap = require("fschauen.plugins.telescope").keymap
|
||||||
local lhs, desc = helper.lhs, helper.description
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- stylua: ignore start
|
-- stylua: ignore start
|
||||||
{ "<leader>n", "<cmd>Notifications<cr>", desc = "Display notification history" },
|
{ "<leader>n", "<cmd>Notifications<cr>", desc = "Display notification history" },
|
||||||
{ "<c-q>", dismiss_notifications, desc = "Dismiss notifications" },
|
{ "<c-q>", dismiss_notifications, desc = "Dismiss notifications" },
|
||||||
{ lhs("n"), telescope_notifications, desc = desc("[n]otifications") },
|
keymap { "n", telescope_notifications, desc = "[n]otifications" },
|
||||||
-- stylua: ignore end
|
-- stylua: ignore end
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -35,9 +35,12 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- I use default <c-l> for navigation, so refresh with <c-r>.
|
|
||||||
["<c-r>"] = "actions.refresh",
|
["<c-r>"] = "actions.refresh",
|
||||||
["<c-l>"] = false,
|
|
||||||
|
-- Remove default keymaps that I use for navigation.
|
||||||
|
-- NOTE: the C must be capitalized (bug in Oil)
|
||||||
|
["<C-h>"] = false, -- use <c-s> intead
|
||||||
|
["<C-l>"] = false, -- use <c-r> instead
|
||||||
|
|
||||||
["<leader>:"] = {
|
["<leader>:"] = {
|
||||||
"actions.open_cmdline",
|
"actions.open_cmdline",
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
|
local keymap = require("fschauen.plugins.telescope").keymap
|
||||||
return {
|
return {
|
||||||
"nvim-telescope/telescope-file-browser.nvim",
|
"nvim-telescope/telescope-file-browser.nvim",
|
||||||
|
|
||||||
dependencies = "nvim-telescope/telescope.nvim",
|
dependencies = "nvim-telescope/telescope.nvim",
|
||||||
|
|
||||||
keys = function()
|
keys = {
|
||||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
keymap {
|
||||||
local lhs, desc = helper.lhs, helper.description
|
"B",
|
||||||
return {
|
|
||||||
{
|
|
||||||
lhs("B"),
|
|
||||||
"<cmd>Telescope file_browser theme=ivy<cr>",
|
"<cmd>Telescope file_browser theme=ivy<cr>",
|
||||||
desc = desc("file [B]rowser"),
|
desc = "file [B]rowser",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
end,
|
|
||||||
|
|
||||||
config = function() require("telescope").load_extension("file_browser") end,
|
config = function() require("telescope").load_extension("file_browser") end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
local ui = require("fschauen.util.icons").ui
|
local ui = require("fschauen.util.icons").ui
|
||||||
|
|
||||||
---Create the left hand side for a Telescope keymap.
|
local builtin = function(name, opts)
|
||||||
local lhs = function(keys) return "<leader>f" .. keys end
|
|
||||||
|
|
||||||
---Create the description for a Telescope keymap.
|
|
||||||
local desc = function(text) return ui.Telescope .. " Telescope " .. text end
|
|
||||||
|
|
||||||
local builtin_picker = function(name, opts)
|
|
||||||
return function(title)
|
return function(title)
|
||||||
return function()
|
return function()
|
||||||
local picker = require("telescope.builtin")[name]
|
local picker = require("telescope.builtin")[name]
|
||||||
|
@ -18,17 +12,17 @@ local builtin_picker = function(name, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pickers = setmetatable({
|
local pickers = setmetatable({
|
||||||
all_files = builtin_picker("find_files", {
|
all_files = builtin("find_files", {
|
||||||
hidden = true,
|
hidden = true,
|
||||||
no_ignore = true,
|
no_ignore = true,
|
||||||
no_ignore_parent = true,
|
no_ignore_parent = true,
|
||||||
}),
|
}),
|
||||||
all_man_pages = builtin_picker("man_pages", {
|
all_man_pages = builtin("man_pages", {
|
||||||
sections = { "ALL" },
|
sections = { "ALL" },
|
||||||
}),
|
}),
|
||||||
colorscheme = builtin_picker("colorscheme", { enable_preview = true }),
|
colorscheme = builtin("colorscheme", { enable_preview = true }),
|
||||||
diagnostics = builtin_picker("diagnostics", { bufnr = 0 }),
|
diagnostics = builtin("diagnostics", { bufnr = 0 }),
|
||||||
dotfiles = builtin_picker("find_files", { cwd = "~/.dotfiles", hidden = true }),
|
dotfiles = builtin("find_files", { cwd = "~/.dotfiles", hidden = true }),
|
||||||
selection = function(title)
|
selection = function(title)
|
||||||
return function()
|
return function()
|
||||||
local text = require("fschauen.util").get_selected_text()
|
local text = require("fschauen.util").get_selected_text()
|
||||||
|
@ -38,13 +32,77 @@ local pickers = setmetatable({
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
here = builtin_picker("current_buffer_fuzzy_find"),
|
here = builtin("current_buffer_fuzzy_find"),
|
||||||
}, {
|
}, {
|
||||||
-- Fall back to telescope's built-in pickers if a custom one is not defined
|
-- Fall back to telescope's built-in pickers if a custom one is not defined
|
||||||
-- above, but make sure to keep the title we defined.
|
-- above, but make sure to keep the title we defined.
|
||||||
__index = function(_, key) return builtin_picker(key) end,
|
__index = function(_, key) return builtin(key) end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
---@class LazyKeysSpec
|
||||||
|
---@field desc string
|
||||||
|
|
||||||
|
---Create consistent key maps with the same prefix and description style.
|
||||||
|
---@param spec LazyKeysSpec lazy.nvim key spec to modify
|
||||||
|
---@return LazyKeysSpec modified key spec with prefix and description
|
||||||
|
local keymap = function(spec)
|
||||||
|
vim.validate("Telescope key spec", spec, "table")
|
||||||
|
vim.validate("Telescope key lhs", spec[1], "string")
|
||||||
|
vim.validate("Telescope key rhs", spec[2], { "string", "function" })
|
||||||
|
vim.validate("Telescope key description", spec.desc, "string")
|
||||||
|
return vim.tbl_extend("force", spec, {
|
||||||
|
"<leader>f" .. spec[1], -- lhs
|
||||||
|
spec[2], -- rhs
|
||||||
|
desc = ui.Telescope .. " Telescope " .. spec.desc,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local keys = {
|
||||||
|
-- stylua: ignore start
|
||||||
|
{ "a", pickers.autocommands " Autocommands" , desc = "[a]utocommands" },
|
||||||
|
{ "b", pickers.buffers " Buffers" , desc = "[b]uffers" },
|
||||||
|
--"B" used in telescope-file-browser
|
||||||
|
{ "c", pickers.colorscheme " Colorschemes" , desc = "[c]olorschemes" },
|
||||||
|
{ "C", pickers.commands " Commands" , desc = "[C]ommands" },
|
||||||
|
{ "d", pickers.diagnostics " Diagnostics" , desc = "[d]iagnostics" },
|
||||||
|
--"e"
|
||||||
|
{ "f", pickers.find_files " Files" , desc = "[f]ind files" },
|
||||||
|
{ "F", pickers.all_files " ALL files" , desc = "all [F]iles" },
|
||||||
|
{ "gr", pickers.live_grep " Live grep" , desc = "Live [gr]ep" },
|
||||||
|
{ "gf", pickers.git_files " Git files" , desc = "[g]it [f]iles" },
|
||||||
|
{ "gc", pickers.git_commits " Commits" , desc = "[g]it [c]ommits" },
|
||||||
|
{ "h", pickers.here " Current buffer" , desc = "[b]uffer [h]ere" },
|
||||||
|
{ "H", pickers.highlights " Highlights" , desc = "[H]ighlights" },
|
||||||
|
--"i" used in nerdy
|
||||||
|
{ "j", pickers.jumplist " Jumplist" , desc = "[j]umplist" },
|
||||||
|
{ "k", pickers.keymaps " Keymaps" , desc = "[k]eymaps" },
|
||||||
|
{ "K", pickers.help_tags " Help tags" , desc = "[K] help/documentation" },
|
||||||
|
{ "l", pickers.loclist " Location list" , desc = "[l]ocation List" },
|
||||||
|
{ "m", pickers.all_man_pages " Man pages" , desc = "[m]an pages" },
|
||||||
|
--"n" used in vim-notify
|
||||||
|
{ "o", pickers.vim_options " Vim options" , desc = "[o]ptions" },
|
||||||
|
--"p"
|
||||||
|
{ "q", pickers.quickfix " Quickfix" , desc = "[q]uickfix" },
|
||||||
|
{ "r", pickers.lsp_references " References" , desc = "[r]eferences" },
|
||||||
|
{ "R", pickers.registers " Registers" , desc = "[R]registers" },
|
||||||
|
{ "s", pickers.lsp_document_symbols " Document Symbols " , desc = "LSP document [s]ymbols" },
|
||||||
|
{ "S", pickers.lsp_workspace_symbols " Workspace Symbols " , desc = "LSP workspace [S]ymbols" },
|
||||||
|
--"t" used in todo_comments
|
||||||
|
{ "T", pickers.treesitter " Treesitter symbols" , desc = "[T]reesitter Symbols" },
|
||||||
|
--"u"
|
||||||
|
--"v"
|
||||||
|
{ "w", pickers.selection " Grep" , desc = "[w]word under cursor" },
|
||||||
|
{ "w", pickers.selection " Grep", mode = "v" , desc = "[w]ord(s) selected" },
|
||||||
|
--"x"
|
||||||
|
--"y"
|
||||||
|
{ "z", pickers.spell_suggest " Spelling suggestions" , desc = "[z] spell suggestions" },
|
||||||
|
{ ".", pickers.dotfiles " Dotfiles" , desc = "[.]dotfiles" },
|
||||||
|
{ ":", pickers.command_history " Command history" , desc = "[:]command history" },
|
||||||
|
{ "/", pickers.search_history " Search history" , desc = "[/]search history" },
|
||||||
|
{ " ", pickers.resume " Resume" , desc = "Resume " },
|
||||||
|
-- stylua: ignore end
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
|
|
||||||
|
@ -57,53 +115,11 @@ return {
|
||||||
|
|
||||||
cmd = "Telescope",
|
cmd = "Telescope",
|
||||||
|
|
||||||
keymap_helper = { lhs = lhs, description = desc },
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
keys = vim.iter(keys):map(keymap):totable(),
|
||||||
|
|
||||||
keys = {
|
-- Export this function so we can use in other plugins.
|
||||||
-- stylua: ignore start
|
keymap = keymap,
|
||||||
{ lhs"a", pickers.autocommands " Autocommands" , desc = desc("[a]utocommands") },
|
|
||||||
{ lhs"b", pickers.buffers " Buffers" , desc = desc("[b]uffers") },
|
|
||||||
--lhs"B" used in telescope-file-browser
|
|
||||||
{ lhs"c", pickers.colorscheme " Colorschemes" , desc = desc("[c]olorschemes") },
|
|
||||||
{ lhs"C", pickers.commands " Commands" , desc = desc("[C]ommands") },
|
|
||||||
{ lhs"d", pickers.diagnostics " Diagnostics" , desc = desc("[d]iagnostics") },
|
|
||||||
--lhs"e"
|
|
||||||
{ lhs"f", pickers.find_files " Files" , desc = desc("[f]ind files") },
|
|
||||||
{ lhs"F", pickers.all_files " ALL files" , desc = desc("all [F]iles") },
|
|
||||||
{ lhs"gr", pickers.live_grep " Live grep" , desc = desc("Live [gr]ep") },
|
|
||||||
{ lhs"gf", pickers.git_files " Git files" , desc = desc("[g]it [f]iles") },
|
|
||||||
{ lhs"gc", pickers.git_commits " Commits" , desc = desc("[g]it [c]ommits") },
|
|
||||||
{ lhs"h", pickers.here " Current buffer" , desc = desc("[b]uffer [h]ere") },
|
|
||||||
{ lhs"H", pickers.highlights " Highlights" , desc = desc("[H]ighlights") },
|
|
||||||
--lhs"i" used in nerdy
|
|
||||||
{ lhs"j", pickers.jumplist " Jumplist" , desc = desc("[j]umplist") },
|
|
||||||
{ lhs"k", pickers.keymaps " Keymaps" , desc = desc("[k]eymaps") },
|
|
||||||
{ lhs"K", pickers.help_tags " Help tags" , desc = desc("[K] help/documentation") },
|
|
||||||
{ lhs"l", pickers.loclist " Location list" , desc = desc("[l]ocation List") },
|
|
||||||
{ lhs"m", pickers.all_man_pages " Man pages" , desc = desc("[m]an pages") },
|
|
||||||
--lhs"n" used in vim-notify
|
|
||||||
{ lhs"o", pickers.vim_options " Vim options" , desc = desc("[o]ptions") },
|
|
||||||
--lhs"p"
|
|
||||||
{ lhs"q", pickers.quickfix " Quickfix" , desc = desc("[q]uickfix") },
|
|
||||||
{ lhs"r", pickers.lsp_references " References" , desc = desc("[r]eferences") },
|
|
||||||
{ lhs"R", pickers.registers " Registers" , desc = desc("[R]registers") },
|
|
||||||
{ lhs"s", pickers.lsp_document_symbols " Document Symbols " , desc = desc("LSP document [s]ymbols") },
|
|
||||||
{ lhs"S", pickers.lsp_workspace_symbols " Workspace Symbols " , desc = desc("LSP workspace [S]ymbols") },
|
|
||||||
--lhs"t" used in todo_comments
|
|
||||||
{ lhs"T", pickers.treesitter " Treesitter symbols" , desc = desc("[T]reesitter Symbols") },
|
|
||||||
--lhs"u"
|
|
||||||
--lhs"v"
|
|
||||||
{ lhs"w", pickers.selection " Grep" , desc = desc("[w]word under cursor") },
|
|
||||||
{ lhs"w", pickers.selection " Grep", mode = "v" , desc = desc("[w]ord(s) selected") },
|
|
||||||
--lhs"x"
|
|
||||||
--lhs"y"
|
|
||||||
{ lhs"z", pickers.spell_suggest " Spelling suggestions" , desc = desc("[z] spell suggestions") },
|
|
||||||
{ lhs".", pickers.dotfiles " Dotfiles" , desc = desc("[.]dotfiles") },
|
|
||||||
{ lhs":", pickers.command_history " Command history" , desc = desc("[:]command history") },
|
|
||||||
{ lhs"/", pickers.search_history " Search history" , desc = desc("[/]search history") },
|
|
||||||
{ lhs"<leader>", pickers.resume " Resume" , desc = desc("Resume ") },
|
|
||||||
-- stylua: ignore end
|
|
||||||
},
|
|
||||||
|
|
||||||
opts = function()
|
opts = function()
|
||||||
local actions = require("telescope.actions")
|
local actions = require("telescope.actions")
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
local keymap = require("fschauen.plugins.telescope").keymap
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"folke/todo-comments.nvim",
|
"folke/todo-comments.nvim",
|
||||||
|
|
||||||
|
@ -8,13 +10,9 @@ return {
|
||||||
|
|
||||||
event = { "BufReadPost", "BufNewFile" },
|
event = { "BufReadPost", "BufNewFile" },
|
||||||
|
|
||||||
keys = function()
|
keys = {
|
||||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
keymap { "t", "<cmd>TodoTelescope<cr>", desc = "[t]odos" },
|
||||||
local lhs, desc = helper.lhs, helper.description
|
},
|
||||||
return {
|
|
||||||
{ lhs("t"), "<cmd>TodoTelescope<cr>", desc = desc("[t]odos") },
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
|
|
||||||
opts = function()
|
opts = function()
|
||||||
local ui = require("fschauen.util.icons").ui
|
local ui = require("fschauen.util.icons").ui
|
||||||
|
|
|
@ -4,7 +4,8 @@ local M = {}
|
||||||
---@param path string: file or directory path.
|
---@param path string: file or directory path.
|
||||||
---@return string|boolean: type if path exists, false otherwise.
|
---@return string|boolean: type if path exists, false otherwise.
|
||||||
M.exists = function(path)
|
M.exists = function(path)
|
||||||
local stat = vim.loop.fs_stat(path)
|
---@diagnostic disable-next-line: undefined-field
|
||||||
|
local stat = vim.uv.fs_stat(path)
|
||||||
return (stat and stat.type) or false
|
return (stat and stat.type) or false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ end
|
||||||
M.execute_lines = function(first, last)
|
M.execute_lines = function(first, last)
|
||||||
first = first or vim.fn.line(".")
|
first = first or vim.fn.line(".")
|
||||||
last = last or first
|
last = last or first
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
local code = vim.fn.join(vim.fn.getline(first, last), "\n")
|
local code = vim.fn.join(vim.fn.getline(first, last), "\n")
|
||||||
loadstring(code)()
|
loadstring(code)()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue