diff options
| author | Ben Beltran <ben@nsovocal.com> | 2019-03-14 23:19:58 +0100 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2019-03-14 23:19:58 +0100 |
| commit | b009b50e81b6c1d0d691505b5f5c0418f559bfc0 (patch) | |
| tree | 5fae800e76219eba28634cb236565f9b4bb7a2f7 /atom/packages/vim-surround | |
| parent | 4efcafab7f0aa454f9ebe767133654bc9f44e12c (diff) | |
Remove Atom config
Diffstat (limited to 'atom/packages/vim-surround')
| -rw-r--r-- | atom/packages/vim-surround/.npmignore | 3 | ||||
| -rw-r--r-- | atom/packages/vim-surround/.travis.yml | 11 | ||||
| -rw-r--r-- | atom/packages/vim-surround/CHANGELOG.md | 61 | ||||
| -rw-r--r-- | atom/packages/vim-surround/LICENSE.md | 20 | ||||
| -rw-r--r-- | atom/packages/vim-surround/README.md | 121 | ||||
| -rw-r--r-- | atom/packages/vim-surround/keymaps/surround.cson | 7 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/base.coffee | 59 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/change.coffee | 74 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/delete.coffee | 33 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/selector.coffee | 24 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/surround.coffee | 18 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/vim-surround.coffee | 45 | ||||
| -rw-r--r-- | atom/packages/vim-surround/package.json | 51 | ||||
| -rw-r--r-- | atom/packages/vim-surround/spec/spec-helper.coffee | 13 | ||||
| -rw-r--r-- | atom/packages/vim-surround/spec/vim-surround-spec.coffee | 72 |
15 files changed, 0 insertions, 612 deletions
diff --git a/atom/packages/vim-surround/.npmignore b/atom/packages/vim-surround/.npmignore deleted file mode 100644 index ade14b9..0000000 --- a/atom/packages/vim-surround/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -npm-debug.log -node_modules diff --git a/atom/packages/vim-surround/.travis.yml b/atom/packages/vim-surround/.travis.yml deleted file mode 100644 index d73c8e2..0000000 --- a/atom/packages/vim-surround/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: objective-c - -notifications: - email: - on_success: never - on_failure: change - -script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' - -git: - depth: 10 diff --git a/atom/packages/vim-surround/CHANGELOG.md b/atom/packages/vim-surround/CHANGELOG.md deleted file mode 100644 index b093333..0000000 --- a/atom/packages/vim-surround/CHANGELOG.md +++ /dev/null @@ -1,61 +0,0 @@ -## 0.8.0 -* Tentative support for - [vim-mode-next](https://atom.io/packages/vim-mode-next). See - [#28](https://github.com/gepoch/vim-surround/issues/28). - -## 0.7.4 -* Bugfixes. - -## 0.7.3 -* Fixed problems cause by vim-mode changing "command-mode" to "normal-mode". - -## 0.7.1 -* Propagate README changes. - -## 0.7.0 -* Change surround and delete surround implemented. Thanks to @shemerey :D ! - -## 0.6.1 -* Fixed keymap -> keymaps change. [vim-surround #19](https://github.com/gepoch/vim-surround/issues/19) - -## 0.6.0 -* Upgraded to new config schema. General restructuring. - -## 0.5.1 -* Handle undefined values in config. - -## 0.5.0 -* Configurable surround key to support muscle memory in response to [vim-surround #12](https://github.com/gepoch/vim-surround/issues/12) - -## 0.4.3 -* Fixed bug [vim-surround #13](https://github.com/gepoch/vim-surround/issues/13) - - -## 0.4.2 -* Fixed bug [vim-surround #11](https://github.com/gepoch/vim-surround/issues/11) -* Readme updates. - -## 0.4.1 -* Renamed the dynamic keybindings to match the package name. -* Added some tests. -* Poked the README. - -## 0.4.0 -* Multiple cursor support. - -## 0.3.0 -* Updated for Atom API v1.0.0 changes. - -## 0.2.3 -* Fixed bug: [vim-surround #5](https://github.com/gepoch/vim-surround/issues/5) - -## 0.2.0 - Activation and Keybindings Improved. -* Keybindings are now dynamically generated from the configured pairs. No more - user keybindings changes necessary! -* Activation is now on atom boot since keybindings are now dynamic and - impossible to predict for the purposes of activation events. -* Fixed bug where surround action did not exit visual mode. - -## 0.1.0 - First Release -* Every feature added -* Every bug fixed diff --git a/atom/packages/vim-surround/LICENSE.md b/atom/packages/vim-surround/LICENSE.md deleted file mode 100644 index 9e77889..0000000 --- a/atom/packages/vim-surround/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 George Marchin - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/atom/packages/vim-surround/README.md b/atom/packages/vim-surround/README.md deleted file mode 100644 index 0418831..0000000 --- a/atom/packages/vim-surround/README.md +++ /dev/null @@ -1,121 +0,0 @@ -# Vim Surround for Atom [](https://travis-ci.org/gepoch/vim-surround) - -Surround is an implementation of vim-surround for the [atom](http://atom.io) -editor, creating a vim-surround with the power of Atom! - -You should definitely have [vim-mode](https://atom.io/packages/vim-mode) for -this package to function properly, of course. - -Inspiration from and kudos to the wonderful [vim-surround for -vim](https://github.com/tpope/vim-surround) - -See vim-surround on [github](https://github.com/gepoch/vim-surround) or -[atom.io](https://atom.io/packages/vim-surround). - -## News - -* This package supports visual mode's `s )` set of commands for a configurable - set of pairs. - -* Next on the roadmap are pair deletions with `d )` and friends. - -* New in 0.4: Multiple cursors are now supported, and conveniently work just - like you think they do. - -* New in 0.5: Stable configuration changes and configurable surround key! - -* New in 0.7: Change surround and delete surround added. - -* New in 0.8: Tentative support for - [vim-mode-next](https://atom.io/packages/vim-mode-next). See - [#28](https://github.com/gepoch/vim-surround/issues/28). - -### Muscle Memory Compatability Note - -vim-surround uses a lowercase `s` instead of `S` for surround commands! This is -configurable in the package settings, if you would like to set it to the -original keybinding. - -## How to use Surround - -### Surrounding - -For double quotes, highlight the string in visual mode and enter `s "`. - -``` -Hello world -> "Hello world" -``` - -For parentheses there are two options. `s )` will surround as normal. `s (` -will pad with a space. All asymmetrical pairs have the secondary space-padded -form. - -For example: - -`s )` - -``` -Hello world -> (Hello world) -``` - -`s (` - -``` -Hello world -> ( Hello world ) -``` - -### Changing Surrounding Pairs - -Suppose I want to make double quotes into single quotes. To do this, I should -put my cursor inside the double quotes in question and enter `c s " '` - -``` -"Hello world" -> 'Hello world' -``` - -### Deleting Surrounding Pairs - -To delete the single quotes, place your cursor inside of them and enter `d s '` - -``` -'Hello world' -> Hello world -``` -### Configuration - -Currently, the following pairs work out of the box!: - -- () -- [] -- {} -- "" -- '' - -You can add to the available pairs in atom's settings, and the commands will -be dynamically added to your keybindings. - -For example if I'm working on Jinja templates, and I want to add the ability to -surround using `{%` and `%}` I would add this in my settings: - -``` -(), [], {}, "", '', {%%} -``` - -Then: - -`s % }` - -``` -Hello world -> {%Hello world%} -``` - -`s { %` - -``` -Hello world -> {% Hello world %} -``` - -### TODO - -- [x] Implement deleting surrounding pairs with `d s` -- [x] Implement changing surrounding pairs with `c s` -- [ ] Intelligent tag surrounding/deleting/replacing with `s <q>` and friends. diff --git a/atom/packages/vim-surround/keymaps/surround.cson b/atom/packages/vim-surround/keymaps/surround.cson deleted file mode 100644 index 5de6766..0000000 --- a/atom/packages/vim-surround/keymaps/surround.cson +++ /dev/null @@ -1,7 +0,0 @@ -# OOPS! Good job with your dilligent hunting, but vim-surround's keybindings -# are actually completely dynamic, so it doesn't use this file.... So I'll use -# this as a guest book. Send me a PR! - -# # OFFICIAL VIM-SURROUND GUEST BOOK :+1: - -# George Marchin ~ Hi Mom! diff --git a/atom/packages/vim-surround/lib/command/base.coffee b/atom/packages/vim-surround/lib/command/base.coffee deleted file mode 100644 index b40e644..0000000 --- a/atom/packages/vim-surround/lib/command/base.coffee +++ /dev/null @@ -1,59 +0,0 @@ -{CompositeDisposable} = require 'atom' - -module.exports = class Base - - constructor: (config) -> - @disposables = new CompositeDisposable - - @curPairs = [] - @registerPairs config.pairs - - registerPairs: (pairs) -> - pairs = (x for x in pairs when x.length > 0 and x.length %2 == 0) - - for pair in pairs - if pair not in @curPairs - @registerPair pair - @curPairs.push(pair) - - registerPair: (pair) -> - [left, right] = @splitPair(pair) - - if left != right - @createPairBindings left, "#{left} ", " #{right}" - @createPairBindings right, left, right - - createPairBindings: (key, left, right) -> - name = "vim-surround:#{@getName key}" - - # First, we add a command to the system to actually perform the surround. - # We attach the disposable to our object's list. - @disposables.add atom.commands.add @context, name, @getRunner left, right - - # Next, we build up keybindings for our command. First, we build a - # space-delineated version of our key that's passed in. This breaks up - # double keys like `{%` into the seperate keystroke form: `{ %` - keys = "" - for i in [0..key.length-1] - if i == 0 - keys = key[i] - else - keys = "#{keys} #{key[i]}" - - # Making a one-command keymap data structure here. Basically: - # "atom-text-editor.vim-mode.visual-mode": - # "s (": - # "vim-surround:surround-(" - - keymapArg = {} - fullCommand = "#{@command} #{keys}" - keymapArg[fullCommand] = name - - contextArg = {} - contextArg[@context] = keymapArg - - # Capture the disposable heretom test! - @disposables.add atom.keymaps.add name, contextArg - - splitPair: (pair) -> - return [pair[..(pair.length/2)-1], pair[pair.length/2..]] diff --git a/atom/packages/vim-surround/lib/command/change.coffee b/atom/packages/vim-surround/lib/command/change.coffee deleted file mode 100644 index 7bdf623..0000000 --- a/atom/packages/vim-surround/lib/command/change.coffee +++ /dev/null @@ -1,74 +0,0 @@ -{CompositeDisposable} = require 'atom' - -Base = require './base' -Selector = require './selector' - -module.exports = class Change - constructor: (config) -> - @command = config.changeSurroundCommand - @context = "atom-text-editor.vim-mode.normal-mode" - @disposables = new CompositeDisposable - @curPairs = [] - @curPairsWithTarget = [] - @registerPairs config.pairs - - getName: (key, targetKey) -> "change-#{key}-to-#{targetKey}" - - registerPairs: (pairs) -> - pairs = (x for x in pairs when x.length > 0 and x.length %2 == 0) - - for pair in pairs - for target in pairs - if "#{pair}#{target}" not in @curPairs - @registerPair pair, target - @curPairs.push("#{pair}#{target}") - - registerPair: (pair, target) -> - [left, right] = @splitPair(pair) - [target_left, target_right] = @splitPair(target) - - for key in [left, right] - for targetKey in [target_left, target_right] - if "#{key}#{targetKey}" not in @curPairsWithTarget - name = "vim-surround:#{@getName(key, targetKey)}" - - unless pair == target - @disposables.add atom.commands.add @context, name, @getRunner pair, target - - keymapArg = {} - fullCommand = "#{@command} #{key} #{targetKey}" - keymapArg[fullCommand] = name - - contextArg = {} - contextArg[@context] = keymapArg - - # Capture the disposable heretom test! - unless pair == target - @disposables.add atom.keymaps.add name, contextArg - @curPairsWithTarget.push("#{key}#{targetKey}") - - splitPair: (pair) -> - return [pair[..(pair.length/2)-1], pair[pair.length/2..]] - - getRunner: (from, to) -> -> - [left, right] = [from[0], from[1]] - [target_left, target_right] = [to[0], to[1]] - editor = atom.workspace.getActiveTextEditor() - selector = new Selector(editor, left, right) - - editor.transact -> - cursorPos = editor.getCursorBufferPosition() - - selector.inside().select() - editor.selections.forEach (selection) -> - text = selection.getText() - - # restore cursore and select text with surrounding keys - editor.setCursorBufferPosition(cursorPos) - selector.outside().select() - - editor.selections.forEach (selection) -> - selection.insertText "#{target_left}#{text}#{target_right}" - - # restore cursore - editor.setCursorBufferPosition(cursorPos) diff --git a/atom/packages/vim-surround/lib/command/delete.coffee b/atom/packages/vim-surround/lib/command/delete.coffee deleted file mode 100644 index 744b3a1..0000000 --- a/atom/packages/vim-surround/lib/command/delete.coffee +++ /dev/null @@ -1,33 +0,0 @@ -{compositedisposable} = require 'atom' - -Base = require './base' -Selector = require './selector' - -module.exports = class Delete extends Base - constructor: (config) -> - @command = config.deleteSurroundCommand - @context = "atom-text-editor.vim-mode.normal-mode" - super config - - getName: (key) -> "delete-#{key}" - - getRunner: (left, right) -> -> - editor = atom.workspace.getActiveTextEditor() - selector = new Selector(editor, left, right) - - editor.transact -> - cursorPos = editor.getCursorBufferPosition() - - selector.inside().select() - editor.selections.forEach (selection) -> - text = selection.getText() - - # restore cursore and select text with surrounding keys - editor.setCursorBufferPosition(cursorPos) - selector.outside().select() - - editor.selections.forEach (selection) -> - selection.insertText text - - # restore cursore - editor.setCursorBufferPosition(cursorPos) diff --git a/atom/packages/vim-surround/lib/command/selector.coffee b/atom/packages/vim-surround/lib/command/selector.coffee deleted file mode 100644 index bcb3c15..0000000 --- a/atom/packages/vim-surround/lib/command/selector.coffee +++ /dev/null @@ -1,24 +0,0 @@ -vimModePath = atom.packages.resolvePackagePath('vim-mode') or - atom.packages.resolvePackagePath('vim-mode-next') - -{SelectInsideQuotes, SelectInsideBrackets} = require "#{vimModePath}/lib/text-objects" - -module.exports = class Selector - constructor: (@editor, left, right) -> - @left = left.trim() - @right = right.trim() - - inside: -> - if @isBraket() - new SelectInsideBrackets(@editor, @left, @right, false) - else - new SelectInsideQuotes(@editor, @left, false) - - outside: -> - if @isBraket() - new SelectInsideBrackets(@editor, @left, @right, true) - else - new SelectInsideQuotes(@editor, @left, true) - - isBraket: -> - ['[', ']', '{', '}', '<', '>', '(', ')'].indexOf?(@left.trim()) >= 0 diff --git a/atom/packages/vim-surround/lib/command/surround.coffee b/atom/packages/vim-surround/lib/command/surround.coffee deleted file mode 100644 index e939f78..0000000 --- a/atom/packages/vim-surround/lib/command/surround.coffee +++ /dev/null @@ -1,18 +0,0 @@ -{CompositeDisposable} = require 'atom' - -Base = require './base' - -module.exports = class Surround extends Base - constructor: (config) -> - @command = config.surroundCommand - @context = "atom-text-editor.vim-mode.visual-mode" - super config - - getName: (key) -> "surround-#{key}" - - getRunner: (left, right) -> -> - editor = atom.workspace.getActiveTextEditor() - editor.transact -> - editor.selections.forEach (selection) -> - text = selection.getText() - selection.insertText "#{left}#{text}#{right}" diff --git a/atom/packages/vim-surround/lib/vim-surround.coffee b/atom/packages/vim-surround/lib/vim-surround.coffee deleted file mode 100644 index f293194..0000000 --- a/atom/packages/vim-surround/lib/vim-surround.coffee +++ /dev/null @@ -1,45 +0,0 @@ -{CompositeDisposable} = require 'atom' - -Surround = require './command/surround' -Delete = require './command/delete' -Change = require './command/change' - -module.exports = - config: - pairs: - type: 'array' - default: ['()', '{}', '[]', '""', "''"] - items: - type: 'string' - changeSurroundCommand: - type: 'string' - default: 'c s' - deleteSurroundCommand: - type: 'string' - default: 'd s' - surroundCommand: - type: 'string' - default: 's' - deleteCommand: - type: 'string' - default: 'd s' - - activate: (state) -> - @commandClasses = [ - Surround, Delete, Change - ] - - @configLoop = atom.config.observe 'vim-surround', (config) => - @disposables.dispose() if @disposables? - @disposables = new CompositeDisposable - - @commands = [] - - for cls in @commandClasses - command = new cls config - @commands.push command - @disposables.add command.disposables - - consumeVimMode: (vimMode) -> @vimMode = vimMode - - deactivate: () -> @disposables.dispose() diff --git a/atom/packages/vim-surround/package.json b/atom/packages/vim-surround/package.json deleted file mode 100644 index b142af6..0000000 --- a/atom/packages/vim-surround/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "vim-surround", - "main": "./lib/vim-surround", - "version": "0.8.0", - "description": "vim-surround for Atom!", - "repository": { - "type": "git", - "url": "git+https://github.com/gepoch/vim-surround.git" - }, - "license": "MIT", - "keywords": [ - "pair", - "parentheses", - "quotes", - "surround", - "vim" - ], - "engines": { - "atom": ">0.50.0" - }, - "dependencies": {}, - "consumedServices": {}, - "readme": "# Vim Surround for Atom [](https://travis-ci.org/gepoch/vim-surround)\n\nSurround is an implementation of vim-surround for the [atom](http://atom.io)\neditor, creating a vim-surround with the power of Atom!\n\nYou should definitely have [vim-mode](https://atom.io/packages/vim-mode) for\nthis package to function properly, of course.\n\nInspiration from and kudos to the wonderful [vim-surround for\nvim](https://github.com/tpope/vim-surround)\n\nSee vim-surround on [github](https://github.com/gepoch/vim-surround) or\n[atom.io](https://atom.io/packages/vim-surround).\n\n## News\n\n* This package supports visual mode's `s )` set of commands for a configurable\n set of pairs.\n\n* Next on the roadmap are pair deletions with `d )` and friends.\n\n* New in 0.4: Multiple cursors are now supported, and conveniently work just\n like you think they do.\n\n* New in 0.5: Stable configuration changes and configurable surround key!\n\n* New in 0.7: Change surround and delete surround added.\n\n* New in 0.8: Tentative support for\n [vim-mode-next](https://atom.io/packages/vim-mode-next). See\n [#28](https://github.com/gepoch/vim-surround/issues/28).\n\n### Muscle Memory Compatability Note\n\nvim-surround uses a lowercase `s` instead of `S` for surround commands! This is\nconfigurable in the package settings, if you would like to set it to the\noriginal keybinding.\n\n## How to use Surround\n\n### Surrounding\n\nFor double quotes, highlight the string in visual mode and enter `s \"`.\n\n```\nHello world -> \"Hello world\"\n```\n\nFor parentheses there are two options. `s )` will surround as normal. `s (`\nwill pad with a space. All asymmetrical pairs have the secondary space-padded\nform.\n\nFor example:\n\n`s )`\n\n```\nHello world -> (Hello world)\n```\n\n`s (`\n\n```\nHello world -> ( Hello world )\n```\n\n### Changing Surrounding Pairs\n\nSuppose I want to make double quotes into single quotes. To do this, I should\nput my cursor inside the double quotes in question and enter `c s \" '`\n\n```\n\"Hello world\" -> 'Hello world'\n```\n\n### Deleting Surrounding Pairs\n\nTo delete the single quotes, place your cursor inside of them and enter `d s '`\n\n```\n'Hello world' -> Hello world\n```\n### Configuration\n\nCurrently, the following pairs work out of the box!:\n\n- ()\n- []\n- {}\n- \"\"\n- ''\n\nYou can add to the available pairs in atom's settings, and the commands will\nbe dynamically added to your keybindings.\n\nFor example if I'm working on Jinja templates, and I want to add the ability to\nsurround using `{%` and `%}` I would add this in my settings:\n\n```\n(), [], {}, \"\", '', {%%}\n```\n\nThen:\n\n`s % }`\n\n```\nHello world -> {%Hello world%}\n```\n\n`s { %`\n\n```\nHello world -> {% Hello world %}\n```\n\n### TODO\n\n- [x] Implement deleting surrounding pairs with `d s`\n- [x] Implement changing surrounding pairs with `c s`\n- [ ] Intelligent tag surrounding/deleting/replacing with `s <q>` and friends.\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/gepoch/vim-surround/issues" - }, - "homepage": "https://github.com/gepoch/vim-surround#readme", - "_id": "vim-surround@0.8.0", - "_shasum": "13e7554fb6a90ba6178fb2b8bddb87ca45e3d0d3", - "_resolved": "file:../d-115828-94497-mmttc8/package.tgz", - "_from": "../d-115828-94497-mmttc8/package.tgz", - "_atomModuleCache": { - "version": 1, - "dependencies": [], - "extensions": { - ".coffee": [ - "lib/command/base.coffee", - "lib/command/change.coffee", - "lib/command/delete.coffee", - "lib/command/selector.coffee", - "lib/command/surround.coffee", - "lib/vim-surround.coffee" - ], - ".json": [ - "package.json" - ] - }, - "folders": [] - } -}
\ No newline at end of file diff --git a/atom/packages/vim-surround/spec/spec-helper.coffee b/atom/packages/vim-surround/spec/spec-helper.coffee deleted file mode 100644 index 931e0b9..0000000 --- a/atom/packages/vim-surround/spec/spec-helper.coffee +++ /dev/null @@ -1,13 +0,0 @@ -getEditorElement = (callback) -> - textEditor = null - - waitsForPromise -> - atom.project.open().then (e) -> - textEditor = e - - runs -> - element = document.createElement("atom-text-editor") - element.setModel(textEditor) - callback(element) - -module.exports = { getEditorElement } diff --git a/atom/packages/vim-surround/spec/vim-surround-spec.coffee b/atom/packages/vim-surround/spec/vim-surround-spec.coffee deleted file mode 100644 index 41a348e..0000000 --- a/atom/packages/vim-surround/spec/vim-surround-spec.coffee +++ /dev/null @@ -1,72 +0,0 @@ -helpers = require './spec-helper' - -describe "Vim Surround activation", -> - [editor, pairs, editorElement, vimSurround, configPairs, chars, names] = [] - - beforeEach -> - pairs = ['()', '{}', '[]', '""', "''"] - atom.config.set('vim-surround.pairs', pairs) - - vimSurround = atom.packages.loadPackage('vim-surround') - vimSurround.activate() - - configPairs = atom.config.get('vim-surround.pairs') - - helpers.getEditorElement (element) -> - editorElement = element - editor = editorElement.getModel() - - editorClassList = editorElement.classList - - editorClassList.add('editor') - editorClassList.add('vim-mode') - editorClassList.add('visual-mode') - - - describe "When the vim-surround module loads", -> - beforeEach -> - chars = [] - pairs.forEach (pair) -> - for i in [0..pair.length-1] - char = pair[i] - chars.push char unless char in chars - - commands = atom.commands.findCommands target: editorElement - - names = [] - commands.forEach (command) -> - names.push(command.name) - - it "Creates a surround command for each configured pair character", -> - chars.forEach (char) -> - expect(names).toContain("vim-surround:surround-#{char}") - - describe "and the list of pairs changes", -> - beforeEach -> - pairs = ['()', '{}', '[]', '""', "-+"] - atom.config.set('vim-surround.pairs', pairs) - commands = atom.commands.findCommands target: editorElement - names = (command.name for command in commands) - chars = [] - pairs.forEach (pair) -> - for i in [0..pair.length-1] - char = pair[i] - chars.push char unless char in chars - - it "should add any new pairs.", -> - chars.forEach (char) -> - expect(names).toContain("vim-surround:surround-#{char}") - - it "should remove any old pairs.", -> - expect(names).not.toContain("vim-surround:surround-'") - - describe "and then deactivates", -> - - beforeEach -> - vimSurround.deactivate() - commands = atom.commands.findCommands target: editorElement - names = (command.name for command in commands) - - it "should clear out all commands from the registry", -> - chars.forEach (char) -> - expect(names).not.toContain("vim-surround:surround-#{char}") |