@difizen/libro-codemirror 0.1.0 → 0.1.2

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 (114) hide show
  1. package/es/auto-complete/closebrackets.d.ts +12 -0
  2. package/es/auto-complete/closebrackets.d.ts.map +1 -0
  3. package/es/auto-complete/completion.d.ts +57 -0
  4. package/es/auto-complete/completion.d.ts.map +1 -0
  5. package/es/auto-complete/config.d.ts +22 -0
  6. package/es/auto-complete/config.d.ts.map +1 -0
  7. package/es/auto-complete/filter.d.ts +13 -0
  8. package/es/auto-complete/filter.d.ts.map +1 -0
  9. package/es/auto-complete/filter.js +1 -7
  10. package/es/auto-complete/index.d.ts.map +1 -1
  11. package/es/auto-complete/index.js +5 -9
  12. package/es/auto-complete/snippet.d.ts +14 -0
  13. package/es/auto-complete/snippet.d.ts.map +1 -0
  14. package/es/auto-complete/snippet.js +2 -2
  15. package/es/auto-complete/state.d.ts +63 -0
  16. package/es/auto-complete/state.d.ts.map +1 -0
  17. package/es/auto-complete/state.js +5 -16
  18. package/es/auto-complete/theme.d.ts +6 -0
  19. package/es/auto-complete/theme.d.ts.map +1 -0
  20. package/es/auto-complete/tooltip.d.ts +5 -0
  21. package/es/auto-complete/tooltip.d.ts.map +1 -0
  22. package/es/auto-complete/view.d.ts +43 -0
  23. package/es/auto-complete/view.d.ts.map +1 -0
  24. package/es/auto-complete/view.js +2 -13
  25. package/es/auto-complete/word.d.ts +3 -0
  26. package/es/auto-complete/word.d.ts.map +1 -0
  27. package/es/completion.js +1 -1
  28. package/es/config.d.ts +15 -10
  29. package/es/config.d.ts.map +1 -1
  30. package/es/config.js +15 -6
  31. package/es/editor-contribution.d.ts +8 -0
  32. package/es/editor-contribution.d.ts.map +1 -0
  33. package/es/editor-contribution.js +30 -0
  34. package/es/editor.d.ts +40 -10
  35. package/es/editor.d.ts.map +1 -1
  36. package/es/editor.js +241 -45
  37. package/es/hyperlink.d.ts +15 -0
  38. package/es/hyperlink.d.ts.map +1 -0
  39. package/es/indentation-markers/config.d.ts +17 -0
  40. package/es/indentation-markers/config.d.ts.map +1 -0
  41. package/es/indentation-markers/index.d.ts +3 -0
  42. package/es/indentation-markers/index.d.ts.map +1 -0
  43. package/es/indentation-markers/map.d.ts +77 -0
  44. package/es/indentation-markers/map.d.ts.map +1 -0
  45. package/es/indentation-markers/utils.d.ts +27 -0
  46. package/es/indentation-markers/utils.d.ts.map +1 -0
  47. package/es/index.d.ts +3 -1
  48. package/es/index.d.ts.map +1 -1
  49. package/es/index.js +3 -1
  50. package/es/libro-icon.d.ts +3 -0
  51. package/es/libro-icon.d.ts.map +1 -0
  52. package/es/libro-icon.js +2 -2
  53. package/es/lsp/completion.d.ts +5 -0
  54. package/es/lsp/completion.d.ts.map +1 -0
  55. package/es/lsp/completion.js +245 -0
  56. package/es/lsp/format.d.ts +7 -0
  57. package/es/lsp/format.d.ts.map +1 -0
  58. package/es/lsp/format.js +193 -0
  59. package/es/lsp/index.d.ts +7 -0
  60. package/es/lsp/index.d.ts.map +1 -0
  61. package/es/lsp/index.js +6 -0
  62. package/es/lsp/lint.d.ts +3 -0
  63. package/es/lsp/lint.d.ts.map +1 -0
  64. package/es/lsp/lint.js +114 -0
  65. package/es/lsp/protocol.d.ts +7 -0
  66. package/es/lsp/protocol.d.ts.map +1 -0
  67. package/es/lsp/protocol.js +1 -0
  68. package/es/lsp/tooltip.d.ts +3 -0
  69. package/es/lsp/tooltip.d.ts.map +1 -0
  70. package/es/lsp/tooltip.js +113 -0
  71. package/es/lsp/util.d.ts +15 -0
  72. package/es/lsp/util.d.ts.map +1 -0
  73. package/es/lsp/util.js +58 -0
  74. package/es/mode.d.ts.map +1 -1
  75. package/es/module.d.ts +3 -0
  76. package/es/module.d.ts.map +1 -0
  77. package/es/module.js +4 -0
  78. package/es/monitor.d.ts +32 -0
  79. package/es/monitor.d.ts.map +1 -0
  80. package/es/python-lang.d.ts +3 -0
  81. package/es/python-lang.d.ts.map +1 -0
  82. package/es/theme.d.ts +35 -0
  83. package/es/theme.d.ts.map +1 -0
  84. package/es/theme.js +4 -5
  85. package/es/tooltip.d.ts +1 -1
  86. package/es/tooltip.d.ts.map +1 -1
  87. package/es/tooltip.js +2 -4
  88. package/package.json +7 -5
  89. package/src/auto-complete/filter.ts +5 -7
  90. package/src/auto-complete/index.ts +6 -7
  91. package/src/auto-complete/snippet.ts +8 -2
  92. package/src/auto-complete/state.ts +13 -18
  93. package/src/auto-complete/view.ts +7 -13
  94. package/src/completion.ts +2 -2
  95. package/src/config.ts +40 -28
  96. package/src/editor-contribution.ts +17 -0
  97. package/src/editor.ts +226 -50
  98. package/src/hyperlink.ts +1 -1
  99. package/src/indentation-markers/index.ts +3 -3
  100. package/src/indentation-markers/map.ts +9 -9
  101. package/src/index.ts +4 -1
  102. package/src/libro-icon.tsx +4 -0
  103. package/src/lsp/completion.ts +175 -0
  104. package/src/lsp/format.ts +144 -0
  105. package/src/lsp/index.ts +6 -0
  106. package/src/lsp/lint.ts +125 -0
  107. package/src/lsp/protocol.ts +8 -0
  108. package/src/lsp/tooltip.ts +76 -0
  109. package/src/lsp/util.ts +69 -0
  110. package/src/mode.ts +1 -1
  111. package/src/module.ts +8 -0
  112. package/src/theme.ts +4 -4
  113. package/src/tooltip.ts +2 -4
  114. package/src/libro-icon.ts +0 -4
@@ -0,0 +1,77 @@
1
+ import type { EditorState, Line } from '@codemirror/state';
2
+ export interface IndentEntry {
3
+ line: Line;
4
+ col: number;
5
+ level: number;
6
+ empty: boolean;
7
+ active?: number;
8
+ }
9
+ /**
10
+ * Indentation map for a set of lines.
11
+ *
12
+ * This map will contain the indentation for lines that are not a part of the given set,
13
+ * but this is because calculating the indentation for those lines was necessary to
14
+ * calculate the indentation for the lines provided to the constructor.
15
+ *
16
+ * @see {@link IndentEntry}
17
+ */
18
+ export declare class IndentationMap {
19
+ /** The {@link EditorState} indentation is derived from. */
20
+ protected state: EditorState;
21
+ /** The set of lines that are used as an entrypoint. */
22
+ protected lines: Set<Line>;
23
+ /** The internal mapping of line numbers to {@link IndentEntry} objects. */
24
+ protected map: Map<number, IndentEntry>;
25
+ /** The width of the editor's indent unit. */
26
+ protected unitWidth: number;
27
+ /** The type of indentation to use (terminate at end of scope vs last non-empty line in scope) */
28
+ protected markerType: 'fullScope' | 'codeOnly';
29
+ /**
30
+ * @param lines - The set of lines to get the indentation map for.
31
+ * @param state - The {@link EditorState} to derive the indentation map from.
32
+ * @param unitWidth - The width of the editor's indent unit.
33
+ * @param markerType - The type of indentation to use (terminate at end of scope vs last line of code in scope)
34
+ */
35
+ constructor(lines: Set<Line>, state: EditorState, unitWidth: number, markerType: 'fullScope' | 'codeOnly');
36
+ /**
37
+ * Checks if the indentation map has an entry for the given line.
38
+ *
39
+ * @param line - The {@link Line} or line number to check for.
40
+ */
41
+ has(line: Line | number): boolean;
42
+ /**
43
+ * Returns the {@link IndentEntry} for the given line.
44
+ *
45
+ * Note that this function will throw an error if the line does not exist in the map.
46
+ *
47
+ * @param line - The {@link Line} or line number to get the entry for.
48
+ */
49
+ get(line: Line | number): IndentEntry;
50
+ /**
51
+ * Sets the {@link IndentEntry} for the given line.
52
+ *
53
+ * @param line - The {@link Line} to set the entry for.
54
+ * @param col - The visual beginning whitespace width of the line.
55
+ * @param level - The indentation level of the line.
56
+ */
57
+ protected set(line: Line, col: number, level: number): IndentEntry;
58
+ /**
59
+ * Adds a line to the indentation map.
60
+ *
61
+ * @param line - The {@link Line} to add to the map.
62
+ */
63
+ protected add(line: Line): IndentEntry;
64
+ /**
65
+ * Finds the closest non-empty line, starting from the given line.
66
+ *
67
+ * @param from - The {@link Line} to start from.
68
+ * @param dir - The direction to search in. Either `1` or `-1`.
69
+ */
70
+ protected closestNonEmpty(from: Line, dir: -1 | 1): IndentEntry;
71
+ /**
72
+ * Finds the state's active block (via the current selection) and sets all
73
+ * the active indent level for the lines in the block.
74
+ */
75
+ protected findAndSetActiveLines(): void;
76
+ }
77
+ //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAK3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACzB,2DAA2D;IAC3D,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC;IAE7B,uDAAuD;IACvD,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAE3B,2EAA2E;IAC3E,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAExC,6CAA6C;IAC7C,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAE5B,iGAAiG;IACjG,SAAS,CAAC,UAAU,EAAE,WAAW,GAAG,UAAU,CAAC;IAE/C;;;;;OAKG;gBAED,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,EAChB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,WAAW,GAAG,UAAU;IAiBtC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAIvB;;;;;;OAMG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAUvB;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQpD;;;;OAIG;IACH,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI;IAkDxB;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC;IAoCjD;;;OAGG;IACH,SAAS,CAAC,qBAAqB;CAiEhC"}
@@ -0,0 +1,27 @@
1
+ import type { EditorState, Line } from '@codemirror/state';
2
+ import type { EditorView } from '@codemirror/view';
3
+ /**
4
+ * Gets the visible lines in the editor. Lines will not be repeated.
5
+ *
6
+ * @param view - The editor view to get the visible lines from.
7
+ * @param state - The editor state. Defaults to the view's current one.
8
+ */
9
+ export declare function getVisibleLines(view: EditorView, state?: EditorState): Set<Line>;
10
+ /**
11
+ * Gets the line at the position of the primary cursor.
12
+ *
13
+ * @param state - The editor state from which to extract the line.
14
+ */
15
+ export declare function getCurrentLine(state: EditorState): Line;
16
+ /**
17
+ * Returns the number of columns that a string is indented, controlling for
18
+ * tabs. This is useful for determining the indentation level of a line.
19
+ *
20
+ * Note that this only returns the number of _visible_ columns, not the number
21
+ * of whitespace characters at the start of the string.
22
+ *
23
+ * @param str - The string to check.
24
+ * @param tabSize - The size of a tab character. Usually 2 or 4.
25
+ */
26
+ export declare function numColumns(str: string, tabSize: number): number;
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,cAAa,aAkBnE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,QAGhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAkCtD"}
package/es/index.d.ts CHANGED
@@ -3,9 +3,11 @@ import './style/theme.css';
3
3
  import './style/variables.css';
4
4
  export * from './config.js';
5
5
  export * from './editor.js';
6
+ export * from './lsp/index.js';
6
7
  export * from './mode.js';
7
- export * from './theme.js';
8
+ export * from './module.js';
8
9
  export * from './factory.js';
9
10
  export * from './monitor.js';
11
+ export * from './theme.js';
10
12
  export * from './auto-complete/index.js';
11
13
  //# sourceMappingURL=index.d.ts.map
package/es/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAE3B,cAAc,0BAA0B,CAAC"}
package/es/index.js CHANGED
@@ -3,8 +3,10 @@ import "./style/theme.css";
3
3
  import "./style/variables.css";
4
4
  export * from "./config.js";
5
5
  export * from "./editor.js";
6
+ export * from "./lsp/index.js";
6
7
  export * from "./mode.js";
7
- export * from "./theme.js";
8
+ export * from "./module.js";
8
9
  export * from "./factory.js";
9
10
  export * from "./monitor.js";
11
+ export * from "./theme.js";
10
12
  export * from "./auto-complete/index.js";
@@ -0,0 +1,3 @@
1
+ export declare const FoldIcon = "<svg width=\"8px\" height=\"6px\" viewBox=\"0 0 8 6\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2015.000000, -434.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\" transform=\"translate(2004.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(11.250000, 27.500000)\"><path d=\"M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z\" id=\"Down\"></path></g></g></g></g></svg>";
2
+ export declare const UnFoldIcon = "<svg width=\"6px\" height=\"8px\" viewBox=\"0 0 6 8\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\u6536\u8D77</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2094.000000, -433.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\u5907\u4EFD\" transform=\"translate(2082.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)\"><path d=\"M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z\" id=\"Down\"></path></g></g></g></g></svg>";
3
+ //# sourceMappingURL=libro-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libro-icon.d.ts","sourceRoot":"","sources":["../src/libro-icon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,+iCACq7B,CAAC;AAC38B,eAAO,MAAM,UAAU,ixCACioC,CAAC"}
package/es/libro-icon.js CHANGED
@@ -1,2 +1,2 @@
1
- export var FoldIcon = '<svg width="8px" height="6px" viewBox="0 0 8 6" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down</title><g id="0424" stroke="none" stroke-width="1" fill="none" fillRule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2015.000000, -434.000000)" fill="#A4AECB"><g id="编组-15" transform="translate(2004.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(11.250000, 27.500000)"><path d="M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z" id="Down"></path></g></g></g></g></svg>';
2
- export var UnFoldIcon = '<svg width="6px" height="8px" viewBox="0 0 6 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down收起</title><g id="0424" stroke="none" stroke-width="1" fill="none" fillRule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2094.000000, -433.000000)" fill="#A4AECB"><g id="编组-15备份" transform="translate(2082.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)"><path d="M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z" id="Down"></path></g></g></g></g></svg>';
1
+ export var FoldIcon = '<svg width="8px" height="6px" viewBox="0 0 8 6" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down</title><g id="0424" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2015.000000, -434.000000)" fill="#A4AECB"><g id="编组-15" transform="translate(2004.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(11.250000, 27.500000)"><path d="M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z" id="Down"></path></g></g></g></g></svg>';
2
+ export var UnFoldIcon = '<svg width="6px" height="8px" viewBox="0 0 6 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down收起</title><g id="0424" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2094.000000, -433.000000)" fill="#A4AECB"><g id="编组-15备份" transform="translate(2082.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)"><path d="M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z" id="Down"></path></g></g></g></g></svg>';
@@ -0,0 +1,5 @@
1
+ import type { Completion } from '../auto-complete/index.js';
2
+ import type { CMLSPExtension } from './protocol.js';
3
+ export type CompletionItemDetailReolve = (completion: Completion) => Node | null | Promise<Node | null>;
4
+ export declare const lspPythonCompletion: CMLSPExtension;
5
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lsp/completion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,MAAM,0BAA0B,GAAG,CACvC,UAAU,EAAE,UAAU,KACnB,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAiCxC,eAAO,MAAM,mBAAmB,EAAE,cAmIjC,CAAC"}
@@ -0,0 +1,245 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ import { pythonLanguage } from '@codemirror/lang-python';
15
+ import { CompletionItemKind, CompletionTriggerKind } from '@difizen/libro-lsp';
16
+ import { offsetToPos, renderMarkupContent } from "./util.js";
17
+ var CompletionItemKindMap = Object.fromEntries(Object.entries(CompletionItemKind).map(function (_ref) {
18
+ var _ref2 = _slicedToArray(_ref, 2),
19
+ key = _ref2[0],
20
+ value = _ref2[1];
21
+ return [value, key];
22
+ }));
23
+ function toSet(chars) {
24
+ var preamble = '';
25
+ var flat = Array.from(chars).join('');
26
+ var words = /\w/.test(flat);
27
+ if (words) {
28
+ preamble += '\\w';
29
+ flat = flat.replace(/\w/g, '');
30
+ }
31
+ return "[".concat(preamble).concat(flat.replace(/[^\w\s]/g, '\\$&'), "]");
32
+ }
33
+ function prefixMatch(options) {
34
+ var first = new Set();
35
+ var rest = new Set();
36
+ var _iterator = _createForOfIteratorHelper(options),
37
+ _step;
38
+ try {
39
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
40
+ var apply = _step.value.apply;
41
+ var _ref3 = apply,
42
+ _ref4 = _toArray(_ref3),
43
+ initial = _ref4[0],
44
+ restStr = _ref4.slice(1);
45
+ first.add(initial);
46
+ var _iterator2 = _createForOfIteratorHelper(restStr),
47
+ _step2;
48
+ try {
49
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
50
+ var char = _step2.value;
51
+ rest.add(char);
52
+ }
53
+ } catch (err) {
54
+ _iterator2.e(err);
55
+ } finally {
56
+ _iterator2.f();
57
+ }
58
+ }
59
+ } catch (err) {
60
+ _iterator.e(err);
61
+ } finally {
62
+ _iterator.f();
63
+ }
64
+ var source = toSet(first) + toSet(rest) + '*$';
65
+ return [new RegExp('^' + source), new RegExp(source)];
66
+ }
67
+ export var lspPythonCompletion = function lspPythonCompletion(_ref5) {
68
+ var lspProvider = _ref5.lspProvider;
69
+ var completionSource = /*#__PURE__*/function () {
70
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(context) {
71
+ var _yield$lspProvider, doc, lspConnection, editor, state, pos, _offsetToPos, line, character, rootPos, virtualPos, result, items, options, _prefixMatch, _prefixMatch2, match, token, word;
72
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
73
+ while (1) switch (_context3.prev = _context3.next) {
74
+ case 0:
75
+ if (!(!lspProvider || context.explicit === true)) {
76
+ _context3.next = 2;
77
+ break;
78
+ }
79
+ return _context3.abrupt("return", null);
80
+ case 2:
81
+ _context3.next = 4;
82
+ return lspProvider();
83
+ case 4:
84
+ _yield$lspProvider = _context3.sent;
85
+ doc = _yield$lspProvider.virtualDocument;
86
+ lspConnection = _yield$lspProvider.lspConnection;
87
+ editor = _yield$lspProvider.editor;
88
+ state = context.state;
89
+ pos = context.pos;
90
+ if (!(!lspConnection || !lspConnection.isReady || !lspConnection.provides('completionProvider'))) {
91
+ _context3.next = 12;
92
+ break;
93
+ }
94
+ return _context3.abrupt("return", null);
95
+ case 12:
96
+ _offsetToPos = offsetToPos(state.doc, pos), line = _offsetToPos.line, character = _offsetToPos.character;
97
+ rootPos = doc.transformFromEditorToRoot(editor, {
98
+ line: line,
99
+ ch: character,
100
+ isEditor: true
101
+ });
102
+ if (rootPos) {
103
+ _context3.next = 16;
104
+ break;
105
+ }
106
+ return _context3.abrupt("return", null);
107
+ case 16:
108
+ virtualPos = doc.virtualPositionAtDocument(rootPos);
109
+ _context3.next = 19;
110
+ return lspConnection.clientRequests['textDocument/completion'].request({
111
+ position: {
112
+ line: virtualPos.line,
113
+ character: virtualPos.ch
114
+ },
115
+ textDocument: {
116
+ uri: doc.documentInfo.uri
117
+ },
118
+ context: {
119
+ triggerKind: CompletionTriggerKind.Invoked
120
+ }
121
+ });
122
+ case 19:
123
+ result = _context3.sent;
124
+ if (result) {
125
+ _context3.next = 22;
126
+ break;
127
+ }
128
+ return _context3.abrupt("return", null);
129
+ case 22:
130
+ items = 'items' in result ? result.items : result;
131
+ options = items.map(function (item) {
132
+ var _textEdit$newText;
133
+ var detail = item.detail,
134
+ label = item.label,
135
+ kind = item.kind,
136
+ textEdit = item.textEdit,
137
+ documentation = item.documentation,
138
+ sortText = item.sortText,
139
+ filterText = item.filterText;
140
+ var completion = {
141
+ label: label,
142
+ detail: detail,
143
+ apply: (_textEdit$newText = textEdit === null || textEdit === void 0 ? void 0 : textEdit.newText) !== null && _textEdit$newText !== void 0 ? _textEdit$newText : label,
144
+ type: kind && CompletionItemKindMap[kind].toLowerCase(),
145
+ sortText: sortText !== null && sortText !== void 0 ? sortText : label,
146
+ filterText: filterText !== null && filterText !== void 0 ? filterText : label
147
+ };
148
+ if (documentation) {
149
+ var resolver = /*#__PURE__*/function () {
150
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
151
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
152
+ while (1) switch (_context.prev = _context.next) {
153
+ case 0:
154
+ return _context.abrupt("return", renderMarkupContent(documentation));
155
+ case 1:
156
+ case "end":
157
+ return _context.stop();
158
+ }
159
+ }, _callee);
160
+ }));
161
+ return function resolver() {
162
+ return _ref7.apply(this, arguments);
163
+ };
164
+ }();
165
+ completion.info = resolver;
166
+ } else {
167
+ var _resolver = /*#__PURE__*/function () {
168
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
169
+ var itemResult;
170
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
171
+ while (1) switch (_context2.prev = _context2.next) {
172
+ case 0:
173
+ _context2.next = 2;
174
+ return lspConnection.clientRequests['completionItem/resolve'].request(item);
175
+ case 2:
176
+ itemResult = _context2.sent;
177
+ return _context2.abrupt("return", itemResult.documentation ? renderMarkupContent(itemResult.documentation) : null);
178
+ case 4:
179
+ case "end":
180
+ return _context2.stop();
181
+ }
182
+ }, _callee2);
183
+ }));
184
+ return function _resolver() {
185
+ return _ref8.apply(this, arguments);
186
+ };
187
+ }();
188
+ completion.info = _resolver;
189
+ }
190
+ return completion;
191
+ });
192
+ _prefixMatch = prefixMatch(options), _prefixMatch2 = _slicedToArray(_prefixMatch, 2), match = _prefixMatch2[1];
193
+ token = context.matchBefore(match); // TODO: sort 方法需要进一步改进
194
+ if (token) {
195
+ pos = token.from;
196
+ word = token.text.toLowerCase();
197
+ if (/^\w+$/.test(word)) {
198
+ options = options.filter(function (_ref9) {
199
+ var filterText = _ref9.filterText;
200
+ return filterText.toLowerCase().startsWith(word);
201
+ }).sort(function (_ref10, _ref11) {
202
+ var a = _ref10.apply,
203
+ sortTexta = _ref10.sortText;
204
+ var b = _ref11.apply,
205
+ sortTextb = _ref11.sortText;
206
+ switch (true) {
207
+ case sortTexta !== undefined && sortTextb !== undefined:
208
+ return sortTexta.localeCompare(sortTextb);
209
+ case a.startsWith(token.text) && !b.startsWith(token.text):
210
+ return -1;
211
+ case !a.startsWith(token.text) && b.startsWith(token.text):
212
+ return 1;
213
+ }
214
+ return 0;
215
+ });
216
+ }
217
+ } else {
218
+ options = options.sort(function (_ref12, _ref13) {
219
+ var sortTexta = _ref12.sortText;
220
+ var sortTextb = _ref13.sortText;
221
+ switch (true) {
222
+ case sortTexta !== undefined && sortTextb !== undefined:
223
+ return sortTexta.localeCompare(sortTextb);
224
+ }
225
+ return 0;
226
+ });
227
+ }
228
+ return _context3.abrupt("return", {
229
+ from: pos,
230
+ options: options
231
+ });
232
+ case 28:
233
+ case "end":
234
+ return _context3.stop();
235
+ }
236
+ }, _callee3);
237
+ }));
238
+ return function completionSource(_x) {
239
+ return _ref6.apply(this, arguments);
240
+ };
241
+ }();
242
+ return pythonLanguage.data.of({
243
+ autocomplete: completionSource
244
+ });
245
+ };
@@ -0,0 +1,7 @@
1
+ import type { Command, KeyBinding } from '@codemirror/view';
2
+ import type { CMLSPExtension } from './protocol.js';
3
+ export declare const startFormatEffect: import("@codemirror/state").StateEffectType<boolean>;
4
+ export declare const formatCell: Command;
5
+ export declare const formatKeymap: readonly KeyBinding[];
6
+ export declare const lspFormat: CMLSPExtension;
7
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/lsp/format.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EAEP,UAAU,EAGX,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC;AAGzE,eAAO,MAAM,iBAAiB,sDAAgC,CAAC;AAE/D,eAAO,MAAM,UAAU,EAAE,OAGxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAwC,CAAC;AAoHvF,eAAO,MAAM,SAAS,EAAE,cAEvB,CAAC"}