diff --git a/lsp_check.sh b/lsp_check.sh index 6c743a1..608463b 100755 --- a/lsp_check.sh +++ b/lsp_check.sh @@ -8,7 +8,7 @@ declare -A lsp_arr=( ["pylsp"]="Install the pylsp provider: python-language-server or pylsp" ["pylint"]="Install the pylint provider: pylint" ["rust-analyzer"]="Install the rust-analyzer provider" - ["pyright"]="Install the pyright provider" + ["yaml-language-server"]="Install the yamlls provider: yaml-language-server (via npm globally or system package)" ) echo '----- Checking for LSP servers...' diff --git a/nvim/after/lsp/yamlls.lua b/nvim/after/lsp/yamlls.lua index 430f80b..877c271 100644 --- a/nvim/after/lsp/yamlls.lua +++ b/nvim/after/lsp/yamlls.lua @@ -1,6 +1,11 @@ -- YAML LSP specific settings with a number of custom tags specifically for use with AWS CloudFormation templates return { + cmd = function (dispatchers, _) + return vim.lsp.rpc.start({'yaml-language-server', '--stdio'}, dispatchers) + end, + filetypes = { 'yaml', 'yaml.docker-compose', 'yaml.gitlab', 'yaml.helm-values' }, + root_markers = { '.git' }, settings = { redhat = { telemetry = { enabled = false } }, yaml = { @@ -29,5 +34,13 @@ return { schemaStore = { enable = true }, validate = true, } - } + }, + on_init = function(client) + -- From nvim-lspconfig's yamlls.lua + --- https://github.com/neovim/nvim-lspconfig/pull/4016 + --- Since formatting is disabled by default if you check `client:supports_method('textDocument/formatting')` + --- during `LspAttach` it will return `false`. This hack sets the capability to `true` to facilitate + --- autocmd's which check this capability + client.server_capabilities.documentFormattingProvider = true + end, }