-
Notifications
You must be signed in to change notification settings - Fork 273
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
Map key order #839
Map key order #839
Conversation
Adds a new validation that checks if the keys of a map are in alphabetical order. Updates the tests to cover the new validation.
Adds a setting to control keyOrdering feature. Tests if the new setting works as expected. Starts using the new setting to enable the feature.
Adds a new codeaction that fixes the map order by rewriting the ast with the alphabetical order of keys.
Updates readme and changelog with the information for the new feature.
Adds tests and updates the logic to preserve comments and spaces.
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.
LGTM
@@ -86,6 +87,7 @@ export class SettingsState { | |||
flowMapping: 'allow' | 'forbid'; | |||
flowSequence: 'allow' | 'forbid'; | |||
}; | |||
keyOrdering = true; |
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.
Seems this should be false
.
When I open a yaml file now in neovim (where I have installed yamlls via Mason and default config) I get a lot of "Wrong order of key" in my docker-compose.yaml and .gitlab-ci.yml files. I have tried to disable it by setting keyOrdering = false but with no improvement. Edit: {
"williamboman/mason-lspconfig.nvim",
config = function(_, opts)
require("mason-lspconfig").setup_handlers {
function(server_name)
require("lspconfig")[server_name].setup {}
end,
["yamlls"] = function()
require("lspconfig").yamlls.setup({
settings = {
yaml = {
keyOrdering = false
}
}
})
end
}
end
}, |
See following link with the pull request: redhat-developer/yaml-language-server#839 (comment)
What does this PR do?
Introduces a new setting
yaml.keyOrder
that enforces the alphabetical key order for mappings when set to true.In addition to validation, it also provides a code action to fix the order for the map
What issues does this PR fix or reference?
redhat-developer/vscode-yaml#95
Is it tested? How?
Adds tests for validation, new settings and code action