├── .gitignore ├── test ├── filetype.vader ├── vimrc_test ├── user_variables.vader ├── .vimrc_test ├── command.vader ├── append_type.vader ├── ranges.vader ├── line.vader └── operator.vader ├── .travis.yml ├── .circleci └── config.yml ├── .gitattributes ├── LICENSE.txt ├── Makefile ├── plugin └── crunch.vim ├── README.md ├── doc └── crunch.txt └── autoload └── crunch.vim /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /test/filetype.vader: -------------------------------------------------------------------------------- 1 | Before: 2 | set filetype=vim 3 | After: 4 | set filetype= 5 | ------------------------------------------------------------------------------ 6 | Given: 7 | " 5*5 8 | Do: 9 | g== 10 | Expect: 11 | " 5*5 = 25 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: vim 2 | 3 | before_script: | 4 | sudo make setup 5 | 6 | git clone https://github.com/vim/vim 7 | cd vim 8 | ./configure --with-features=huge 9 | make 10 | sudo make install 11 | cd - 12 | 13 | script: make 14 | -------------------------------------------------------------------------------- /test/vimrc_test: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | 3 | filetype off 4 | 5 | execute 'set runtimepath+=build/vader.vim' 6 | execute 'set runtimepath+=build/selection.vim' 7 | execute 'set runtimepath+=../crunch.vim' 8 | set runtimepath+=. 9 | 10 | filetype plugin indent on 11 | syntax enable 12 | set nomore 13 | -------------------------------------------------------------------------------- /test/user_variables.vader: -------------------------------------------------------------------------------- 1 | Before: 2 | let g:crunch_user_variables = {'foo': 123, 'bar':456} 3 | Given: 4 | foo * bar 5 | sin(foo)pow(bar,2) 6 | Execute (variables): 7 | let g:selection_mode="V" 8 | %Crunch 9 | Expect: 10 | foo * bar = 56088 11 | sin(foo)pow(bar,2) = -95630.49224 12 | After: 13 | unlet g:crunch_variables 14 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/python:3.7 6 | steps: 7 | - checkout 8 | - run: | 9 | sudo make setup 10 | git clone https://github.com/vim/vim 11 | cd vim 12 | ./configure --with-features=huge 13 | make 14 | sudo make install 15 | cd - 16 | 17 | - run: make 18 | -------------------------------------------------------------------------------- /test/.vimrc_test: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | 3 | let s:hasWindows = has("win16") || has("win32") || has("win64") 4 | if s:hasWindows 5 | let s:vimpath = $HOME."/vimfiles" 6 | cd $HOME "start in home directory, this is just here for convince 7 | else 8 | let s:vimpath = $HOME."/.vim" 9 | endif 10 | 11 | filetype off 12 | 13 | execute "set rtp+=".s:vimpath."/bundle/vader.vim" 14 | execute "set rtp+=".s:vimpath."/bundle/crunch.vim" 15 | execute "set rtp+=".s:vimpath."/bundle/selection.vim" 16 | set rtp+=. 17 | 18 | filetype plugin indent on 19 | syntax enable 20 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | 3 | # Custom for Visual Studio 4 | *.cs diff=csharp 5 | *.sln merge=union 6 | *.csproj merge=union 7 | *.vbproj merge=union 8 | *.fsproj merge=union 9 | *.dbproj merge=union 10 | 11 | # Standard to msysgit 12 | *.doc diff=astextplain 13 | *.DOC diff=astextplain 14 | *.docx diff=astextplain 15 | *.DOCX diff=astextplain 16 | *.dot diff=astextplain 17 | *.DOT diff=astextplain 18 | *.pdf diff=astextplain 19 | *.PDF diff=astextplain 20 | *.rtf diff=astextplain 21 | *.RTF diff=astextplain 22 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: lint test 2 | 3 | # use a platform in depended path separator 4 | ifdef ComSpec 5 | PATHSEP2=\\ 6 | else 7 | PATHSEP2=/ 8 | endif 9 | PATHSEP=$(strip $(PATHSEP2)) 10 | 11 | .PHONY: setup 12 | setup: 13 | apt install python3-pip 14 | python3 -m pip install vim-vint 15 | mkdir build 16 | git clone https://github.com/junegunn/vader.vim.git build/vader.vim 17 | git clone https://github.com/arecarn/selection.vim.git build/selection.vim 18 | 19 | .PHONY: clean 20 | clean: 21 | git clean -x -d --force 22 | 23 | .PHONY: lint 24 | lint: 25 | vint plugin/*.vim autoload/*.vim 26 | 27 | .PHONY: test 28 | test: 29 | vim -Nu test/vimrc_test -c 'Vader! test/*.vader' 30 | -------------------------------------------------------------------------------- /test/command.vader: -------------------------------------------------------------------------------- 1 | Before: 2 | redir => g:MsgOutputGot 3 | Execute (Test Commandline Input #1): 4 | let g:MsgOutputExpect = "\n5*5 = 25\nYanked Result" 5 | Crunch 5*5 6 | After: 7 | redir END 8 | AssertEqual g:MsgOutputExpect, g:MsgOutputGot 9 | ------------------------------------------------------------------------------ 10 | Before: 11 | Do (Test Commandline Input #1): 12 | p 13 | Expect (): 14 | 25 15 | After: 16 | ############################################################################## 17 | Before: 18 | redir => g:MsgOutputGot 19 | Execute (Test Commandline Input #2): 20 | let g:MsgOutputExpect = "\nsin(5*5) = -0.132352\nYanked Result" 21 | Crunch sin(5*5) 22 | After: 23 | redir END 24 | AssertEqual g:MsgOutputExpect, g:MsgOutputGot 25 | ------------------------------------------------------------------------------ 26 | Before: 27 | Do (Test Commandline Input #2): 28 | p 29 | Expect (): 30 | -0.132352 31 | After: 32 | -------------------------------------------------------------------------------- /plugin/crunch.vim: -------------------------------------------------------------------------------- 1 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2 | " Original Author: Ryan Carney 3 | " License: WTFPL 4 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 5 | 6 | " BOILER PLATE {{{ 7 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 8 | let s:save_cpo = &cpo 9 | set cpo&vim 10 | 11 | if exists('g:loaded_crunch') 12 | finish 13 | else 14 | let g:loaded_crunch = 1 15 | endif 16 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}} 17 | 18 | " GLOBALS {{{ 19 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 20 | let g:crunch_prompt = get(g:, 'crunch_prompt', 'Calc >> ') 21 | let g:crunch_comment = get(g:, 'crunch_comment', '"') 22 | let g:crunch_user_variables = get(g:, 'crunch_user_variables', {}) 23 | let g:crunch_result_type_append = get(g:, 'crunch_result_type_append', 1) 24 | let g:crunch_precision = get(g:, 'crunch_precision', 6) 25 | let g:util_debug = get(g:, 'util_debug', 0) 26 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}} 27 | 28 | " COMMANDS {{{ 29 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 30 | command! -nargs=* -range=0 -bang Crunch 31 | \ call crunch#command(, , , , "") 32 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}} 33 | 34 | " MAPPINGS {{{ 35 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 36 | nnoremap