lean4monaco 1.0.46 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/README.md +75 -0
  2. package/dist/JuliaMono-Regular.ttf +0 -0
  3. package/dist/css/custom.css +7 -1
  4. package/dist/infowebview.d.ts +3 -4
  5. package/dist/infowebview.js +4 -4
  6. package/dist/lean4-infoview/codicon.ttf +0 -0
  7. package/dist/lean4-infoview/esm-shims/react-dom.d.ts +5 -0
  8. package/dist/lean4-infoview/esm-shims/react-jsx-runtime.d.ts +5 -0
  9. package/dist/lean4-infoview/esm-shims/react.d.ts +5 -0
  10. package/dist/lean4-infoview/index.css +4161 -0
  11. package/dist/lean4-infoview/index.d.ts +16 -0
  12. package/dist/lean4-infoview/index.development.js +37312 -0
  13. package/dist/lean4-infoview/index.production.min.js +1528 -0
  14. package/dist/lean4-infoview/infoview/collapsing.d.ts +12 -0
  15. package/dist/lean4-infoview/infoview/contexts.d.ts +10 -0
  16. package/dist/lean4-infoview/infoview/editorConnection.d.ts +22 -0
  17. package/dist/lean4-infoview/infoview/errors.d.ts +14 -0
  18. package/dist/lean4-infoview/infoview/event.d.ts +33 -0
  19. package/dist/lean4-infoview/infoview/goalLocation.d.ts +61 -0
  20. package/dist/lean4-infoview/infoview/goals.d.ts +46 -0
  21. package/dist/lean4-infoview/infoview/info.d.ts +18 -0
  22. package/dist/lean4-infoview/infoview/infos.d.ts +2 -0
  23. package/dist/lean4-infoview/infoview/interactiveCode.d.ts +19 -0
  24. package/dist/lean4-infoview/infoview/main.d.ts +13 -0
  25. package/dist/lean4-infoview/infoview/messages.d.ts +19 -0
  26. package/dist/lean4-infoview/infoview/rpcSessions.d.ts +11 -0
  27. package/dist/lean4-infoview/infoview/serverVersion.d.ts +10 -0
  28. package/dist/lean4-infoview/infoview/tooltips.d.ts +32 -0
  29. package/dist/lean4-infoview/infoview/traceExplorer.d.ts +11 -0
  30. package/dist/lean4-infoview/infoview/userWidget.d.ts +39 -0
  31. package/dist/lean4-infoview/infoview/util.d.ts +144 -0
  32. package/dist/lean4-infoview/loader.d.ts +20 -0
  33. package/dist/lean4-infoview/loader.development.js +1006 -0
  34. package/dist/lean4-infoview/loader.production.min.js +1 -0
  35. package/dist/lean4-infoview/react-dom.development.js +30537 -0
  36. package/dist/lean4-infoview/react-dom.production.min.js +21 -0
  37. package/dist/lean4-infoview/react-jsx-runtime.development.js +1362 -0
  38. package/dist/lean4-infoview/react-jsx-runtime.production.min.js +1 -0
  39. package/dist/lean4-infoview/react.development.js +2823 -0
  40. package/dist/lean4-infoview/react.production.min.js +1 -0
  41. package/dist/leanmonaco.js +5 -4
  42. package/dist/monaco-lean4/vscode-lean4/package.json +944 -0
  43. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +9 -0
  44. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +20 -0
  45. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.d.ts +12 -0
  46. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.js +40 -0
  47. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +20 -0
  48. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +79 -0
  49. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.d.ts +13 -0
  50. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.js +29 -0
  51. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +28 -0
  52. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +124 -0
  53. package/dist/monaco-lean4/vscode-lean4/src/config.d.ts +33 -0
  54. package/dist/monaco-lean4/vscode-lean4/src/config.js +119 -0
  55. package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +27 -0
  56. package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +133 -0
  57. package/dist/monaco-lean4/vscode-lean4/src/infoview.d.ts +69 -0
  58. package/dist/monaco-lean4/vscode-lean4/src/infoview.js +711 -0
  59. package/dist/monaco-lean4/vscode-lean4/src/leanclient.d.ts +67 -0
  60. package/dist/monaco-lean4/vscode-lean4/src/leanclient.js +443 -0
  61. package/dist/monaco-lean4/vscode-lean4/src/rpc.d.ts +16 -0
  62. package/dist/monaco-lean4/vscode-lean4/src/rpc.js +102 -0
  63. package/dist/monaco-lean4/vscode-lean4/src/taskgutter.d.ts +11 -0
  64. package/dist/monaco-lean4/vscode-lean4/src/taskgutter.js +130 -0
  65. package/dist/monaco-lean4/vscode-lean4/src/utils/batch.d.ts +37 -0
  66. package/dist/monaco-lean4/vscode-lean4/src/utils/batch.js +203 -0
  67. package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.d.ts +41 -0
  68. package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.js +205 -0
  69. package/dist/monaco-lean4/vscode-lean4/src/utils/converters.d.ts +16 -0
  70. package/dist/monaco-lean4/vscode-lean4/src/utils/converters.js +129 -0
  71. package/dist/monaco-lean4/vscode-lean4/src/utils/elan.d.ts +3 -0
  72. package/dist/monaco-lean4/vscode-lean4/src/utils/elan.js +4 -0
  73. package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.d.ts +21 -0
  74. package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.js +53 -0
  75. package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.d.ts +35 -0
  76. package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.js +136 -0
  77. package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.d.ts +17 -0
  78. package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.js +36 -0
  79. package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +37 -0
  80. package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.js +210 -0
  81. package/dist/monaco-lean4/vscode-lean4/src/utils/logger.d.ts +7 -0
  82. package/dist/monaco-lean4/vscode-lean4/src/utils/logger.js +20 -0
  83. package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.d.ts +24 -0
  84. package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.js +110 -0
  85. package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.d.ts +9 -0
  86. package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.js +125 -0
  87. package/dist/monacoleanclient.d.ts +1 -2
  88. package/dist/monacoleanclient.js +3 -3
  89. package/dist/vscode-lean4/lean4-infoview/package.json +25 -23
  90. package/dist/vscode-lean4/lean4-infoview/src/infoview/highlightjs.css +210 -0
  91. package/dist/vscode-lean4/lean4-infoview/tsconfig.json +6 -2
  92. package/dist/vscode-lean4/lean4-infoview-api/package.json +1 -1
  93. package/dist/vscode-lean4/lean4-unicode-input/package.json +1 -1
  94. package/dist/vscode-lean4/lean4-unicode-input/src/abbreviations.json +12 -12
  95. package/dist/vscode-lean4/lean4-unicode-input-component/package.json +2 -2
  96. package/dist/vscode-lean4/package-lock.json +6129 -3245
  97. package/dist/vscode-lean4/vscode-lean4/language-configuration.json +1 -1
  98. package/dist/vscode-lean4/vscode-lean4/loogleview/static/index.css +19 -16
  99. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-dark.svg +91 -0
  100. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-dark.svg +114 -0
  101. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-light.svg +114 -0
  102. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-passthrough-dark.svg +109 -0
  103. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-i-passthrough-light.svg +109 -0
  104. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-init-dark.svg +100 -0
  105. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-init-light.svg +100 -0
  106. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-dark.svg +123 -0
  107. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-light.svg +123 -0
  108. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-passthrough-dark.svg +109 -0
  109. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-l-passthrough-light.svg +109 -0
  110. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-light.svg +91 -0
  111. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-dark.svg +123 -0
  112. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-light.svg +123 -0
  113. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-passthrough-dark.svg +118 -0
  114. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/error-t-passthrough-light.svg +118 -0
  115. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-dark.svg +138 -0
  116. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-i-passthrough-dark.svg +160 -0
  117. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-i-passthrough-light.svg +160 -0
  118. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-l-passthrough-dark.svg +158 -0
  119. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-l-passthrough-light.svg +158 -0
  120. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-light.svg +138 -0
  121. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-t-passthrough-dark.svg +169 -0
  122. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-checkmark-t-passthrough-light.svg +169 -0
  123. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-dark.svg +147 -0
  124. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-i-passthrough-dark.svg +170 -0
  125. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-i-passthrough-light.svg +170 -0
  126. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-l-passthrough-dark.svg +167 -0
  127. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-l-passthrough-light.svg +167 -0
  128. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-light.svg +147 -0
  129. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-t-passthrough-dark.svg +179 -0
  130. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-circled-checkmark-t-passthrough-light.svg +179 -0
  131. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-dark.svg +165 -0
  132. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-i-passthrough-dark.svg +187 -0
  133. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-i-passthrough-light.svg +187 -0
  134. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-l-passthrough-dark.svg +185 -0
  135. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-l-passthrough-light.svg +185 -0
  136. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-light.svg +165 -0
  137. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-t-passthrough-dark.svg +196 -0
  138. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-octopus-t-passthrough-light.svg +196 -0
  139. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-dark.svg +184 -0
  140. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-i-passthrough-dark.svg +206 -0
  141. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-i-passthrough-light.svg +206 -0
  142. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-l-passthrough-dark.svg +204 -0
  143. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-l-passthrough-light.svg +204 -0
  144. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-light.svg +184 -0
  145. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-t-passthrough-dark.svg +215 -0
  146. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/goals-accomplished-tada-t-passthrough-light.svg +215 -0
  147. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-dark.svg +132 -0
  148. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-i-passthrough-dark.svg +154 -0
  149. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-i-passthrough-light.svg +154 -0
  150. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-l-passthrough-dark.svg +152 -0
  151. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-l-passthrough-light.svg +152 -0
  152. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-light.svg +132 -0
  153. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-t-passthrough-dark.svg +163 -0
  154. package/dist/vscode-lean4/vscode-lean4/media/diagnostic-gutter-icons/warning-t-passthrough-light.svg +163 -0
  155. package/dist/vscode-lean4/vscode-lean4/moogleview/static/index.css +198 -0
  156. package/dist/vscode-lean4/vscode-lean4/moogleview/tsconfig.json +10 -0
  157. package/dist/vscode-lean4/vscode-lean4/package.json +638 -18
  158. package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +2 -2
  159. package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +2 -2
  160. package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +2 -3
  161. package/dist/vscode-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +3 -5
  162. package/dist/vscode-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +1 -2
  163. package/dist/vscode-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +4 -8
  164. package/dist/vscode-lean4/vscode-lean4/src/config.d.ts +14 -1
  165. package/dist/vscode-lean4/vscode-lean4/src/config.js +56 -5
  166. package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnoser.d.ts +36 -5
  167. package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnoser.js +59 -23
  168. package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnostics.d.ts +22 -17
  169. package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupDiagnostics.js +182 -119
  170. package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +33 -20
  171. package/dist/vscode-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +235 -89
  172. package/dist/vscode-lean4/vscode-lean4/src/infoview.d.ts +7 -18
  173. package/dist/vscode-lean4/vscode-lean4/src/infoview.js +217 -102
  174. package/dist/vscode-lean4/vscode-lean4/src/leanclient.d.ts +12 -7
  175. package/dist/vscode-lean4/vscode-lean4/src/leanclient.js +187 -64
  176. package/dist/vscode-lean4/vscode-lean4/src/taskgutter.d.ts +35 -3
  177. package/dist/vscode-lean4/vscode-lean4/src/taskgutter.js +533 -93
  178. package/dist/vscode-lean4/vscode-lean4/src/utils/batch.d.ts +12 -4
  179. package/dist/vscode-lean4/vscode-lean4/src/utils/batch.js +78 -72
  180. package/dist/vscode-lean4/vscode-lean4/src/utils/clientProvider.d.ts +9 -9
  181. package/dist/vscode-lean4/vscode-lean4/src/utils/clientProvider.js +121 -77
  182. package/dist/vscode-lean4/vscode-lean4/src/utils/converters.d.ts +15 -0
  183. package/dist/vscode-lean4/vscode-lean4/src/utils/converters.js +9 -0
  184. package/dist/vscode-lean4/vscode-lean4/src/utils/elan.d.ts +179 -1
  185. package/dist/vscode-lean4/vscode-lean4/src/utils/elan.js +422 -3
  186. package/dist/vscode-lean4/vscode-lean4/src/utils/exturi.d.ts +3 -1
  187. package/dist/vscode-lean4/vscode-lean4/src/utils/exturi.js +11 -11
  188. package/dist/vscode-lean4/vscode-lean4/src/utils/groupBy.d.ts +2 -0
  189. package/dist/vscode-lean4/vscode-lean4/src/utils/groupBy.js +17 -0
  190. package/dist/vscode-lean4/vscode-lean4/src/utils/internalErrors.d.ts +2 -0
  191. package/dist/vscode-lean4/vscode-lean4/src/utils/internalErrors.js +35 -0
  192. package/dist/vscode-lean4/vscode-lean4/src/utils/leanCmdRunner.d.ts +34 -0
  193. package/dist/vscode-lean4/vscode-lean4/src/utils/leanCmdRunner.js +249 -0
  194. package/dist/vscode-lean4/vscode-lean4/src/utils/leanEditorProvider.d.ts +83 -0
  195. package/dist/vscode-lean4/vscode-lean4/src/utils/leanEditorProvider.js +323 -0
  196. package/dist/vscode-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +41 -12
  197. package/dist/vscode-lean4/vscode-lean4/src/utils/leanInstaller.js +245 -128
  198. package/dist/vscode-lean4/vscode-lean4/src/utils/notifs.d.ts +27 -22
  199. package/dist/vscode-lean4/vscode-lean4/src/utils/notifs.js +177 -82
  200. package/dist/vscode-lean4/vscode-lean4/src/utils/projectInfo.d.ts +11 -4
  201. package/dist/vscode-lean4/vscode-lean4/src/utils/projectInfo.js +18 -16
  202. package/dist/vscode-lean4/vscode-lean4/src/utils/semverRegex.d.ts +1 -0
  203. package/dist/vscode-lean4/vscode-lean4/src/utils/semverRegex.js +2 -0
  204. package/dist/vscode-lean4/vscode-lean4/src/utils/viewColumn.d.ts +3 -0
  205. package/dist/vscode-lean4/vscode-lean4/src/utils/viewColumn.js +22 -0
  206. package/dist/vscode-lean4/vscode-lean4/tsconfig.json +2 -1
  207. package/dist/vscode-lean4/vscode-lean4/webview/tsconfig.json +3 -1
  208. package/dist/vscode.css +7 -0
  209. package/package.json +7 -5
@@ -1,10 +1,12 @@
1
1
  import { RpcErrorCode, } from '@leanprover/infoview-api';
2
- import { commands, env, languages, Selection, TextEditorRevealType, ViewColumn, window, workspace, } from 'vscode';
3
- import { getEditorLineHeight, getInfoViewAllErrorsOnLine, getInfoViewAutoOpen, getInfoViewAutoOpenShowsGoal, getInfoViewDebounceTime, getInfoViewEmphasizeFirstGoal, getInfoViewReverseTacticState, getInfoViewShowExpectedType, getInfoViewShowGoalNames, getInfoViewShowTooltipOnHover, getInfoViewStyle, } from './config';
2
+ import { commands, ConfigurationTarget, env, Selection, TextEditorRevealType, Uri, window, workspace, } from 'vscode';
3
+ import { getEditorLineHeight, getInfoViewAllErrorsOnLine, getInfoViewAutoOpen, getInfoViewAutoOpenShowsGoal, getInfoViewDebounceTime, getInfoViewEmphasizeFirstGoal, getInfoViewExpectedTypeVisibility, getInfoViewHideInaccessibleAssumptions, getInfoViewHideInstanceAssumptions, getInfoViewHideLetValues, getInfoViewHideTypeAssumptions, getInfoViewReverseTacticState, getInfoViewShowGoalNames, getInfoViewShowTooltipOnHover, getInfoViewStyle, minIfProd, prodOrDev, } from './config';
4
4
  import { c2pConverter, p2cConverter } from './utils/converters';
5
5
  import { parseExtUri, toExtUri } from './utils/exturi';
6
+ import { lean } from './utils/leanEditorProvider';
6
7
  import { logger } from './utils/logger';
7
- import { displayError, displayInformation } from './utils/notifs';
8
+ import { displayNotification } from './utils/notifs';
9
+ import { viewColumnOfActiveTextEditor } from './utils/viewColumn';
8
10
  const keepAlivePeriodMs = 10000;
9
11
  async function rpcConnect(client, uri) {
10
12
  const connParams = { uri };
@@ -39,8 +41,7 @@ export class RpcSessionAtPos {
39
41
  }
40
42
  }
41
43
  export class InfoProvider {
42
- provider;
43
- leanDocs;
44
+ clientProvider;
44
45
  context;
45
46
  infoWebviewFactory;
46
47
  /** Instance of the panel, if it is open. Otherwise `undefined`. */
@@ -49,7 +50,6 @@ export class InfoProvider {
49
50
  clientSubscriptions = [];
50
51
  stylesheet = '';
51
52
  autoOpened = false;
52
- clientProvider;
53
53
  // Subscriptions are counted and only disposed of when count becomes 0.
54
54
  serverNotifSubscriptions = new Map();
55
55
  clientNotifSubscriptions = new Map();
@@ -85,10 +85,48 @@ export class InfoProvider {
85
85
  return h;
86
86
  }
87
87
  editorApi = {
88
+ saveConfig: async (config) => {
89
+ await workspace
90
+ .getConfiguration('lean4.infoview')
91
+ .update('allErrorsOnLine', config.allErrorsOnLine, ConfigurationTarget.Global);
92
+ await workspace
93
+ .getConfiguration('lean4.infoview')
94
+ .update('autoOpenShowsGoal', config.autoOpenShowsGoal, ConfigurationTarget.Global);
95
+ await workspace
96
+ .getConfiguration('lean4.infoview')
97
+ .update('debounceTime', config.debounceTime, ConfigurationTarget.Global);
98
+ await workspace
99
+ .getConfiguration('lean4.infoview')
100
+ .update('expectedTypeVisibility', config.expectedTypeVisibility, ConfigurationTarget.Global);
101
+ await workspace
102
+ .getConfiguration('lean4.infoview')
103
+ .update('showGoalNames', config.showGoalNames, ConfigurationTarget.Global);
104
+ await workspace
105
+ .getConfiguration('lean4.infoview')
106
+ .update('emphasizeFirstGoal', config.emphasizeFirstGoal, ConfigurationTarget.Global);
107
+ await workspace
108
+ .getConfiguration('lean4.infoview')
109
+ .update('reverseTacticState', config.reverseTacticState, ConfigurationTarget.Global);
110
+ await workspace
111
+ .getConfiguration('lean4.infoview')
112
+ .update('hideTypeAssumptions', config.hideTypeAssumptions, ConfigurationTarget.Global);
113
+ await workspace
114
+ .getConfiguration('lean4.infoview')
115
+ .update('hideInstanceAssumptions', config.hideInstanceAssumptions, ConfigurationTarget.Global);
116
+ await workspace
117
+ .getConfiguration('lean4.infoview')
118
+ .update('hideInaccessibleAssumptions', config.hideInaccessibleAssumptions, ConfigurationTarget.Global);
119
+ await workspace
120
+ .getConfiguration('lean4.infoview')
121
+ .update('hideLetValues', config.hideLetValues, ConfigurationTarget.Global);
122
+ await workspace
123
+ .getConfiguration('lean4.infoview')
124
+ .update('showTooltipOnHover', config.showTooltipOnHover, ConfigurationTarget.Global);
125
+ },
88
126
  sendClientRequest: async (uri, method, params) => {
89
127
  const extUri = parseExtUri(uri);
90
128
  if (extUri === undefined) {
91
- return undefined;
129
+ throw Error(`Unexpected URI scheme: ${Uri.parse(uri).scheme}`);
92
130
  }
93
131
  const client = this.clientProvider.findClient(extUri);
94
132
  if (client) {
@@ -108,7 +146,7 @@ export class InfoProvider {
108
146
  throw ex;
109
147
  }
110
148
  }
111
- return undefined;
149
+ throw Error('No active Lean client.');
112
150
  },
113
151
  sendClientNotification: async (uri, method, params) => {
114
152
  const extUri = parseExtUri(uri);
@@ -205,7 +243,7 @@ export class InfoProvider {
205
243
  },
206
244
  copyToClipboard: async (text) => {
207
245
  await env.clipboard.writeText(text);
208
- displayInformation(`Copied to clipboard: ${text}`);
246
+ displayNotification('Information', `Copied to clipboard: ${text}`);
209
247
  },
210
248
  insertText: async (text, kind, tdpp) => {
211
249
  let uri;
@@ -235,29 +273,22 @@ export class InfoProvider {
235
273
  if (extUri === undefined) {
236
274
  return;
237
275
  }
238
- const client = this.clientProvider.findClient(extUri);
239
- if (!client) {
240
- return;
241
- }
242
- const document = workspace.textDocuments.find(doc => extUri.equalsUri(doc.uri));
243
- if (!document || document.isClosed) {
244
- return;
245
- }
246
- await client.restartFile(document);
276
+ this.clientProvider.restartFile(extUri);
247
277
  },
248
278
  createRpcSession: async (uri) => {
249
279
  const extUri = parseExtUri(uri);
250
280
  if (extUri === undefined) {
251
- return '';
281
+ throw Error(`Unexpected URI scheme: ${Uri.parse(uri).scheme}`);
252
282
  }
253
283
  const client = this.clientProvider.findClient(extUri);
254
- if (!client)
255
- return '';
284
+ if (client === undefined) {
285
+ throw Error('No active Lean client.');
286
+ }
256
287
  const sessionId = await rpcConnect(client, uri);
257
288
  const session = new RpcSessionAtPos(client, sessionId, uri);
258
289
  if (!this.webviewPanel) {
259
290
  session.dispose();
260
- throw Error('infoview disconnect while connecting to RPC session');
291
+ throw Error('InfoView disconnected while connecting to RPC session.');
261
292
  }
262
293
  else {
263
294
  this.rpcSessions.set(sessionId, session);
@@ -272,32 +303,78 @@ export class InfoProvider {
272
303
  }
273
304
  },
274
305
  };
275
- constructor(provider, leanDocs, context, infoWebviewFactory) {
276
- this.provider = provider;
277
- this.leanDocs = leanDocs;
306
+ constructor(clientProvider, context, infoWebviewFactory) {
307
+ this.clientProvider = clientProvider;
278
308
  this.context = context;
279
309
  this.infoWebviewFactory = infoWebviewFactory;
280
- this.clientProvider = provider;
281
310
  this.updateStylesheet();
282
- provider.clientAdded(client => {
311
+ clientProvider.clientAdded(client => {
283
312
  void this.onClientAdded(client);
284
313
  });
285
- provider.clientRemoved(client => {
314
+ clientProvider.clientRemoved(client => {
286
315
  void this.onClientRemoved(client);
287
316
  });
288
- provider.clientStopped(([client, activeClient, reason]) => {
317
+ clientProvider.clientStopped(([client, activeClient, reason]) => {
289
318
  void this.onActiveClientStopped(client, activeClient, reason);
290
319
  });
291
- this.subscriptions.push(window.onDidChangeActiveTextEditor(() => this.sendPosition()), window.onDidChangeTextEditorSelection(() => this.sendPosition()), workspace.onDidChangeConfiguration(async (_e) => {
320
+ this.subscriptions.push(lean.onDidChangeActiveLeanEditor(() => this.sendPosition()), lean.onDidChangeLeanEditorSelection(() => this.sendPosition()), workspace.onDidChangeConfiguration(async (_e) => {
292
321
  // regression; changing the style needs a reload. :/
293
322
  this.updateStylesheet();
294
323
  await this.sendConfig();
295
324
  }), workspace.onDidChangeTextDocument(async () => {
296
325
  await this.sendPosition();
297
- }), commands.registerTextEditorCommand('lean4.displayGoal', editor => this.openPreview(editor)), commands.registerCommand('lean4.toggleInfoview', () => this.toggleInfoview()), commands.registerTextEditorCommand('lean4.displayList', async (editor) => {
298
- await this.openPreview(editor);
326
+ }), lean.registerLeanEditorCommand('lean4.displayGoal', leanEditor => this.openPreview(leanEditor)), commands.registerCommand('lean4.toggleInfoview', () => this.toggleInfoview()), lean.registerLeanEditorCommand('lean4.displayList', async (leanEditor) => {
327
+ await this.openPreview(leanEditor);
299
328
  await this.webviewPanel?.api.requestedAction({ kind: 'toggleAllMessages' });
300
- }), commands.registerTextEditorCommand('lean4.infoView.copyToComment', () => this.webviewPanel?.api.requestedAction({ kind: 'copyToComment' })), commands.registerCommand('lean4.infoView.toggleUpdating', () => this.webviewPanel?.api.requestedAction({ kind: 'togglePaused' })), commands.registerCommand('lean4.infoView.toggleExpectedType', () => this.webviewPanel?.api.requestedAction({ kind: 'toggleExpectedType' })), commands.registerTextEditorCommand('lean4.infoView.toggleStickyPosition', () => this.webviewPanel?.api.requestedAction({ kind: 'togglePin' })), commands.registerCommand('lean4.infoview.goToDefinition', args => this.webviewPanel?.api.goToDefinition(args.interactiveCodeTagId)));
329
+ }), lean.registerLeanEditorCommand('lean4.infoView.copyToComment', () => this.webviewPanel?.api.requestedAction({ kind: 'copyToComment' })), commands.registerCommand('lean4.infoView.toggleUpdating', () => this.webviewPanel?.api.requestedAction({ kind: 'togglePaused' })), commands.registerCommand('lean4.infoView.toggleExpectedType', () => this.webviewPanel?.api.requestedAction({ kind: 'toggleExpectedType' })), lean.registerLeanEditorCommand('lean4.infoView.toggleStickyPosition', () => this.webviewPanel?.api.requestedAction({ kind: 'togglePin' })), commands.registerCommand('lean4.infoview.goToDefinition', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'goToDefinition', id: args.interactiveCodeTagId })), commands.registerCommand('lean4.infoview.select', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'select', id: args.selectableLocationId })), commands.registerCommand('lean4.infoview.unselect', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'unselect', id: args.unselectableLocationId })), commands.registerCommand('lean4.infoview.unselectAll', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'unselectAll', id: args.selectedLocationsId })), commands.registerCommand('lean4.infoview.pause', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'pause', id: args.pauseId })), commands.registerCommand('lean4.infoview.unpause', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'unpause', id: args.unpauseId })), commands.registerCommand('lean4.infoview.pin', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'pin', id: args.pinId })), commands.registerCommand('lean4.infoview.unpin', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'unpin', id: args.unpinId })), commands.registerCommand('lean4.infoview.refresh', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'refresh', id: args.refreshId })), commands.registerCommand('lean4.infoview.pauseAllMessages', args => this.webviewPanel?.api.clickedContextMenu({
330
+ entry: 'pauseAllMessages',
331
+ id: args.pauseAllMessagesId,
332
+ })), commands.registerCommand('lean4.infoview.unpauseAllMessages', args => this.webviewPanel?.api.clickedContextMenu({
333
+ entry: 'unpauseAllMessages',
334
+ id: args.unpauseAllMessagesId,
335
+ })), commands.registerCommand('lean4.infoview.goToPinnedLocation', args => this.webviewPanel?.api.clickedContextMenu({
336
+ entry: 'goToPinnedLocation',
337
+ id: args.goToPinnedLocationId,
338
+ })), commands.registerCommand('lean4.infoview.goToMessageLocation', args => this.webviewPanel?.api.clickedContextMenu({
339
+ entry: 'goToMessageLocation',
340
+ id: args.goToMessageLocationId,
341
+ })), commands.registerCommand('lean4.infoview.displayTargetBeforeAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
342
+ entry: 'displayTargetBeforeAssumptions',
343
+ id: args.displayTargetBeforeAssumptionsId,
344
+ })), commands.registerCommand('lean4.infoview.displayAssumptionsBeforeTarget', args => this.webviewPanel?.api.clickedContextMenu({
345
+ entry: 'displayAssumptionsBeforeTarget',
346
+ id: args.displayAssumptionsBeforeTargetId,
347
+ })), commands.registerCommand('lean4.infoview.hideTypeAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
348
+ entry: 'hideTypeAssumptions',
349
+ id: args.hideTypeAssumptionsId,
350
+ })), commands.registerCommand('lean4.infoview.showTypeAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
351
+ entry: 'showTypeAssumptions',
352
+ id: args.showTypeAssumptionsId,
353
+ })), commands.registerCommand('lean4.infoview.hideInstanceAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
354
+ entry: 'hideInstanceAssumptions',
355
+ id: args.hideInstanceAssumptionsId,
356
+ })), commands.registerCommand('lean4.infoview.showInstanceAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
357
+ entry: 'showInstanceAssumptions',
358
+ id: args.showInstanceAssumptionsId,
359
+ })), commands.registerCommand('lean4.infoview.hideInaccessibleAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
360
+ entry: 'hideInaccessibleAssumptions',
361
+ id: args.hideInaccessibleAssumptionsId,
362
+ })), commands.registerCommand('lean4.infoview.showInaccessibleAssumptions', args => this.webviewPanel?.api.clickedContextMenu({
363
+ entry: 'showInaccessibleAssumptions',
364
+ id: args.showInaccessibleAssumptionsId,
365
+ })), commands.registerCommand('lean4.infoview.hideLetValues', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'hideLetValues', id: args.hideLetValuesId })), commands.registerCommand('lean4.infoview.showLetValues', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'showLetValues', id: args.showLetValuesId })), commands.registerCommand('lean4.infoview.hideGoalNames', args => this.webviewPanel?.api.clickedContextMenu({
366
+ entry: 'hideGoalNames',
367
+ id: args.hideGoalNamesId,
368
+ })), commands.registerCommand('lean4.infoview.showGoalNames', args => this.webviewPanel?.api.clickedContextMenu({
369
+ entry: 'showGoalNames',
370
+ id: args.showGoalNamesId,
371
+ })), commands.registerCommand('lean4.infoview.emphasizeFirstGoal', args => this.webviewPanel?.api.clickedContextMenu({
372
+ entry: 'emphasizeFirstGoal',
373
+ id: args.emphasizeFirstGoalId,
374
+ })), commands.registerCommand('lean4.infoview.deemphasizeFirstGoal', args => this.webviewPanel?.api.clickedContextMenu({
375
+ entry: 'deemphasizeFirstGoal',
376
+ id: args.deemphasizeFirstGoalId,
377
+ })), commands.registerCommand('lean4.infoview.saveSettings', args => this.webviewPanel?.api.clickedContextMenu({ entry: 'saveSettings', id: args.saveSettingsId })));
301
378
  }
302
379
  async onClientRestarted(client) {
303
380
  // if we already have subscriptions for a previous client, we need to also
@@ -329,7 +406,7 @@ export class InfoProvider {
329
406
  if (this.clientsFailed.has(folderUri.toString())) {
330
407
  this.clientsFailed.delete(folderUri.toString());
331
408
  }
332
- await this.initInfoView(window.activeTextEditor, client);
409
+ await this.initInfoView(lean.activeLeanEditor, client);
333
410
  }
334
411
  async onClientAdded(client) {
335
412
  logger.log(`[InfoProvider] Adding client for workspace: ${client.getClientFolder()}`);
@@ -441,13 +518,10 @@ export class InfoProvider {
441
518
  this.stylesheet = extraCSS + configCSS;
442
519
  }
443
520
  async autoOpen() {
444
- if (!this.webviewPanel && !this.autoOpened && getInfoViewAutoOpen() && window.activeTextEditor) {
445
- // only auto-open for lean files, not for markdown.
446
- if (languages.match(this.leanDocs, window.activeTextEditor.document)) {
447
- // remember we've auto opened during this session so if user closes it it remains closed.
448
- this.autoOpened = true;
449
- return await this.openPreview(window.activeTextEditor);
450
- }
521
+ if (!this.webviewPanel && !this.autoOpened && getInfoViewAutoOpen() && lean.activeLeanEditor !== undefined) {
522
+ // remember we've auto opened during this session so if user closes it it remains closed.
523
+ this.autoOpened = true;
524
+ return await this.openPreview(lean.activeLeanEditor);
451
525
  }
452
526
  return false;
453
527
  }
@@ -478,40 +552,70 @@ export class InfoProvider {
478
552
  this.webviewPanel.dispose();
479
553
  // the onDispose handler sets this.webviewPanel = undefined
480
554
  }
481
- else if (window.activeTextEditor && window.activeTextEditor.document.languageId === 'lean4') {
482
- await this.openPreview(window.activeTextEditor);
555
+ else if (lean.activeLeanEditor !== undefined) {
556
+ await this.openPreview(lean.activeLeanEditor);
483
557
  }
484
558
  else {
485
- displayError('No active Lean editor tab. Make sure to focus the Lean editor tab for which you want to open the infoview.');
559
+ displayNotification('Error', 'No active Lean editor tab. Make sure to focus the Lean editor tab for which you want to open the infoview.');
486
560
  }
487
561
  }
488
- async openPreview(editor) {
489
- const docUri = toExtUri(editor.document.uri);
490
- if (docUri === undefined) {
491
- return false;
492
- }
493
- let column = editor && editor.viewColumn ? editor.viewColumn + 1 : ViewColumn.Two;
494
- if (column === 4) {
495
- column = ViewColumn.Three;
496
- }
562
+ async openPreview(leanEditor) {
497
563
  if (this.webviewPanel) {
498
- this.webviewPanel.reveal(column, true);
564
+ this.webviewPanel.reveal(undefined, true);
499
565
  }
500
566
  else {
501
- this.webviewPanel = this.infoWebviewFactory.make(this.editorApi, this.stylesheet, column);
502
- this.webviewPanel.onDidDispose(() => {
567
+ const webviewPanel = this.infoWebviewFactory.make(this.editorApi, this.stylesheet);
568
+ /*
569
+ window.createWebviewPanel(
570
+ 'lean4_infoview',
571
+ 'Lean InfoView',
572
+ { viewColumn: viewColumnOfInfoView(), preserveFocus: true },
573
+ {
574
+ enableFindWidget: true,
575
+ retainContextWhenHidden: true,
576
+ enableScripts: true,
577
+ enableCommandUris: true,
578
+ },
579
+ ) as WebviewPanel & { rpc: Rpc; api: InfoviewApi }
580
+
581
+ // Note that an extension can send data to its webviews using webview.postMessage().
582
+ // This method sends any JSON serializable data to the webview. The message is received
583
+ // inside the webview through the standard message event.
584
+ // The receiving of these messages is done inside webview\index.ts where it
585
+ // calls window.addEventListener('message',...
586
+ webviewPanel.rpc = new Rpc(m => {
587
+ try {
588
+ void webviewPanel.webview.postMessage(m)
589
+ } catch (e) {
590
+ // ignore any disposed object exceptions
591
+ }
592
+ })
593
+ webviewPanel.rpc.register(this.editorApi)
594
+
595
+ // Similarly, we can received data from the webview by listening to onDidReceiveMessage.
596
+ webviewPanel.webview.onDidReceiveMessage(m => {
597
+ try {
598
+ webviewPanel.rpc.messageReceived(m)
599
+ } catch {
600
+ // ignore any disposed object exceptions
601
+ }
602
+ })
603
+ webviewPanel.api = webviewPanel.rpc.getApi()
604
+ */
605
+ webviewPanel.onDidDispose(() => {
503
606
  this.webviewPanel = undefined;
504
607
  this.clearNotificationHandlers();
505
608
  this.clearRpcSessions(null); // should be after `webviewPanel = undefined`
506
609
  });
507
- const client = this.clientProvider.findClient(docUri);
508
- await this.initInfoView(editor, client);
610
+ this.webviewPanel = webviewPanel;
611
+ const client = this.clientProvider.findClient(leanEditor.documentExtUri);
612
+ await this.initInfoView(leanEditor, client);
509
613
  }
510
614
  return true;
511
615
  }
512
- async initInfoView(editor, client) {
513
- if (editor) {
514
- const loc = this.getLocation(editor);
616
+ async initInfoView(leanEditor, client) {
617
+ if (leanEditor !== undefined) {
618
+ const loc = this.getLocation(leanEditor);
515
619
  if (loc) {
516
620
  await this.webviewPanel?.api.initialize(loc);
517
621
  }
@@ -540,10 +644,14 @@ export class InfoProvider {
540
644
  allErrorsOnLine: getInfoViewAllErrorsOnLine(),
541
645
  autoOpenShowsGoal: getInfoViewAutoOpenShowsGoal(),
542
646
  debounceTime: getInfoViewDebounceTime(),
543
- showExpectedType: getInfoViewShowExpectedType(),
647
+ expectedTypeVisibility: getInfoViewExpectedTypeVisibility(),
544
648
  showGoalNames: getInfoViewShowGoalNames(),
545
649
  emphasizeFirstGoal: getInfoViewEmphasizeFirstGoal(),
546
650
  reverseTacticState: getInfoViewReverseTacticState(),
651
+ hideTypeAssumptions: getInfoViewHideTypeAssumptions(),
652
+ hideInstanceAssumptions: getInfoViewHideInstanceAssumptions(),
653
+ hideInaccessibleAssumptions: getInfoViewHideInaccessibleAssumptions(),
654
+ hideLetValues: getInfoViewHideLetValues(),
547
655
  showTooltipOnHover: getInfoViewShowTooltipOnHover(),
548
656
  });
549
657
  }
@@ -585,13 +693,10 @@ export class InfoProvider {
585
693
  })
586
694
  .catch(() => { });
587
695
  }
588
- getLocation(editor) {
589
- if (!editor)
590
- return undefined;
591
- const uri = editor.document.uri;
592
- const selection = editor.selection;
696
+ getLocation(leanEditor) {
697
+ const selection = leanEditor.editor.selection;
593
698
  return {
594
- uri: uri.toString(),
699
+ uri: leanEditor.documentExtUri.toString(),
595
700
  range: {
596
701
  start: selection.start,
597
702
  end: selection.end,
@@ -599,21 +704,12 @@ export class InfoProvider {
599
704
  };
600
705
  }
601
706
  async sendPosition() {
602
- const editor = window.activeTextEditor;
603
- if (!editor)
604
- return;
605
- const loc = this.getLocation(editor);
606
- if (languages.match(this.leanDocs, editor.document) === 0) {
607
- // language is not yet 'lean4', but the LeanClient will fire the didSetLanguage event
608
- // in openLean4Document and that's when we can send the position to update the
609
- // InfoView for the newly opened document.
610
- return;
611
- }
612
- const uri = toExtUri(editor.document.uri);
613
- if (uri === undefined) {
707
+ const editor = lean.activeLeanEditor;
708
+ if (editor === undefined) {
614
709
  return;
615
710
  }
616
- // actual editor
711
+ const loc = this.getLocation(editor);
712
+ const uri = editor.documentExtUri;
617
713
  if (this.clientsFailed.size > 0 || this.workersFailed.size > 0) {
618
714
  const client = this.clientProvider.findClient(uri);
619
715
  const uriKey = uri.toString();
@@ -648,16 +744,12 @@ export class InfoProvider {
648
744
  await this.webviewPanel?.api.changedCursorLocation(loc);
649
745
  }
650
746
  async revealEditorSelection(uri, selection) {
651
- let editor;
652
- for (const e of window.visibleTextEditors) {
653
- if (uri.equalsUri(e.document.uri)) {
654
- editor = e;
655
- break;
656
- }
657
- }
658
- if (!editor) {
659
- const c = window.activeTextEditor ? window.activeTextEditor.viewColumn : ViewColumn.One;
660
- editor = await window.showTextDocument(uri.asUri(), { viewColumn: c, preserveFocus: false });
747
+ let editor = lean.getVisibleLeanEditorsByUri(uri).at(0)?.editor;
748
+ if (editor === undefined) {
749
+ editor = await window.showTextDocument(uri.asUri(), {
750
+ viewColumn: viewColumnOfActiveTextEditor(),
751
+ preserveFocus: false,
752
+ });
661
753
  }
662
754
  if (selection !== undefined) {
663
755
  editor.revealRange(selection, TextEditorRevealType.InCenterIfOutsideViewport);
@@ -667,23 +759,17 @@ export class InfoProvider {
667
759
  }
668
760
  }
669
761
  async handleInsertText(text, kind, uri, pos) {
670
- let editor;
762
+ let leanEditor;
671
763
  if (uri) {
672
- editor = window.visibleTextEditors.find(e => uri.equalsUri(e.document.uri));
764
+ leanEditor = lean.getVisibleLeanEditorsByUri(uri).at(0);
673
765
  }
674
766
  else {
675
- editor = window.activeTextEditor;
676
- if (!editor) {
677
- // sometimes activeTextEditor is null.
678
- editor = window.visibleTextEditors.find(e => e.document.languageId === 'lean4');
679
- }
767
+ leanEditor = lean.activeLeanEditor;
680
768
  }
681
- if (!editor) {
682
- // user must have switch away from any lean source file in which case we don't know
683
- // what to do here. TODO: show a popup error? Or should we use the last uri used in
684
- // sendPosition and automatically activate that editor?
769
+ if (leanEditor === undefined) {
685
770
  return;
686
771
  }
772
+ const editor = leanEditor.editor;
687
773
  pos = pos ? pos : editor.selection.active;
688
774
  if (kind === 'above') {
689
775
  // in this case, assume that we actually want to insert at the same
@@ -708,4 +794,33 @@ export class InfoProvider {
708
794
  // ensure the text document has the keyboard focus.
709
795
  await window.showTextDocument(editor.document, { viewColumn: editor.viewColumn, preserveFocus: false });
710
796
  }
797
+ getLocalPath(path) {
798
+ if (this.webviewPanel) {
799
+ // return this.webviewPanel.webview.asWebviewUri(Uri.file(join(this.context.extensionPath, path))).toString()
800
+ }
801
+ return undefined;
802
+ }
803
+ initialHtml() {
804
+ const libPostfix = `.${prodOrDev}${minIfProd}.js`;
805
+ return `
806
+ <!DOCTYPE html>
807
+ <html>
808
+ <head>
809
+ <meta charset="UTF-8" />
810
+ <meta http-equiv="Content-type" content="text/html;charset=utf-8">
811
+ <title>Infoview</title>
812
+ <style>${this.stylesheet}</style>
813
+ <link rel="stylesheet" href="${this.getLocalPath('dist/lean4-infoview/index.css')}">
814
+ </head>
815
+ <body>
816
+ <div id="react_root"></div>
817
+ <script
818
+ data-importmap-leanprover-infoview="${this.getLocalPath(`dist/lean4-infoview/index${libPostfix}`)}"
819
+ data-importmap-react="${this.getLocalPath(`dist/lean4-infoview/react${libPostfix}`)}"
820
+ data-importmap-react-jsx-runtime="${this.getLocalPath(`dist/lean4-infoview/react-jsx-runtime${libPostfix}`)}"
821
+ data-importmap-react-dom="${this.getLocalPath(`dist/lean4-infoview/react-dom${libPostfix}`)}"
822
+ src="${this.getLocalPath('dist/webview.js')}"></script>
823
+ </body>
824
+ </html>`;
825
+ }
711
826
  }
@@ -1,10 +1,12 @@
1
- import { DiagnosticCollection, Disposable, OutputChannel, TextDocument } from 'vscode';
2
- import { BaseLanguageClient, DidChangeTextDocumentParams, DidCloseTextDocumentParams, InitializeResult, LanguageClientOptions, PublishDiagnosticsParams } from 'vscode-languageclient/node';
1
+ import { DiagnosticCollection, Disposable, OutputChannel } from 'vscode';
2
+ import { BaseLanguageClient, DidChangeTextDocumentParams, DidCloseTextDocumentParams, InitializeResult, LanguageClientOptions } from 'vscode-languageclient/node';
3
3
  import { LeanFileProgressProcessingInfo, ServerStoppedReason } from '@leanprover/infoview-api';
4
+ import { LeanPublishDiagnosticsParams } from './utils/converters';
4
5
  import { ExtUri } from './utils/exturi';
6
+ import { LeanDocument } from './utils/leanEditorProvider';
5
7
  export type ServerProgress = Map<ExtUri, LeanFileProgressProcessingInfo[]>;
6
8
  export declare class LeanClient implements Disposable {
7
- private setupClient;
9
+ private setupLanguageClient;
8
10
  running: boolean;
9
11
  private client;
10
12
  private outputChannel;
@@ -12,14 +14,13 @@ export declare class LeanClient implements Disposable {
12
14
  private subscriptions;
13
15
  private noPrompt;
14
16
  private showingRestartMessage;
15
- private elanDefaultToolchain;
16
17
  private isRestarting;
17
18
  private staleDepNotifier;
18
19
  private openServerDocuments;
19
20
  private didChangeEmitter;
20
21
  didChange: import("vscode").Event<DidChangeTextDocumentParams>;
21
22
  private diagnosticsEmitter;
22
- diagnostics: import("vscode").Event<PublishDiagnosticsParams>;
23
+ diagnostics: import("vscode").Event<LeanPublishDiagnosticsParams>;
23
24
  private didSetLanguageEmitter;
24
25
  didSetLanguage: import("vscode").Event<string>;
25
26
  private didCloseEmitter;
@@ -44,10 +45,11 @@ export declare class LeanClient implements Disposable {
44
45
  restartedWorker: import("vscode").Event<string>;
45
46
  private serverFailedEmitter;
46
47
  serverFailed: import("vscode").Event<string>;
47
- constructor(folderUri: ExtUri, outputChannel: OutputChannel, elanDefaultToolchain: string, setupClient: (clientOptions: LanguageClientOptions, folderUri: ExtUri, elanDefaultToolchain: string) => Promise<BaseLanguageClient>);
48
+ constructor(folderUri: ExtUri, outputChannel: OutputChannel, setupLanguageClient: (clientOptions: LanguageClientOptions) => Promise<BaseLanguageClient>);
48
49
  dispose(): void;
49
50
  showRestartMessage(restartFile?: boolean, uri?: ExtUri | undefined): void;
50
51
  restart(): Promise<void>;
52
+ private determineToolchainOverride;
51
53
  private startClient;
52
54
  private checkForImportsOutdatedError;
53
55
  withStoppedClient(action: () => Promise<void>): Promise<'Success' | 'IsRestarting'>;
@@ -57,10 +59,13 @@ export declare class LeanClient implements Disposable {
57
59
  isStarted(): boolean;
58
60
  isRunning(): boolean;
59
61
  stop(): Promise<void>;
60
- restartFile(doc: TextDocument): Promise<void>;
62
+ restartFile(leanDoc: LeanDocument): Promise<void>;
61
63
  sendRequest(method: string, params: any): Promise<any>;
62
64
  sendNotification(method: string, params: any): Promise<void> | undefined;
63
65
  getDiagnostics(): DiagnosticCollection | undefined;
64
66
  get initializeResult(): InitializeResult | undefined;
67
+ private determineServerOptions;
68
+ private determineExecutable;
65
69
  private obtainClientOptions;
70
+ private setupClient;
66
71
  }