weirongxu / coc-calc

Calculate extension for coc.nvim
MIT License
80 stars 1 forks source link
calc calculate coc coc-nvim mathematics neovim nvim vim

coc-calc

coc-calc
Build Status
Calculate extension for coc.nvim

Features

screenshot

Usage

  1. Install by coc.nvim command:
    :CocInstall coc-calc
  2. Input calculate expression in any buffer
    sin(PI / 2) =

Commands

Keymaps

Create keymappings like:

" append result on current expression
nmap <Leader>ca <Plug>(coc-calc-result-append)
" replace result on current expression
nmap <Leader>cr <Plug>(coc-calc-result-replace)

Configurations

Vim API

calc.calculate

let result = CocAction('runCommand', 'calc.calculate', '1.5 * PI')

Operators

Precedence is from highest to lowest.

Operator Example
exponentiation ** 4 ** 3 ** 2 equivalent to 4 ** (3 ** 2)
unary + - -2 +2
multiply / divide / remainder * / % 4 % 3 4 * 3
addition / subtraction .2 - .1 .1 + .2

Mathematics Constant

Mathematics Functions

abs, acos, acosh, add, asin,
asinh, atan, atanh, atan2, cbrt
ceil, cos, cosh, div, exp,
floor, hypot, ln, log, log2,
log10, max, min, mod, mul,
pow, random, round, sign, sin,
sinh, sqrt, sub, tan, tanh, trunc

Details: http://mikemcl.github.io/decimal.js/#methods

License

MIT