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=
→ suggests4
and2+2 = 4
10*5+3
→ suggests53
and10*5+3 = 53
sqrt(16)
→ suggests4.0
andsqrt(16) = 4.0
sin(3.14159/2)
→ suggests1.0
andsin(3.14159/2) = 1.0
Run the test suite with:
nvim --headless -c "luafile tests/test_calc.lua" -c "qa"
MIT