-
Notifications
You must be signed in to change notification settings - Fork 184
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
Recursive variable expansion in lsp_execute command #1499
Comments
The way to replace some selected variables as top-level items implemented in Lines 44 to 57 in bd0dfc2
sublime.expand_variables() here to automatically search through arrays/mappings, but this isn't possible because it only works like a "string interpolation", i.e. all values would have to be strings, while in practice values can also be numbers or other valid JSON values (arrays, objects).
I'm not sure whether it would be worth to recursively search through all arrays/objects here, because I would assume that the overwhelming majority of language servers use some of the predefined structures from LSP if they expect a more complex value than some scalar int/string/boolean. And even if a recursive search would be implemented, it still isn't guaranteed that all possible values can be constructed from the variables we defined. So for this application here, I would suggest to just add another variable for textDocumentIdentifier like the suggested from .core.views import text_document_identifier
# [....]
elif arg in ["$document_id", "${document_id}"]:
command_args[i] = text_document_identifier(self.view) Perhaps we should name it more similar to the actual name from LSP And if a server requires another kind of LSP structure as value in the future, we can easily add it when necessary. |
Is your feature request related to a problem? Please describe.
The documentation states ...
Note:
command_args
is optional depending on theworkspace/executeCommand
that are supported by the LSP server.The following variables will be expanded, but only if they are top-level array items and not within nested arrays or objects:
The LemMinX language server provides a validation command which expects textDocumentIdentifie as first parameter.
see: eclipse-lemminx/lemminx#938
The proper command definition in ST would look like
Unfortunatelly
${file_uri}
is not expanded as it is not in the top-level array.Describe the solution you'd like
The most flexible and straight forward solution would probably be to support recursive variable expansions in all nested arrays and objects.
Describe alternatives you've considered
An
$document_id
variable which is expanded to{"uri": "file:///path/to/file.xml"}
would do the job as well. The command definition would look as follows then.The text was updated successfully, but these errors were encountered: