|
31 | 31 | hover_at_position(Path, Line0, Char0, S) :- |
32 | 32 | Loc = line_char(Line0, Char0), thread_signal(main,make), |
33 | 33 | clause_with_arity_in_file_at_position(Term, Arity, Path, Loc), |
| 34 | + %assume_mode(markdown), |
| 35 | + assume_mode(markdown), |
34 | 36 | findall(S, lsp_hooks:hover_string(Path, Loc, Term, Arity, S), SS), |
35 | 37 | combine_hover(SS, S). |
36 | 38 |
|
|
231 | 233 |
|
232 | 234 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
233 | 235 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
234 | | -in_markdown(G) :- format("~N", []), call(G). |
| 236 | +in_markdown(G) :- in_mode(markdown,call(G)). |
| 237 | +in_textual(G) :- in_mode(textual,call(G)). |
| 238 | +in_mode(X,G):- enter_mode(X),call(G),format("~N", []). |
| 239 | + |
| 240 | +inside_mode(X):-nb_current(md_mode,M),M==X. |
| 241 | + |
| 242 | +enter_mode(X):- inside_mode(X),!. |
| 243 | +enter_mode(X):- assume_mode(X),start_mode(X),!. |
| 244 | +assume_mode(X):- nb_setval(md_mode,X),!. |
| 245 | +start_mode(textual):- write('\n```no-wrap\n'). |
| 246 | +start_mode(markdown):- write('\n```\n'). |
| 247 | +start_mode(_). |
| 248 | + |
235 | 249 | banner_for(Type, Target):- in_markdown(format('***~n ## ~w: ~w', [Type, Target])). |
236 | 250 | lsp_separator :- in_markdown(format('~N***~n',[])). |
| 251 | +linebr:- inside_mode(pre),!, lsp_separator. |
| 252 | +linebr:- nl,write(' -'),nl. |
| 253 | + |
237 | 254 |
|
238 | 255 | show_checked(Name, Value, Caption) :- fail, |
239 | 256 | format("[~w](file:command:myExtension.toggleValue?{\"name\":\"~w\", \"value\":\"~w\"}) ~w ", [Value, Name, Value, Caption]). |
|
278 | 295 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
279 | 296 | lsp_hooks:hover_print(_Path,_Loc, Target, _) :- use_vitalys_help, |
280 | 297 | lsp_separator, |
281 | | - % Don't redirect so we can capture output of this predicate |
282 | | - locally(nb_setval('$dont_redirect_output', true), |
283 | | - xref_call(eval(['help!', Target], _))), |
| 298 | + in_textual_eval(['help!', Target]), |
284 | 299 | lsp_separator. % Evaluate the help command for the term. |
285 | 300 |
|
286 | 301 |
|
| 302 | +% Eval capturing output of this code |
| 303 | +in_textual_eval(MeTTa):- |
| 304 | + locally(nb_setval('$dont_redirect_output', true), |
| 305 | + % Don't redirect so we can capture output of this predicate |
| 306 | + forall(in_textual(xref_call(eval(MeTTa, _))),true)). |
| 307 | + |
287 | 308 | lsp_hooks:hover_print(_Path,_Loc, Term, Arity):- fail, % this isn't very helpful |
288 | 309 | lsp_separator, |
289 | 310 | (((some_arities(Term,Arity, Try, _TryArity), |
|
308 | 329 | lsp_hooks:hover_print(_Path,_Loc, Target, _) :- |
309 | 330 | lsp_separator, |
310 | 331 | each_type_at_sorted(Target, Term, AtPath, AtLoc, Type), |
| 332 | + lsp_separator, |
311 | 333 | write_src_xref(Term, Type, AtPath, AtLoc). % Write the source cross-reference for the atom. |
312 | 334 |
|
| 335 | + |
| 336 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 337 | +% Compiled predicate Help |
| 338 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 339 | +lsp_hooks:hover_print(_Path,_Loc, Target, _) :- |
| 340 | + lsp_separator, |
| 341 | + %in_textual_eval(writeq(['sinfo!', Target])), |
| 342 | + in_textual(catch_ignore(compiled_info(Target))), |
| 343 | + lsp_separator. % Evaluate the help command for the term. |
| 344 | + |
| 345 | + |
| 346 | + |
313 | 347 | get_code_at_range_type(term). |
314 | 348 | get_code_at_range_type(expression). |
315 | 349 | get_code_at_range_type(toplevel). |
|
420 | 454 | write_src_xref(Src):- |
421 | 455 | write_src_woi(Src). % Otherwise, write the source content without additional information. |
422 | 456 |
|
423 | | - |
424 | 457 | write_src_xref(Term, Type, Path, Loc):- |
425 | | - catch_skip((write_src_xref(Term), |
426 | | - in_markdown(ignore(write_file_link(Type, Path, Loc))))). |
| 458 | + catch_skip(( |
| 459 | + in_textual(write_src_xref(Term)), |
| 460 | + in_markdown(ignore(write_file_link(Type, Path, Loc))))). |
427 | 461 |
|
428 | 462 | write_src_xref(Term, Path, Loc):- |
429 | 463 | catch_skip((write_src_xref(Term), |
|
456 | 490 |
|
457 | 491 | % ~n```~n*~w*~n```lisp~n |
458 | 492 | write_file_link(Type, Path, Position):- |
459 | | - write_file_link(Path, Position), format(' _(~w)_', [Type]). |
| 493 | + in_markdown((write_file_link(Path, Position), format(' _(~w)_', [Type]))). |
460 | 494 |
|
461 | 495 | write_file_link(Path, Position):- is_in_emacs, !, |
462 | 496 | must_succeed1(position_line(Position, Line0)), succ(Line0, Line1), |
|
0 commit comments