From d8027f26166cd65bbcd503062313681232177e1d Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Sun, 4 Sep 2022 10:02:20 +0300 Subject: [PATCH 01/14] Fix UI and client (#1) --- lua/yaml-companion/lsp/util.lua | 10 ++++++++-- lua/yaml-companion/select/ui.lua | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lua/yaml-companion/lsp/util.lua b/lua/yaml-companion/lsp/util.lua index 4ec6716..7572237 100644 --- a/lua/yaml-companion/lsp/util.lua +++ b/lua/yaml-companion/lsp/util.lua @@ -7,8 +7,8 @@ local matchers = require("yaml-companion._matchers")._loaded --- @return table schemas: merged list of user-defined, server-provided, and matcher-provided yaml schemas M.get_all_yaml_schemas = function() local schemas = lsp.get_all_jsonschemas(0) - - if schemas == nil then + if schemas == nil or vim.tbl_count(schemas.result or {}) == 0 then + vim.notify("Schemas not loaded yet.") return end @@ -19,6 +19,12 @@ M.get_all_yaml_schemas = function() require("yaml-companion.config").options.schemas.result or {} ) + for i, schema in ipairs(schemas) do + if not schema.uri or not schema.uri:find("^https?") then + table.remove(schemas, i) + end + end + -- merge with matchers exposed schemas for _, matcher in pairs(matchers) do local handles = matcher.handles() or {} diff --git a/lua/yaml-companion/select/ui.lua b/lua/yaml-companion/select/ui.lua index eb32131..58c76f3 100644 --- a/lua/yaml-companion/select/ui.lua +++ b/lua/yaml-companion/select/ui.lua @@ -6,12 +6,15 @@ local matchers = require("yaml-companion._matchers")._loaded --- Callback to be passed to vim.ui.select to display a single schema item --- @param schema table: Schema local display_schema_item = function(schema) - return schema.name + return schema.name or schema.uri end --- Callback to be passed to vim.ui.select that changes the active yaml schema --- @param schema table: Chosen schema local select_schema = function(schema) + if not schema then + return + end local selected_schema = { result = { { name = schema.name, uri = schema.uri } } } require("yaml-companion.context").schema(0, selected_schema) end @@ -24,7 +27,11 @@ M.open_ui_select = function() return end - vim.ui.select(schemas, { format_item = display_schema_item, prompt = "Schema" }, select_schema) + vim.ui.select( + schemas, + { format_item = display_schema_item, prompt = "Select YAML Schema" }, + select_schema + ) end return M From de1460dc7321d3f554647f82fe342c743ba81fe7 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Sun, 4 Sep 2022 10:04:07 +0300 Subject: [PATCH 02/14] Fix requests --- lua/yaml-companion/lsp/requests.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lua/yaml-companion/lsp/requests.lua b/lua/yaml-companion/lsp/requests.lua index f0dc3e3..d620c4b 100644 --- a/lua/yaml-companion/lsp/requests.lua +++ b/lua/yaml-companion/lsp/requests.lua @@ -3,6 +3,15 @@ local M = {} local lsp = vim.lsp local sync_timeout = 1000 +local function get_yamlls_client(bufnr) + local clients = vim.tbl_filter(function(c) + return c.name == "yamlls" + end, lsp.buf_get_clients(bufnr)) + if #clients > 0 then + return clients[1] + end +end + -- let the yamlls attached to {bufnr} know that we support -- schema selection and it should fire a 'yaml/schema/store/initialized' -- when ready to use it @@ -12,7 +21,7 @@ M.support_schema_selection = function(bufnr, client) if bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end - client = client or lsp.get_active_clients({ name = "yamlls", bufnr = bufnr })[1] + client = client or get_yamlls_client(bufnr) if client then return client.notify("yaml/supportSchemaSelection") @@ -26,7 +35,7 @@ M.get_all_jsonschemas = function(bufnr, client) if bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end - client = client or lsp.get_active_clients({ name = "yamlls", bufnr = bufnr })[1] + client = client or get_yamlls_client(bufnr) if client then return client.request_sync( @@ -45,7 +54,7 @@ M.get_jsonschema = function(bufnr, client) if bufnr == 0 then bufnr = vim.api.nvim_get_current_buf() end - client = client or lsp.get_active_clients({ name = "yamlls", bufnr = bufnr })[1] + client = client or get_yamlls_client(bufnr) if client then local schemas = From 63df0901ce150cdafc378f986692f0f945b99a65 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Sun, 4 Sep 2022 19:39:01 +0300 Subject: [PATCH 03/14] =?UTF-8?q?=F0=9F=91=BB=20wip=20Sun=20Sep=20=204=201?= =?UTF-8?q?9:39:01=202022?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/yaml-companion/builtin/kubernetes/init.lua | 4 ++-- lua/yaml-companion/context/init.lua | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/yaml-companion/builtin/kubernetes/init.lua b/lua/yaml-companion/builtin/kubernetes/init.lua index 243a288..0270351 100644 --- a/lua/yaml-companion/builtin/kubernetes/init.lua +++ b/lua/yaml-companion/builtin/kubernetes/init.lua @@ -4,8 +4,8 @@ local api = vim.api local resources = require("yaml-companion.builtin.kubernetes.resources") local version = require("yaml-companion.builtin.kubernetes.version") local uri = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/" - .. version - .. "-standalone-strict/all.json" + .. version + .. "-standalone-strict/all.json" local schema = { name = "Kubernetes", diff --git a/lua/yaml-companion/context/init.lua b/lua/yaml-companion/context/init.lua index d2e61ba..3da29aa 100644 --- a/lua/yaml-companion/context/init.lua +++ b/lua/yaml-companion/context/init.lua @@ -34,6 +34,7 @@ M.autodiscover = function(bufnr, client) local schema = lsp.get_jsonschema(bufnr, client) local options = require("yaml-companion.config").options + P(schema) if schema and schema.result and schema.result[1] and schema.result[1].uri then -- if LSP returns a name that means it came from SchemaStore @@ -44,7 +45,7 @@ M.autodiscover = function(bufnr, client) -- if it returned something without a name it means it came from our own -- internal schema table and we have to loop through it to get the name - else + elseif options and options.schemas and options.schemas.result then for _, option_schema in ipairs(options.schemas.result) do if option_schema.uri == schema.result[1].uri then M.ctxs[bufnr].schema = { @@ -124,7 +125,7 @@ M.schema = function(bufnr, schema) override[schema.result[1].uri] = bufuri settings = vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } }) client.config.settings = - vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } }) + vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } }) client.workspace_did_change_configuration(client.config.settings) end From 20246d11f37288de57309a7fb35c6fc846cdd387 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Sun, 4 Sep 2022 19:39:20 +0300 Subject: [PATCH 04/14] =?UTF-8?q?=F0=9F=98=88=20wip=20Sun=20Sep=20=204=201?= =?UTF-8?q?9:39:20=202022?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/yaml-companion/context/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/yaml-companion/context/init.lua b/lua/yaml-companion/context/init.lua index 3da29aa..c657b19 100644 --- a/lua/yaml-companion/context/init.lua +++ b/lua/yaml-companion/context/init.lua @@ -34,7 +34,6 @@ M.autodiscover = function(bufnr, client) local schema = lsp.get_jsonschema(bufnr, client) local options = require("yaml-companion.config").options - P(schema) if schema and schema.result and schema.result[1] and schema.result[1].uri then -- if LSP returns a name that means it came from SchemaStore From 6037e768134416b4b2566092d156741047f29bb1 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Mon, 20 May 2024 12:01:56 +0300 Subject: [PATCH 05/14] fix!: deprecate get_active_clients() --- lua/yaml-companion/lsp/util.lua | 2 +- tests/schema_spec.lua | 6 +++--- tests/yaml-companion_spec.lua | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/yaml-companion/lsp/util.lua b/lua/yaml-companion/lsp/util.lua index cf88517..5dad13e 100644 --- a/lua/yaml-companion/lsp/util.lua +++ b/lua/yaml-companion/lsp/util.lua @@ -7,7 +7,7 @@ local sync_timeout = 5000 ---@param bufnr number ---@return vim.lsp.client | nil M.get_client = function(bufnr) - return vim.lsp.get_active_clients({ name = "yamlls", bufnr = bufnr })[1] + return vim.lsp.get_clients({ name = "yamlls", bufnr = bufnr })[1] end ---@param bufnr number diff --git a/tests/schema_spec.lua b/tests/schema_spec.lua index bbd3d68..8088e4e 100644 --- a/tests/schema_spec.lua +++ b/tests/schema_spec.lua @@ -19,7 +19,7 @@ local function buf(input, ft, name) vim.api.nvim_command("buffer " .. b) vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n")) return wait_until(function() - local clients = vim.lsp.get_active_clients() + local clients = vim.lsp.get_clients() if #clients > 0 then return true end @@ -40,11 +40,11 @@ describe("user defined schemas:", function() vim.api.nvim_buf_delete(0, { force = true }) vim.fn.delete("foo.yaml", "rf") assert(wait_until(function() - local clients = vim.lsp.get_active_clients() + local clients = vim.lsp.get_clients() if #clients == 0 then return true end - vim.lsp.stop_client(vim.lsp.get_active_clients(), true) + vim.lsp.stop_client(vim.lsp.get_clients(), true) end)) end) diff --git a/tests/yaml-companion_spec.lua b/tests/yaml-companion_spec.lua index cec692d..da0c846 100644 --- a/tests/yaml-companion_spec.lua +++ b/tests/yaml-companion_spec.lua @@ -17,7 +17,7 @@ local function buf(input, ft, name) vim.api.nvim_command("buffer " .. b) vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n")) return wait_until(function() - local clients = vim.lsp.get_active_clients() + local clients = vim.lsp.get_clients() if #clients > 0 then return true end From 1cb56f9400fd5f93ee39c1cea6719f78654c64dd Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Mon, 20 May 2024 12:09:20 +0300 Subject: [PATCH 06/14] =?UTF-8?q?=F0=9F=98=88=20work=20in=20progress=20Mon?= =?UTF-8?q?=20May=2020=2012:09:20=202024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/yaml-companion/lsp/util.lua | 4 +++- tests/schema_spec.lua | 10 +++++++--- tests/yaml-companion_spec.lua | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lua/yaml-companion/lsp/util.lua b/lua/yaml-companion/lsp/util.lua index 5dad13e..0a68995 100644 --- a/lua/yaml-companion/lsp/util.lua +++ b/lua/yaml-companion/lsp/util.lua @@ -7,7 +7,9 @@ local sync_timeout = 5000 ---@param bufnr number ---@return vim.lsp.client | nil M.get_client = function(bufnr) - return vim.lsp.get_clients({ name = "yamlls", bufnr = bufnr })[1] + ---@diagnostic disable-next-line: deprecated + local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients + return get_clients({ name = "yamlls", bufnr = bufnr })[1] end ---@param bufnr number diff --git a/tests/schema_spec.lua b/tests/schema_spec.lua index 8088e4e..1c44dcd 100644 --- a/tests/schema_spec.lua +++ b/tests/schema_spec.lua @@ -19,7 +19,9 @@ local function buf(input, ft, name) vim.api.nvim_command("buffer " .. b) vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n")) return wait_until(function() - local clients = vim.lsp.get_clients() + ---@diagnostic disable-next-line: deprecated + local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients + local clients = get_clients() if #clients > 0 then return true end @@ -40,11 +42,13 @@ describe("user defined schemas:", function() vim.api.nvim_buf_delete(0, { force = true }) vim.fn.delete("foo.yaml", "rf") assert(wait_until(function() - local clients = vim.lsp.get_clients() + ---@diagnostic disable-next-line: deprecated + local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients + local clients = get_clients() if #clients == 0 then return true end - vim.lsp.stop_client(vim.lsp.get_clients(), true) + vim.lsp.stop_client(get_clients(), true) end)) end) diff --git a/tests/yaml-companion_spec.lua b/tests/yaml-companion_spec.lua index da0c846..856eee7 100644 --- a/tests/yaml-companion_spec.lua +++ b/tests/yaml-companion_spec.lua @@ -17,7 +17,9 @@ local function buf(input, ft, name) vim.api.nvim_command("buffer " .. b) vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n")) return wait_until(function() - local clients = vim.lsp.get_clients() + ---@diagnostic disable-next-line: deprecated + local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients + local clients = get_clients() if #clients > 0 then return true end From b95c47ef385315442d573cbca9410a7b43653ed0 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Mon, 20 May 2024 12:11:25 +0300 Subject: [PATCH 07/14] =?UTF-8?q?=F0=9F=91=BB=20work=20in=20progress=20Mon?= =?UTF-8?q?=20May=2020=2012:11:25=202024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/yaml-companion/builtin/kubernetes/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/yaml-companion/builtin/kubernetes/init.lua b/lua/yaml-companion/builtin/kubernetes/init.lua index 0270351..243a288 100644 --- a/lua/yaml-companion/builtin/kubernetes/init.lua +++ b/lua/yaml-companion/builtin/kubernetes/init.lua @@ -4,8 +4,8 @@ local api = vim.api local resources = require("yaml-companion.builtin.kubernetes.resources") local version = require("yaml-companion.builtin.kubernetes.version") local uri = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/" - .. version - .. "-standalone-strict/all.json" + .. version + .. "-standalone-strict/all.json" local schema = { name = "Kubernetes", From b70bc5d0cf4585f003b2e03062a06851fd13a566 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Wed, 26 Jun 2024 11:52:53 +0300 Subject: [PATCH 08/14] =?UTF-8?q?=F0=9F=91=91=20work=20in=20progress=20Wed?= =?UTF-8?q?=20Jun=2026=2011:52:53=202024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/yaml-companion/context/init.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/yaml-companion/context/init.lua b/lua/yaml-companion/context/init.lua index ab289ce..6fc9b0e 100644 --- a/lua/yaml-companion/context/init.lua +++ b/lua/yaml-companion/context/init.lua @@ -150,7 +150,7 @@ M.schema = function(bufnr, new_schema) local bufuri = vim.uri_from_bufnr(bufnr) local client = M.ctxs[bufnr].client - local settings = client.config.settings + local settings = client.settings -- we don't want more than 1 schema per file for key, _ in pairs(settings.yaml.schemas) do @@ -165,9 +165,8 @@ M.schema = function(bufnr, new_schema) log.fmt_debug("file=%s schema=%s set new override", bufuri, new_schema.uri) settings = vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } }) - client.config.settings = - vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } }) - client.workspace_did_change_configuration(client.config.settings) + client.settings = vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } }) + client.workspace_did_change_configuration(client.settings) end return M.ctxs[bufnr].schema From 52225d934fda804ade76b33968120e4095644bc1 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Wed, 26 Jun 2024 12:48:36 +0300 Subject: [PATCH 09/14] fix --- lua/yaml-companion/context/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/yaml-companion/context/init.lua b/lua/yaml-companion/context/init.lua index 6fc9b0e..56d2503 100644 --- a/lua/yaml-companion/context/init.lua +++ b/lua/yaml-companion/context/init.lua @@ -106,7 +106,7 @@ M.setup = function(bufnr, client) -- remove yamlls from not yaml files -- https://github.com/towolf/vim-helm/issues/15 if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then - vim.diagnostic.disable(bufnr) + vim.diagnostic.enable(false, { bufnr = bufnr }) vim.defer_fn(function() vim.diagnostic.reset(nil, bufnr) end, 1000) @@ -145,7 +145,7 @@ M.schema = function(bufnr, new_schema) new_schema = new_schema.result[1] end - if new_schema and new_schema.uri and new_schema.name then + if new_schema and new_schema.uri then M.ctxs[bufnr].schema = new_schema local bufuri = vim.uri_from_bufnr(bufnr) From bae2337af1ac4cbf29b16ebf0d5242cbbb40a147 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Wed, 26 Jun 2024 20:36:37 +0300 Subject: [PATCH 10/14] fix tests option value --- tests/schema_spec.lua | 2 +- tests/yaml-companion_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/schema_spec.lua b/tests/schema_spec.lua index 1c44dcd..47293c7 100644 --- a/tests/schema_spec.lua +++ b/tests/schema_spec.lua @@ -15,7 +15,7 @@ end local function buf(input, ft, name) local b = vim.api.nvim_create_buf(false, false) vim.api.nvim_buf_set_name(b, name) - vim.api.nvim_buf_set_option(b, "filetype", ft) + vim.api.nvim_set_option_value("filetype", ft, { buf = b }) vim.api.nvim_command("buffer " .. b) vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n")) return wait_until(function() diff --git a/tests/yaml-companion_spec.lua b/tests/yaml-companion_spec.lua index 856eee7..849655a 100644 --- a/tests/yaml-companion_spec.lua +++ b/tests/yaml-companion_spec.lua @@ -13,7 +13,7 @@ end local function buf(input, ft, name) local b = vim.api.nvim_create_buf(false, false) vim.api.nvim_buf_set_name(b, name) - vim.api.nvim_buf_set_option(b, "filetype", ft) + vim.api.nvim_set_option_value("filetype", ft, { buf = b }) vim.api.nvim_command("buffer " .. b) vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n")) return wait_until(function() From 8cc8ea2e563277810a5983610c4a9188f0a7470a Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Wed, 26 Jun 2024 21:55:30 +0300 Subject: [PATCH 11/14] remove duplicate urls and add uri field --- lua/yaml-companion/config.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/yaml-companion/config.lua b/lua/yaml-companion/config.lua index 17ce531..851d346 100644 --- a/lua/yaml-companion/config.lua +++ b/lua/yaml-companion/config.lua @@ -51,6 +51,19 @@ function M.setup(options, on_attach) M.options.lspconfig.on_attach = add_hook_after(options.lspconfig.on_attach, on_attach) + local all_schemas = vim.deepcopy(M.options.schemas) + local collected_uris = {} + M.options.schemas = {} + for _, schema in pairs(all_schemas) do + if not schema.uri then + schema.uri = schema.url + end + if not collected_uris[schema.uri] then + vim.list_extend(M.options.schemas, { schema }) + collected_uris[schema.uri] = true + end + end + M.options.lspconfig.on_init = add_hook_after(options.lspconfig.on_init, function(client) client.notify("yaml/supportSchemaSelection", { {} }) return true From f3aa1a75700653c7a50b14bde38a5d6a5618eb35 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Wed, 26 Jun 2024 21:55:44 +0300 Subject: [PATCH 12/14] fix ui select prompt --- lua/yaml-companion/select/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/yaml-companion/select/ui.lua b/lua/yaml-companion/select/ui.lua index 569539f..996f079 100644 --- a/lua/yaml-companion/select/ui.lua +++ b/lua/yaml-companion/select/ui.lua @@ -26,7 +26,7 @@ M.open_ui_select = function() vim.ui.select( schemas, - { format_item = display_schema_item, prompt = "Select YAML Schema" }, + { format_item = display_schema_item, prompt = "Select YAML Schema: " }, select_schema ) end From 539f9e60637d3117b78f89741c3fe3f4840d1c1c Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Thu, 11 Jul 2024 15:00:15 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=F0=9F=A5=A8=20work=20in=20progress=20Thu?= =?UTF-8?q?=20Jul=2011=2015:00:15=202024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/yaml-companion/builtin/kubernetes/resources.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/yaml-companion/builtin/kubernetes/resources.lua b/lua/yaml-companion/builtin/kubernetes/resources.lua index 8eb38f4..2432f04 100644 --- a/lua/yaml-companion/builtin/kubernetes/resources.lua +++ b/lua/yaml-companion/builtin/kubernetes/resources.lua @@ -16,8 +16,6 @@ return { "CSIStorageCapacityList", "CertificateSigningRequest", "CertificateSigningRequestList", - "ClusterCIDR", - "ClusterCIDRList", "ClusterRole", "ClusterRoleBinding", "ClusterRoleBindingList", From 7db9bf1bb183563234acef4413a8da4e1bac5321 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Mon, 15 Jul 2024 09:59:43 +0300 Subject: [PATCH 14/14] chore/remove-deprecated-apis --- lua/yaml-companion/builtin/kubernetes/resources.lua | 2 ++ lua/yaml-companion/config.lua | 13 ------------- lua/yaml-companion/context/init.lua | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lua/yaml-companion/builtin/kubernetes/resources.lua b/lua/yaml-companion/builtin/kubernetes/resources.lua index 2432f04..8eb38f4 100644 --- a/lua/yaml-companion/builtin/kubernetes/resources.lua +++ b/lua/yaml-companion/builtin/kubernetes/resources.lua @@ -16,6 +16,8 @@ return { "CSIStorageCapacityList", "CertificateSigningRequest", "CertificateSigningRequestList", + "ClusterCIDR", + "ClusterCIDRList", "ClusterRole", "ClusterRoleBinding", "ClusterRoleBindingList", diff --git a/lua/yaml-companion/config.lua b/lua/yaml-companion/config.lua index 851d346..17ce531 100644 --- a/lua/yaml-companion/config.lua +++ b/lua/yaml-companion/config.lua @@ -51,19 +51,6 @@ function M.setup(options, on_attach) M.options.lspconfig.on_attach = add_hook_after(options.lspconfig.on_attach, on_attach) - local all_schemas = vim.deepcopy(M.options.schemas) - local collected_uris = {} - M.options.schemas = {} - for _, schema in pairs(all_schemas) do - if not schema.uri then - schema.uri = schema.url - end - if not collected_uris[schema.uri] then - vim.list_extend(M.options.schemas, { schema }) - collected_uris[schema.uri] = true - end - end - M.options.lspconfig.on_init = add_hook_after(options.lspconfig.on_init, function(client) client.notify("yaml/supportSchemaSelection", { {} }) return true diff --git a/lua/yaml-companion/context/init.lua b/lua/yaml-companion/context/init.lua index 56d2503..2addb2f 100644 --- a/lua/yaml-companion/context/init.lua +++ b/lua/yaml-companion/context/init.lua @@ -145,7 +145,7 @@ M.schema = function(bufnr, new_schema) new_schema = new_schema.result[1] end - if new_schema and new_schema.uri then + if new_schema and new_schema.uri and new_schema.name then M.ctxs[bufnr].schema = new_schema local bufuri = vim.uri_from_bufnr(bufnr)