From 6023cb514910664bef890c9a65948dff7147a74f Mon Sep 17 00:00:00 2001 From: Konstantin Zaitsev Date: Sat, 11 Feb 2017 18:50:12 +0700 Subject: [PATCH] Nim documentation support improvements for hover and code completion --- CHANGELOG.md | 3 +++ README.md | 2 +- package.json | 2 +- src/nimHover.ts | 8 +++++++- src/nimSuggestExec.ts | 8 +++++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b0b701..451f0b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # ChangeLog +## 0.5.17 (11 Feb 2017) +* Nim documentation support improvements for hover and code completion + ## 0.5.16 (07 Feb 2017) * Fixed toggle line comment stopped working in .nim files after 0.5.15 update [#35](https://github.com/pragmagic/vscode-nim/issues/35) * Readded bracket auto closing (it is intended that the string literals are brackets, VSCode recognises this and doesn't show a box around quotation marks) diff --git a/README.md b/README.md index 478f416..5fd476a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This extension adds language support for the Nim language to VS Code, including: - Syntax Highlight (nim, nimble, nim.cfg) - Code Completion +- Signature Help - Goto Definition - Find References - File outline @@ -67,7 +68,6 @@ This command available from file context menu or by `F6` keyboard shortcut. ## TODO * Rename support -* Documentation * Quick info * Code action for imports (suggest available modules to import) * Debug support diff --git a/package.json b/package.json index 49575ac..e007859 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nim", "displayName": "Nim", "description": "Nim language support for Visual Studio Code", - "version": "0.5.16", + "version": "0.5.17", "publisher": "kosz78", "author": { "name": "Xored Software Inc." diff --git a/src/nimHover.ts b/src/nimHover.ts index e765e5b..15c7bde 100644 --- a/src/nimHover.ts +++ b/src/nimHover.ts @@ -6,6 +6,7 @@ 'use strict'; import vscode = require('vscode'); +import { NIM_MODE } from './nimMode'; import { getDirtyFile } from './nimUtils'; import { execNimSuggest, NimSuggestResult, NimSuggestType } from './nimSuggestExec'; @@ -22,7 +23,12 @@ export class NimHoverProvider implements vscode.HoverProvider { let label = def.fullName; if (def.type !== '') label += ': ' + def.type; - resolve(new vscode.Hover(label, def.range)); + let hoverLabel = { language: NIM_MODE.language, value: label }; + if (def.documentation !== '') { + resolve(new vscode.Hover([hoverLabel, def.documentation], def.range)); + } else { + resolve(new vscode.Hover(hoverLabel, def.range)); + } } else { resolve(null); } diff --git a/src/nimSuggestExec.ts b/src/nimSuggestExec.ts index 42d60f3..f9654ef 100644 --- a/src/nimSuggestExec.ts +++ b/src/nimSuggestExec.ts @@ -194,7 +194,13 @@ export async function execNimSuggest(suggestType: NimSuggestType, filename: stri item.type = parts[4]; item.line = parts[5]; item.column = parts[6]; - item.documentation = parts[7]; + var doc = parts[7]; + if (doc !== '') { + doc = doc.replace(/\\,u000A|\\,u000D\\,u000A/g, '\n'); + doc = doc.replace(/\`\`/g, '`'); + doc = doc.replace(/\`([^\<\`]+)\<([^\>]+)\>\`\_/g, '\[$1\]\($2\)'); + } + item.documentation = doc; result.push(item); } }