New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add volar #1223
Merged
Merged
Add volar #1223
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
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 (util.path.join(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 = '', | ||
}, | ||
languageFeatures = { | ||
-- not supported - https://github.com/neovim/neovim/pull/14122 | ||
semanticTokens = false, | ||
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, | ||
diagnostics = true, | ||
}, | ||
documentFeatures = { | ||
-- not supported - https://github.com/neovim/neovim/pull/13654 | ||
documentColor = false, | ||
selectionRange = true, | ||
foldingRange = true, | ||
linkedEditingRange = true, | ||
documentSymbol = 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, | ||
on_new_config = function(new_config, new_root_dir) | ||
if | ||
new_config.init_options | ||
and new_config.init_options.typescript | ||
and new_config.init_options.typescript.serverPath == '' | ||
then | ||
new_config.init_options.typescript.serverPath = get_typescript_server_path(new_root_dir) | ||
end | ||
end, | ||
}, | ||
docs = { | ||
package_json = 'https://raw.githubusercontent.com/johnsoncodehk/volar/master/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 | ||
``` | ||
|
||
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 `volar` at the same time. | ||
|
||
To check which language servers are running, open a `.vue` file and run the `:LspInfo` command. | ||
]], | ||
}, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all of these options need to be explicitly set, or are these overriding defaults? General question, not just limited to this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, need explicitly set to enable these features. Otherwise features was disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! If you could, since you are the expert, please let me know if anything needs to change in this PR regarding settings or init_options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options look good to me! And no need to specifically set false for unsupported features, it will just ignore if unsupported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to be explicit