Skip to content

joelazar/blink-calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

blink-calc

A blink.cmp source for basic math calculations, similar to cmp-calc.

Features

  • Evaluates mathematical expressions in real-time as you type
  • Supports basic arithmetic operations: +, -, *, /
  • Supports parentheses for complex expressions
  • Supports Lua's math library functions (sin, cos, sqrt, etc.)
  • Provides two completion options:
    • Just the result
    • Expression with result (when typing with =)

Installation

Using lazy.nvim

{
  'saghen/blink.cmp',
  dependencies = { { "joelazar/blink-calc" } },
  opts = {
    sources = {
      default = { 'lsp', 'path', 'snippets', 'buffer', 'calc' },
      providers = {
        calc = {
          name = 'Calc',
          module = 'blink-calc',
        },
      },
    },
  },
}

Usage

Simply type a mathematical expression and the completion menu will show the result:

  • 2+2= → suggests 4 and 2+2 = 4
  • 10*5+3 → suggests 53 and 10*5+3 = 53
  • sqrt(16) → suggests 4.0 and sqrt(16) = 4.0
  • sin(3.14159/2) → suggests 1.0 and sin(3.14159/2) = 1.0

Testing

Run the test suite with:

nvim --headless -c "luafile tests/test_calc.lua" -c "qa"

License

MIT

About

blink.cmp source for math calculation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages