fix: critical bugs and add documentation
- Fix missing path separator in glob patterns (files were not found) - Fix nvim-tree setup overriding user config on every IdeaTree call - Fix deprecated nvim API (nvim_buf_set_option, nvim_win_set_option) - Fix missing arguments in sidebar.open() call in list.lua - Remove unused variable in tags.lua - Update help documentation with all commands - Fix README.md (telescope reference, add changelog link) - Add CHANGELOG.md - Add llms.txt for AI/LLM context
This commit is contained in:
49
CHANGELOG.md
Normal file
49
CHANGELOG.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to ideaDrop.nvim will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Critical**: Fixed glob pattern bug where files were not being found due to missing path separator (`/`) between directory and pattern in `list.lua`, `tags.lua`, and `search.lua`
|
||||||
|
- **Critical**: Fixed nvim-tree integration that was overriding user's nvim-tree configuration on every `:IdeaTree` call. Now uses nvim-tree API directly without calling `setup()`
|
||||||
|
- Fixed deprecated Neovim API usage: replaced `vim.api.nvim_buf_set_option()` and `vim.api.nvim_win_set_option()` with `vim.bo[]` and `vim.wo[]` in `sidebar.lua`
|
||||||
|
- Fixed missing arguments in `sidebar.open()` call in `list.lua` which could cause unexpected behavior
|
||||||
|
- Removed unused variable in `tags.lua` (`filename` in `show_files_with_tag` function)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated help documentation (`doc/ideaDrop.txt`) to include all commands: `IdeaBuffer`, `IdeaRight`, `IdeaTree`, tag commands, and search commands
|
||||||
|
- Improved nvim-tree integration to preserve user's existing nvim-tree configuration
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `CHANGELOG.md` to track project changes
|
||||||
|
- Added `llms.txt` for AI/LLM context about the project
|
||||||
|
|
||||||
|
## [1.0.0] - Initial Release
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Multiple view modes: floating window, current buffer, right-side buffer
|
||||||
|
- Smart tagging system with `#tag` format
|
||||||
|
- Advanced fuzzy search through titles and content
|
||||||
|
- nvim-tree integration for file browsing
|
||||||
|
- Markdown support with syntax highlighting
|
||||||
|
- Auto-save functionality
|
||||||
|
- Date-based file organization
|
||||||
|
- Nested folder support
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
- `:Idea` - Open idea in floating window
|
||||||
|
- `:IdeaBuffer` - Open idea in current buffer
|
||||||
|
- `:IdeaRight` - Open idea in right-side buffer
|
||||||
|
- `:IdeaTree` - Open file tree browser
|
||||||
|
- `:IdeaTags` - Browse and filter by tags
|
||||||
|
- `:IdeaAddTag` / `:IdeaRemoveTag` - Manage tags
|
||||||
|
- `:IdeaSearch` / `:IdeaSearchContent` / `:IdeaSearchTitle` - Search functionality
|
||||||
@@ -215,9 +215,13 @@ This plugin is built with:
|
|||||||
- **Lua**: Core functionality
|
- **Lua**: Core functionality
|
||||||
- **Neovim API**: Native Neovim integration
|
- **Neovim API**: Native Neovim integration
|
||||||
- **nvim-tree**: File tree browsing
|
- **nvim-tree**: File tree browsing
|
||||||
- **telescope**: Search functionality
|
- **vim.ui.select**: Native picker for search and tag selection
|
||||||
- **Markdown**: Rich text support
|
- **Markdown**: Rich text support
|
||||||
|
|
||||||
|
## 📋 Changelog
|
||||||
|
|
||||||
|
See [CHANGELOG.md](CHANGELOG.md) for a detailed list of changes.
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
MIT License - feel free to use this plugin in your own projects!
|
MIT License - feel free to use this plugin in your own projects!
|
||||||
@@ -239,7 +243,7 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|||||||
|
|
||||||
1. **Module not found errors**: Ensure all dependencies are installed
|
1. **Module not found errors**: Ensure all dependencies are installed
|
||||||
2. **Tree not opening**: Make sure nvim-tree is properly configured
|
2. **Tree not opening**: Make sure nvim-tree is properly configured
|
||||||
3. **Search not working**: Verify telescope is installed and configured
|
3. **Search not working**: Verify your idea directory path is correct
|
||||||
4. **Tags not showing**: Check that your idea directory exists and contains markdown files
|
4. **Tags not showing**: Check that your idea directory exists and contains markdown files
|
||||||
|
|
||||||
### Getting Help
|
### Getting Help
|
||||||
|
|||||||
213
doc/ideaDrop.txt
213
doc/ideaDrop.txt
@@ -3,33 +3,55 @@
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
INTRODUCTION *ideaDrop-introduction*
|
INTRODUCTION *ideaDrop-introduction*
|
||||||
|
|
||||||
ideaDrop.nvim is a simple Neovim plugin that allows you to drop and organize
|
ideaDrop.nvim is a powerful Neovim plugin for capturing, organizing, and
|
||||||
your ideas in floating Markdown sidebars. It provides a clean and
|
managing your ideas with multiple view modes, tagging system, and advanced
|
||||||
distraction-free interface for quick note-taking and idea organization.
|
search capabilities.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INSTALLATION *ideaDrop-installation*
|
INSTALLATION *ideaDrop-installation*
|
||||||
|
|
||||||
Using lazy.nvim:
|
Using lazy.nvim:
|
||||||
|
>lua
|
||||||
{
|
{
|
||||||
dir = "path/ideaDrop",
|
"CarGDev/ideadrop.nvim",
|
||||||
name = "ideaDrop",
|
name = "ideaDrop",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("ideaDrop").setup({
|
require("ideaDrop").setup({
|
||||||
idea_dir = "path/ideaDrop",
|
idea_dir = "/path/to/your/ideas",
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
<
|
||||||
|
|
||||||
|
Using packer:
|
||||||
|
>lua
|
||||||
|
use {
|
||||||
|
"CarGDev/ideadrop.nvim",
|
||||||
|
requires = {
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("ideaDrop").setup({
|
||||||
|
idea_dir = "/path/to/your/ideas",
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CONFIGURATION *ideaDrop-configuration*
|
CONFIGURATION *ideaDrop-configuration*
|
||||||
|
|
||||||
ideaDrop.nvim can be configured by passing a table to the setup function:
|
ideaDrop.nvim can be configured by passing a table to the setup function:
|
||||||
|
>lua
|
||||||
require("ideaDrop").setup({
|
require("ideaDrop").setup({
|
||||||
idea_dir = "/path/to/your/ideas", -- Directory to store idea files
|
idea_dir = "/path/to/your/ideas",
|
||||||
})
|
})
|
||||||
|
<
|
||||||
|
|
||||||
OPTIONS *ideaDrop-options*
|
OPTIONS *ideaDrop-options*
|
||||||
|
|
||||||
@@ -40,37 +62,182 @@ idea_dir (string) ~
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
COMMANDS *ideaDrop-commands*
|
COMMANDS *ideaDrop-commands*
|
||||||
|
|
||||||
|
CORE COMMANDS ~
|
||||||
|
|
||||||
:Idea *:Idea*
|
:Idea *:Idea*
|
||||||
Opens today's idea file in a floating sidebar.
|
Opens today's idea file in a floating sidebar.
|
||||||
|
|
||||||
:Idea {name} *:Idea-name*
|
:Idea {name} *:Idea-name*
|
||||||
Opens or creates an idea file with the specified name.
|
Opens or creates an idea file with the specified name in floating window.
|
||||||
Example: `:Idea project/vision`
|
Example: `:Idea project/vision`
|
||||||
|
|
||||||
:Idea listAll *:Idea-listAll*
|
:Idea listAll *:Idea-listAll*
|
||||||
Opens a fuzzy picker to select from existing ideas.
|
Opens a picker to select from existing ideas.
|
||||||
|
|
||||||
|
:IdeaBuffer *:IdeaBuffer*
|
||||||
|
Opens today's idea file in the current buffer.
|
||||||
|
|
||||||
|
:IdeaBuffer {name} *:IdeaBuffer-name*
|
||||||
|
Opens or creates an idea file in the current buffer.
|
||||||
|
|
||||||
|
:IdeaRight *:IdeaRight*
|
||||||
|
Opens today's idea file in a persistent right-side buffer.
|
||||||
|
|
||||||
|
:IdeaRight {name} *:IdeaRight-name*
|
||||||
|
Opens or creates an idea file in the right-side buffer.
|
||||||
|
Example: `:IdeaRight meetings/standup`
|
||||||
|
|
||||||
|
:IdeaTree *:IdeaTree*
|
||||||
|
Opens nvim-tree file browser focused on the idea directory.
|
||||||
|
|
||||||
|
TAG COMMANDS ~
|
||||||
|
|
||||||
|
:IdeaTags *:IdeaTags*
|
||||||
|
Shows a tag picker to browse all tags and filter files by tag.
|
||||||
|
|
||||||
|
:IdeaAddTag {tag} *:IdeaAddTag*
|
||||||
|
Adds a tag to the current idea file.
|
||||||
|
Example: `:IdeaAddTag work`
|
||||||
|
|
||||||
|
:IdeaRemoveTag {tag} *:IdeaRemoveTag*
|
||||||
|
Removes a tag from the current idea file.
|
||||||
|
Example: `:IdeaRemoveTag todo`
|
||||||
|
|
||||||
|
:IdeaSearchTag {tag} *:IdeaSearchTag*
|
||||||
|
Searches for all files containing a specific tag.
|
||||||
|
Example: `:IdeaSearchTag project`
|
||||||
|
|
||||||
|
SEARCH COMMANDS ~
|
||||||
|
|
||||||
|
:IdeaSearch {query} *:IdeaSearch*
|
||||||
|
Fuzzy search through idea titles and content.
|
||||||
|
Example: `:IdeaSearch machine learning`
|
||||||
|
|
||||||
|
:IdeaSearchContent {query} *:IdeaSearchContent*
|
||||||
|
Search only in idea content (not titles).
|
||||||
|
Example: `:IdeaSearchContent algorithm`
|
||||||
|
|
||||||
|
:IdeaSearchTitle {query} *:IdeaSearchTitle*
|
||||||
|
Search only in idea file names/titles.
|
||||||
|
Example: `:IdeaSearchTitle project`
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
KEYMAPS *ideaDrop-keymaps*
|
||||||
|
|
||||||
|
Buffer-local keymaps (in right-side buffer):
|
||||||
|
|
||||||
|
<C-t> Toggle tree view
|
||||||
|
<C-r> Refresh current file
|
||||||
|
|
||||||
|
Suggested global keymaps (add to your config):
|
||||||
|
>lua
|
||||||
|
vim.keymap.set("n", "<leader>id", ":IdeaRight<CR>", { desc = "Open today's idea" })
|
||||||
|
vim.keymap.set("n", "<leader>in", ":IdeaRight ", { desc = "Open named idea" })
|
||||||
|
vim.keymap.set("n", "<leader>it", ":IdeaTree<CR>", { desc = "Open idea tree" })
|
||||||
|
vim.keymap.set("n", "<leader>is", ":IdeaSearch ", { desc = "Search ideas" })
|
||||||
|
vim.keymap.set("n", "<leader>ig", ":IdeaTags<CR>", { desc = "Browse tags" })
|
||||||
|
vim.keymap.set("n", "<leader>if", ":Idea<CR>", { desc = "Open idea in float" })
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
FEATURES *ideaDrop-features*
|
FEATURES *ideaDrop-features*
|
||||||
|
|
||||||
- Markdown editor in a floating sidebar
|
VIEW MODES ~
|
||||||
- Automatic save on close
|
|
||||||
- Date-based and custom named notes
|
1. Floating Window (`:Idea`)
|
||||||
- Folder support (e.g., project/vision.md)
|
- Opens ideas in a floating window
|
||||||
- Fuzzy finder for existing ideas
|
- Good for quick notes
|
||||||
- Clean and distraction-free interface
|
|
||||||
|
2. Current Buffer (`:IdeaBuffer`)
|
||||||
|
- Opens ideas in the current buffer
|
||||||
|
- Replaces current content
|
||||||
|
|
||||||
|
3. Right-Side Buffer (`:IdeaRight`) - Recommended
|
||||||
|
- Persistent buffer on the right side
|
||||||
|
- Stays open while you work
|
||||||
|
|
||||||
|
4. Tree Browser (`:IdeaTree`)
|
||||||
|
- Full file tree on the left side
|
||||||
|
- Uses nvim-tree integration
|
||||||
|
|
||||||
|
TAGGING SYSTEM ~
|
||||||
|
|
||||||
|
Tags use the `#tag` format in your markdown files:
|
||||||
|
>markdown
|
||||||
|
# My Idea Title
|
||||||
|
|
||||||
|
This is my idea content.
|
||||||
|
|
||||||
|
#work #project-x #feature #todo
|
||||||
|
<
|
||||||
|
|
||||||
|
- Tags are automatically detected and indexed
|
||||||
|
- Filter ideas by tags using `:IdeaTags`
|
||||||
|
- Add/remove tags with `:IdeaAddTag` and `:IdeaRemoveTag`
|
||||||
|
|
||||||
|
SEARCH FEATURES ~
|
||||||
|
|
||||||
|
- Fuzzy search through titles and content
|
||||||
|
- Real-time results as you type
|
||||||
|
- Jump to specific lines in search results
|
||||||
|
- Separate content and title search options
|
||||||
|
|
||||||
|
AUTO-SAVE ~
|
||||||
|
|
||||||
|
All changes are automatically saved when:
|
||||||
|
- Closing a floating window
|
||||||
|
- Writing the buffer (`:w`)
|
||||||
|
- Closing the right-side window
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
EXAMPLES *ideaDrop-examples*
|
EXAMPLES *ideaDrop-examples*
|
||||||
|
|
||||||
1. Open today's idea:
|
1. Open today's idea in right buffer:
|
||||||
:Idea
|
>vim
|
||||||
|
:IdeaRight
|
||||||
|
<
|
||||||
|
|
||||||
2. Create a new idea in a project folder:
|
2. Create a nested folder structure:
|
||||||
:Idea project/nextgen
|
>vim
|
||||||
|
:IdeaRight meetings/2024-01-15
|
||||||
|
:IdeaRight projects/app/features
|
||||||
|
<
|
||||||
|
|
||||||
3. List and select from existing ideas:
|
3. Add tags to current idea:
|
||||||
:Idea listAll
|
>vim
|
||||||
|
:IdeaAddTag work
|
||||||
|
:IdeaAddTag todo
|
||||||
|
<
|
||||||
|
|
||||||
|
4. Search for ideas:
|
||||||
|
>vim
|
||||||
|
:IdeaSearch "machine learning"
|
||||||
|
:IdeaSearchContent "algorithm"
|
||||||
|
<
|
||||||
|
|
||||||
|
5. Browse and filter by tags:
|
||||||
|
>vim
|
||||||
|
:IdeaTags
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim:tw=78:ts=8:ft=help:norl:
|
TROUBLESHOOTING *ideaDrop-troubleshooting*
|
||||||
|
|
||||||
|
Common Issues ~
|
||||||
|
|
||||||
|
1. Module not found errors
|
||||||
|
- Ensure all dependencies are installed (nvim-tree, nvim-web-devicons)
|
||||||
|
|
||||||
|
2. Tree not opening
|
||||||
|
- Make sure nvim-tree is properly configured in your Neovim setup
|
||||||
|
|
||||||
|
3. Tags not showing
|
||||||
|
- Check that your idea directory exists and contains markdown files
|
||||||
|
- Ensure tags use the `#tag` format
|
||||||
|
|
||||||
|
4. Search not working
|
||||||
|
- Verify your idea directory path is correct
|
||||||
|
- Check that markdown files exist in the directory
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
|
|||||||
111
llms.txt
Normal file
111
llms.txt
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
# ideaDrop.nvim - LLM Context
|
||||||
|
|
||||||
|
> A Neovim plugin for capturing, organizing, and managing ideas with markdown support.
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
ideaDrop.nvim is a Lua-based Neovim plugin that provides a distraction-free environment for note-taking and idea management. It features multiple view modes, a tagging system, and search capabilities.
|
||||||
|
|
||||||
|
## Tech Stack
|
||||||
|
|
||||||
|
- **Language**: Lua
|
||||||
|
- **Platform**: Neovim (requires Neovim 0.8+)
|
||||||
|
- **Dependencies**: nvim-tree/nvim-tree.lua, nvim-tree/nvim-web-devicons
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
ideaDrop.nvim/
|
||||||
|
├── lua/ideaDrop/
|
||||||
|
│ ├── init.lua # Main entry point
|
||||||
|
│ ├── core/
|
||||||
|
│ │ ├── init.lua # Core module with setup and commands
|
||||||
|
│ │ └── config.lua # Configuration management
|
||||||
|
│ ├── ui/
|
||||||
|
│ │ ├── sidebar.lua # Floating/buffer/right-side window management
|
||||||
|
│ │ └── tree.lua # nvim-tree integration
|
||||||
|
│ ├── features/
|
||||||
|
│ │ ├── list.lua # File listing functionality
|
||||||
|
│ │ ├── tags.lua # Tag extraction and management
|
||||||
|
│ │ └── search.lua # Fuzzy search implementation
|
||||||
|
│ └── utils/
|
||||||
|
│ ├── utils.lua # Utility functions
|
||||||
|
│ ├── keymaps.lua # Keymap setup
|
||||||
|
│ └── constants.lua # Constants and defaults
|
||||||
|
├── doc/
|
||||||
|
│ └── ideaDrop.txt # Vim help documentation
|
||||||
|
├── README.md
|
||||||
|
├── CONTRIBUTING.md
|
||||||
|
├── CHANGELOG.md
|
||||||
|
└── LICENSE
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
|
||||||
|
1. **Multiple View Modes**
|
||||||
|
- Floating window (`:Idea`)
|
||||||
|
- Current buffer (`:IdeaBuffer`)
|
||||||
|
- Right-side persistent buffer (`:IdeaRight`)
|
||||||
|
- Tree browser (`:IdeaTree`)
|
||||||
|
|
||||||
|
2. **Tagging System**
|
||||||
|
- Uses `#tag` format in markdown files
|
||||||
|
- Tag extraction, caching, and filtering
|
||||||
|
- Commands: `:IdeaTags`, `:IdeaAddTag`, `:IdeaRemoveTag`, `:IdeaSearchTag`
|
||||||
|
|
||||||
|
3. **Search Functionality**
|
||||||
|
- Fuzzy search through titles and content
|
||||||
|
- Commands: `:IdeaSearch`, `:IdeaSearchContent`, `:IdeaSearchTitle`
|
||||||
|
|
||||||
|
4. **Auto-save**
|
||||||
|
- Automatic saving on window close
|
||||||
|
- Uses `BufWriteCmd` autocmd for custom save handling
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require("ideaDrop").setup({
|
||||||
|
idea_dir = "/path/to/your/ideas", -- Directory for storing idea files
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Code Conventions
|
||||||
|
|
||||||
|
- Type annotations using LuaCATS/EmmyLua format (`---@param`, `---@return`, `---@class`)
|
||||||
|
- Module pattern with local `M = {}` tables
|
||||||
|
- Neovim API usage:
|
||||||
|
- `vim.bo[buf]` for buffer options
|
||||||
|
- `vim.wo[win]` for window options
|
||||||
|
- `vim.api.nvim_*` for other API calls
|
||||||
|
- Error handling with `pcall` for optional dependencies
|
||||||
|
- Notifications via `vim.notify()` with appropriate log levels
|
||||||
|
|
||||||
|
## Important Implementation Details
|
||||||
|
|
||||||
|
- **Glob patterns**: Must include `/` separator: `path .. "/**/*.md"`
|
||||||
|
- **nvim-tree**: Use API directly (`require("nvim-tree.api")`) without calling `setup()` to preserve user config
|
||||||
|
- **Buffer management**: Right-side buffer uses `buftype = "acwrite"` for custom save handling
|
||||||
|
- **File paths**: Use `vim.fn.fnameescape()` for safe path handling
|
||||||
|
|
||||||
|
## Commands Reference
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `:Idea [name]` | Open in floating window |
|
||||||
|
| `:IdeaBuffer [name]` | Open in current buffer |
|
||||||
|
| `:IdeaRight [name]` | Open in right-side buffer |
|
||||||
|
| `:IdeaTree` | Open file tree browser |
|
||||||
|
| `:IdeaTags` | Browse tags |
|
||||||
|
| `:IdeaAddTag {tag}` | Add tag to current file |
|
||||||
|
| `:IdeaRemoveTag {tag}` | Remove tag from current file |
|
||||||
|
| `:IdeaSearchTag {tag}` | Search files by tag |
|
||||||
|
| `:IdeaSearch {query}` | Fuzzy search all |
|
||||||
|
| `:IdeaSearchContent {query}` | Search content only |
|
||||||
|
| `:IdeaSearchTitle {query}` | Search titles only |
|
||||||
|
|
||||||
|
## Development Notes
|
||||||
|
|
||||||
|
- Help tags file at `doc/tags` is auto-generated
|
||||||
|
- Uses `vim.ui.select()` for picker interfaces
|
||||||
|
- Tag cache invalidation via `tag_cache_dirty` flag
|
||||||
|
- Markdown files default template includes title and bullet point
|
||||||
@@ -11,7 +11,7 @@ local M = {}
|
|||||||
function M.list_all()
|
function M.list_all()
|
||||||
local path = config.options.idea_dir
|
local path = config.options.idea_dir
|
||||||
-- Find all .md files recursively
|
-- Find all .md files recursively
|
||||||
local files = vim.fn.glob(path .. "**/*.md", false, true)
|
local files = vim.fn.glob(path .. "/**/*.md", false, true)
|
||||||
|
|
||||||
if #files == 0 then
|
if #files == 0 then
|
||||||
vim.notify("📂 No idea files found", vim.log.levels.INFO)
|
vim.notify("📂 No idea files found", vim.log.levels.INFO)
|
||||||
@@ -21,7 +21,8 @@ function M.list_all()
|
|||||||
-- Present file selection UI
|
-- Present file selection UI
|
||||||
vim.ui.select(files, { prompt = "📂 Select an idea file to open:" }, function(choice)
|
vim.ui.select(files, { prompt = "📂 Select an idea file to open:" }, function(choice)
|
||||||
if choice then
|
if choice then
|
||||||
sidebar.open(choice) -- Open the selected file in sidebar
|
local filename = vim.fn.fnamemodify(choice, ":t")
|
||||||
|
sidebar.open(choice, filename, false) -- Open the selected file in sidebar
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ function M.fuzzy_search(query)
|
|||||||
local results = {}
|
local results = {}
|
||||||
|
|
||||||
-- Find all .md files recursively
|
-- Find all .md files recursively
|
||||||
local files = vim.fn.glob(idea_path .. "**/*.md", false, true)
|
local files = vim.fn.glob(idea_path .. "/**/*.md", false, true)
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
if vim.fn.filereadable(file) == 1 then
|
if vim.fn.filereadable(file) == 1 then
|
||||||
@@ -199,7 +199,7 @@ function M.search_in_content(query)
|
|||||||
local results = {}
|
local results = {}
|
||||||
|
|
||||||
-- Find all .md files recursively
|
-- Find all .md files recursively
|
||||||
local files = vim.fn.glob(idea_path .. "**/*.md", false, true)
|
local files = vim.fn.glob(idea_path .. "/**/*.md", false, true)
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
if vim.fn.filereadable(file) == 1 then
|
if vim.fn.filereadable(file) == 1 then
|
||||||
@@ -257,7 +257,7 @@ function M.search_by_title(query)
|
|||||||
local results = {}
|
local results = {}
|
||||||
|
|
||||||
-- Find all .md files recursively
|
-- Find all .md files recursively
|
||||||
local files = vim.fn.glob(idea_path .. "**/*.md", false, true)
|
local files = vim.fn.glob(idea_path .. "/**/*.md", false, true)
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
if vim.fn.filereadable(file) == 1 then
|
if vim.fn.filereadable(file) == 1 then
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function M.get_all_tags()
|
|||||||
local seen = {}
|
local seen = {}
|
||||||
|
|
||||||
-- Find all .md files recursively
|
-- Find all .md files recursively
|
||||||
local files = vim.fn.glob(idea_path .. "**/*.md", false, true)
|
local files = vim.fn.glob(idea_path .. "/**/*.md", false, true)
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
if vim.fn.filereadable(file) == 1 then
|
if vim.fn.filereadable(file) == 1 then
|
||||||
@@ -203,7 +203,7 @@ function M.get_files_by_tag(tag)
|
|||||||
local matching_files = {}
|
local matching_files = {}
|
||||||
|
|
||||||
-- Find all .md files recursively
|
-- Find all .md files recursively
|
||||||
local files = vim.fn.glob(idea_path .. "**/*.md", false, true)
|
local files = vim.fn.glob(idea_path .. "/**/*.md", false, true)
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
if vim.fn.filereadable(file) == 1 then
|
if vim.fn.filereadable(file) == 1 then
|
||||||
@@ -264,7 +264,6 @@ function M.show_files_with_tag(tag)
|
|||||||
-- Format file names for display
|
-- Format file names for display
|
||||||
local file_choices = {}
|
local file_choices = {}
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local filename = vim.fn.fnamemodify(file, ":t")
|
|
||||||
local relative_path = file:sub(#config.options.idea_dir + 2) -- Remove idea_dir + "/"
|
local relative_path = file:sub(#config.options.idea_dir + 2) -- Remove idea_dir + "/"
|
||||||
table.insert(file_choices, relative_path)
|
table.insert(file_choices, relative_path)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function M.open(file, filename, use_buffer)
|
|||||||
|
|
||||||
-- Create a new buffer
|
-- Create a new buffer
|
||||||
local buf = vim.api.nvim_create_buf(false, true)
|
local buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
|
vim.bo[buf].filetype = "markdown"
|
||||||
|
|
||||||
-- Calculate window dimensions (30% of screen width, 80% of screen height)
|
-- Calculate window dimensions (30% of screen width, 80% of screen height)
|
||||||
local width = math.floor(vim.o.columns * 0.3)
|
local width = math.floor(vim.o.columns * 0.3)
|
||||||
@@ -124,9 +124,9 @@ function M.open_right_side(file, filename)
|
|||||||
-- Create buffer if it doesn't exist
|
-- Create buffer if it doesn't exist
|
||||||
if not right_side_buf or not vim.api.nvim_buf_is_valid(right_side_buf) then
|
if not right_side_buf or not vim.api.nvim_buf_is_valid(right_side_buf) then
|
||||||
right_side_buf = vim.api.nvim_create_buf(false, false)
|
right_side_buf = vim.api.nvim_create_buf(false, false)
|
||||||
vim.api.nvim_buf_set_option(right_side_buf, "filetype", "markdown")
|
vim.bo[right_side_buf].filetype = "markdown"
|
||||||
vim.api.nvim_buf_set_option(right_side_buf, "buftype", "acwrite")
|
vim.bo[right_side_buf].buftype = "acwrite"
|
||||||
vim.api.nvim_buf_set_option(right_side_buf, "bufhidden", "hide")
|
vim.bo[right_side_buf].bufhidden = "hide"
|
||||||
|
|
||||||
-- Set up autosave for the right-side buffer
|
-- Set up autosave for the right-side buffer
|
||||||
vim.api.nvim_create_autocmd("BufWriteCmd", {
|
vim.api.nvim_create_autocmd("BufWriteCmd", {
|
||||||
@@ -190,11 +190,11 @@ function M.open_right_side(file, filename)
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Set window options
|
-- Set window options
|
||||||
vim.api.nvim_win_set_option(right_side_win, "wrap", true)
|
vim.wo[right_side_win].wrap = true
|
||||||
vim.api.nvim_win_set_option(right_side_win, "number", true)
|
vim.wo[right_side_win].number = true
|
||||||
vim.api.nvim_win_set_option(right_side_win, "relativenumber", false)
|
vim.wo[right_side_win].relativenumber = false
|
||||||
vim.api.nvim_win_set_option(right_side_win, "cursorline", true)
|
vim.wo[right_side_win].cursorline = true
|
||||||
vim.api.nvim_win_set_option(right_side_win, "winhl", "Normal:Normal,FloatBorder:FloatBorder")
|
vim.wo[right_side_win].winhl = "Normal:Normal,FloatBorder:FloatBorder"
|
||||||
|
|
||||||
-- Set up autosave on window close
|
-- Set up autosave on window close
|
||||||
vim.api.nvim_create_autocmd("WinClosed", {
|
vim.api.nvim_create_autocmd("WinClosed", {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local M = {}
|
|||||||
-- Tree state
|
-- Tree state
|
||||||
local tree_callback = nil
|
local tree_callback = nil
|
||||||
local original_cwd = nil
|
local original_cwd = nil
|
||||||
|
local ideadrop_tree_autocmd_group = nil
|
||||||
|
|
||||||
---Opens nvim-tree focused on the idea directory
|
---Opens nvim-tree focused on the idea directory
|
||||||
---@param callback fun(file_path: string): nil Callback function when a file is selected
|
---@param callback fun(file_path: string): nil Callback function when a file is selected
|
||||||
@@ -16,8 +17,8 @@ function M.open_tree_window(callback)
|
|||||||
tree_callback = callback
|
tree_callback = callback
|
||||||
|
|
||||||
-- Check if nvim-tree is available
|
-- Check if nvim-tree is available
|
||||||
local has_nvim_tree, nvim_tree = pcall(require, "nvim-tree")
|
local has_nvim_tree_api, nvim_tree_api = pcall(require, "nvim-tree.api")
|
||||||
if not has_nvim_tree then
|
if not has_nvim_tree_api then
|
||||||
vim.notify("❌ nvim-tree is not installed. Please install nvim-tree to use this feature.", vim.log.levels.ERROR)
|
vim.notify("❌ nvim-tree is not installed. Please install nvim-tree to use this feature.", vim.log.levels.ERROR)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -27,112 +28,66 @@ function M.open_tree_window(callback)
|
|||||||
|
|
||||||
-- Change to idea directory
|
-- Change to idea directory
|
||||||
local idea_path = config.options.idea_dir
|
local idea_path = config.options.idea_dir
|
||||||
if vim.fn.isdirectory(idea_path) == 1 then
|
if vim.fn.isdirectory(idea_path) == 0 then
|
||||||
vim.cmd("cd " .. vim.fn.fnameescape(idea_path))
|
-- Create the directory if it doesn't exist
|
||||||
else
|
vim.fn.mkdir(idea_path, "p")
|
||||||
vim.notify("❌ Idea directory not found: " .. idea_path, vim.log.levels.ERROR)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set up nvim-tree to open on the left side
|
-- Create autocmd group for ideaDrop tree handling
|
||||||
nvim_tree.setup({
|
if ideadrop_tree_autocmd_group then
|
||||||
view = {
|
vim.api.nvim_del_augroup_by_id(ideadrop_tree_autocmd_group)
|
||||||
side = "left",
|
end
|
||||||
width = 30,
|
ideadrop_tree_autocmd_group = vim.api.nvim_create_augroup("IdeaDropTree", { clear = true })
|
||||||
},
|
|
||||||
actions = {
|
-- Set up autocmd to handle file selection from nvim-tree
|
||||||
open_file = {
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
quit_on_open = false,
|
group = ideadrop_tree_autocmd_group,
|
||||||
},
|
callback = function(args)
|
||||||
},
|
local bufname = vim.api.nvim_buf_get_name(args.buf)
|
||||||
on_attach = function(bufnr)
|
-- Check if this is a markdown file in the idea directory
|
||||||
-- Override the default file opening behavior
|
if bufname:match("%.md$") and bufname:find(idea_path, 1, true) then
|
||||||
local api = require("nvim-tree.api")
|
-- Call our callback with the selected file
|
||||||
|
if tree_callback then
|
||||||
-- Map Enter to custom handler
|
|
||||||
vim.keymap.set("n", "<CR>", function()
|
|
||||||
local node = api.tree.get_node_under_cursor()
|
|
||||||
if node and node.type == "file" then
|
|
||||||
-- Call our callback with the selected file
|
|
||||||
if tree_callback then
|
|
||||||
tree_callback(node.absolute_path)
|
|
||||||
end
|
|
||||||
-- Close nvim-tree
|
-- Close nvim-tree
|
||||||
api.tree.close()
|
nvim_tree_api.tree.close()
|
||||||
-- Restore original working directory
|
-- Restore original working directory
|
||||||
if original_cwd then
|
if original_cwd then
|
||||||
vim.cmd("cd " .. vim.fn.fnameescape(original_cwd))
|
vim.cmd("cd " .. vim.fn.fnameescape(original_cwd))
|
||||||
end
|
end
|
||||||
else
|
-- Use vim.schedule to avoid issues with buffer switching
|
||||||
-- Default behavior for directories
|
vim.schedule(function()
|
||||||
api.node.open.edit()
|
tree_callback(bufname)
|
||||||
|
end)
|
||||||
|
-- Clear the autocmd group after handling
|
||||||
|
vim.api.nvim_del_augroup_by_id(ideadrop_tree_autocmd_group)
|
||||||
|
ideadrop_tree_autocmd_group = nil
|
||||||
end
|
end
|
||||||
end, { buffer = bufnr, noremap = true, silent = true })
|
end
|
||||||
|
|
||||||
-- Map 'q' to close tree and restore directory
|
|
||||||
vim.keymap.set("n", "q", function()
|
|
||||||
api.tree.close()
|
|
||||||
if original_cwd then
|
|
||||||
vim.cmd("cd " .. vim.fn.fnameescape(original_cwd))
|
|
||||||
end
|
|
||||||
end, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
|
|
||||||
-- Keep other default mappings
|
|
||||||
vim.keymap.set("n", "<C-]>", api.tree.change_root_to_node, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<C-e>", api.node.open.replace_tree_buffer, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<C-k>", api.node.show_info_popup, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<C-r>", api.fs.rename_sub, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<C-t>", api.node.open.tab, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<C-v>", api.node.open.vertical, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<C-x>", api.node.open.horizontal, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<BS>", api.node.navigate.parent_close, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<Tab>", api.node.open.preview, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", ">", api.node.navigate.sibling.next, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<", api.node.navigate.sibling.prev, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", ".", api.node.run.cmd, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "-", api.tree.change_root_to_parent, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "a", api.fs.create, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "bmv", api.marks.bulk.move, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "B", api.tree.toggle_no_buffer_filter, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "c", api.fs.copy.node, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "C", api.tree.toggle_git_clean_filter, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "[c", api.node.navigate.git.prev, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "]c", api.node.navigate.git.next, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "d", api.fs.remove, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "D", api.fs.trash, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "E", api.tree.expand_all, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "e", api.fs.rename_basename, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "]e", api.node.navigate.diagnostics.next, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "[e", api.node.navigate.diagnostics.prev, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "F", api.live_filter.clear, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "f", api.live_filter.start, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "g?", api.tree.toggle_help, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "gy", api.fs.copy.absolute_path, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "H", api.tree.toggle_hidden_filter, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "J", api.node.navigate.sibling.last, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "K", api.node.navigate.sibling.first, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "m", api.marks.toggle, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "o", api.node.open.edit, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "O", api.node.open.no_window_picker, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "P", api.node.navigate.parent, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "r", api.fs.rename, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "R", api.tree.reload, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "s", api.node.run.system, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "S", api.tree.search_node, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "U", api.tree.toggle_custom_filter, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "W", api.tree.collapse_all, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "x", api.fs.cut, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "y", api.fs.copy.filename, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "Y", api.fs.copy.relative_path, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<2-LeftMouse>", api.node.open.edit, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
vim.keymap.set("n", "<2-RightMouse>", api.tree.change_root_to_node, { buffer = bufnr, noremap = true, silent = true })
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Open nvim-tree using the correct API
|
-- Set up autocmd to restore cwd when nvim-tree is closed
|
||||||
local api = require("nvim-tree.api")
|
vim.api.nvim_create_autocmd("BufLeave", {
|
||||||
api.tree.open()
|
group = ideadrop_tree_autocmd_group,
|
||||||
|
pattern = "NvimTree_*",
|
||||||
|
callback = function()
|
||||||
|
-- Restore original working directory when leaving nvim-tree
|
||||||
|
if original_cwd then
|
||||||
|
vim.schedule(function()
|
||||||
|
-- Only restore if we're not in an idea file
|
||||||
|
local current_buf = vim.api.nvim_get_current_buf()
|
||||||
|
local bufname = vim.api.nvim_buf_get_name(current_buf)
|
||||||
|
if not (bufname:match("%.md$") and bufname:find(idea_path, 1, true)) then
|
||||||
|
vim.cmd("cd " .. vim.fn.fnameescape(original_cwd))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Open nvim-tree in the idea directory (without calling setup)
|
||||||
|
-- This preserves the user's nvim-tree configuration
|
||||||
|
nvim_tree_api.tree.open({ path = idea_path })
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
Reference in New Issue
Block a user