Skip to content

Commit a2a140a

Browse files
jackcaseydvcrn
authored andcommitted
feat(core): Skip welcome when nothing changed (dvcrn#254)
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.
1 parent 532f6f3 commit a2a140a

File tree

4 files changed

+50
-31
lines changed

4 files changed

+50
-31
lines changed

MANUAL.md

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [proton manual](#proton-manual)
44
- [.proton](#proton)
55
- [Editor configuration](#editor-configuration)
6+
- [Configuring proton core itself](#configuring-proton-core-itself)
67
- [Syntax specific configuration](#syntax-specific-configuration)
78
- [Custom SPC keybinding](#custom-spc-keybinding)
89
- [Editor keymaps](#editor-keymaps)
@@ -37,6 +38,15 @@ would result in 2 vectors:
3738
["editor.softWrap" true]
3839
```
3940

41+
### Configuring proton core itself
42+
43+
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:
44+
45+
```
46+
;; Prefer to skip the welcome screen if there is nothing important being shown
47+
["proton.core.alwaysShowWelcomeScreen" false]
48+
```
49+
4050
### Syntax specific configuration
4151

4252
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:

src/cljs/proton/core.cljs

+26-19
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
(defn init []
113113
(go
114114
(proton/init-proton-mode-keymaps!)
115-
(atom-env/show-modal-panel)
116115
(atom-env/insert-process-step! "Initialising proton... Just a moment!" "")
117116
(let [{:keys [additional-packages layers configuration disabled-packages keybindings keymaps]} (proton/load-config)
118117
editor-default editor-config/default
@@ -130,7 +129,14 @@
130129
all-keymaps (into [] (distinct (concat keymaps (:keymaps editor-default) (proton/keymaps-for-layers all-layers))))
131130
all-keybindings (helpers/deep-merge (proton/keybindings-for-layers all-layers) keybindings)
132131
wipe-configs? (true? (config-map "proton.core.wipeUserConfigs"))
133-
all-packages (pm/register-packages (into (hash-map) (concat (map pm/register-installable selected-packages) (map pm/register-removable disabled-packages))))]
132+
all-packages (pm/register-packages (into (hash-map) (concat (map pm/register-installable selected-packages) (map pm/register-removable disabled-packages))))
133+
to-install (pm/get-to-install all-packages)
134+
to-remove (pm/get-to-remove (filter (comp not pm/is-bundled?) all-packages))]
135+
136+
;; Show welcome screen if there are packages to install/remove or the option to always show is enabled
137+
(if (or (config-map "proton.core.alwaysShowWelcomeScreen") (> (count to-install) 0) (> (count to-remove) 0) )
138+
(atom-env/show-modal-panel))
139+
134140
;; wipe existing config
135141
(when wipe-configs?
136142
(do
@@ -153,24 +159,22 @@
153159
(atom-env/mark-last-step-as-completed!)
154160

155161
;; Install all necessary packages
156-
(let [to-install (pm/get-to-install all-packages)]
157-
(if (> (count to-install) 0)
158-
(do
159-
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package-count'>" (count to-install) "</span> new package(s)") "")
160-
(doseq [package to-install]
161-
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package'>" (name package) "</span>"))
162-
(<! (pm/install-package (name package)))
163-
(atom-env/mark-last-step-as-completed!)))))
162+
(if (> (count to-install) 0)
163+
(do
164+
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package-count'>" (count to-install) "</span> new package(s)") "")
165+
(doseq [package to-install]
166+
(atom-env/insert-process-step! (str "Installing <span class='proton-status-package'>" (name package) "</span>"))
167+
(<! (pm/install-package (name package)))
168+
(atom-env/mark-last-step-as-completed!))))
164169

165170
;; Remove deleted packages
166-
(let [to-remove (pm/get-to-remove (filter (comp not pm/is-bundled?) all-packages))]
167-
(if (> (count to-remove) 0)
168-
(do
169-
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package-count'>" (count to-remove) "</span> orphaned package(s)") "")
170-
(doseq [package to-remove]
171-
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package'>" (name package) "</span>"))
172-
(<! (pm/remove-package (name package)))
173-
(atom-env/mark-last-step-as-completed!)))))
171+
(if (> (count to-remove) 0)
172+
(do
173+
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package-count'>" (count to-remove) "</span> orphaned package(s)") "")
174+
(doseq [package to-remove]
175+
(atom-env/insert-process-step! (str "Removing <span class='proton-status-package'>" (name package) "</span>"))
176+
(<! (pm/remove-package (name package)))
177+
(atom-env/mark-last-step-as-completed!))))
174178

175179
;; set the user config
176180
(atom-env/insert-process-step! "Applying user configuration")
@@ -188,7 +192,10 @@
188192
(mode-manager/activate-mode (atom-env/get-active-editor))
189193
(keymap-manager/set-proton-leader-keys all-keybindings)
190194
(proton/init-proton-leader-keys! all-configuration)
191-
(.setTimeout js/window #(atom-env/hide-modal-panel) (config-map "proton.core.post-init-timeout")))))))
195+
196+
;; Hide the welcome screen after a timeout if we showed it earlier
197+
(if (or (config-map "proton.core.alwaysShowWelcomeScreen") (> (count to-install) 0) (> (count to-remove) 0) )
198+
(.setTimeout js/window #(atom-env/hide-modal-panel) (config-map "proton.core.post-init-timeout"))))))))
192199

193200
(defn on-space []
194201
(reset! current-chain [])

src/cljs/proton/layers/core/README.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ The core layer should get included by default. No installation needed.
88

99
### Configuration
1010

11-
| Name | Default | Type | Description |
12-
|-----------------------------------|----------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|
13-
| `proton.core.showTabBar` | false | __boolean__ | whether the tab bar should be visible by default |
14-
| `proton.core.relativeLineNumbers` | false | __boolean__ | whether to use relative line numbers instead of absolute ones |
15-
| `proton.core.vim-provider` | :vim-mode-plus | __keyword__ | which vim emulation provider to use. Possible options are `:vim-mode-plus` and `:vim-mode` |
16-
| `proton.core.wipeUserConfigs` | true | __boolean__ | always reset atom configuration before applying conifgs from layers and `~/.proton` |
17-
| `proton.core.whichKeyDelay` | 0.4 | __number__ | which-key modal delay in seconds |
18-
| `proton.core.whichKeyDelayOnInit` | false | __boolean__ | which-key modal delay for first show up and no delay when shown |
19-
| `proton.core.whichKeyDisabled` | false | __boolean__ | which-key modal always hidden |
20-
| `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 |
21-
| `proton.core.leaderKey` | "space" | __string__ | proton leader key binding. For non-vim modes its value is `alt-m` if not set manualy by user |
22-
| `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 |
11+
| Name | Default | Type | Description |
12+
|---------------------------------------|----------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------|
13+
| `proton.core.alwaysShowWelcomeScreen` | true | __boolean__ | whether the welcome screen is always shown, even when there are only expected messages.
14+
| `proton.core.showTabBar` | false | __boolean__ | whether the tab bar should be visible by default |
15+
| `proton.core.relativeLineNumbers` | false | __boolean__ | whether to use relative line numbers instead of absolute ones |
16+
| `proton.core.vim-provider` | :vim-mode-plus | __keyword__ | which vim emulation provider to use. Possible options are `:vim-mode-plus` and `:vim-mode` |
17+
| `proton.core.wipeUserConfigs` | true | __boolean__ | always reset atom configuration before applying conifgs from layers and `~/.proton` |
18+
| `proton.core.whichKeyDelay` | 0.4 | __number__ | which-key modal delay in seconds |
19+
| `proton.core.whichKeyDelayOnInit` | false | __boolean__ | which-key modal delay for first show up and no delay when shown |
20+
| `proton.core.whichKeyDisabled` | false | __boolean__ | which-key modal always hidden |
21+
| `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 |
22+
| `proton.core.leaderKey` | "space" | __string__ | proton leader key binding. For non-vim modes its value is `alt-m` if not set manualy by user |
23+
| `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 |
2324

2425

2526
### Key Bindings

src/cljs/proton/layers/core/core.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
["proton.core.relativeLineNumbers" false]
3030
["proton.core.quickOpenProvider" :normal]
3131
["proton.core.post-init-timeout" 3000]
32+
["proton.core.alwaysShowWelcomeScreen" true]
3233
["proton.core.wipeUserConfigs" true]
3334
["proton.core.whichKeyDelay" 0.4]
3435
["proton.core.whichKeyDelayOnInit" false]

0 commit comments

Comments
 (0)