Skip to content

Commit fe373fb

Browse files
committed
feat(parser): add isNeovim option
1 parent 6a8c69e commit fe373fb

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ lsp client config example with coc.nvim
6565
"module": "/path/to/vim-language-server/bin/index.js",
6666
"args": ["--node-ipc"],
6767
"initializationOptions": {
68+
"isNeovim": true, // is neovim, default false
6869
"iskeyword": "@,48-57,_,192-255,-#", // vim iskeyword option
6970
"vimruntime": "", // $VIMRUNTIME option
7071
"runtimepath": "", // vim runtime path separate by `,`
@@ -95,6 +96,7 @@ lsp client config example with coc.nvim
9596
"command": "vim-language-server",
9697
"args": ["--stdio"],
9798
"initializationOptions": {
99+
"isNeovim": true, // is neovim, default false
98100
"iskeyword": "@,48-57,_,192-255,-#", // vim iskeyword option
99101
"vimruntime": "", // $VIMRUNTIME option
100102
"runtimepath": "", // vim runtime path separate by `,`
@@ -119,6 +121,7 @@ lsp client config example with coc.nvim
119121

120122
**Note**:
121123

124+
- if you set `isNeovim: true`, command like `fixdel` in vimrc which neovim does not support will report error.
122125
- if you want to speed up index, change `gap` to smaller and `count` to greater, this will cause high CPU usage for some time
123126
- if you don't want to index vim's runtimepath files, set `runtimepath` to `false` and you will not get any suggest from those files.
124127

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": "2.1.2",
3+
"version": "2.1.3",
44
"description": "vim language server",
55
"keywords": [
66
"viml",

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IIndexes {
2323

2424
// initialization options
2525
export interface IConfig {
26+
isNeovim: boolean;
2627
iskeyword: string;
2728
vimruntime: string;
2829
runtimepath: string[];

src/common/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Readable} from "stream";
77
import {CompletionItem, InsertTextFormat, Position, Range, TextDocument} from "vscode-languageserver";
88
import {INode, StringReader, VimLParser} from "../lib/vimparser";
99
import {commentPattern, keywordPattern, kindPattern, wordNextPattern, wordPrePattern} from "./patterns";
10+
import config from '../server/config';
1011

1112
export function isSomeMatchPattern(patterns: kindPattern, line: string): boolean {
1213
return patterns.some((p) => p.test(line));
@@ -168,7 +169,7 @@ export async function handleParse(textDoc: TextDocument | string): Promise<[INod
168169
const text = textDoc instanceof Object ? textDoc.getText() : textDoc;
169170
const tokens = new StringReader(text.split(/\r\n|\r|\n/));
170171
try {
171-
const node: INode = new VimLParser(true).parse(tokens);
172+
const node: INode = new VimLParser(config.isNeovim).parse(tokens);
172173
return [node, ""];
173174
} catch (error) {
174175
return [null, error];

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ import logger from "./common/logger";
2525
connection.onInitialize((param: InitializeParams) => {
2626
const { initializationOptions = {} } = param;
2727
const {
28+
isNeovim,
2829
iskeyword,
2930
runtimepath,
3031
vimruntime,
3132
diagnostic,
3233
suggest,
3334
indexes,
3435
}: {
36+
isNeovim: boolean
3537
iskeyword: string
3638
runtimepath: string
3739
vimruntime: string
@@ -44,6 +46,7 @@ connection.onInitialize((param: InitializeParams) => {
4446

4547
// config by user's initializationOptions
4648
const conf: IConfig = {
49+
isNeovim: isNeovim || false,
4750
iskeyword: iskeyword || "",
4851
runtimepath: runtimepaths,
4952
vimruntime: (vimruntime || "").trim(),

src/server/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export default {
1414
}
1515
},
1616

17+
get isNeovim(): boolean {
18+
return conf && conf.isNeovim || false;
19+
},
20+
1721
get iskeyword(): string {
1822
return conf && conf.iskeyword || "";
1923
},

0 commit comments

Comments
 (0)