Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weirongxu/coc-calc
Calculate extension for coc.nvim
https://github.com/weirongxu/coc-calc
calc calculate coc coc-nvim mathematics neovim nvim vim
Last synced: 6 days ago
JSON representation
Calculate extension for coc.nvim
- Host: GitHub
- URL: https://github.com/weirongxu/coc-calc
- Owner: weirongxu
- License: mit
- Created: 2019-05-14T07:25:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-19T07:18:09.000Z (2 months ago)
- Last Synced: 2025-01-12T01:09:44.350Z (13 days ago)
- Topics: calc, calculate, coc, coc-nvim, mathematics, neovim, nvim, vim
- Language: TypeScript
- Homepage:
- Size: 404 KB
- Stars: 80
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# coc-calc
Calculate extension for coc.nvim## Features
- Support underscores in numbers `10_000_000`
- Support bignumber, use [decimal.js](https://github.com/MikeMcl/decimal.js)
- Support [Mathematics functions](http://mikemcl.github.io/decimal.js/#methods)![screenshot](https://user-images.githubusercontent.com/1709861/65944119-9ab59f00-e463-11e9-886f-11513a8e01c9.gif)
## Usage
1. Install by coc.nvim command:
```
:CocInstall coc-calc
```
2. Input calculate expression in any buffer
```
sin(PI / 2) =
```## Commands
- `calc.appendWithCursor` Calculate and append in front of cursor
- `calc.append` Calculate and append
- `calc.replaceWithCursor` Calculate and replace in front of cursor
- `calc.replace` Calculate and replace
- `calc.calculate` see Vim API## Keymaps
Create keymappings like:
```vim
" append result on current expression
nmap ca (coc-calc-result-append)
" replace result on current expression
nmap cr (coc-calc-result-replace)
```## Configurations
- `calc.priority`, calc priority, default: `1000`
- `calc.highlight`, enable calc highlight, default: `true`## Vim API
### calc.calculate
```vim
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
- `E`
- `PI`## 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