Skip to content

Instantly share code, notes, and snippets.

@caesarsol
Last active November 6, 2018 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caesarsol/fb38e7b2105e54f6788b061191a04476 to your computer and use it in GitHub Desktop.
Save caesarsol/fb38e7b2105e54f6788b061191a04476 to your computer and use it in GitHub Desktop.
caesarsol Atom settings
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
getPrevChar = (editor, chars = 1) ->
pos = editor.getCursorBufferPosition()
posStart = pos.translate([0, -chars])
posEnd = pos
prevChar = editor.getTextInBufferRange([posStart, posEnd])
return prevChar
getCharsPrevAndNext = (editor, chars = 1) ->
pos = editor.getCursorBufferPosition()
posStart = pos.translate([0, -chars])
posEnd = pos.translate([0, chars])
nextAndPrev = editor.getTextInBufferRange([posStart, posEnd])
return nextAndPrev
###
SPACE PARENS COUPLE
###
PARENS_NEEDING_SPACES = ['{}', '[]', '()']
parensAlreadySpaced = PARENS_NEEDING_SPACES.map ([p, q]) => "#{p} #{q}"
atom.commands.add 'atom-text-editor',
'user:space-parens': (event) ->
editor = atom.workspace.getActiveTextEditor()
return event.abortKeyBinding() if not editor
inParens = getCharsPrevAndNext(editor) in PARENS_NEEDING_SPACES
if inParens
editor.insertText(' ')
editor.moveLeft()
else
event.abortKeyBinding()
'user:delete-space-parens': (event) ->
editor = atom.workspace.getActiveTextEditor()
return event.abortKeyBinding() if not editor
inParens = getCharsPrevAndNext(editor, 2) in parensAlreadySpaced
if inParens
editor.delete()
editor.backspace()
else
event.abortKeyBinding()
###
AUTOCOMPLETE JUST TABBING
###
atom.commands.add 'atom-text-editor',
'user:autocomplete-or-indent': (event) ->
editor = atom.workspace.getActiveTextEditor()
if editor.getSelectedBufferRanges().some((r) => not r.isEmpty())
event.abortKeyBinding()
return
prevChar = getPrevChar(editor)
if prevChar in ['', ' ', '\t']
event.abortKeyBinding()
else
atom.commands.dispatch event.target, 'autocomplete-plus:activate'
###
AUTO-SYNC with package sync-settings
###
# Returns a function, that, as long as it continues to be invoked, will not
# be triggered. The function will be called after it stops being called for
# N milliseconds. If `immediate` is passed, trigger the function on the
# leading edge, instead of the trailing.
debounce = (func, wait, immediate = false) ->
timeout = null
return () ->
context = this
args = arguments
later = () ->
timeout = null
if not immediate
func.apply(context, args)
callNow = immediate && !timeout
clearTimeout(timeout)
timeout = setTimeout(later, wait)
if callNow
func.apply(context, args)
lastBackup = null
doBackup = ->
# atom.notifications.addInfo 'Initiated sync-settings:backup'
target = document.getElementsByTagName('atom-workspace')[0]
atom.commands.dispatch target, 'sync-settings:backup'
SECONDS = 1000
maybeBackup = debounce(doBackup, 1 * SECONDS)
atom.workspace.observeTextEditors (editor) ->
editor.onDidSave ->
path = editor.getPath()
if path.includes '/.atom/'
# There could be errors in init.coffee, so we backup it on next reload
unless path.endsWith '/init.coffee'
maybeBackup()
atom.workspace.onDidDestroyPaneItem (event) ->
if event.item.constructor.name == "SettingsView"
# atom.notifications.addInfo('Closed Settings view')
doBackup()
###
PASTE AND INDENT
###
atom.commands.add 'atom-text-editor',
'user:paste-and-indent': (event) ->
editor = atom.workspace.getActiveTextEditor()
editor.pasteText({
select: true,
})
'atom-text-editor':
'ctrl-alt-right': 'editor:move-to-next-subword-boundary'
'ctrl-alt-left': 'editor:move-to-previous-subword-boundary'
'ctrl-alt-up': 'editor:add-selection-above'
'ctrl-alt-down': 'editor:add-selection-below'
'ctrl-shift-up': 'expand-region:expand'
'ctrl-shift-down': 'expand-region:shrink'
'ctrl-shift-right': 'editor:select-to-next-subword-boundary'
'ctrl-shift-left': 'editor:select-to-previous-subword-boundary'
'cmd-\'': 'toggle-quotes:toggle'
'alt-cmd-d': 'refactor:rename'
'alt-cmd-up': 'expand-region:expand'
'alt-cmd-down': 'expand-region:shrink'
'atom-workspace':
'cmd-alt-u': 'last-cursor-position:previous'
'cmd-shift-u': 'last-cursor-position:next'
'atom-text-editor:not(.mini)':
'tab': 'user:autocomplete-or-indent'
'space': 'user:space-parens'
'backspace': 'user:delete-space-parens'
'cmd-shift-r': 'tree-view:reveal-active-file'
'cmd-v': 'user:paste-and-indent'
'atom-text-editor.autocomplete-active':
'shift-tab': 'autocomplete-plus:move-up'
'tab': 'autocomplete-plus:move-down'
'up': 'autocomplete-plus:move-up'
'down': 'autocomplete-plus:move-down'
'pageup': 'autocomplete-plus:page-up'
'pagedown': 'autocomplete-plus:page-down'
'home': 'autocomplete-plus:move-to-top'
'end': 'autocomplete-plus:move-to-bottom'
[
{
"name": "about",
"version": "1.9.1"
},
{
"name": "advanced-open-file",
"version": "0.16.8"
},
{
"name": "archive-view",
"version": "0.65.1"
},
{
"name": "atom-beautify",
"version": "0.33.4"
},
{
"name": "atom-dark-syntax",
"version": "0.29.0",
"theme": "syntax"
},
{
"name": "atom-dark-ui",
"version": "0.53.2",
"theme": "ui"
},
{
"name": "atom-light-syntax",
"version": "0.29.0",
"theme": "syntax"
},
{
"name": "atom-light-ui",
"version": "0.46.2",
"theme": "ui"
},
{
"name": "atom-typescript",
"version": "12.6.3"
},
{
"name": "auto-detect-indentation",
"version": "1.3.0"
},
{
"name": "autocomplete-atom-api",
"version": "0.10.7"
},
{
"name": "autocomplete-css",
"version": "0.17.5"
},
{
"name": "autocomplete-html",
"version": "0.8.4"
},
{
"name": "autocomplete-modules",
"version": "2.2.4"
},
{
"name": "autocomplete-plus",
"version": "2.40.7"
},
{
"name": "autocomplete-snippets",
"version": "1.12.0"
},
{
"name": "autoflow",
"version": "0.29.4"
},
{
"name": "autosave",
"version": "0.24.6"
},
{
"name": "background-tips",
"version": "0.28.0"
},
{
"name": "base16-tomorrow-dark-theme",
"version": "1.5.0",
"theme": "syntax"
},
{
"name": "base16-tomorrow-light-theme",
"version": "1.5.0",
"theme": "syntax"
},
{
"name": "block-comment-plus",
"version": "0.5.1"
},
{
"name": "block-travel",
"version": "1.0.5"
},
{
"name": "bookmarks",
"version": "0.45.1"
},
{
"name": "bracket-matcher",
"version": "0.89.2"
},
{
"name": "busy-signal",
"version": "1.4.3"
},
{
"name": "command-palette",
"version": "0.43.5"
},
{
"name": "dalek",
"version": "0.2.2"
},
{
"name": "deprecation-cop",
"version": "0.56.9"
},
{
"name": "dev-live-reload",
"version": "0.48.1"
},
{
"name": "encoding-selector",
"version": "0.23.9"
},
{
"name": "exception-reporting",
"version": "0.43.1"
},
{
"name": "expand-region",
"version": "0.4.2"
},
{
"name": "file-icons",
"version": "2.1.26"
},
{
"name": "file-watcher",
"version": "2.0.0"
},
{
"name": "find-and-replace",
"version": "0.215.12"
},
{
"name": "flow-ide",
"version": "1.12.1"
},
{
"name": "fuzzy-finder",
"version": "1.8.2"
},
{
"name": "git-blame",
"version": "1.7.0"
},
{
"name": "git-diff",
"version": "1.3.9"
},
{
"name": "github",
"version": "0.19.0"
},
{
"name": "go-to-line",
"version": "0.33.0"
},
{
"name": "grammar-selector",
"version": "0.50.1"
},
{
"name": "hyperclick",
"version": "0.1.5"
},
{
"name": "image-view",
"version": "0.63.1"
},
{
"name": "incompatible-packages",
"version": "0.27.3"
},
{
"name": "intentions",
"version": "1.1.5"
},
{
"name": "js-hyperclick",
"version": "1.13.3"
},
{
"name": "js-refactor",
"version": "0.8.1"
},
{
"name": "keybinding-resolver",
"version": "0.38.2"
},
{
"name": "language-babel",
"version": "2.85.0"
},
{
"name": "language-c",
"version": "0.60.4"
},
{
"name": "language-clojure",
"version": "0.22.7"
},
{
"name": "language-coffee-script",
"version": "0.49.3"
},
{
"name": "language-csharp",
"version": "1.0.4"
},
{
"name": "language-css",
"version": "0.42.11"
},
{
"name": "language-docker",
"version": "1.1.8"
},
{
"name": "language-gfm",
"version": "0.90.5"
},
{
"name": "language-git",
"version": "0.19.1"
},
{
"name": "language-go",
"version": "0.46.2"
},
{
"name": "language-html",
"version": "0.51.5"
},
{
"name": "language-hyperlink",
"version": "0.16.3"
},
{
"name": "language-java",
"version": "0.30.0"
},
{
"name": "language-javascript",
"version": "0.129.9"
},
{
"name": "language-json",
"version": "0.19.2"
},
{
"name": "language-less",
"version": "0.34.2"
},
{
"name": "language-make",
"version": "0.22.3"
},
{
"name": "language-mustache",
"version": "0.14.5"
},
{
"name": "language-objective-c",
"version": "0.15.1"
},
{
"name": "language-perl",
"version": "0.38.1"
},
{
"name": "language-php",
"version": "0.44.0"
},
{
"name": "language-property-list",
"version": "0.9.1"
},
{
"name": "language-pug",
"version": "0.0.22"
},
{
"name": "language-python",
"version": "0.51.4"
},
{
"name": "language-ruby",
"version": "0.72.7"
},
{
"name": "language-ruby-on-rails",
"version": "0.25.3"
},
{
"name": "language-rust",
"version": "0.4.12"
},
{
"name": "language-sass",
"version": "0.62.0"
},
{
"name": "language-shellscript",
"version": "0.27.4"
},
{
"name": "language-source",
"version": "0.9.0"
},
{
"name": "language-sql",
"version": "0.25.10"
},
{
"name": "language-text",
"version": "0.7.4"
},
{
"name": "language-todo",
"version": "0.29.4"
},
{
"name": "language-toml",
"version": "0.18.2"
},
{
"name": "language-typescript",
"version": "0.4.6"
},
{
"name": "language-vue",
"version": "0.23.1"
},
{
"name": "language-xml",
"version": "0.35.2"
},
{
"name": "language-yaml",
"version": "0.32.0"
},
{
"name": "last-cursor-position",
"version": "0.9.3"
},
{
"name": "line-ending-selector",
"version": "0.7.7"
},
{
"name": "link",
"version": "0.31.4"
},
{
"name": "linter",
"version": "2.2.0"
},
{
"name": "linter-eslint",
"version": "8.4.1"
},
{
"name": "linter-php",
"version": "1.5.1"
},
{
"name": "linter-rust",
"version": "0.9.0"
},
{
"name": "linter-ui-default",
"version": "1.7.1"
},
{
"name": "mark",
"version": "1.3.3"
},
{
"name": "markdown-preview",
"version": "0.159.23"
},
{
"name": "metrics",
"version": "1.6.2"
},
{
"name": "notifications",
"version": "0.70.5"
},
{
"name": "one-dark-syntax",
"version": "1.8.4",
"theme": "syntax"
},
{
"name": "one-dark-ui",
"version": "1.12.4",
"theme": "ui"
},
{
"name": "one-light-syntax",
"version": "1.8.4",
"theme": "syntax"
},
{
"name": "one-light-ui",
"version": "1.12.5",
"theme": "ui"
},
{
"name": "open-on-github",
"version": "1.3.1"
},
{
"name": "package-generator",
"version": "1.3.0"
},
{
"name": "prettier-atom",
"version": "0.55.2"
},
{
"name": "refactor",
"version": "0.11.5"
},
{
"name": "selection-highlight",
"version": "0.1.6"
},
{
"name": "settings-view",
"version": "0.255.0"
},
{
"name": "snippets",
"version": "1.3.5"
},
{
"name": "solarized-dark-syntax",
"version": "1.1.5",
"theme": "syntax"
},
{
"name": "solarized-light-syntax",
"version": "1.1.5",
"theme": "syntax"
},
{
"name": "sort-lines",
"version": "0.18.0"
},
{
"name": "spell-check",
"version": "0.74.0"
},
{
"name": "status-bar",
"version": "1.8.15"
},
{
"name": "styleguide",
"version": "0.49.12"
},
{
"name": "symbols-view",
"version": "0.118.2"
},
{
"name": "sync-settings",
"version": "0.8.6"
},
{
"name": "tabs",
"version": "0.109.2"
},
{
"name": "timecop",
"version": "0.36.2"
},
{
"name": "toggle-quotes",
"version": "1.1.2"
},
{
"name": "tree-view",
"version": "0.224.2"
},
{
"name": "update-package-dependencies",
"version": "0.13.1"
},
{
"name": "welcome",
"version": "0.36.7"
},
{
"name": "whitespace",
"version": "0.37.6"
},
{
"name": "wrap-guide",
"version": "0.40.3"
}
]
{
"atom-beautify": {
"general": {
"_analyticsUserId": "82064412-b168-476f-ab29-30ac55e5a61e"
}
},
"atom-ide-ui": {
"hyperclick": {
"darwinTriggerKeys": "altKey,metaKey"
}
},
"autocomplete-plus": {
"confirmCompletion": "enter",
"enableAutoActivation": false,
"minimumWordLength": 2,
"strictMatching": true,
"useAlternateScoring": false,
"useCoreMovementCommands": false
},
"core": {
"audioBeep": false,
"disabledPackages": [
"git-diff",
"autocomplete-snippets"
],
"packagesWithKeymapsDisabled": [
"git-plus"
],
"projectHome": "/Users/accurat_caesarsol/dev",
"telemetryConsent": "limited",
"themes": [
"one-dark-ui",
"atom-dark-syntax"
],
"warnOnLargeFileLimit": 1
},
"editor": {
"autoIndentOnPaste": true,
"fontFamily": "Ubuntu Mono",
"fontSize": 19,
"invisibles": {},
"nonWordCharacters": "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?…",
"preferredLineLength": 100,
"scrollPastEnd": true,
"showIndentGuide": true
},
"exception-reporting": {
"userId": "7035dd31-68ec-475d-b629-91c0b9e39e15"
},
"git-blame": {
"columnWidth": 344
},
"git-diff": {
"showIconsInEditorGutter": true
},
"goto-definition": {
"performanceMode": true
},
"hyperclick": {
"darwinTriggerKeys": "altKey"
},
"js-hyperclick": {
"usePendingPanes": true
},
"language-babel": {},
"linter": {},
"linter-eslint": {
"rulesToSilenceWhileTyping": [
"no-trailing-spaces",
"eol-last"
]
},
"linter-ui-default": {
"decorateOnTreeView": "Files and Directories",
"panelHeight": 74,
"showPanel": true,
"showTooltip": false,
"tooltipFollows": "Keyboard"
},
"one-dark-ui": {
"fontSize": 13,
"hideDockButtons": true,
"tabSizing": "Minimum"
},
"pigments": {
"markerType": "native-square-dot"
},
"prettier-atom": {
"formatOnSaveOptions": {
"excludedGlobs": [
"node_modules/"
],
"isDisabledIfNotInPackageJson": true
},
"prettierOptions": {
"printWidth": 100,
"semi": false,
"singleQuote": true,
"trailingComma": "all"
},
"useEditorConfig": false,
"useEslint": true
},
"sync-settings": {
"gistDescription": "caesarsol Atom settings"
},
"toggle-quotes": {
"quoteCharacters": "`\"'"
},
"welcome": {
"showOnStartup": false
},
"whitespace": {
"ignoreWhitespaceOnCurrentLine": false
}
}
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
'.source':
'Bound log':
'prefix': '::l'
'body': '::(function(){console.log(`$1`,this);return this})()'
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/
// style UI elements inside atom-text-editor
atom-text-editor {
// Yellow cursor
.cursor {
border-color: yellow;
}
// Yellow selection borders
.selection .region {
border: solid 1px yellow;
border-radius: 2px;
}
// Highlight current line
.cursor-line {
background-color: rgba(255,255,255,0.1)
}
// Yellow matching brackets underlines
.bracket-matcher .region {
border-bottom: 2px solid yellow;
}
}
// Fixes linter-ui transparent gutter
atom-text-editor.editor .gutter[gutter-name="linter-ui-default"],
atom-text-editor.editor .gutter[gutter-name="linter-ui-default"] .custom-decorations {
background-color: #262829 !important;
}
// Hide the Featured Packages section
.settings-view .section.packages:not(:first-child) {
display: none;
}
table.linter thead {
display: none;
}
// Refactor package
atom-text-editor.editor .refactor-decl .region {
border-bottom: 2px solid steelblue;
}
atom-text-editor.editor .refactor-ref .region {
border-bottom: 1px solid steelblue;
}
atom-text-editor.editor {
// Markdown - GitHub Flavored
.syntax--gfm {
.syntax--markup.syntax--raw { background-color: rgba(255, 255, 255, 0.13); }
//.syntax--markup.syntax--code { background-color: rgba(255, 255, 255, 0.13); }
.syntax--variable.syntax--list { color: orange; }
.syntax--link { color: steelblue; }
}
// JS
.syntax--js {
// Object Property
.syntax--variable.syntax--property {
color: steelblue;
}
.syntax--keyword.syntax--control {
color: #fb6432;
}
}
.syntax--source.syntax--ts .syntax--import-equals .syntax--string,
.syntax--source.syntax--tsx .syntax--import-equals .syntax--string,
.syntax--source.syntax--ts .syntax--import .syntax--string,
.syntax--source.syntax--tsx .syntax--import .syntax--string,
.syntax--source.syntax--ts .syntax--triple-slash .syntax--string,
.syntax--source.syntax--tsx .syntax--triple-slash .syntax--string {
text-decoration: none !important;
}
.syntax--meta.syntax--separator {
background-color: transparent;
}
}
.tab-bar .tab:not(.modified) .close-icon {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment