Skip to content

Commit

Permalink
Pull yaml ls into a virtual plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
NonlinearFruit committed Dec 31, 2024
1 parent 96f3271 commit 2015a0d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
13 changes: 0 additions & 13 deletions nvim/lua/plugins/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,6 @@ local function configure()
on_attach = on_attach,
capabilities = capabilities,
})

lsp_config.yamlls.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
yaml = {
schemas = {
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "/.gitlab-ci.yml",
},
},
},
})
end
end

Expand Down
43 changes: 43 additions & 0 deletions nvim/lua/plugins/yaml.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local function install_lsp_and_dap_if_needed()
local INSTALL_THESE = {
"yaml-language-server", -- LSP
}
for _, pkg in ipairs(INSTALL_THESE) do
if not require("mason-registry").is_installed(pkg) then
require("mason.api.command").MasonInstall({ pkg })
end
end
end

local function configure_lsp()
local lsp = require("language-server")
local lsp_config_ok, lsp_config = pcall(require, "lspconfig")
if not lsp_config_ok then
return
end

lsp_config.yamlls.setup({
on_attach = on_attach,
capabilities = capabilities,
settings = {
yaml = {
schemas = {
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "/.gitlab-ci.yml",
},
},
},
})
end

local function configure()
install_lsp_and_dap_if_needed()
configure_lsp()
end

return {
"local/yaml",
config = configure,
ft = "yaml",
virtual = true,
}

0 comments on commit 2015a0d

Please sign in to comment.