Skip to content

Instantly share code, notes, and snippets.

@kfly8
Created February 12, 2023 14:30
Show Gist options
  • Select an option

  • Save kfly8/3989101b80918e674d567900b3ba5c6d to your computer and use it in GitHub Desktop.

Select an option

Save kfly8/3989101b80918e674d567900b3ba5c6d to your computer and use it in GitHub Desktop.
Perl Navigator server/src/hover.ts をいじって、前後の数行を表示してみる
diff --git a/server/src/hover.ts b/server/src/hover.ts
index e469b56..dfb7e60 100644
--- a/server/src/hover.ts
+++ b/server/src/hover.ts
@@ -22,6 +22,20 @@ export function getHover(params: TextDocumentPositionParams, perlDoc: PerlDocume
let hoverStr = buildHoverDoc(symbol, elem);
if(!hoverStr) return; // Sometimes, there's nothing worth showing.
+ const BEFORE_CONTEXT_COUNT = 3;
+ const AFTER_CONTEXT_COUNT = 3;
+ const context = [
+ '----',
+ "\n",
+ '```perl',
+ txtDoc.getText({
+ start: { line: elem.line - BEFORE_CONTEXT_COUNT, character: 0 },
+ end: { line: elem.line + AFTER_CONTEXT_COUNT, character: 0 }
+ }),
+ '```',
+ ].join("\n");
+ hoverStr += "\n" + context;
+
const documentation = {contents: hoverStr};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment