From 88ac3d23653a27973be8ff60e500848cacfcf968 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Tue, 23 Mar 2021 17:16:12 +0100 Subject: Address #1067: check whether lockfile exists --- lua/nvim-treesitter/install.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index e830a1afd..817514115 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -33,7 +33,8 @@ end local function get_revision(lang) if #lockfile == 0 then - lockfile = vim.fn.json_decode(vim.fn.readfile(utils.join_path(utils.get_package_path(), 'lockfile.json'))) + local filename = utils.join_path(utils.get_package_path(), 'lockfile.json') + lockfile = vim.fn.filereadable(filename) == 1 and vim.fn.json_decode(vim.fn.readfile(filename)) or {} end return (lockfile[lang] and lockfile[lang].revision) end -- cgit v1.2.3-70-g09d2