Add google-java-format for linting java

pull/2/head
Ensar Sarajčić 2021-10-04 08:37:53 +02:00
parent d805419714
commit 47936f7267
4 changed files with 33 additions and 6 deletions

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
JAR="$HOME/lsp/java/google-java-format/google-java-format.jar"
if [[ ! -f $JAR ]]; then
echo "Google Java format is not installed! Install by running:"
echo ""
echo "javatoolinstall google-java-format"
exit 1
fi
java \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
-jar $JAR $@

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
TOOL=$1
VERSION=$2
case $TOOL in
google-java-format)
if [ -z "$VERSION" ]; then
VERSION="v1.11.0"
fi
mkdir -p $HOME/lsp/java/google-java-format
wget -O - https://github.com/google/google-java-format/releases/download/v1.11.0/google-java-format-1.11.0-all-deps.jar > $HOME/lsp/java/google-java-format/google-java-format.jar
;;
esac

View File

@ -1,6 +1 @@
require('lsp.jdtls_setup').setup()
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true

View File

@ -6,8 +6,8 @@ local common_config = require("lsp.server_config")
local M = {}
function M.setup()
require'jdtls.setup'.add_commands()
require'jdtls'.setup_dap()
require'jdtls.setup'.add_commands()
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end