Neovim plugin to change quotes
Find a file
2025-07-28 21:22:43 +02:00
.forgejo/workflows refactor: Refactor everything 2025-07-28 21:19:35 +02:00
lua/jquote refactor: Refactor everything 2025-07-28 21:19:35 +02:00
tests refactor: Refactor everything 2025-07-28 21:19:35 +02:00
Makefile refactor: Refactor everything 2025-07-28 21:19:35 +02:00
README.md docs: Add readme 2025-07-28 21:22:43 +02:00
release.config.cjs chore: Add semantic releases 2025-07-28 20:55:06 +02:00

JQuote.nvim

A powerful Neovim plugin for cycling through quote characters with intelligent auto-jump functionality.

License: MIT Lua Neovim

Features

  • 🔄 Quote Cycling: Seamlessly cycle through different quote characters (', ", `)
  • 🎯 Auto Jump: Automatically jump to the next quote pair when cursor is not inside quotes
  • ⚙️ Configurable: Customize quote characters, hotkeys, and jump behavior
  • 🛡️ Enterprise-Grade: Comprehensive error handling and defensive programming
  • 📊 Health Monitoring: Built-in health check and diagnostics
  • 🏗️ Version Management: Dynamic version detection from git tags
  • 🧪 Thoroughly Tested: Comprehensive unit test suite with 25+ test cases

📋 Requirements

  • Neovim 0.5.0 or later
  • Lua 5.1+

📦 Installation

Using lazy.nvim

{
  "your-username/jquote.nvim",
  config = function()
    require("jquote").setup({
      -- Optional configuration
      hotkey = "<leader>tq",
      quote_chars = { "'", '"', "`" },
      jump_behavior = "auto"
    })
  end,
}

Using packer.nvim

use {
  "your-username/jquote.nvim",
  config = function()
    require("jquote").setup()
  end
}

Using vim-plug

Plug 'your-username/jquote.nvim'

lua << EOF
require("jquote").setup()
EOF

Manual Installation

# Clone the repository
git clone https://github.com/your-username/jquote.nvim.git ~/.config/nvim/lua/jquote

# Or use the Makefile
make install

⚙️ Configuration

Default Configuration

require("jquote").setup({
  hotkey = "<leader>tq",              -- Key binding for quote toggle
  quote_chars = { "'", '"', "`" },    -- Quote characters to cycle through
  jump_behavior = "auto"              -- "auto" or "manual" jump behavior
})

Configuration Options

Option Type Default Description
hotkey string "<leader>tq" Key mapping for toggling quotes
quote_chars table { "'", '"', "" }` List of quote characters to cycle through
jump_behavior string "auto" Jump behavior when cursor is not in quotes ("auto" or "manual")

Custom Configuration Examples

-- Minimal setup with custom hotkey
require("jquote").setup({
  hotkey = "<leader>q"
})

-- Custom quote characters
require("jquote").setup({
  quote_chars = { "'", '"' }  -- Only single and double quotes
})

-- Manual jump behavior
require("jquote").setup({
  jump_behavior = "manual"  -- Don't auto-jump, only toggle quotes at cursor
})

-- Full customization
require("jquote").setup({
  hotkey = "<C-q>",
  quote_chars = { "'", '"', "`", "«", "»" },  -- Including Unicode quotes
  jump_behavior = "auto"
})

🚀 Usage

Basic Usage

  1. Toggle Quotes: Place your cursor inside or on a quoted string and press <leader>tq (or your configured hotkey)
  2. Auto Jump: When cursor is not inside quotes, the plugin automatically jumps to the next quote pair forward

Examples

-- Before: cursor anywhere in 'hello world'
'hello world'

-- After pressing <leader>tq
"hello world"

-- After pressing <leader>tq again
`hello world`

-- After pressing <leader>tq again (cycles back)
'hello world'

Auto Jump Feature

-- Before: cursor at beginning of line
hello 'world' and "test"
^

-- After pressing <leader>tq (auto-jumps to first quote)
hello 'world' and "test"
      ^
-- And toggles the quotes
hello "world" and "test"

Multiple Quote Pairs

-- Works with multiple quote pairs on the same line
print('Hello', "World", `Template`)

-- Handles nested quotes intelligently
outer "inner 'nested' text" end

🔧 Commands and Functions

Available Functions

local jquote = require("jquote")

-- Setup the plugin
jquote.setup(options)

-- Toggle quotes at cursor position
jquote.toggle_quotes()

-- Get current plugin version
local version = jquote.get_version()

-- Get plugin health information
local health = jquote.health()

Health Check

Check plugin status and configuration:

:lua print(vim.inspect(require("jquote").health()))

Output example:

{
  hotkey_configured = true,
  jump_behavior_valid = true,
  options = { ... },
  plugin_version = "1.2.0",
  quote_chars_count = 3
}

🧪 Development

Running Tests

# Run all tests
make test

# Check syntax
make check

# Run development checks (syntax + tests)
make dev-check

# Quick development workflow
make quick

Test Coverage

The plugin includes comprehensive unit tests covering:

  • Plugin initialization and configuration
  • Quote detection and cycling
  • Auto jump functionality
  • Error handling and edge cases
  • Version management
  • Health monitoring
  • Boundary conditions and defensive programming

Project Structure

jquote.nvim/
├── lua/
│   └── jquote/
│       └── init.lua          # Main plugin code
├── tests/
│   ├── init_spec.lua         # Comprehensive test suite
│   ├── test_runner.lua       # Custom test framework
│   └── README.md             # Testing documentation
├── Makefile                  # Development workflow
└── README.md                 # This file

🤝 Contributing

Contributions are welcome! Please ensure:

  1. Code Quality: Follow the established corporate clean code standards
  2. Testing: Add tests for new features and ensure all tests pass
  3. Documentation: Update documentation for any new features or changes

Development Workflow

# Clone the repository
git clone https://github.com/your-username/jquote.nvim.git
cd jquote.nvim

# Run tests
make test

# Check code quality
make check

# Install for local development
make install

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by the need for efficient quote management in Neovim
  • Built with enterprise-grade reliability and comprehensive testing
  • Designed for developer productivity and workflow optimization

📞 Support

If you encounter any issues or have suggestions:

  1. Check the Issues page
  2. Run the health check: :lua print(vim.inspect(require("jquote").health()))
  3. Create a new issue with:
    • Your configuration
    • Health check output
    • Steps to reproduce the problem

Made with ❤️ for the Neovim community