Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ATOM Editor の設定(カスタマイズ, Windows 環境用)
################################################################
# miscellaneous functions
insertText = (str) ->
return unless editor = atom.workspace.getActiveTextEditor()
selection = editor.getLastSelection()
selection.insertText(str)
################################################################
# 現在日時を挿入するコマンドを追加
# refs https://github.com/dannyfritz/atom-date
# refs https://github.com/JerrySievert/date-utils
# refs http://qiita.com/toruot/items/b26fde1a898bb52985e1
daysAbbr = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
#daysKanji = ['日', '月', '火', '水', '木', '金', '土']
paddingZero = (str, length) ->
str = String(str)
str = '0' + str while(str.length < length)
str
timezone = (offset) ->
if offset == 0
'Z'
else if offset < 0
'+' + paddingZero(-offset / 60, 2) + ':00' # 今のところ分単位の時差はないので計算を端折る
else
'-' + paddingZero(offset / 60, 2) + ':00' # 今のところ分単位の時差はないので計算を端折る
dateOrTime = (kind) ->
now = new Date()
yyyy = now.getYear() + 1900
mm = paddingZero(now.getMonth() + 1, 2)
dd = paddingZero(now.getDate(), 2)
ddd = daysAbbr[now.getDay()]
#ddd = daysKanji[now.getDay()]
hh24 = paddingZero(now.getHours(), 2)
mi = paddingZero(now.getMinutes(), 2)
ss = paddingZero(now.getSeconds(), 2)
tz = timezone(now.getTimezoneOffset())
if kind == 1
"#{yyyy}/#{mm}/#{dd} (#{ddd})"
else if kind == 2
"#{hh24}:#{mi}:#{ss}"
else if kind == 3
"#{yyyy}/#{mm}/#{dd} (#{ddd}) #{hh24}:#{mi}:#{ss}"
else
"#{yyyy}-#{mm}-#{dd}T#{hh24}:#{mi}:#{ss}#{tz}"
atom.commands.add 'atom-text-editor', 'my-date:date', ->
insertText(dateOrTime(1))
atom.commands.add 'atom-text-editor', 'my-date:time', ->
insertText(dateOrTime(2))
atom.commands.add 'atom-text-editor', 'my-date:datetime', ->
insertText(dateOrTime(3))
atom.commands.add 'atom-text-editor', 'my-date:rfc3339', ->
insertText(dateOrTime(0))
################################################################
# Amazon Associate ID を含んだ商品 URL を生成する
# 選択文字列またはクリップボードの内容を読み込み,変換してセットする
# http(s)://www.amazon.co.jp/... から始まる文字列を想定
# /dp/XXXXXXXXXX または /ASIN/XXXXXXXXXX のパタンを探す
# 変換できない場合はクリップボードの内容をそのままセットする
# refs http://d.hatena.ne.jp/hyuki/20120413/amazon
amazonUrl = (id) ->
return "" unless editor = atom.workspace.getActiveTextEditor()
url = editor.getSelectedText()
if url == ""
url = atom.clipboard.read()
re = /^htt(?:p|ps):\/\/www.amazon.co.jp\//
if !re.test(url)
return url
result = url.match(/\/(?:dp|ASIN)\/(.{10})/)
if result == null
return url
else if result.length < 2
return url
asin = result[1]
if id == ""
"https://www.amazon.co.jp/exec/obidos/ASIN/#{asin}/"
else
"https://www.amazon.co.jp/exec/obidos/ASIN/#{asin}/#{id}/"
atom.commands.add 'atom-text-editor', 'my-tools:amazon', ->
id = 'baldandersinf-22' #Amazon Associate ID
insertText(amazonUrl(id))
'body':
'alt-shift-down': 'editor:add-selection-below'
'alt-shift-left': 'core:select-left'
'alt-shift-right': 'core:select-right'
'alt-shift-up': 'editor:add-selection-above'
'atom-workspace atom-text-editor':
'ctrl-backspace': 'editor:delete-to-beginning-of-subword'
'ctrl-delete': 'editor:delete-to-end-of-subword'
'ctrl-left': 'editor:move-to-previous-subword-boundary'
'ctrl-right': 'editor:move-to-next-subword-boundary'
'f1': 'command-palette:toggle'
'atom-workspace atom-text-editor:not([mini])':
'ctrl-shift-D': 'abort!'
'shift-f10': 'editor:duplicate-lines'
'ctrl-shift-K': 'abort!'
'ctrl-f10': 'editor:delete-line'
'atom-text-editor[data-grammar~="go"]:not([mini])':
'f12': 'golang:godef'
'shift-f12': 'golang:godef-return'
'.platform-win32':
'shift-f1': 'git-plus:menu'
'.platform-win32 atom-workspace':
'ctrl-f1': 'platformio-ide-terminal:new'
//font setting
@ui-fonts: "Meiryo UI";
.tree-view {
// background-color: whitesmoke;
font-family: @ui-fonts;
}
atom-workspace {
font-family: @ui-fonts;
}
.markdown-preview.markdown-preview {
font-family: @ui-fonts;
}
// Customize for highlight-line and show-ideographic-space packages
// https://atom.io/packages/highlight-line
// https://atom.io/packages/show-ideographic-space
atom-text-editor, atom-text-editor.editor {
// Forhighlight-lin package
// This is for the bottom line (underline)
.line.highlight-line-multi-line-solid-bottom {
border-bottom-color: green;
}
// This is for the top line when you have the selection borders enabled.
.line.highlight-line-multi-line-solid-top {
border-top-color: green;
}
// For show-ideographic-space package
.highlight.ideographic-space {
.region:after {
color: rgba(197, 200, 198, 0.2);
content: '';
}
}
}
@jerrymaguireliarliar

This comment has been minimized.

Copy link

commented Jan 24, 2016

Hmmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.