-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add telescope pickers for markdown files and grepping #6
base: master
Are you sure you want to change the base?
Conversation
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).
Reviewer's Guide by SourceryThis PR implements telescope integration for markdown files by adding new pickers for browsing and grepping markdown files. The implementation includes configuration options, core functionality, data handling, and UI integration across multiple modules. Class diagram for new Telescope pickersclassDiagram
class TelescopeExtension {
+setup_telescope()
+setup()
+custom_picker()
+browse_markdown_files(opts)
+grep_markdown_files(opts)
}
class MarkdownFilePicker {
+markdown_files(opts)
+grep_markdown_files(opts)
}
class Finder {
+browse_markdown_files(opts)
+find_markdown_files(opts)
+grep_markdown_files(opts)
}
class UIIntegration {
+browse_markdown_files(opts)
+grep_markdown_files(opts)
}
class WorkspaceIntegration {
+browse_markdown_files(opts)
+grep_markdown_files(opts)
}
class DataHandler {
+browse_markdown_files(opts)
+grep_markdown_files(opts)
}
class Utility {
+get_markdown_files()
+grep_markdown_files(query)
}
TelescopeExtension --> MarkdownFilePicker
MarkdownFilePicker --> Finder
Finder --> UIIntegration
Finder --> WorkspaceIntegration
Finder --> DataHandler
Finder --> Utility
UIIntegration --> Utility
WorkspaceIntegration --> Utility
DataHandler --> Utility
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @clpi - I've reviewed your changes - here's some feedback:
Overall Comments:
- There is significant code duplication of the telescope picker implementation across multiple files (browse.lua, files.lua, grep.lua, etc). This should be consolidated into a single implementation that other modules can import and reuse.
- Several hardcoded paths like "path/to/markdown/files" need to be parameterized and made configurable. Consider adding these to the config options.
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -8,4 +8,28 @@ function M.word(ns) | |||
a.nvim_create_namespace(ns) | |||
end | |||
|
|||
function M.get_markdown_files() | |||
local markdown_files = {} | |||
local handle = io.popen('find . -type f -name "*.md"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): Consider using vim.fn.systemlist() instead of io.popen for better performance and safety
io.popen can be slow for large directories and may have platform compatibility issues. vim.fn.systemlist() is the recommended approach in Neovim.
local markdown_files = vim.fn.systemlist('find . -type f -name "*.md"')
vim.api.nvim_create_autocmd({ "BufDelete", "WinClosed" }, { | ||
buffer = buf, | ||
once = true, | ||
callback = function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Consider using vim.schedule() for autocmd cleanup to prevent race conditions
The buffer cleanup in autocmds should be scheduled to avoid race conditions when multiple events fire simultaneously.
callback = function()
vim.schedule(function()
pcall(vim.api.nvim_win_close, window, true)
pcall(vim.api.nvim_buf_delete, buf, { force = true })
end)
@@ -1,21 +1,15 @@ | |||
local hastel, tel = pcall(require, "telescope") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Add consistent error handling for all required modules
While pcall is used for some requires, others are direct. Consider using pcall consistently for all external module requires.
local hastel, tel = pcall(require, "telescope")
local hasact, act = pcall(require, "telescope.actions")
local hasset, set = pcall(require, "telescope.actions.set")
Add telescope functionality, a default picker, and pickers for markdown files and grepping in markdown files.
Telescope Configuration:
setup_telescope
function inlua/telescope/_extensions/word/init.lua
to configure telescope pickers for markdown files and grepping in markdown files.setup
function to callsetup_telescope
.exports
table to include new pickers for markdown files and grepping in markdown files.Configuration Options:
lua/telescope/_extensions/word/config/init.lua
.Core Functionality:
lua/telescope/_extensions/word/core/init.lua
.Data Handling:
lua/telescope/_extensions/word/data/init.lua
.Finders:
lua/telescope/_extensions/word/finders/browse.lua
.lua/telescope/_extensions/word/finders/files.lua
.lua/telescope/_extensions/word/finders/grep.lua
.init
function inlua/telescope/_extensions/word/finders/init.lua
to include the new finders.lua/telescope/_extensions/word/finders/root.lua
.Pickers:
lua/telescope/_extensions/word/picker/init.lua
.Utility Functions:
lua/telescope/_extensions/word/util/init.lua
.Integration:
lua/word/init.lua
to call the new telescope pickers.lua/word/mod/treesitter/init.lua
.lua/word/mod/ui/init.lua
.lua/word/mod/workspace/init.lua
.lua/word/ui/init.lua
.For more details, open the Copilot Workspace session.
Summary by Sourcery
Add new telescope pickers for markdown files and integrate them with existing modules to enhance markdown file handling capabilities.
New Features:
Enhancements: