Merge pull request #69 from nzyuzin/set_options
Add support for :set [option]
This commit is contained in:
commit
e679604c21
2 changed files with 47 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
path = require 'path'
|
||||
CommandError = require './command-error'
|
||||
fs = require 'fs'
|
||||
VimOption = require './vim-option'
|
||||
|
||||
trySave = (func) ->
|
||||
deferred = Promise.defer()
|
||||
|
|
@ -235,4 +236,27 @@ class Ex
|
|||
range = [[range[0], 0], [range[1] + 1, 0]]
|
||||
atom.workspace.getActiveTextEditor().buffer.setTextInRange(range, '')
|
||||
|
||||
set: (range, args) ->
|
||||
args = args.trim()
|
||||
if args == ""
|
||||
throw new CommandError("No option specified")
|
||||
options = args.split(' ')
|
||||
for option in options
|
||||
do ->
|
||||
if option.includes("=")
|
||||
nameValPair = option.split("=")
|
||||
if (nameValPair.length != 2)
|
||||
throw new CommandError("Wrong option format. [name]=[value] format is expected")
|
||||
optionName = nameValPair[0]
|
||||
optionValue = nameValPair[1]
|
||||
optionProcessor = VimOption.singleton()[optionName]
|
||||
if not optionProcessor?
|
||||
throw new CommandError("No such option: #{optionName}")
|
||||
optionProcessor(optionValue)
|
||||
else
|
||||
optionProcessor = VimOption.singleton()[option]
|
||||
if not optionProcessor?
|
||||
throw new CommandError("No such option: #{option}")
|
||||
optionProcessor()
|
||||
|
||||
module.exports = Ex
|
||||
|
|
|
|||
23
lib/vim-option.coffee
Normal file
23
lib/vim-option.coffee
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class VimOption
|
||||
@singleton: =>
|
||||
@option ||= new VimOption
|
||||
|
||||
list: =>
|
||||
atom.config.set("editor.showInvisibles", true)
|
||||
|
||||
nolist: =>
|
||||
atom.config.set("editor.showInvisibles", false)
|
||||
|
||||
number: =>
|
||||
atom.config.set("editor.showLineNumbers", true)
|
||||
|
||||
nu: =>
|
||||
@number()
|
||||
|
||||
nonumber: =>
|
||||
atom.config.set("editor.showLineNumbers", false)
|
||||
|
||||
nonu: =>
|
||||
@nonumber()
|
||||
|
||||
module.exports = VimOption
|
||||
Loading…
Add table
Add a link
Reference in a new issue