├── .gitignore ├── .travis.yml ├── HISTORY.md ├── LICENSE.md ├── Makefile ├── README.md ├── autoload └── closer.vim ├── doc └── closer.txt ├── plugin └── closer.vim └── test ├── closer_test.vader ├── endwise └── endwise_test.vader └── javascript_test.vader /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | doc/tags 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | script: make test 3 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | ## v0.2.0 2 | > Sep 28, 2015 3 | 4 | * JavaScript: add semicolons in the file when `'use strict';` is found. 5 | 6 | ## v0.1.2 7 | > Jun 19, 2015 8 | 9 | * Hotfix to actually make the last version's change work. 10 | 11 | ## v0.1.1 12 | > Jun 19, 2015 13 | 14 | * Prevent semicolons in if/else in JavaScript. 15 | 16 | ## v0.1.0 17 | > Jun 3, 2015 18 | 19 | * Initial release. 20 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Rico Sta. Cruz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | vim := vim 2 | 3 | test: test-plain test-endwise 4 | 5 | test-plain: vendor/vimrc 6 | @echo env HOME="$(shell pwd)/vendor" ${vim} -Nu $< +"Vader! test/*" 7 | 8 | test-endwise: vendor/vimrc 9 | @env test_endwise=1 HOME="$(shell pwd)/vendor" ${vim} -Nu $< +"Vader! test/endwise/* test/*" 10 | 11 | vim: vendor/vimrc 12 | @env HOME="$(shell pwd)/vendor" ${vim} -Nu $< 13 | 14 | vendor/vimrc: vendor/vader.vim vendor/vim-endwise 15 | @mkdir -p ./vendor 16 | @echo "filetype off" > $@ 17 | @echo "set rtp+=vendor/vader.vim" >> $@ 18 | @echo "set rtp+=vendor/vim-endwise" >> $@ 19 | @echo "set rtp+=." >> $@ 20 | @echo "filetype plugin indent on" >> $@ 21 | @echo "syntax enable" >> $@ 22 | 23 | vendor/vader.vim: 24 | @mkdir -p ./vendor 25 | @git clone https://github.com/junegunn/vader.vim.git ./vendor/vader.vim 26 | 27 | vendor/vim-endwise: 28 | @mkdir -p ./vendor 29 | @git clone https://github.com/tpope/vim-endwise.git ./vendor/vim-endwise 30 | 31 | .PHONY: test vendor/vimrc doc 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-closer 2 | 3 | **Closes brackets.** Perfect companion to [vim-endwise]. Basically, a more conservative version of [auto-pairs] that only works when you press Enter. 4 | 5 | > NB: This plugin is known to have issues when used with COQ.nvim. See [#37](https://github.com/rstacruz/vim-closer/issues/37). 6 | 7 | ---- 8 | 9 | ![](https://raw.githubusercontent.com/rstacruz/vim-closer/gh-pages/closer.gif) 10 | 11 | ---- 12 | 13 | [![Status](http://img.shields.io/travis/rstacruz/vim-closer/master.svg)](https://travis-ci.org/rstacruz/vim-closer/ "See test builds") 14 | 15 | [auto-pairs]: https://github.com/jiangmiao/auto-pairs 16 | [vim-endwise]: https://github.com/tpope/vim-endwise 17 | 18 |
19 | 20 | ## What 21 | 22 | Closings are automatically inserted after pressing Enter ⏎. It supports languages that have `(`, `[`, and `{` brackets. 23 | 24 | ```css 25 | .section {⏎ 26 | ``` 27 | 28 | ```css 29 | .section { 30 | | 31 | } 32 | ``` 33 | 34 | It tries to automatically figure out whatever braces were opened in the line. This is useful for, say, JavaScript where `});` is commonly seen. 35 | 36 | ```js 37 | describe('test', function () {⏎ 38 | ``` 39 | 40 | ```js 41 | describe('test', function () { 42 | | 43 | }) 44 | ``` 45 | 46 | Semicolons are automatically added if it makes sense, and only if another line in the buffer ends in `;`. 47 | 48 | ```js 49 | var x = 1; 50 | setImmediate(function () {⏎ 51 | ``` 52 | 53 | ```js 54 | var x = 1; 55 | setImmediate(function () { 56 | | 57 | }); 58 | ``` 59 | 60 |
61 | 62 | ## Install 63 | 64 | When using [vim-plug], add this to your `~/.vimrc`: 65 | 66 | [vim-plug]: https://github.com/junegunn/vim-plug 67 | 68 | ```vim 69 | Plug 'rstacruz/vim-closer' 70 | ``` 71 | 72 |
73 | 74 | ## By the way 75 | 76 | Do you edit CSS often? Of course you do. Let me help you make that [a better experience.](http://ricostacruz.com/vim-hyperstyle/) 77 | 78 |
79 | 80 | ## Thanks 81 | 82 | **vim-closer** © 2015+, Rico Sta. Cruz. Released under the [MIT] License.
83 | Authored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]). 84 | 85 | > [ricostacruz.com](http://ricostacruz.com)  ·  86 | > GitHub [@rstacruz](https://github.com/rstacruz)  ·  87 | > Twitter [@rstacruz](https://twitter.com/rstacruz) 88 | 89 | [MIT]: http://mit-license.org/ 90 | [contributors]: http://github.com/rstacruz/vim-closer/contributors 91 | -------------------------------------------------------------------------------- /autoload/closer.vim: -------------------------------------------------------------------------------- 1 | if exists("g:closer_autoloaded") | finish | endif 2 | let g:closer_autoloaded=1 3 | 4 | if maparg("CloserClose") == "" 5 | inoremap CloserClose =closer#close() 6 | imap