Skip to content

Commit ad5ab1c

Browse files
committed
Only attach to file or jdt:// buffers
Attaching to buffers like fugitive:// can result in errors
1 parent 1069131 commit ad5ab1c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/jdtls/setup.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ function M.start_or_attach(config, opts, start_opts)
293293
end
294294
end
295295

296+
local uri = vim.uri_from_bufnr(bufnr)
297+
-- jdtls requires files to exist on the filesystem; it doesn't play well with scratch buffers
298+
if not vim.startswith(uri, "file://") or vim.bo[bufnr].buftype ~= "" then
299+
return
300+
end
301+
296302
config.root_dir = (config.root_dir
297303
or M.find_root({'.git', 'gradlew', 'mvnw'}, bufname)
298304
or vim.fn.getcwd()

0 commit comments

Comments
 (0)