From 2a9e67310b333eabf0a15acc0c78da42e9e8202e Mon Sep 17 00:00:00 2001 From: Mathias Fussenegger Date: Fri, 6 Aug 2021 12:42:43 +0200 Subject: [PATCH] Fix error in implicit save on empty buffer If you open up neovim and run `:set ft=java` there is no file name Fixes https://github.com/mfussenegger/nvim-jdtls/issues/109 --- lua/jdtls/setup.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/jdtls/setup.lua b/lua/jdtls/setup.lua index 3c8def8..2c9e2ad 100644 --- a/lua/jdtls/setup.lua +++ b/lua/jdtls/setup.lua @@ -164,7 +164,11 @@ local function maybe_implicit_save() if scheme ~= 'file' then return end - local stat = vim.loop.fs_stat(api.nvim_buf_get_name(bufnr)) + local fname = api.nvim_buf_get_name(bufnr) + if fname == '' then + return + end + local stat = vim.loop.fs_stat(fname) if not stat then vim.fn.mkdir(vim.fn.expand('%:p:h'), 'p') vim.cmd('w')