1 | # VimScript Language Server
|
2 |
|
3 | [![CI](https://github.com/iamcco/vim-language-server/workflows/CI/badge.svg?branch=master)](https://github.com/iamcco/vim-language-server/actions?query=workflow%3ACI)
|
4 | [![Npm](https://img.shields.io/github/package-json/v/iamcco/vim-language-server)](https://www.npmjs.com/package/vim-language-server)
|
5 | ![Type](https://img.shields.io/npm/types/vim-language-server)
|
6 | ![download](https://img.shields.io/npm/dm/vim-language-server)
|
7 |
|
8 | > language server for VimScript
|
9 |
|
10 | **Features:**
|
11 |
|
12 | - auto completion
|
13 | - function signature help
|
14 | - hover document
|
15 | - go to definition
|
16 | - go to references
|
17 | - document symbols
|
18 | - document highlight
|
19 | - folding range
|
20 | - select range
|
21 | - rename
|
22 | - snippets
|
23 | - diagnostic
|
24 |
|
25 | ![autocomplete](https://user-images.githubusercontent.com/5492542/81493984-909c2e80-92d7-11ea-9638-d7be3e18e1d1.gif)
|
26 |
|
27 | ## Install
|
28 |
|
29 | **For yarn**
|
30 |
|
31 | ```sh
|
32 | yarn global add vim-language-server
|
33 | ```
|
34 |
|
35 | **For npm**
|
36 |
|
37 | ```sh
|
38 | npm install -g vim-language-server
|
39 | ```
|
40 |
|
41 | **For coc.nvim user** install coc extension:
|
42 |
|
43 | ```vim
|
44 | :CocInstall coc-vimlsp
|
45 | ```
|
46 |
|
47 | ## Config
|
48 |
|
49 | for document highlight
|
50 |
|
51 | ```vim
|
52 | let g:markdown_fenced_languages = [
|
53 | \ 'vim',
|
54 | \ 'help'
|
55 | \]
|
56 | ```
|
57 |
|
58 | lsp client config example with coc.nvim
|
59 |
|
60 | - Using node ipc
|
61 |
|
62 | ```jsonc
|
63 | "languageserver": {
|
64 | "vimls": {
|
65 | "module": "/path/to/vim-language-server/bin/index.js",
|
66 | "args": ["--node-ipc"],
|
67 | "initializationOptions": {
|
68 | "iskeyword": "@,48-57,_,192-255,-#", // vim iskeyword option
|
69 | "vimruntime": "", // $VIMRUNTIME option
|
70 | "runtimepath": "", // vim runtime path separate by `,`
|
71 | "diagnostic": {
|
72 | "enable": true
|
73 | },
|
74 | "indexes": {
|
75 | "runtimepath": true, // if index runtimepath's vim files this will effect the suggest
|
76 | "gap": 100, // index time gap between next file
|
77 | "count": 3, // count of files index at the same time
|
78 | "projectRootPatterns" : ["strange-root-pattern", ".git", "autoload", "plugin"] // Names of files used as the mark of project root. If empty, the default value [".git", "autoload", "plugin"] will be used
|
79 | },
|
80 | "suggest": {
|
81 | "fromVimruntime": true, // completionItems from vimruntime's vim files
|
82 | "fromRuntimepath": false // completionItems from runtimepath's vim files, if this is true that fromVimruntime is true
|
83 | }
|
84 | },
|
85 | "filetypes": [ "vim" ],
|
86 | }
|
87 | }
|
88 | ```
|
89 |
|
90 | - Using stdio
|
91 |
|
92 | ```jsonc
|
93 | "languageserver": {
|
94 | "vimls": {
|
95 | "command": "vim-language-server",
|
96 | "args": ["--stdio"],
|
97 | "initializationOptions": {
|
98 | "iskeyword": "@,48-57,_,192-255,-#", // vim iskeyword option
|
99 | "vimruntime": "", // $VIMRUNTIME option
|
100 | "runtimepath": "", // vim runtime path separate by `,`
|
101 | "diagnostic": {
|
102 | "enable": true
|
103 | },
|
104 | "indexes": {
|
105 | "runtimepath": true, // if index runtimepath's vim files this will effect the suggest
|
106 | "gap": 100, // index time gap between next file
|
107 | "count": 3, // count of files index at the same time
|
108 | "projectRootPatterns" : ["strange-root-pattern", ".git", "autoload", "plugin"] // Names of files used as the mark of project root. If empty, the default value [".git", "autoload", "plugin"] will be used
|
109 | },
|
110 | "suggest": {
|
111 | "fromVimruntime": true, // completionItems from vimruntime's vim files
|
112 | "fromRuntimepath": false // completionItems from runtimepath's vim files, if this is true that fromVimruntime is true
|
113 | }
|
114 | },
|
115 | "filetypes": [ "vim" ]
|
116 | }
|
117 | }
|
118 | ```
|
119 |
|
120 | **Note**:
|
121 |
|
122 | - if you want to speed up index, change `gap` to smaller and `count` to greater, this will cause high CPU usage for some time
|
123 | - 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.
|
124 |
|
125 | ## Usage
|
126 |
|
127 | > The screen record is using coc.nvim as LSP client.
|
128 |
|
129 | **Auto complete and function signature help**:
|
130 |
|
131 | ![autocomplete](https://user-images.githubusercontent.com/5492542/81493984-909c2e80-92d7-11ea-9638-d7be3e18e1d1.gif)
|
132 |
|
133 | **Hover document**:
|
134 |
|
135 | ![hover](https://user-images.githubusercontent.com/5492542/81494066-5aab7a00-92d8-11ea-9ccd-31bd6440e622.gif)
|
136 |
|
137 | **Go to definition and references**:
|
138 |
|
139 | ![goto](https://user-images.githubusercontent.com/5492542/81494125-c261c500-92d8-11ea-83c0-fecba34ea55e.gif)
|
140 |
|
141 | **Document symbols**:
|
142 |
|
143 | ![symbols](https://user-images.githubusercontent.com/5492542/81494183-5cc20880-92d9-11ea-9495-a7691420df39.gif)
|
144 |
|
145 | **Document highlight**:
|
146 |
|
147 | ![highlight](https://user-images.githubusercontent.com/5492542/81494214-b1fe1a00-92d9-11ea-9cc1-0420cddc5cbc.gif)
|
148 |
|
149 | **Folding range and selection range**:
|
150 |
|
151 | ![fold](https://user-images.githubusercontent.com/5492542/81494276-3bade780-92da-11ea-8c93-bc3d2127a19d.gif)
|
152 |
|
153 | **Rename**:
|
154 |
|
155 | ![rename](https://user-images.githubusercontent.com/5492542/81494329-aa8b4080-92da-11ea-8a5d-ace5385445e9.gif)
|
156 |
|
157 | **Snippets and diagnostic**:
|
158 |
|
159 | ![dia](https://user-images.githubusercontent.com/5492542/81494408-503eaf80-92db-11ea-96ac-641d46027623.gif)
|
160 |
|
161 | ## References
|
162 |
|
163 | - [vim-vimlparser](https://github.com/vim-jp/vim-vimlparser)
|
164 | - [neco-vim](https://github.com/Shougo/neco-vim)
|
165 |
|
166 | ### Buy Me A Coffee ☕️
|
167 |
|
168 | ![btc](https://img.shields.io/keybase/btc/iamcco.svg?style=popout-square)
|
169 |
|
170 | ![image](https://user-images.githubusercontent.com/5492542/42771079-962216b0-8958-11e8-81c0-520363ce1059.png)
|