Skip to content

feat: Add lualine integration and enhanced per-buffer IM management#39

Open
itshare4u wants to merge 7 commits intokeaising:masterfrom
itshare4u:feature/lualine-integration-pr
Open

feat: Add lualine integration and enhanced per-buffer IM management#39
itshare4u wants to merge 7 commits intokeaising:masterfrom
itshare4u:feature/lualine-integration-pr

Conversation

@itshare4u
Copy link
Copy Markdown

🚀 New Features

This PR adds comprehensive lualine integration and enhanced per-buffer input method management.

✨ 1. Lualine Component Integration

A new lualine component that shows which input method will be used when entering insert mode:

  • Always visible: Shows IM info even in normal mode
  • Context-aware: Different display for each buffer/window
  • No fallback assumptions: Only shows when context is actually known
  • Customizable: Colors, icons, and display can be configured

Basic Usage:

require('lualine').setup {
    sections = {
        lualine_c = { 
            'filename',
            require('im_select.lualine').get_component()
        },
    }
}

Advanced Usage:

require('lualine').setup {
    sections = {
        lualine_x = { 
            require('im_select.lualine').get_component({
                color_english = { fg = "#98be65", gui = "bold" },
                color_other = { fg = "#ECBE7B", gui = "bold" },
                icon = "⌨️",
            })
        },
    }
}

🔧 2. Enhanced IM Context Management

Display Name Storage

  • Automatically converts IM identifiers to readable display names (EN, VI, CN, JP, etc.)
  • Stores both raw IM and display name for performance
  • Single source of truth for display logic

Improved Per-Buffer Management

  • Better priority: Buffer pinned > Buffer > Window
  • Consistent storage: Both vim.b.im_select_context and vim.b.im_select_display_name
  • Enhanced pin command: Shows both display name and raw IM identifier

📁 Files Added/Modified

New Files:

  • lua/im_select/lualine.lua - Lualine component implementation
  • examples/lualine_config.lua - Usage examples and configurations

Modified Files:

  • lua/im_select.lua - Added display name logic and enhanced storage
  • README.md - Comprehensive lualine integration documentation

🎯 Benefits

For Users:

  • Preview IM: Know which language you'll type before entering insert mode
  • Visual feedback: Clear indication in statusline with colors and icons
  • Per-context awareness: Each buffer remembers its own input method
  • No surprises: Only shows reliable information, no guessing

For Developers:

  • Clean architecture: Separation between core logic and UI display
  • Extensible: Easy to add new IM support or customize display
  • Performance: Cached display names, no repeated conversions
  • Maintainable: Single place to modify display logic

🧪 Testing

Tested extensively on macOS with:

  • Vietnamese input method (com.apple.inputmethod.VietnameseIM.VietnameseSimpleTelex)
  • Multiple buffers and windows
  • Buffer pinning scenarios
  • Lualine integration in various sections

📚 Usage Examples

Display shows context-aware IM:

  • Buffer with Vietnamese context → ⌨️ VI
  • Buffer with English context → ⌨️ EN
  • New buffer with no context → (nothing displayed)
  • Pinned buffer → Always shows pinned IM

🔄 Backward Compatibility

  • All existing functionality preserved
  • No breaking changes to existing configurations
  • Lualine integration is completely optional
  • Enhanced commands are additive only

💡 Implementation Highlights

  1. Smart Context Detection: Uses same priority logic as core IM switching
  2. Performance Optimized: Display names cached at source, lualine just reads
  3. Cross-platform: Works with macOS, Windows, WSL, and Linux IM systems
  4. User-friendly: Clear visual feedback without cluttering the interface

This enhancement makes im-select.nvim much more user-friendly for multilingual workflows while maintaining its reliability and performance.

- Add lualine component to show IM that will be used in insert mode
- Display name is computed and stored by im_select.lua for consistency
- Component shows context-aware IM: buffer pinned > buffer > window
- Add get_display_name() function to convert IM identifiers to readable names
- Store display names in vim.b.im_select_display_name and vim.w.im_select_display_name
- Support customizable colors and icons in lualine component
- Add comprehensive examples and documentation
- Component only displays when context is available (no fallback assumptions)

Files:
- lua/im_select.lua: Add display name logic and storage
- lua/im_select/lualine.lua: Lualine component implementation
- examples/lualine_config.lua: Usage examples
- README.md: Documentation for lualine integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant