From 5238753029f76332860bcc699bda86a03b4826e2 Mon Sep 17 00:00:00 2001 From: Marco Kellershoff Date: Sat, 17 Aug 2024 16:26:29 +0200 Subject: [PATCH] fix(comp): error when no schema is available --- lua/kulala-cmp-graphql/completions/init.lua | 4 ++++ lua/kulala-cmp-graphql/globals/init.lua | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/kulala-cmp-graphql/completions/init.lua b/lua/kulala-cmp-graphql/completions/init.lua index 76b305e..2abee5a 100644 --- a/lua/kulala-cmp-graphql/completions/init.lua +++ b/lua/kulala-cmp-graphql/completions/init.lua @@ -161,6 +161,10 @@ end ---@param params cmp.SourceCompletionApiParams ---@param callback fun(response: lsp.CompletionResponse|nil) function M.complete(self, params, callback) + local schema = self:_get_schema() + if schema == nil then + return callback({}) + end vim.defer_fn(function() local bufnr = vim.fn.bufnr("%") local node = Utils.get_ts_node_under_cursor() diff --git a/lua/kulala-cmp-graphql/globals/init.lua b/lua/kulala-cmp-graphql/globals/init.lua index 28ea619..a9bb1f6 100644 --- a/lua/kulala-cmp-graphql/globals/init.lua +++ b/lua/kulala-cmp-graphql/globals/init.lua @@ -1,5 +1,5 @@ local M = {} -M.VERSION = "1.0.1" +M.VERSION = "1.0.2" return M