A blink.cmp source for basic math calculations, similar to cmp-calc.
- 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
=)
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',
},
},
},
},
}Simply type a mathematical expression and the completion menu will show the result:
2+2=→ suggests4and2+2 = 410*5+3→ suggests53and10*5+3 = 53sqrt(16)→ suggests4.0andsqrt(16) = 4.0sin(3.14159/2)→ suggests1.0andsin(3.14159/2) = 1.0
Run the test suite with:
nvim --headless -c "luafile tests/test_calc.lua" -c "qa"MIT