Skip to content

Commit 960d226

Browse files
committed
feat(parser): upgrade vimparser #35 to support eval heredoc method
1 parent c02ebe7 commit 960d226

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vim-language-server",
3-
"version": "1.4.2",
3+
"version": "1.5.0",
44
"description": "vim language server",
55
"keywords": [
66
"viml",

src/common/patterns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const notFunctionPattern = [
3838
/^[ \t]*\w+$/,
3939
/^[ \t]*"/,
4040
/(let|set|colorscheme)[ \t][^ \t]*$/,
41-
/[^([,\\ \t\w#]\w*$/,
41+
/[^([,\\ \t\w#>]\w*$/,
4242
/^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
4343
autocmdPattern,
4444
];

src/common/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export function getWordFromPosition(
164164
// parse vim buffer
165165
export async function handleParse(textDoc: TextDocument | string): Promise<[INode | null, string]> {
166166
const text = textDoc instanceof Object ? textDoc.getText() : textDoc;
167-
const tokens = new StringReader(text);
167+
const tokens = new StringReader(text.split(/\r\n|\r|\n/));
168168
try {
169169
const node: INode = new VimLParser(true).parse(tokens);
170170
return [node, ""];

src/lib/vimparser.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export declare interface INode {
3434
export declare class StringReader {
3535
public buf: string[];
3636
public pos: Array<[number, number, number]>;
37-
constructor(str: string)
37+
constructor(lines: string[])
3838
}
3939

4040
// tslint:disable-next-line

src/server/buffer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ const NODE_CURLYNAMEPART = 90; // TODO
8787
const NODE_CURLYNAMEEXPR = 91; // TODO
8888
const NODE_LAMBDA = 92;
8989
const NODE_CONST = 94;
90+
const NODE_EVAL = 95;
91+
const NODE_HEREDOC = 96;
92+
const NODE_METHOD = 97;
9093

9194
/*
9295
* buffer's completion items
@@ -411,6 +414,7 @@ export class Buffer {
411414
case NODE_RETURN:
412415
case NODE_DELFUNCTION:
413416
case NODE_THROW:
417+
case NODE_EVAL:
414418
nodeList = nodeList.concat(node.left);
415419
break;
416420
case NODE_DOT:
@@ -483,6 +487,7 @@ export class Buffer {
483487
case NODE_ADD:
484488
case NODE_SUBTRACT:
485489
case NODE_SUBSCRIPT:
490+
case NODE_METHOD:
486491
nodeList = nodeList.concat(node.left || []);
487492
nodeList = nodeList.concat(node.right || []);
488493
break;

0 commit comments

Comments
 (0)