-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add telescope pickers for markdown files and grepping
Add telescope functionality, a default picker, and pickers for markdown files and grepping in markdown files. * **Telescope Configuration:** - Add `setup_telescope` function in `lua/telescope/_extensions/word/init.lua` to configure telescope pickers for markdown files and grepping in markdown files. - Update `setup` function to call `setup_telescope`. - Update `exports` table to include new pickers for markdown files and grepping in markdown files. * **Configuration Options:** - Add configuration options for the new telescope pickers in `lua/telescope/_extensions/word/config/init.lua`. * **Core Functionality:** - Add core functionality for the new telescope pickers in `lua/telescope/_extensions/word/core/init.lua`. * **Data Handling:** - Add data handling for the new telescope pickers in `lua/telescope/_extensions/word/data/init.lua`. * **Finders:** - Add a new finder for browsing markdown files in `lua/telescope/_extensions/word/finders/browse.lua`. - Add a new finder for finding markdown files in `lua/telescope/_extensions/word/finders/files.lua`. - Add a new finder for grepping in markdown files in `lua/telescope/_extensions/word/finders/grep.lua`. - Update the `init` function in `lua/telescope/_extensions/word/finders/init.lua` to include the new finders. - Add a new root finder for the new telescope pickers in `lua/telescope/_extensions/word/finders/root.lua`. * **Pickers:** - Add a new picker for the new telescope pickers in `lua/telescope/_extensions/word/picker/init.lua`. * **Utility Functions:** - Add utility functions for the new telescope pickers in `lua/telescope/_extensions/word/util/init.lua`. * **Integration:** - Update `lua/word/init.lua` to call the new telescope pickers. - Add treesitter integration for the new telescope pickers in `lua/word/mod/treesitter/init.lua`. - Add UI integration for the new telescope pickers in `lua/word/mod/ui/init.lua`. - Add workspace integration for the new telescope pickers in `lua/word/mod/workspace/init.lua`. - Add UI components for the new telescope pickers in `lua/word/ui/init.lua`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/clpi/word.lua?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
Showing
17 changed files
with
854 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local config = {} | ||
|
||
config.telescope_pickers = { | ||
markdown_files = { | ||
theme = "dropdown", | ||
previewer = false, | ||
layout_config = { | ||
width = 0.5, | ||
height = 0.4, | ||
}, | ||
}, | ||
grep_markdown_files = { | ||
theme = "dropdown", | ||
previewer = false, | ||
layout_config = { | ||
width = 0.5, | ||
height = 0.4, | ||
}, | ||
}, | ||
} | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local M = {} | ||
|
||
local function browse_markdown_files(opts) | ||
opts = opts or {} | ||
opts.prompt_title = "Browse Markdown Files" | ||
opts.find_command = { "rg", "--files", "--glob", "*.md" } | ||
require("telescope.builtin").find_files(opts) | ||
end | ||
|
||
local function grep_markdown_files(opts) | ||
opts = opts or {} | ||
opts.prompt_title = "Grep in Markdown Files" | ||
opts.search_dirs = { "path/to/markdown/files" } | ||
require("telescope.builtin").live_grep(opts) | ||
end | ||
|
||
M.browse_markdown_files = browse_markdown_files | ||
M.grep_markdown_files = grep_markdown_files | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
local bi = require("telescope.builtin") | ||
local act = require("telescope.actions") | ||
local state = require("telescope.actions.state") | ||
|
||
local M = {} | ||
|
||
M.browse_markdown_files = function(opts) | ||
opts = opts or {} | ||
opts.prompt_title = "Browse Markdown Files" | ||
opts.find_command = { "rg", "--files", "--glob", "*.md" } | ||
bi.find_files(opts) | ||
end | ||
|
||
M.grep_markdown_files = function(opts) | ||
opts = opts or {} | ||
opts.prompt_title = "Grep in Markdown Files" | ||
opts.search_dirs = { "path/to/markdown/files" } | ||
bi.live_grep(opts) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local finders = require("telescope.finders") | ||
local sorters = require("telescope.sorters") | ||
local pickers = require("telescope.pickers") | ||
local previewers = require("telescope.previewers") | ||
local actions = require("telescope.actions") | ||
local action_state = require("telescope.actions.state") | ||
|
||
local browse_markdown_files = function(opts) | ||
opts = opts or {} | ||
pickers.new(opts, { | ||
prompt_title = "Browse Markdown Files", | ||
finder = finders.new_oneshot_job({ "rg", "--files", "--glob", "*.md" }, opts), | ||
sorter = sorters.get_fuzzy_file(), | ||
previewer = previewers.vim_buffer_cat.new(opts), | ||
attach_mappings = function(prompt_bufnr, map) | ||
actions.select_default:replace(function() | ||
local selection = action_state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
vim.cmd("edit " .. selection.value) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end | ||
|
||
return browse_markdown_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local finders = require("telescope.finders") | ||
local sorters = require("telescope.sorters") | ||
local pickers = require("telescope.pickers") | ||
local previewers = require("telescope.previewers") | ||
local actions = require("telescope.actions") | ||
local action_state = require("telescope.actions.state") | ||
|
||
local find_markdown_files = function(opts) | ||
opts = opts or {} | ||
pickers.new(opts, { | ||
prompt_title = "Find Markdown Files", | ||
finder = finders.new_oneshot_job({ "rg", "--files", "--glob", "*.md" }, opts), | ||
sorter = sorters.get_fuzzy_file(), | ||
previewer = previewers.vim_buffer_cat.new(opts), | ||
attach_mappings = function(prompt_bufnr, map) | ||
actions.select_default:replace(function() | ||
local selection = action_state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
vim.cmd("edit " .. selection.value) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end | ||
|
||
return find_markdown_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local finders = require("telescope.finders") | ||
local sorters = require("telescope.sorters") | ||
local pickers = require("telescope.pickers") | ||
local previewers = require("telescope.previewers") | ||
local actions = require("telescope.actions") | ||
local action_state = require("telescope.actions.state") | ||
|
||
local grep_markdown_files = function(opts) | ||
opts = opts or {} | ||
pickers.new(opts, { | ||
prompt_title = "Grep in Markdown Files", | ||
finder = finders.new_oneshot_job({ "rg", "--files", "--glob", "*.md" }, opts), | ||
sorter = sorters.get_fuzzy_file(), | ||
previewer = previewers.vim_buffer_vimgrep.new(opts), | ||
attach_mappings = function(prompt_bufnr, map) | ||
actions.select_default:replace(function() | ||
local selection = action_state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
vim.cmd("edit " .. selection.value) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end | ||
|
||
return grep_markdown_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local browse_markdown_files = require("telescope._extensions.word.finders.browse") | ||
local find_markdown_files = require("telescope._extensions.word.finders.files") | ||
local grep_markdown_files = require("telescope._extensions.word.finders.grep") | ||
|
||
local M = {} | ||
|
||
function M.init() | ||
-- Initialize the finders | ||
browse_markdown_files() | ||
find_markdown_files() | ||
grep_markdown_files() | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
local browse_markdown_files = require("telescope._extensions.word.finders.browse") | ||
local find_markdown_files = require("telescope._extensions.word.finders.files") | ||
local grep_markdown_files = require("telescope._extensions.word.finders.grep") | ||
|
||
local M = {} | ||
|
||
function M.browse_markdown_files(opts) | ||
browse_markdown_files(opts) | ||
end | ||
|
||
function M.find_markdown_files(opts) | ||
find_markdown_files(opts) | ||
end | ||
|
||
function M.grep_markdown_files(opts) | ||
grep_markdown_files(opts) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
local pickers = require("telescope.pickers") | ||
local finders = require("telescope.finders") | ||
local sorters = require("telescope.sorters") | ||
local actions = require("telescope.actions") | ||
local action_state = require("telescope.actions.state") | ||
|
||
local M = {} | ||
|
||
function M.markdown_files(opts) | ||
opts = opts or {} | ||
pickers.new(opts, { | ||
prompt_title = "Markdown Files", | ||
finder = finders.new_oneshot_job({ "rg", "--files", "--glob", "*.md" }), | ||
sorter = sorters.get_fuzzy_file(), | ||
attach_mappings = function(prompt_bufnr, map) | ||
actions.select_default:replace(function() | ||
local selection = action_state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
vim.cmd("edit " .. selection[1]) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end | ||
|
||
function M.grep_markdown_files(opts) | ||
opts = opts or {} | ||
pickers.new(opts, { | ||
prompt_title = "Grep in Markdown Files", | ||
finder = finders.new_oneshot_job({ "rg", "--files", "--glob", "*.md" }), | ||
sorter = sorters.get_fuzzy_file(), | ||
attach_mappings = function(prompt_bufnr, map) | ||
actions.select_default:replace(function() | ||
local selection = action_state.get_selected_entry() | ||
actions.close(prompt_bufnr) | ||
vim.cmd("grep " .. selection[1]) | ||
end) | ||
return true | ||
end, | ||
}):find() | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.