diff options
author | Christian Chiarulli <[email protected]> | 2021-07-13 21:13:55 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-07-13 21:13:55 -0400 |
commit | a097fa4c04e6db34bb409e0dea302c20629da8ec (patch) | |
tree | fb1c5bdd14cac82a363ea6c25b03a475050305f2 /ftplugin/java.lua | |
parent | 04f9f53914a7dd999117ed73c5fa0ab3b0dc95e4 (diff) |
LunarVim 0.4.8 (#919)0.4.8
Diffstat (limited to 'ftplugin/java.lua')
-rw-r--r-- | ftplugin/java.lua | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/ftplugin/java.lua b/ftplugin/java.lua index bba968b9..7db90f0e 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -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 @@ -18,11 +43,24 @@ if O.lang.java.java_tools.active then cmd = { JAVA_LS_EXECUTABLE, WORKSPACE_PATH .. vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") }, } + vim.api.nvim_set_keymap( + "n", + "<leader>la", + ":lua require('jdtls').code_action()<CR>", + { noremap = true, silent = true } + ) + vim.api.nvim_set_keymap( + "n", + "<leader>lR", + ":lua require('jdtls').code_action(false, 'refactor')<CR>", + { noremap = true, silent = true } + ) + vim.cmd "command! -buffer JdtCompile lua require('jdtls').compile()" vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" - vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" + -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" - vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" + -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" else local util = require "lspconfig/util" @@ -48,7 +86,7 @@ end -- init_options = {bundles = bundles} -- }) --- TODO setup autoformat stuff later +-- TODO: setup autoformat stuff later -- _java = { -- -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, -- { |