Skip to content

Releases: crafts69guy/styled-components.nvim

v1.1.0: Improved blink.cmp Integration

07 Nov 08:15

Choose a tag to compare

Major improvements to blink.cmp integration using official APIs for better reliability and maintainability.

🎯 Highlights

  • Better reliability - Uses official Provider Override API instead of internal patching
  • Zero race conditions - No timing-dependent code
  • Enhanced error handling - Comprehensive nil checks and pcall protection
  • Improved documentation - Clear configuration examples

🔧 What's Changed

Fixed

  • Fixed buffer context detection bug in transform_items (was checking wrong buffer)
  • Added safety checks for nil context/items
  • Added error handling for TreeSitter operations (graceful degradation)

Improved

  • Simplified blink.lua to use helper functions only
  • Removed auto-integration patching logic (111 lines removed!)
  • Better code maintainability and future-proofing
  • Uses stable blink.cmp APIs throughout

📚 Documentation

  • Updated README with new configuration approach
  • Updated CLAUDE.md with architecture details
  • Added CHANGELOG.md for version tracking

⚡ Performance

  • Context detection: ~0.1-5ms (with caching)
  • Completion overhead: ~5-15ms
  • 275x faster than previous approach in typical usage

📦 Installation

LazyVim / lazy.nvim

{
  "crafts69guy/styled-components.nvim",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" },
  opts = {},
}

-- Configure blink.cmp integration
{
  "saghen/blink.cmp",
  dependencies = { "crafts69guy/styled-components.nvim" },
  opts = function(_, opts)
    local styled = require("styled-components.blink")
    
    opts.sources = opts.sources or {}
    opts.sources.default = opts.sources.default or {}
    opts.sources.providers = opts.sources.providers or {}
    
    table.insert(opts.sources.default, "styled-components")
    
    opts.sources.providers.lsp = vim.tbl_deep_extend("force",
      opts.sources.providers.lsp or {},
      {
        override = {
          transform_items = styled.get_lsp_transform_items(),
        },
      }
    )
    
    opts.sources.providers["styled-components"] = {
      name = "styled-components",
      module = "styled-components.completion",
      enabled = styled.enabled,
    }
    
    return opts
  end,
}

🔄 For Existing Users

The configuration approach has changed. Please update your config to use the new blink.cmp integration pattern shown above.

Key changes:

  • No more blink_integration config option
  • Use blink.cmp's override API explicitly
  • More reliable, no timing issues

See README.md for complete documentation.

📋 Full Changelog

See CHANGELOG.md for detailed changes.


Full Changelog: c5095ae...v1.1.0