├── README.md ├── ftdetect └── brainfuck.vim ├── indent └── brainfuck.vim ├── license └── syntax └── brainfuck.vim /README.md: -------------------------------------------------------------------------------- 1 | # Vim Brainfuck 2 | 3 | Brainfuck syntax highlight plugin for vim. 4 | 5 | ![Example](https://i.imgur.com/GhUxNkP.png) 6 | 7 | ## Installation 8 | 9 | ### Vundle 10 | 11 | In case if you are using [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim) just add this to your `~/.vimrc` 12 | ```vim 13 | Plugin 'llathasa-veleth/vim-brainfuck' 14 | ``` 15 | Then do either this: 16 | ```sh 17 | vim +PluginInstall 18 | ``` 19 | or, while in **vim** do: 20 | ```vim 21 | :PluginInstall 22 | ``` 23 | 24 | ### Plug 25 | 26 | If you prefer [junegunn/vim-plug](https://github.com/junegunn/vim-plug), add this to `~/.vimrc` 27 | ```vim 28 | Plug 'llathasa-veleth/vim-brainfuck' 29 | ``` 30 | Then do either this: 31 | ```sh 32 | vim +PlugInstall 33 | ``` 34 | or, while in **vim** do: 35 | ```vim 36 | :PlugInstall 37 | ``` 38 | 39 | ### Other methods 40 | 41 | | **Plugin Manager** | **How to install** | 42 | |------------------------------------------------------ |---------------------------------------------------------------------------------------------- | 43 | | [Pathogen](https://github.com/tpope/vim-pathogen) | Run `git clone https://github.com/llathasa-veleth/vim-brainfuck ~/.vim/bundle/vim-brainfuck` | 44 | | [NeoBundle](https://github.com/Shougo/neobundle.vim) | `NeoBundle 'llathasa-veleth/vim-brainfuck'` | 45 | | [dein](https://github.com/Shougo/dein.vim) | `call dein#add('llathasa-veleth/vim-brainfuck')` | 46 | | [minpac](https://github.com/k-takata/minpac/) | `call minpac#add('llathasa-veleth/vim-brainfuck')` | 47 | 48 | 49 | ## TODO List 50 | 51 | - [x] [Fast Interpreter](https://github.com/llathasa-veleth/brainfuck). 52 | - [x] Automatic indentation (folding function). 53 | - [x] Syntax highlights. 54 | - [ ] *? Multiline comments*. 55 | 56 | ## Version history 57 | 58 | - **`2.1.0`** - *Removed multiline comments due to unsolved problems.* 59 | - **`2.0.0`** - **Bracket folding added.** 60 | - **`1.2.0`** - *Testing brackets folding function.* 61 | - **`1.1.1`** - *Multiline comments now support TODO, FIXME, etc.* 62 | - **`1.1.0`** - *Changed highlight colors.* 63 | - **`1.0.0`** - *Initial version.* 64 | -------------------------------------------------------------------------------- /ftdetect/brainfuck.vim: -------------------------------------------------------------------------------- 1 | " Name: vim-brainfuck 2 | " Author: veleth 3 | " Version: 2.1.0 4 | " 5 | " vim-brainfuck 6 | " ├─ ftdetect 7 | " │ └─ brainfuck.vim <- 8 | " ├─ syntax 9 | " │ └─ brainfuck.vim 10 | " └─ indent 11 | " └─ brainfuck.vim 12 | " Filetype detect 13 | """""""""""""""""""""""""""""""""""""""""""" 14 | au BufNewFile,BufRead *.bf,*.brainfuck set filetype=brainfuck 15 | -------------------------------------------------------------------------------- /indent/brainfuck.vim: -------------------------------------------------------------------------------- 1 | " Name: vim-brainfuck 2 | " Author: veleth 3 | " Version: 2.1.0 4 | " 5 | " ├─ ftdetect 6 | " │ └─ brainfuck.vim 7 | " ├─ syntax 8 | " │ └─ brainfuck.vim 9 | " └─ indent 10 | " └─ brainfuck.vim <- 11 | " Indentation 12 | """""""""""""""""""""""""""""""""""""""""""" 13 | if exists("b:did_indent") 14 | finish 15 | endif 16 | let b:did_indent = 1 17 | setlocal nolisp 18 | setlocal autoindent 19 | setlocal indentexpr=BrainfuckIndentation(v:lnum) 20 | let s:cpo_save = &cpo 21 | set cpo&vim 22 | function! BrainfuckIndentation(lnum) abort 23 | let previous_line_number = prevnonblank(a:lnum-1) 24 | if previous_line_number == 0 25 | return 0 26 | endif 27 | let previous_line = substitute(getline(previous_line_number), '//.*$', '', '') 28 | let current_line = substitute(getline(a:lnum), '//.*$', '', '') 29 | let previous_indent = indent(previous_line_number) 30 | let indentation = previous_indent 31 | if previous_line =~ '\[\s*$' 32 | let indentation += shiftwidth() 33 | endif 34 | if current_line =~ '^\s*\]' 35 | let indentation -= shiftwidth() 36 | endif 37 | return indentation 38 | endfunction 39 | let &cpo = s:cpo_save 40 | unlet s:cpo_save 41 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /syntax/brainfuck.vim: -------------------------------------------------------------------------------- 1 | " Name: vim-brainfuck 2 | " Author: veleth 3 | " Version: 2.1.0 4 | " 5 | " vim-brainfuck 6 | " ├─ ftdetect 7 | " │ └─ brainfuck.vim 8 | " ├─ syntax 9 | " │ └─ brainfuck.vim <- 10 | " └─ indent 11 | " └─ brainfuck.vim 12 | " Syntax highlight 13 | """""""""""""""""""""""""""""""""""""""""""" 14 | " Match TODO comments 15 | syn keyword bf_todo 16 | \ TODO 17 | \ FIXME 18 | \ NOTE 19 | \ ToDo 20 | \ FixMe 21 | \ Note 22 | 23 | " Match brackets 24 | syn match bf_brackets /[\[\]]/ 25 | 26 | " Match plus and minus signs 27 | syn match bf_byte /[\+-]/ 28 | 29 | " Match IO operators 30 | syn match bf_io /[\.,]/ 31 | 32 | " Match data pointer increment/decrement operators 33 | syn match bf_cell /[><]/ 34 | 35 | " Match comments 36 | syn match bf_comment /!.*/ contains=bf_todo 37 | " syn region bf_comment_multiline start=/\/\*/ end=/\*\// contains=bf_todo 38 | 39 | " Higlight 40 | hi def link bf_todo Conditional 41 | hi def link bf_brackets Conditional 42 | hi def link bf_byte Operator 43 | hi def link bf_io String 44 | hi def link bf_cell Delimiter 45 | hi def link bf_comment Comment 46 | " hi def link bf_comment_multiline Comment 47 | 48 | let b:current_syntax='brainfuck' 49 | --------------------------------------------------------------------------------