File tree Expand file tree Collapse file tree 8 files changed +43
-16
lines changed Expand file tree Collapse file tree 8 files changed +43
-16
lines changed Original file line number Diff line number Diff line change 22"name" : " nix-env-selector"  ,
33"displayName" : " Nix Environment Selector"  ,
44"description" : " Allows switch environment for Visual Studio Code and extensions based on Nix config file."  ,
5- "version" : " 1.0.5 "  ,
5+ "version" : " 1.0.6 "  ,
66"keywords" : [
77" nix"  ,
88" nix-env"  ,
  Load Diff This file was deleted. 
Original file line number Diff line number Diff line change 22 (:require  [" fs"   :refer  [readdir]]
33 [config :refer  [config vscode-config]]
44 [vscode.window :as  w]
5+  [vscode.env :refer  [open-external-url]]
56 [vscode.command :as  cmd]
67 [vscode.workspace :as  workspace]
78 [vscode.status-bar :as  status-bar]
89 [ext.lang :as  l]
10+  [ext.constants :as  constants]
911 [ext.nix-env :as  env]
1012 [promesa.core :as  p]
1113 [utils.helpers :refer  [unrender-workspace]]))
2325 (not ))) %1 )
2426 files-res)))
2527
26- 
2728(defn  show-propose-env-dialog  []
2829 (let  [select-label (->  l/lang :label  :select-env )
2930 dismiss-label (->  l/lang :label  :dismiss )
3738 :nix-env-selector/suggestion 
3839 false ))))))
3940
41+ (defn  show-donate-message  [state]
42+  (let  [show-message-info-path (str  :nix-env-selector/select-env )
43+  show-message? (.get  state show-message-info-path true )
44+  support-label (->  l/lang :label  :support )
45+  dismiss-label (->  l/lang :label  :dismiss )
46+  support-message (->  l/lang :notification  :support )]
47+  (when  show-message?
48+  (p/chain  (w/show-notification  support-message
49+  [support-label
50+  dismiss-label])
51+  (fn  [answer]
52+  (.update  state show-message-info-path false )
53+  (when 
54+  (=  answer support-label)
55+  (open-external-url  constants/donate-url)))))))
4056
4157(defn  show-reload-dialog  []
4258 (let  [reload-label (->  l/lang :label  :reload )
Original file line number Diff line number Diff line change 1+ (ns  ext.constants )
2+ 
3+ (def  donate-url  " https://secure.wayforpay.com/button/b2fdead505bff"  )
Original file line number Diff line number Diff line change 33(def  ^:private lang-eng 
44 {:notification  {:env-restored  " Original vscode environment will apply after reload" 
55 :env-applied  " Environment successfully prepared and will be using after reload" 
6-  :env-available  " The nix environment is available in your workspace"  }
6+  :env-available  " The nix environment is available in your workspace" 
7+  :support  " Do you like the extension? You can support the author if you wish"  }
78 :label  {:env-loading  " $(loading~spin) Applying environment..." 
89 :env-selected  " $(beaker) Environment: %ENV_NAME%" 
910 :env-need-reload  " $(beaker) Need reload" 
1011 :select-config-placeholder  " Select environment config" 
1112 :disabled-nix  " Disable Nix environment" 
1213 :reload  " Reload" 
1314 :select-env  " Select" 
14-  :dismiss  " Dismiss"  }})
15+  :dismiss  " Dismiss" 
16+  :support  " Support"  }})
1517
1618(def  lang  lang-eng )
Original file line number Diff line number Diff line change 22 (:require  [config :refer  [config update-config!]]
33 [promesa.core :as  p]
44 [vscode.status-bar :as  status]
5-  [vscode.context :refer  [subsciribe]]
5+  [vscode.context :refer  [subsciribe global-state ]]
66 [vscode.command :as  cmd]
77 [ext.actions :as  act]
88 [ext.nix-env :as  env]
1313 (update-config! )
1414 (let  [status-bar (status/create  :left  100 )]
1515 (if  (or  (not-empty  (:nix-file  @config)) (not-empty  (:nix-packages  @config)))
16-  (do 
16+  (try 
1717 (->  (env/get-nix-env-sync  {:nix-config  (:nix-file  @config)
1818 :packages  (:nix-packages  @config)
1919 :args  (:nix-args  @config)
2020 :nix-shell-path  (:nix-shell-path  @config)})
2121 (env/set-current-env ))
2222 (->>  status-bar
2323 (status/show  {:text  (render-env-status  lang (:nix-file  @config))
24-  :command  :nix-env-selector/select-env })))
24+  :command  :nix-env-selector/select-env }))
25+  (act/show-donate-message  (global-state  ctx))
26+ 
27+  (catch  :default  e
28+  (js/console.error  " Applying environment error"   e)))
2529
2630 ; ; show notification that nix config available
2731 ; ; if workspace contains .nix file(s)
Original file line number Diff line number Diff line change 44
55(defn  subsciribe  [ctx cmd]
66 (.push  (.-subscriptions  ctx) cmd))
7+ 
8+ (defn  global-state  [ctx]
9+  (.-globalState  ctx))
Original file line number Diff line number Diff line change 1+ (ns  vscode.env 
2+  (:require  [" vscode"   :refer  [env Uri]]))
3+ 
4+ (set!  *warn-on-infer* false )
5+ 
6+ (defn  open-external-url  [url]
7+  (.openExternal  env
8+  (.parse  Uri url)))
                                 You can’t perform that action at this time. 
               
                  
0 commit comments