Compare commits
No commits in common. "4e38fd5de12fcf9a6104f240a9e47a685f306422" and "d925f8ca0d108f775f57bde30aaf5c51390c356a" have entirely different histories.
4e38fd5de1
...
d925f8ca0d
8 changed files with 91 additions and 104 deletions
|
@ -1,5 +1,3 @@
|
|||
local keymap = require("fschauen.plugins.telescope").keymap
|
||||
|
||||
return {
|
||||
"2kabhishek/nerdy.nvim",
|
||||
|
||||
|
@ -10,7 +8,11 @@ return {
|
|||
"nvim-telescope/telescope.nvim",
|
||||
},
|
||||
|
||||
keys = {
|
||||
keymap { "i", "<cmd>Nerdy<cr>", desc = "Nerd [i]cons" },
|
||||
},
|
||||
keys = function()
|
||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
||||
local lhs, desc = helper.lhs, helper.description
|
||||
return {
|
||||
{ lhs("i"), "<cmd>Nerdy<cr>", desc = desc("Nerd [i]cons") },
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@ return {
|
|||
|
||||
local dismiss_notifications = function() require("notify").dismiss() end
|
||||
|
||||
local keymap = require("fschauen.plugins.telescope").keymap
|
||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
||||
local lhs, desc = helper.lhs, helper.description
|
||||
|
||||
return {
|
||||
-- stylua: ignore start
|
||||
{ "<leader>n", "<cmd>Notifications<cr>", desc = "Display notification history" },
|
||||
{ "<c-q>", dismiss_notifications, desc = "Dismiss notifications" },
|
||||
keymap { "n", telescope_notifications, desc = "[n]otifications" },
|
||||
{ lhs("n"), telescope_notifications, desc = desc("[n]otifications") },
|
||||
-- stylua: ignore end
|
||||
}
|
||||
end,
|
||||
|
|
|
@ -35,12 +35,9 @@ return {
|
|||
},
|
||||
},
|
||||
|
||||
-- I use default <c-l> for navigation, so refresh with <c-r>.
|
||||
["<c-r>"] = "actions.refresh",
|
||||
|
||||
-- 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
|
||||
["<c-l>"] = false,
|
||||
|
||||
["<leader>:"] = {
|
||||
"actions.open_cmdline",
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
local keymap = require("fschauen.plugins.telescope").keymap
|
||||
return {
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
|
||||
dependencies = "nvim-telescope/telescope.nvim",
|
||||
|
||||
keys = {
|
||||
keymap {
|
||||
"B",
|
||||
"<cmd>Telescope file_browser theme=ivy<cr>",
|
||||
desc = "file [B]rowser",
|
||||
},
|
||||
},
|
||||
keys = function()
|
||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
||||
local lhs, desc = helper.lhs, helper.description
|
||||
return {
|
||||
{
|
||||
lhs("B"),
|
||||
"<cmd>Telescope file_browser theme=ivy<cr>",
|
||||
desc = desc("file [B]rowser"),
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
||||
config = function() require("telescope").load_extension("file_browser") end,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
local ui = require("fschauen.util.icons").ui
|
||||
|
||||
local builtin = function(name, opts)
|
||||
---Create the left hand side for a Telescope keymap.
|
||||
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()
|
||||
local picker = require("telescope.builtin")[name]
|
||||
|
@ -12,17 +18,17 @@ local builtin = function(name, opts)
|
|||
end
|
||||
|
||||
local pickers = setmetatable({
|
||||
all_files = builtin("find_files", {
|
||||
all_files = builtin_picker("find_files", {
|
||||
hidden = true,
|
||||
no_ignore = true,
|
||||
no_ignore_parent = true,
|
||||
}),
|
||||
all_man_pages = builtin("man_pages", {
|
||||
all_man_pages = builtin_picker("man_pages", {
|
||||
sections = { "ALL" },
|
||||
}),
|
||||
colorscheme = builtin("colorscheme", { enable_preview = true }),
|
||||
diagnostics = builtin("diagnostics", { bufnr = 0 }),
|
||||
dotfiles = builtin("find_files", { cwd = "~/.dotfiles", hidden = true }),
|
||||
colorscheme = builtin_picker("colorscheme", { enable_preview = true }),
|
||||
diagnostics = builtin_picker("diagnostics", { bufnr = 0 }),
|
||||
dotfiles = builtin_picker("find_files", { cwd = "~/.dotfiles", hidden = true }),
|
||||
selection = function(title)
|
||||
return function()
|
||||
local text = require("fschauen.util").get_selected_text()
|
||||
|
@ -32,77 +38,13 @@ local pickers = setmetatable({
|
|||
}
|
||||
end
|
||||
end,
|
||||
here = builtin("current_buffer_fuzzy_find"),
|
||||
here = builtin_picker("current_buffer_fuzzy_find"),
|
||||
}, {
|
||||
-- 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.
|
||||
__index = function(_, key) return builtin(key) end,
|
||||
__index = function(_, key) return builtin_picker(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 {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
|
||||
|
@ -115,11 +57,53 @@ return {
|
|||
|
||||
cmd = "Telescope",
|
||||
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
keys = vim.iter(keys):map(keymap):totable(),
|
||||
keymap_helper = { lhs = lhs, description = desc },
|
||||
|
||||
-- Export this function so we can use in other plugins.
|
||||
keymap = keymap,
|
||||
keys = {
|
||||
-- stylua: ignore start
|
||||
{ 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()
|
||||
local actions = require("telescope.actions")
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
local keymap = require("fschauen.plugins.telescope").keymap
|
||||
|
||||
return {
|
||||
"folke/todo-comments.nvim",
|
||||
|
||||
|
@ -10,9 +8,13 @@ return {
|
|||
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
|
||||
keys = {
|
||||
keymap { "t", "<cmd>TodoTelescope<cr>", desc = "[t]odos" },
|
||||
},
|
||||
keys = function()
|
||||
local helper = require("fschauen.plugins.telescope").keymap_helper
|
||||
local lhs, desc = helper.lhs, helper.description
|
||||
return {
|
||||
{ lhs("t"), "<cmd>TodoTelescope<cr>", desc = desc("[t]odos") },
|
||||
}
|
||||
end,
|
||||
|
||||
opts = function()
|
||||
local ui = require("fschauen.util.icons").ui
|
||||
|
|
|
@ -4,8 +4,7 @@ local M = {}
|
|||
---@param path string: file or directory path.
|
||||
---@return string|boolean: type if path exists, false otherwise.
|
||||
M.exists = function(path)
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local stat = vim.uv.fs_stat(path)
|
||||
local stat = vim.loop.fs_stat(path)
|
||||
return (stat and stat.type) or false
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ end
|
|||
M.execute_lines = function(first, last)
|
||||
first = first or vim.fn.line(".")
|
||||
last = last or first
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
local code = vim.fn.join(vim.fn.getline(first, last), "\n")
|
||||
loadstring(code)()
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue