Compare commits
8 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e58c11751 | ||
|
|
054eca5d79 | ||
|
|
bf2d86248a | ||
|
|
c4f739f390 | ||
|
|
566996a9fd | ||
|
|
11abdb95fa | ||
|
|
c1a464ba13 | ||
|
|
ddbeed1dd9 |
9 changed files with 32 additions and 129 deletions
29
.travis.yml
29
.travis.yml
|
|
@ -1,5 +1,4 @@
|
||||||
## Project specific config ###
|
language: objective-c
|
||||||
language: generic
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|
@ -10,36 +9,12 @@ env:
|
||||||
- ATOM_CHANNEL=stable
|
- ATOM_CHANNEL=stable
|
||||||
- ATOM_CHANNEL=beta
|
- ATOM_CHANNEL=beta
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
### Generic setup follows ###
|
|
||||||
script:
|
|
||||||
- curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh
|
|
||||||
- chmod u+x build-package.sh
|
|
||||||
- ./build-package.sh
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
on_success: never
|
on_success: never
|
||||||
on_failure: change
|
on_failure: change
|
||||||
|
|
||||||
branches:
|
script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh'
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
||||||
git:
|
git:
|
||||||
depth: 10
|
depth: 10
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- build-essential
|
|
||||||
- git
|
|
||||||
- libgnome-keyring-dev
|
|
||||||
- libsecret-1-dev
|
|
||||||
- fakeroot
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
## (unpublished)
|
## (unpublished)
|
||||||
|
|
||||||
* Fix `:enew` not working ([#215](https://github.com/lloeki/ex-mode/pull/215))
|
|
||||||
|
|
||||||
## 0.18.0
|
|
||||||
|
|
||||||
* Add Gdefault support ([#191](https://github.com/lloeki/ex-mode/pull/191))
|
|
||||||
* Add :sort command ([#190](https://github.com/lloeki/ex-mode/pull/190))
|
* Add :sort command ([#190](https://github.com/lloeki/ex-mode/pull/190))
|
||||||
|
|
||||||
## 0.17.0
|
## 0.17.0
|
||||||
|
|
|
||||||
31
README.md
Executable file → Normal file
31
README.md
Executable file → Normal file
|
|
@ -30,34 +30,7 @@ atom.packages.onDidActivatePackage (pack) ->
|
||||||
Ex.registerAlias 'Wq', 'wq'
|
Ex.registerAlias 'Wq', 'wq'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Existing commands
|
See `lib/ex.coffee` for some examples commands. Contributions are very welcome!
|
||||||
|
|
||||||
This is the baseline list of commands supported in `ex-mode`.
|
|
||||||
|
|
||||||
| Command | Operation |
|
|
||||||
| --------------------------------------- | ---------------------------------- |
|
|
||||||
| `q/quit/tabc/tabclose` | Close active tab |
|
|
||||||
| `qall/quitall` | Close all tabs |
|
|
||||||
| `tabe/tabedit/tabnew` | Open new tab |
|
|
||||||
| `e/edit/tabe/tabedit/tabnew <file>` | Edit given file |
|
|
||||||
| `tabn/tabnext` | Go to next tab |
|
|
||||||
| `tabp/tabprevious` | Go to previous tab |
|
|
||||||
| `tabo/tabonly` | Close other tabs |
|
|
||||||
| `w/write` | Save active tab |
|
|
||||||
| `w/write/saveas <file>` | Save as |
|
|
||||||
| `wall/wa` | Save all tabs |
|
|
||||||
| `sp/split` | Split window |
|
|
||||||
| `sp/split <file>` | Open file in split window |
|
|
||||||
| `s/substitute` | Substitute regular expression in active line |
|
|
||||||
| `vsp/vsplit` | Vertical split window |
|
|
||||||
| `vsp/vsplit <file>` | Open file in vertical split window |
|
|
||||||
| `delete` | Cut active line |
|
|
||||||
| `yank` | Copy active line |
|
|
||||||
| `set <options>` | Set options |
|
|
||||||
| `sort` | Sort all lines in file |
|
|
||||||
| `sort <line range>` | Sort lines in line range |
|
|
||||||
|
|
||||||
See `lib/ex.coffee` for the implementations of these commands. Contributions are very welcome!
|
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
|
|
@ -66,3 +39,5 @@ Groundwork is done. More ex commands are easy to add and will be coming as time
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
# Below is a basic keybinding which registers on all platforms by applying to
|
# Below is a basic keybinding which registers on all platforms by applying to
|
||||||
# the root workspace element.
|
# the root workspace element.
|
||||||
|
|
||||||
|
|
||||||
# For more detailed documentation see
|
# For more detailed documentation see
|
||||||
# https://atom.io/docs/latest/advanced/keymaps
|
# https://atom.io/docs/latest/advanced/keymaps
|
||||||
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
|
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
|
||||||
':': 'ex-mode:open'
|
':': 'ex-mode:open'
|
||||||
'atom-text-editor.ex-mode-editor':
|
'atom-text-editor.ex-mode-editor':
|
||||||
'ctrl-c': 'ex-mode:close'
|
'ctrl-c': 'ex-mode:close'
|
||||||
'ctrl-[': 'ex-mode:close'
|
|
||||||
'atom-text-editor.vim-mode:not(.insert-mode)':
|
'atom-text-editor.vim-mode:not(.insert-mode)':
|
||||||
':': 'ex-mode:open'
|
':': 'ex-mode:open'
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,3 @@ module.exports = ExMode =
|
||||||
description: 'when splitting, split from right'
|
description: 'when splitting, split from right'
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
gdefault:
|
|
||||||
title: 'Gdefault'
|
|
||||||
description: 'When on, the ":substitute" flag \'g\' is default on'
|
|
||||||
type: 'boolean'
|
|
||||||
default: 'false'
|
|
||||||
onlyCloseBuffers:
|
|
||||||
title: 'Only close buffers'
|
|
||||||
description: 'When on, quitall only closes all buffers, not entire Atom instance'
|
|
||||||
type: 'boolean'
|
|
||||||
default: 'false'
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ CommandError = require './command-error'
|
||||||
fs = require 'fs-plus'
|
fs = require 'fs-plus'
|
||||||
VimOption = require './vim-option'
|
VimOption = require './vim-option'
|
||||||
_ = require 'underscore-plus'
|
_ = require 'underscore-plus'
|
||||||
atom
|
|
||||||
|
|
||||||
defer = () ->
|
defer = () ->
|
||||||
deferred = {}
|
deferred = {}
|
||||||
|
|
@ -133,11 +132,7 @@ class Ex
|
||||||
atom.workspace.getActivePane().destroyActiveItem()
|
atom.workspace.getActivePane().destroyActiveItem()
|
||||||
|
|
||||||
quitall: ->
|
quitall: ->
|
||||||
if !atom.config.get('ex-mode.onlyCloseBuffers')
|
|
||||||
atom.close()
|
atom.close()
|
||||||
else
|
|
||||||
atom.workspace.getTextEditors().forEach (editor) ->
|
|
||||||
editor.destroy()
|
|
||||||
|
|
||||||
q: => @quit()
|
q: => @quit()
|
||||||
|
|
||||||
|
|
@ -211,7 +206,9 @@ class Ex
|
||||||
e: (args) => @edit(args)
|
e: (args) => @edit(args)
|
||||||
|
|
||||||
enew: ->
|
enew: ->
|
||||||
atom.workspace.open()
|
buffer = atom.workspace.getActiveTextEditor().buffer
|
||||||
|
buffer.setPath(undefined)
|
||||||
|
buffer.load()
|
||||||
|
|
||||||
write: ({ range, args, editor, saveas }) ->
|
write: ({ range, args, editor, saveas }) ->
|
||||||
saveas ?= false
|
saveas ?= false
|
||||||
|
|
@ -229,30 +226,29 @@ class Ex
|
||||||
deferred = defer()
|
deferred = defer()
|
||||||
|
|
||||||
editor = atom.workspace.getActiveTextEditor()
|
editor = atom.workspace.getActiveTextEditor()
|
||||||
|
saved = false
|
||||||
# Case 1; path is provided
|
|
||||||
if filePath.length isnt 0
|
if filePath.length isnt 0
|
||||||
fullPath = getFullPath filePath
|
fullPath = getFullPath(filePath)
|
||||||
|
if editor.getPath()? and (not fullPath? or editor.getPath() == fullPath)
|
||||||
# Only write when it does not exist or we have a force flag set.
|
if saveas
|
||||||
if force or not fs.existsSync(fullPath)
|
throw new CommandError("Argument required")
|
||||||
editor.saveAs(fullPath)
|
|
||||||
return deferred.promise
|
|
||||||
|
|
||||||
throw new CommandError("File exists (add ! to override)")
|
|
||||||
|
|
||||||
# Case 2; no path provided, call editor save.
|
|
||||||
editor = atom.workspace.getActiveTextEditor()
|
|
||||||
|
|
||||||
# Does the current buffer exist?
|
|
||||||
if editor.getPath()? and fs.existsSync(editor.getPath())
|
|
||||||
trySave(-> editor.save()).then(deferred.promise)
|
|
||||||
else
|
else
|
||||||
# Cant see what the better API is but Pane.saveActiveItemAs() is the only call
|
# Use editor.save when no path is given or the path to the file is given
|
||||||
# I could find that states it will ask the user.
|
trySave(-> editor.save()).then(deferred.resolve)
|
||||||
trySave(-> atom.workspace.getActivePane().saveActiveItemAs()).then(deferred.promise)
|
saved = true
|
||||||
|
else if not fullPath?
|
||||||
|
fullPath = atom.showSaveDialogSync()
|
||||||
|
|
||||||
return deferred.promise
|
if not saved and fullPath?
|
||||||
|
if not force and fs.existsSync(fullPath)
|
||||||
|
throw new CommandError("File exists (add ! to override)")
|
||||||
|
if saveas or editor.getFileName() == null
|
||||||
|
editor = atom.workspace.getActiveTextEditor()
|
||||||
|
trySave(-> editor.saveAs(fullPath, editor)).then(deferred.resolve)
|
||||||
|
else
|
||||||
|
trySave(-> saveAs(fullPath, editor)).then(deferred.resolve)
|
||||||
|
|
||||||
|
deferred.promise
|
||||||
|
|
||||||
wall: ->
|
wall: ->
|
||||||
atom.workspace.saveAll()
|
atom.workspace.saveAll()
|
||||||
|
|
@ -365,9 +361,6 @@ class Ex
|
||||||
try
|
try
|
||||||
flagsObj = {}
|
flagsObj = {}
|
||||||
flags.split('').forEach((flag) -> flagsObj[flag] = true)
|
flags.split('').forEach((flag) -> flagsObj[flag] = true)
|
||||||
# gdefault option
|
|
||||||
if atom.config.get('ex-mode.gdefault')
|
|
||||||
flagsObj.g = !flagsObj.g
|
|
||||||
patternRE = getSearchTerm(pattern, flagsObj)
|
patternRE = getSearchTerm(pattern, flagsObj)
|
||||||
catch e
|
catch e
|
||||||
if e.message.indexOf('Invalid flags supplied to RegExp constructor') is 0
|
if e.message.indexOf('Invalid flags supplied to RegExp constructor') is 0
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,4 @@ class VimOption
|
||||||
noscs: =>
|
noscs: =>
|
||||||
@nosmartcase()
|
@nosmartcase()
|
||||||
|
|
||||||
gdefault: =>
|
|
||||||
atom.config.set("ex-mode.gdefault", true)
|
|
||||||
|
|
||||||
nogdefault: =>
|
|
||||||
atom.config.set("ex-mode.gdefault", false)
|
|
||||||
|
|
||||||
module.exports = VimOption
|
module.exports = VimOption
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "ex-mode",
|
"name": "ex-mode",
|
||||||
"main": "./lib/ex-mode",
|
"main": "./lib/ex-mode",
|
||||||
"version": "0.18.0",
|
"version": "0.17.0",
|
||||||
"description": "Ex for Atom's vim-mode",
|
"description": "Ex for Atom's vim-mode",
|
||||||
"activationCommands": {
|
"activationCommands": {
|
||||||
"atom-workspace": "ex-mode:open"
|
"atom-workspace": "ex-mode:open"
|
||||||
|
|
|
||||||
|
|
@ -715,17 +715,6 @@ describe "the commands", ->
|
||||||
submitNormalModeInputText(':%substitute/abc/ghi/ig')
|
submitNormalModeInputText(':%substitute/abc/ghi/ig')
|
||||||
expect(editor.getText()).toEqual('ghiaghi\ndefdDEF\nghiaghi')
|
expect(editor.getText()).toEqual('ghiaghi\ndefdDEF\nghiaghi')
|
||||||
|
|
||||||
it "set gdefault option", ->
|
|
||||||
openEx()
|
|
||||||
atom.config.set('ex-mode.gdefault', true)
|
|
||||||
submitNormalModeInputText(':substitute/a/x')
|
|
||||||
expect(editor.getText()).toEqual('xbcxABC\ndefdDEF\nabcaABC')
|
|
||||||
|
|
||||||
atom.commands.dispatch(editorElement, 'ex-mode:open')
|
|
||||||
atom.config.set('ex-mode.gdefault', true)
|
|
||||||
submitNormalModeInputText(':substitute/a/x/g')
|
|
||||||
expect(editor.getText()).toEqual('xbcaABC\ndefdDEF\nabcaABC')
|
|
||||||
|
|
||||||
describe ":yank", ->
|
describe ":yank", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.setText('abc\ndef\nghi\njkl')
|
editor.setText('abc\ndef\nghi\njkl')
|
||||||
|
|
@ -955,14 +944,6 @@ describe "the commands", ->
|
||||||
submitNormalModeInputText(':set nosmartcase')
|
submitNormalModeInputText(':set nosmartcase')
|
||||||
expect(atom.config.get('vim-mode.useSmartcaseForSearch')).toBe(false)
|
expect(atom.config.get('vim-mode.useSmartcaseForSearch')).toBe(false)
|
||||||
|
|
||||||
it "sets (no)gdefault", ->
|
|
||||||
openEx()
|
|
||||||
submitNormalModeInputText(':set gdefault')
|
|
||||||
expect(atom.config.get('ex-mode.gdefault')).toBe(true)
|
|
||||||
atom.commands.dispatch(editorElement, 'ex-mode:open')
|
|
||||||
submitNormalModeInputText(':set nogdefault')
|
|
||||||
expect(atom.config.get('ex-mode.gdefault')).toBe(false)
|
|
||||||
|
|
||||||
describe "aliases", ->
|
describe "aliases", ->
|
||||||
it "calls the aliased function without arguments", ->
|
it "calls the aliased function without arguments", ->
|
||||||
ExClass.registerAlias('W', 'w')
|
ExClass.registerAlias('W', 'w')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue