Skip to content

Commit

Permalink
feat(parser): upgrade vimparser #35 to support eval heredoc method
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcco committed Mar 25, 2020
1 parent c02ebe7 commit 960d226
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vim-language-server",
"version": "1.4.2",
"version": "1.5.0",
"description": "vim language server",
"keywords": [
"viml",
Expand Down
2 changes: 1 addition & 1 deletion src/common/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const notFunctionPattern = [
/^[ \t]*\w+$/,
/^[ \t]*"/,
/(let|set|colorscheme)[ \t][^ \t]*$/,
/[^([,\\ \t\w#]\w*$/,
/[^([,\\ \t\w#>]\w*$/,
/^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
autocmdPattern,
];
Expand Down
2 changes: 1 addition & 1 deletion src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function getWordFromPosition(
// parse vim buffer
export async function handleParse(textDoc: TextDocument | string): Promise<[INode | null, string]> {
const text = textDoc instanceof Object ? textDoc.getText() : textDoc;
const tokens = new StringReader(text);
const tokens = new StringReader(text.split(/\r\n|\r|\n/));
try {
const node: INode = new VimLParser(true).parse(tokens);
return [node, ""];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/vimparser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export declare interface INode {
export declare class StringReader {
public buf: string[];
public pos: Array<[number, number, number]>;
constructor(str: string)
constructor(lines: string[])
}

// tslint:disable-next-line
Expand Down
5 changes: 5 additions & 0 deletions src/server/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const NODE_CURLYNAMEPART = 90; // TODO
const NODE_CURLYNAMEEXPR = 91; // TODO
const NODE_LAMBDA = 92;
const NODE_CONST = 94;
const NODE_EVAL = 95;
const NODE_HEREDOC = 96;
const NODE_METHOD = 97;

/*
* buffer's completion items
Expand Down Expand Up @@ -411,6 +414,7 @@ export class Buffer {
case NODE_RETURN:
case NODE_DELFUNCTION:
case NODE_THROW:
case NODE_EVAL:
nodeList = nodeList.concat(node.left);
break;
case NODE_DOT:
Expand Down Expand Up @@ -483,6 +487,7 @@ export class Buffer {
case NODE_ADD:
case NODE_SUBTRACT:
case NODE_SUBSCRIPT:
case NODE_METHOD:
nodeList = nodeList.concat(node.left || []);
nodeList = nodeList.concat(node.right || []);
break;
Expand Down

0 comments on commit 960d226

Please sign in to comment.