Skip to content

Commit

Permalink
Nim documentation support improvements for hover and code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
kosz78 committed Feb 11, 2017
1 parent 5650926 commit 6023cb5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ChangeLog

## 0.5.17 (11 Feb 2017)

This comment has been minimized.

Copy link
@dom96

dom96 Feb 14, 2017

Thank you for tagging :)

* 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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 7 additions & 1 deletion src/nimHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
}
Expand Down
8 changes: 7 additions & 1 deletion src/nimSuggestExec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 6023cb5

Please sign in to comment.