Skip to content

Commit

Permalink
feat(core): Skip welcome when nothing changed (#254)
Browse files Browse the repository at this point in the history
Add a configuration setting to skip showing the welcoming dialog box
if there are no packages to add or remove.

Add documentation on this to MANUAL and core layer README.

This behaviour can be enabled by setting the new configuration option
`proton.core.alwaysShowWelcomeScreen` to false.
  • Loading branch information
jackcasey authored and dvcrn committed Feb 13, 2017
1 parent 532f6f3 commit a2a140a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
10 changes: 10 additions & 0 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [proton manual](#proton-manual)
- [.proton](#proton)
- [Editor configuration](#editor-configuration)
- [Configuring proton core itself](#configuring-proton-core-itself)
- [Syntax specific configuration](#syntax-specific-configuration)
- [Custom SPC keybinding](#custom-spc-keybinding)
- [Editor keymaps](#editor-keymaps)
Expand Down Expand Up @@ -37,6 +38,15 @@ would result in 2 vectors:
["editor.softWrap" true]
```

### Configuring proton core itself

There are several settings that allow users to customize proton's behaviour. These are under the `proton.core` namespace and can be seen [README for the core layer](/src/cljs/proton/layers/core/README.md). To set them to values other than the defaults add a row to your `.proton` file as above. For example:

```
;; Prefer to skip the welcome screen if there is nothing important being shown
["proton.core.alwaysShowWelcomeScreen" false]
```

### Syntax specific configuration

proton also supports configuration of `.xxx.source` kind of settings. Due to the leading dot, configuration for this is slightly different than with the previous settings. Use the `:scopeSelector` key inside the third vector element (options) like so:
Expand Down
45 changes: 26 additions & 19 deletions src/cljs/proton/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
(defn init []
(go
(proton/init-proton-mode-keymaps!)
(atom-env/show-modal-panel)
(atom-env/insert-process-step! "Initialising proton... Just a moment!" "")
(let [{:keys [additional-packages layers configuration disabled-packages keybindings keymaps]} (proton/load-config)
editor-default editor-config/default
Expand All @@ -130,7 +129,14 @@
all-keymaps (into [] (distinct (concat keymaps (:keymaps editor-default) (proton/keymaps-for-layers all-layers))))
all-keybindings (helpers/deep-merge (proton/keybindings-for-layers all-layers) keybindings)
wipe-configs? (true? (config-map "proton.core.wipeUserConfigs"))
all-packages (pm/register-packages (into (hash-map) (concat (map pm/register-installable selected-packages) (map pm/register-removable disabled-packages))))]
all-packages (pm/register-packages (into (hash-map) (concat (map pm/register-installable selected-packages) (map pm/register-removable disabled-packages))))
to-install (pm/get-to-install all-packages)
to-remove (pm/get-to-remove (filter (comp not pm/is-bundled?) all-packages))]

;; Show welcome screen if there are packages to install/remove or the option to always show is enabled
(if (or (config-map "proton.core.alwaysShowWelcomeScreen") (> (count to-install) 0) (> (count to-remove) 0) )
(atom-env/show-modal-panel))

;; wipe existing config
(when wipe-configs?
(do
Expand All @@ -153,24 +159,22 @@
(atom-env/mark-last-step-as-completed!)

;; Install all necessary packages
(let [to-install (pm/get-to-install all-packages)]
(if (> (count to-install) 0)
(do
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package-count'>" (count to-install) "</span> new package(s)") "")
(doseq [package to-install]
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package'>" (name package) "</span>"))
(<! (pm/install-package (name package)))
(atom-env/mark-last-step-as-completed!)))))
(if (> (count to-install) 0)
(do
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package-count'>" (count to-install) "</span> new package(s)") "")
(doseq [package to-install]
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package'>" (name package) "</span>"))
(<! (pm/install-package (name package)))
(atom-env/mark-last-step-as-completed!))))

;; Remove deleted packages
(let [to-remove (pm/get-to-remove (filter (comp not pm/is-bundled?) all-packages))]
(if (> (count to-remove) 0)
(do
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package-count'>" (count to-remove) "</span> orphaned package(s)") "")
(doseq [package to-remove]
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package'>" (name package) "</span>"))
(<! (pm/remove-package (name package)))
(atom-env/mark-last-step-as-completed!)))))
(if (> (count to-remove) 0)
(do
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package-count'>" (count to-remove) "</span> orphaned package(s)") "")
(doseq [package to-remove]
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package'>" (name package) "</span>"))
(<! (pm/remove-package (name package)))
(atom-env/mark-last-step-as-completed!))))

;; set the user config
(atom-env/insert-process-step! "Applying user configuration")
Expand All @@ -188,7 +192,10 @@
(mode-manager/activate-mode (atom-env/get-active-editor))
(keymap-manager/set-proton-leader-keys all-keybindings)
(proton/init-proton-leader-keys! all-configuration)
(.setTimeout js/window #(atom-env/hide-modal-panel) (config-map "proton.core.post-init-timeout")))))))

;; Hide the welcome screen after a timeout if we showed it earlier
(if (or (config-map "proton.core.alwaysShowWelcomeScreen") (> (count to-install) 0) (> (count to-remove) 0) )
(.setTimeout js/window #(atom-env/hide-modal-panel) (config-map "proton.core.post-init-timeout"))))))))

(defn on-space []
(reset! current-chain [])
Expand Down
25 changes: 13 additions & 12 deletions src/cljs/proton/layers/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ The core layer should get included by default. No installation needed.

### Configuration

| Name | Default | Type | Description |
|-----------------------------------|----------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `proton.core.showTabBar` | false | __boolean__ | whether the tab bar should be visible by default |
| `proton.core.relativeLineNumbers` | false | __boolean__ | whether to use relative line numbers instead of absolute ones |
| `proton.core.vim-provider` | :vim-mode-plus | __keyword__ | which vim emulation provider to use. Possible options are `:vim-mode-plus` and `:vim-mode` |
| `proton.core.wipeUserConfigs` | true | __boolean__ | always reset atom configuration before applying conifgs from layers and `~/.proton` |
| `proton.core.whichKeyDelay` | 0.4 | __number__ | which-key modal delay in seconds |
| `proton.core.whichKeyDelayOnInit` | false | __boolean__ | which-key modal delay for first show up and no delay when shown |
| `proton.core.whichKeyDisabled` | false | __boolean__ | which-key modal always hidden |
| `proton.core.inputProvider` | :vim-mode-plus | __keyword__ | editor input. available options are :vim-mode-plus, :vim-mode, :emacs, :default. You need to reload editor to apply changes properly |
| `proton.core.leaderKey` | "space" | __string__ | proton leader key binding. For non-vim modes its value is `alt-m` if not set manualy by user |
| `proton.core.modeKey` | "," | __string__ | proton major mode key alias to quickly invoke `SPC m`. For non-vim modes its value is `ctrl-alt-m` if not set by user |
| Name | Default | Type | Description |
|---------------------------------------|----------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `proton.core.alwaysShowWelcomeScreen` | true | __boolean__ | whether the welcome screen is always shown, even when there are only expected messages.
| `proton.core.showTabBar` | false | __boolean__ | whether the tab bar should be visible by default |
| `proton.core.relativeLineNumbers` | false | __boolean__ | whether to use relative line numbers instead of absolute ones |
| `proton.core.vim-provider` | :vim-mode-plus | __keyword__ | which vim emulation provider to use. Possible options are `:vim-mode-plus` and `:vim-mode` |
| `proton.core.wipeUserConfigs` | true | __boolean__ | always reset atom configuration before applying conifgs from layers and `~/.proton` |
| `proton.core.whichKeyDelay` | 0.4 | __number__ | which-key modal delay in seconds |
| `proton.core.whichKeyDelayOnInit` | false | __boolean__ | which-key modal delay for first show up and no delay when shown |
| `proton.core.whichKeyDisabled` | false | __boolean__ | which-key modal always hidden |
| `proton.core.inputProvider` | :vim-mode-plus | __keyword__ | editor input. available options are :vim-mode-plus, :vim-mode, :emacs, :default. You need to reload editor to apply changes properly |
| `proton.core.leaderKey` | "space" | __string__ | proton leader key binding. For non-vim modes its value is `alt-m` if not set manualy by user |
| `proton.core.modeKey` | "," | __string__ | proton major mode key alias to quickly invoke `SPC m`. For non-vim modes its value is `ctrl-alt-m` if not set by user |


### Key Bindings
Expand Down
1 change: 1 addition & 0 deletions src/cljs/proton/layers/core/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
["proton.core.relativeLineNumbers" false]
["proton.core.quickOpenProvider" :normal]
["proton.core.post-init-timeout" 3000]
["proton.core.alwaysShowWelcomeScreen" true]
["proton.core.wipeUserConfigs" true]
["proton.core.whichKeyDelay" 0.4]
["proton.core.whichKeyDelayOnInit" false]
Expand Down

0 comments on commit a2a140a

Please sign in to comment.