Last active
March 14, 2018 06:38
-
-
Save ykpythemind/9f9ac4e42c0bfe38c2d8f726c02ef72f to your computer and use it in GitHub Desktop.
Atom Init script (for Rails) https://qiita.com/ykpythemind/items/a65f24c59b9311c57163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use babel'; | |
// for Rails haml view file | |
const setTabTitle = () => { | |
const tabs = atom.views.getView(atom.workspace).querySelectorAll('.vertical li.tab .title'); | |
Array.from(tabs, (tab) => { | |
if (tab.innerText.match(/\.(haml|erb)/)) { | |
tab.innerText = tab.dataset.path.split(path.sep).slice(-2).join('/').replace(/\.html\.(haml|erb)/, ''); | |
} | |
}); | |
}; | |
atom.workspace.onDidChangeActiveTextEditor(() => { | |
setTabTitle(); | |
}); | |
atom.workspace.onDidOpen(() => { | |
setTabTitle(); | |
}); | |
atom.workspace.onDidDestroyPaneItem(() => { | |
setTabTitle(); | |
}); | |
// --- | |
atom.commands.add('atom-text-editor', 'pry:toggle-binding-pry', () => { | |
const editor = atom.workspace.getActiveTextEditor(); | |
if (!editor) { | |
return; | |
} | |
const row = editor.getCursorBufferPosition().row; | |
const line = editor.lineTextForBufferRow(row); | |
if (line.includes('binding.pry')) { | |
const buffer = editor.getBuffer(); | |
const range = buffer.rangeForRow(row, false); | |
editor.setTextInBufferRange(range, ''); | |
} else { | |
editor.insertText('binding.pry'); | |
} | |
}); | |
atom.keymaps.add('frominit', { | |
"body": { | |
"alt-p": "pry:toggle-binding-pry" | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment