Skip to content

Commit

Permalink
Update JSON schema (#77)
Browse files Browse the repository at this point in the history
* update json schema

Some settings have been skipped, because they are VS Code related, or they are simply not supported:
"volar-language-features.trace.server" - Traces the communication between VS Code and the language server.
"volar-language-features-2.trace.server" - Traces the communication between VS Code and the language server.
"volar-document-features.trace.server" - Traces the communication between VS Code and the language server.
"volar.vueserver.useSecondServer" - Not supported
"volar.icon.splitEditors" - Not supported - Show split editor icon in title area of editor.
"volar.icon.preview" - Not supported - Show Vite / Nuxt App preview icon.
"volar.takeOverMode.enabled" - Skipped, because LSP-volar does it this way https://github.com/sublimelsp/LSP-volar#enable-for-non-vue-files
"volar.preview.port" - Not supported, yet
"volar.preview.backgroundColor" - Not supported
"volar.preview.transparentGrid" - Not supported

DEPRECATIONS

"volar.preferredAttrNameCase" was renamed to "volar.completion.preferredAttrNameCase"
"volar.preferredTagNameCase" was renamed to "volar.completion.preferredTagNameCase"

* LSP supports implementation

https://github.com/johnsoncodehk/volar/blob/master/CHANGELOG.md#0330-2022313
> eat: support for goto implementations
    if you're not using VSCode, you should config new option languageFeatures.implementation = true in initializationOptions to enable it

* LSP doesn't supports inlay hints just yet

* refactor: define a find_typescript_path method

* programmatically set initialization options for languageFeatures and documentFeatures
  • Loading branch information
predragnikolic authored Apr 27, 2022
1 parent d953f41 commit 9cc8db3
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 51 deletions.
39 changes: 4 additions & 35 deletions LSP-volar.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,17 @@
// else the typescript bundled with LSP-volar will be used.
"typescript": {
// "serverPath": "/path/to/tsserverlibrary.js"
},
"languageFeatures": {
"references": true,
"definition": true,
"typeDefinition": true,
"callHierarchy": false,
"hover": true,
"rename": true,
"renameFileRefactoring": false,
"signatureHelp": true,
"codeAction": true,
"completion": {
"defaultTagNameCase": "both",
"defaultAttrNameCase": "kebab",
"getDocumentNameCasesRequest": false,
"getDocumentSelectionRequest": false,
},
"documentHighlight": true,
"documentLink": false,
"codeLens": false,
"semanticTokens": false,
"schemaRequestService": false,
"diagnostics": true
},
"documentFeatures": {
"selectionRange": true,
"foldingRange": true,
"linkedEditingRange": false,
"documentSymbol": true,
"documentColor": true,
"documentFormatting": {
"defaultPrintWidth": 90
}
}
},
"settings": {
"volar.codeLens.references": true,
"volar.codeLens.pugTools": false,
"volar.codeLens.scriptSetupTools": false,
"volar.autoWrapParentheses": true,
"volar.autoCompleteRefs": false,
"volar.completion.autoImportComponent": true,
"volar.preferredAttrNameCase": "auto-kebab",
"volar.preferredTagNameCase": "auto"
"volar.completion.preferredAttrNameCase": "kebab",
"volar.completion.preferredTagNameCase": "both"
},
"languages": [
{
Expand Down
61 changes: 58 additions & 3 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,51 @@ def is_allowed_to_start(
):
if not workspace_folders or not configuration:
return
configuration.init_options.set('languageFeatures', {
"references": True,
"definition": True,
"implementation": True,
"typeDefinition": True,
"callHierarchy": False,
"inlayHints": False,
"hover": True,
"rename": True,
"renameFileRefactoring": False,
"signatureHelp": True,
"codeAction": True,
"completion": {
"defaultTagNameCase": get_default_tag_name_case(configuration),
"defaultAttrNameCase": get_default_attr_name_case(configuration),
"getDocumentNameCasesRequest": False,
"getDocumentSelectionRequest": False,
},
"documentHighlight": True,
"documentLink": False,
"codeLens": False,
"semanticTokens": False,
"schemaRequestService": False,
"diagnostics": True
})
configuration.init_options.set('documentFeatures', {
"selectionRange": True,
"foldingRange": True,
"linkedEditingRange": False,
"documentSymbol": True,
"documentColor": True,
"documentFormatting": {
"defaultPrintWidth": 90
}
})
if configuration.init_options.get('typescript.serverPath'):
return # don't find the `typescript.serverPath` if it was set explicitly in LSP-volar.sublime-settings
typescript_path = LspVolarPlugin.find_typescript_path(workspace_folders[0].path)
configuration.init_options.set('typescript.serverPath', typescript_path)

@classmethod
def find_typescript_path(cls, current_folder: str) -> str:
server_directory_path = cls._server_directory_path()
resolve_module_script = os.path.join(server_directory_path, 'resolve_module.js')
first_folder = workspace_folders[0].path
find_ts_server_command = [cls._node_bin(), resolve_module_script, first_folder]
find_ts_server_command = [cls._node_bin(), resolve_module_script, current_folder]
startupinfo = None
# Prevent cmd.exe popup on Windows.
if sublime.platform() == "windows":
Expand All @@ -45,4 +84,20 @@ def is_allowed_to_start(
)
workspace_ts_path = subprocess.check_output(find_ts_server_command, universal_newlines=True, startupinfo=startupinfo)
bundled_ts_path = os.path.join(server_directory_path, 'node_modules', 'typescript', 'lib', 'tsserverlibrary.js')
configuration.init_options.set('typescript.serverPath', workspace_ts_path or bundled_ts_path)
return workspace_ts_path or bundled_ts_path


def get_default_tag_name_case(configuration: ClientConfig) -> str:
preferred_tag_name_case = configuration.settings.get('volar.completion.preferredTagNameCase')
if preferred_tag_name_case == 'kebab':
return 'kebabCase'
elif preferred_tag_name_case == 'pascal':
return 'pascalCase'
return 'both'


def get_default_attr_name_case(configuration: ClientConfig) -> str:
preferred_attr_name_case = configuration.settings.get('volar.completion.preferredAttrNameCase')
if preferred_attr_name_case == 'camel':
return 'camelCase'
return 'kebabCase'
30 changes: 17 additions & 13 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,42 @@
"default": false,
"description": "[ref sugar ☐] code lens."
},
"volar.preferredTagNameCase": {
"volar.autoWrapParentheses": {
"type": "boolean",
"default": true,
"description": "Auto-wrap `()` to As Expression in interpolations for fix issue #520."
},
"volar.autoCompleteRefs": {
"type": "boolean",
"default": false,
"description": "Auto-complete Ref value with `.value`."
},
"volar.completion.preferredTagNameCase": {
"type": "string",
"enum": [
"auto",
"both",
"kebab",
"pascal"
],
"enumDescriptions": [
"Auto Detect from Content",
"<kebab-case> and <PascalCase>",
"<kebab-case>",
"<PascalCase>"
],
"default": "auto",
"default": "both",
"description": "Preferred tag name case."
},
"volar.preferredAttrNameCase": {
"volar.completion.preferredAttrNameCase": {
"type": "string",
"enum": [
"auto-kebab",
"auto-pascal",
"kebab",
"pascal"
"camel"
],
"enumDescriptions": [
"Auto Detect from Content (Preference kebab-case)",
"Auto Detect from Content (Preference pascalCase)",
"kebab-case",
"pascalCase"
":kebab-case=\"...\"",
":camelCase=\"...\""
],
"default": "auto-kebab",
"default": "kebab",
"description": "Preferred attr name case."
},
"volar.completion.autoImportComponent": {
Expand Down

0 comments on commit 9cc8db3

Please sign in to comment.