rouslan | 357569e | 2016-08-15 00:49:35 | [diff] [blame] | 1 | # Atom |
| 2 | |
pwnall | 7ebe6ab | 2016-12-06 02:46:58 | [diff] [blame] | 3 | [Atom](https://atom.io/) |
| 4 | ([Wikipedia](https://en.wikipedia.org/wiki/Atom_(text_editor))) is a |
| 5 | multi-platform code editor that is itself based on Chromium. |
| 6 | [Turtles aside](https://en.wikipedia.org/wiki/Turtles_all_the_way_down), Atom |
| 7 | has a growing community and base of installable plugins and themes. |
| 8 | |
| 9 | You can download and install via links from the |
| 10 | [main Atom site](https://atom.io/). If you're interested in checking out the |
| 11 | code and contributing, see the |
| 12 | [developer page](https://github.com/atom/atom/blob/master/docs/build-instructions/linux.md). |
| 13 | |
rouslan | 357569e | 2016-08-15 00:49:35 | [diff] [blame] | 14 | [TOC] |
| 15 | |
| 16 | ## Workflow |
| 17 | |
| 18 | A typical Atom workflow consists of the following. |
| 19 | |
| 20 | 1. Use `Ctrl-Shift-R` to find a symbol in the `.tags` file or `Ctrl-P` to find |
| 21 | a file by name. |
chaopeng | 3299ca3 | 2016-10-30 20:19:06 | [diff] [blame] | 22 | 2. Switch between the header and the source using `Alt-O`(`Ctrl-Opt-S` on OSX). |
rouslan | 357569e | 2016-08-15 00:49:35 | [diff] [blame] | 23 | 3. While editing, `you-complete-me` package helps with C++ auto-completion and |
| 24 | shows compile errors through `lint` package. |
| 25 | 4. Press `Ctrl-Shift-P` and type `format<Enter>` to format the code. |
| 26 | 5. Select the target to build by pressing `F7` and typing, for example, |
| 27 | `base_unittests`. |
| 28 | 6. Rebuild again by pressing `F9`. |
| 29 | |
| 30 | ## Atom packages |
| 31 | |
| 32 | To setup this workflow, install Atom packages for Chrome development. |
| 33 | |
| 34 | ``` |
pwnall | 7ebe6ab | 2016-12-06 02:46:58 | [diff] [blame] | 35 | $ apm install build build-ninja clang-format \ |
chaopeng | 3299ca3 | 2016-10-30 20:19:06 | [diff] [blame] | 36 | linter linter-cpplint linter-eslint switch-header-source you-complete-me |
rouslan | 357569e | 2016-08-15 00:49:35 | [diff] [blame] | 37 | ``` |
| 38 | |
| 39 | ## Autocomplete |
| 40 | |
| 41 | Install C++ auto-completion engine. |
| 42 | |
| 43 | ``` |
| 44 | $ git clone https://github.com/Valloric/ycmd.git ~/.ycmd |
| 45 | $ cd ~/.ycmd |
| 46 | $ ./build.py --clang-completer |
| 47 | ``` |
| 48 | |
Victor Costan | 1a50407 | 2018-02-20 20:10:25 | [diff] [blame] | 49 | On Mac, replace the last command above with the following. |
| 50 | |
| 51 | ``` |
| 52 | $ ./build.py --clang-completer --system-libclang |
| 53 | ``` |
| 54 | |
rouslan | 357569e | 2016-08-15 00:49:35 | [diff] [blame] | 55 | ## JavaScript lint |
| 56 | |
Kent Tamura | 59ffb02 | 2018-11-27 05:30:56 | [diff] [blame] | 57 | Install JavaScript linter for Blink web tests. |
rouslan | 357569e | 2016-08-15 00:49:35 | [diff] [blame] | 58 | |
| 59 | ``` |
| 60 | $ npm install -g eslint eslint-config-google |
| 61 | ``` |
| 62 | |
| 63 | Configure the JavaScript linter to use the Google style by default by replacing |
| 64 | the contents of `~/.eslintrc` with the following. |
| 65 | |
| 66 | ``` |
| 67 | { |
| 68 | "extends": "google", |
| 69 | "env": { |
| 70 | "browser": true |
| 71 | } |
| 72 | } |
| 73 | ``` |
| 74 | |
| 75 | ## Configuration |
| 76 | |
| 77 | Configure Atom by replacing the contents of `~/.atom/config.cson` with the |
| 78 | following. Replace `<path-of-your-home-dir>` and |
| 79 | `<path-of-your-chrome-checkout>` with the actual full paths of your home |
| 80 | directory and chrome checkout. For example, these can be `/Users/bob` and |
| 81 | `/Users/bob/chrome/src`. |
| 82 | |
| 83 | ``` |
| 84 | "*": |
| 85 | # Configure ninja builder. |
| 86 | "build-ninja": |
| 87 | ninjaOptions: [ |
| 88 | # The number of jobs to use when running ninja. Adjust to taste. |
| 89 | "-j10" |
| 90 | ] |
| 91 | subdirs: [ |
| 92 | # The location of your build.ninja file. |
| 93 | "out/gn" |
| 94 | ] |
| 95 | # Do not auto-format entire files on save. |
| 96 | "clang-format": |
| 97 | formatCOnSave: false |
| 98 | formatCPlusPlusOnSave: false |
| 99 | core: |
| 100 | # Treat .h files as C++. |
| 101 | customFileTypes: |
| 102 | "source.cpp": [ |
| 103 | "h" |
| 104 | ] |
| 105 | # Don't send metrics if you're working on anything sensitive. |
| 106 | disabledPackages: [ |
| 107 | "metrics" |
| 108 | "exception-reporting" |
| 109 | ] |
| 110 | # Use spaces instead of tabs. |
| 111 | editor: |
| 112 | tabType: "soft" |
| 113 | # Show lint errors only when you save the file. |
| 114 | linter: |
| 115 | lintOnFly: false |
| 116 | # Configure JavaScript lint. |
| 117 | "linter-eslint": |
| 118 | eslintrcPath: "<path-of-your-home-dir>/.eslintrc" |
| 119 | useGlobalEslint: true |
| 120 | # Don't show ignored files in the project file browser. |
| 121 | "tree-view": |
| 122 | hideIgnoredNames: true |
| 123 | hideVcsIgnoredFiles: true |
| 124 | # Configure C++ autocomplete and lint. |
| 125 | "you-complete-me": |
| 126 | globalExtraConfig: "<path-of-your-chrome-checkout>/tools/vim/chromium.ycm_extra_conf.py" |
| 127 | ycmdPath: "<path-of-your-home-dir>/.ycmd/" |
| 128 | # Java uses 4 space indents and 100 character lines. |
| 129 | ".java.source": |
| 130 | editor: |
| 131 | preferredLineLength: 100 |
| 132 | tabLength: 4 |
| 133 | ``` |
| 134 | |
| 135 | ## Symbol lookup |
| 136 | |
| 137 | Atom fuzzy file finder is slow to index all files in Chrome. If you're working |
| 138 | on a project that frequently uses `foo` or `bar` in files names, you can create |
| 139 | a small `.tags` file to efficiently search the symbols within these files. Be |
| 140 | sure to use "Exuberant Ctags." |
| 141 | |
| 142 | ``` |
| 143 | $ git ls | egrep -i "foo|bar" | ctags -f .tags -L - |
| 144 | ``` |
| 145 | |
| 146 | Don't create a ctags file for the full Chrome repository, as that would result |
| 147 | in ~9GB tag file that will not be usable in Atom. |