@@ -90,31 +90,32 @@ const SAGEMATH_METHODS = [
9090 'save' , 'load' , 'show' , 'latex' , 'pretty_print'
9191] ;
9292
93- const SYMBOL_DOCUMENTATION : Record < string , string > = {
94- ZZ : 'The ring of integers. Example: `ZZ(5)` creates the integer 5 in the integer ring.' ,
95- QQ : 'The field of rational numbers. Example: `QQ(1/2)` creates the rational number 1/2.' ,
96- RR : 'The field of real numbers with arbitrary precision. Example: `RR(pi)`.' ,
97- CC : 'The field of complex numbers. Example: `CC(1, 2)` creates `1 + 2*I`.' ,
98- PolynomialRing : 'Creates a polynomial ring. Example: `R = PolynomialRing(QQ, "x"); x = R.gen()`.' ,
99- LaurentPolynomialRing : 'Creates a Laurent polynomial ring. Example: `R = LaurentPolynomialRing(QQ, "x")`.' ,
100- PowerSeriesRing : 'Creates a power series ring. Example: `R = PowerSeriesRing(QQ, "x")`.' ,
101- NumberField : 'Creates a number field. Example: `K = NumberField(x^2 - 2, "a")`.' ,
102- GF : 'Creates a finite field (Galois field). Example: `F = GF(7)` 或 `F = GF(2^8)`.' ,
103- EllipticCurve : 'Creates an elliptic curve. Example: `EllipticCurve([0, 0, 0, -1, 0])`.' ,
104- var : 'Creates symbolic variables. Example: `var("x y z")` creates symbolic variables x, y, z.' ,
105- matrix : 'Creates a matrix. Example: `matrix([[1, 2], [3, 4]])` creates a 2×2 matrix.' ,
106- plot : 'Plots functions. Example: `plot(sin(x), (x, 0, 2*pi))`.' ,
107- solve : 'Solves equations. Example: `solve(x^2 - 4 == 0, x)`.' ,
108- factor : 'Factors polynomials or integers. Example: `factor(x^2 - 4)`.' ,
109- integrate : 'Computes integrals. Example: `integrate(sin(x), x)`.' ,
110- diff : 'Computes derivatives. Example: `diff(sin(x), x)`.' ,
111- expand : 'Expands expressions. Example: `expand((x + 1)^3)`.' ,
112- simplify : 'Simplifies expressions. Example: `simplify(sin(x)^2 + cos(x)^2)`.' ,
113- Graph : 'Creates a graph. Example: `G = Graph(); G.add_edges([(1, 2), (2, 3)])`.' ,
114- gcd : 'Greatest common divisor. Example: `gcd(12, 18)`.' ,
115- is_prime : 'Primality test. Example: `is_prime(17)`.' ,
116- factorial : 'Computes factorial. Example: `factorial(5)`.'
117- } ;
93+ // NOTE: Hover 文档目前不稳定,先注释掉详细映射,避免影响默认提示。
94+ // const SYMBOL_DOCUMENTATION: Record<string, string> = {
95+ // ZZ: 'The ring of integers. Example: `ZZ(5)` creates the integer 5 in the integer ring.',
96+ // QQ: 'The field of rational numbers. Example: `QQ(1/2)` creates the rational number 1/2.',
97+ // RR: 'The field of real numbers with arbitrary precision. Example: `RR(pi)`.',
98+ // CC: 'The field of complex numbers. Example: `CC(1, 2)` creates `1 + 2*I`.',
99+ // PolynomialRing: 'Creates a polynomial ring. Example: `R = PolynomialRing(QQ, "x"); x = R.gen()`.',
100+ // LaurentPolynomialRing: 'Creates a Laurent polynomial ring. Example: `R = LaurentPolynomialRing(QQ, "x")`.',
101+ // PowerSeriesRing: 'Creates a power series ring. Example: `R = PowerSeriesRing(QQ, "x")`.',
102+ // NumberField: 'Creates a number field. Example: `K = NumberField(x^2 - 2, "a")`.',
103+ // GF: 'Creates a finite field (Galois field). Example: `F = GF(7)` 或 `F = GF(2^8)`.',
104+ // EllipticCurve: 'Creates an elliptic curve. Example: `EllipticCurve([0, 0, 0, -1, 0])`.',
105+ // var: 'Creates symbolic variables. Example: `var("x y z")` creates symbolic variables x, y, z.',
106+ // matrix: 'Creates a matrix. Example: `matrix([[1, 2], [3, 4]])` creates a 2×2 matrix.',
107+ // plot: 'Plots functions. Example: `plot(sin(x), (x, 0, 2*pi))`.',
108+ // solve: 'Solves equations. Example: `solve(x^2 - 4 == 0, x)`.',
109+ // factor: 'Factors polynomials or integers. Example: `factor(x^2 - 4)`.',
110+ // integrate: 'Computes integrals. Example: `integrate(sin(x), x)`.',
111+ // diff: 'Computes derivatives. Example: `diff(sin(x), x)`.',
112+ // expand: 'Expands expressions. Example: `expand((x + 1)^3)`.',
113+ // simplify: 'Simplifies expressions. Example: `simplify(sin(x)^2 + cos(x)^2)`.',
114+ // Graph: 'Creates a graph. Example: `G = Graph(); G.add_edges([(1, 2), (2, 3)])`.',
115+ // gcd: 'Greatest common divisor. Example: `gcd(12, 18)`.',
116+ // is_prime: 'Primality test. Example: `is_prime(17)`.',
117+ // factorial: 'Computes factorial. Example: `factorial(5)`.'
118+ // };
118119
119120connection . onInitialize ( ( params : InitializeParams ) => {
120121 const capabilities = params . capabilities ;
@@ -470,26 +471,17 @@ connection.onCompletionResolve(
470471
471472// Provide hover information
472473connection . onHover (
473- ( textDocumentPosition : TextDocumentPositionParams ) : Hover | undefined => {
474- const document = documents . get ( textDocumentPosition . textDocument . uri ) ;
475- if ( ! document ) {
476- return undefined ;
477- }
478-
479- const word = getWordAtPosition ( document , textDocumentPosition . position ) ;
480- if ( ! word ) {
481- return undefined ;
482- }
483-
484- const doc = SYMBOL_DOCUMENTATION [ word ] ;
485- if ( ! doc ) {
486- return undefined ;
487- }
488-
474+ ( _textDocumentPosition : TextDocumentPositionParams ) : Hover | undefined => {
489475 return {
490476 contents : {
491477 kind : MarkupKind . Markdown ,
492- value : `**${ word } **\n\n${ doc } `
478+ value : [
479+ '**SageMath Enhanced**' ,
480+ '' ,
481+ 'Hover over SageMath symbols to get documentation.' ,
482+ '' ,
483+ 'Use Ctrl+Space for code completion.'
484+ ] . join ( '\n' )
493485 }
494486 } ;
495487 }
0 commit comments