java default formatter

This commit is contained in:
christianchiarulli 2021-07-13 20:57:58 -04:00
parent 0bdba7a00c
commit 3279553481
3 changed files with 30 additions and 1 deletions

View file

@ -1,3 +1,28 @@
vim.cmd "let proj = FindRootDirectory()"
local root_dir = vim.api.nvim_get_var "proj"
-- use the global prettier if you didn't find the local one
local prettier_instance = root_dir .. "/node_modules/.bin/prettier"
if vim.fn.executable(prettier_instance) ~= 1 then
prettier_instance = O.lang.tsserver.formatter.exe
end
O.formatters.filetype["java"] = {
function()
return {
exe = prettier_instance,
-- TODO: allow user to override this
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) },
stdin = true,
}
end,
}
require("formatter.config").set_defaults {
logging = false,
filetype = O.formatters.filetype,
}
if require("lv-utils").check_lsp_client_active "jdtls" then
return
end