/
volar.lua
82 lines (75 loc) · 2.33 KB
/
volar.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local function get_typescript_server_path(root_dir)
local project_root = util.find_node_modules_ancestor(root_dir);
return project_root and (project_root .. '/node_modules/typescript/lib/tsserverlibrary.js') or '';
end
local server_name = 'volar'
local bin_name = 'volar-server'
-- https://github.com/johnsoncodehk/volar/blob/master/packages/shared/src/types.ts
local volar_init_options = {
typescript = {
serverPath = get_typescript_server_path(vim.fn.getcwd()),
},
languageFeatures={
references = true,
definition = true,
typeDefinition = true,
callHierarchy = true,
hover = true,
rename = true,
renameFileRefactoring = true,
signatureHelp = true,
codeAction = true,
completion={
defaultTagNameCase='both',
defaultAttrNameCase='kebabCase',
},
schemaRequestService = true ,
documentHighlight = true,
documentLink = true ,
codeLens = true,
semanticTokens = true,
diagnostics = true,
},
documentFeatures={
selectionRange = true,
foldingRange = true,
linkedEditingRange = true,
documentSymbol = true,
documentColor = true,
documentFormatting = {
defaultPrintWidth = 100,
},
}
}
configs[server_name] = {
default_config = {
cmd = { bin_name, '--stdio' },
filetypes = { 'vue' },
root_dir = util.root_pattern('package.json'),
init_options = volar_init_options,
},
docs = {
package_json = 'https://raw.githubusercontent.com/johnsoncodehk/volar/master/packages/server/package.json',
description = [[
https://github.com/johnsoncodehk/volar/tree/master/packages/server
Volar language server for Vue
Volar can be installed via npm
```sh
npm install -g @volar/server
vue-server --stdio
```
With Vue 3 projects - it works out of the box.
With Vue 2 projects - requires [additional configuration](https://github.com/johnsoncodehk/volar#using)
Do not run `vuels` and `volarvuels` at the same time.
To check which language servers are running, open a `.vue` file and run the `:LspInfo` command.
]],
default_config = {
cmd = { bin_name, '--stdio' },
filetypes = { 'vue' },
root_dir = [[root_pattern('package.json')]],
init_options = volar_init_options,
}
}
}