diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | init.lua | 1 | ||||
-rw-r--r-- | lua/lsp/java-ls.lua | 44 | ||||
-rw-r--r-- | lua/lv-autocommands/init.lua | 2 | ||||
-rw-r--r-- | lua/lv-lspinstall/init.lua | 18 |
5 files changed, 40 insertions, 27 deletions
@@ -296,6 +296,8 @@ To install a supported language server: See [LspInstall](https://github.com/kabouzeid/nvim-lspinstall) for more info. +In order for Java LSP to work, edit `~/.local/share/nvim/lspinstall/java/jdtls.sh` and replace `WORKSPACE="$1"` with `WORKSPACE="$HOME/workspace"` + Most common languages should be supported out of the box, if yours is not I would welcome a PR @@ -40,6 +40,7 @@ vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim') -- LSP require('lsp') +require('lsp.java-ls') require('lsp.angular-ls') require('lsp.bash-ls') require('lsp.clangd') diff --git a/lua/lsp/java-ls.lua b/lua/lsp/java-ls.lua index 88f12498..90985ff4 100644 --- a/lua/lsp/java-ls.lua +++ b/lua/lsp/java-ls.lua @@ -1,3 +1,4 @@ +local util = require 'lspconfig/util' -- In Vimscript -- augroup lsp -- au! @@ -5,27 +6,36 @@ -- augroup end -- find_root looks for parent directories relative to the current buffer containing one of the given arguments. -- require'lspconfig'.jdtls.setup {cmd = {'java-linux-ls'}} -if vim.fn.has("mac") == 1 then - JAVA_LS_EXECUTABLE = 'java-mac-ls' -elseif vim.fn.has("unix") == 1 then - JAVA_LS_EXECUTABLE = 'java-linux-ls' -else - print("Unsupported system") -end +-- if vim.fn.has("mac") == 1 then +-- JAVA_LS_EXECUTABLE = 'java-mac-ls' +-- elseif vim.fn.has("unix") == 1 then +-- JAVA_LS_EXECUTABLE = 'java-linux-ls' +-- else +-- print("Unsupported system") +-- end -local bundles = { - vim.fn.glob( - CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar") -}; +-- local bundles = { +-- vim.fn.glob( +-- CONFIG_PATH.."/.debuggers/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar") +-- }; local on_attach = function(client, bufr) - require('jdtls').setup_dap() + -- require('jdtls').setup_dap() require'lsp'.common_on_attach(client, bufr) end -require('jdtls').start_or_attach({ +require'lspconfig'.jdtls.setup { on_attach = on_attach, - cmd = {JAVA_LS_EXECUTABLE}, - root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}), - init_options = {bundles = bundles} -}) + cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"}, + filetypes = { "java" }, + root_dir = util.root_pattern({'.git', 'build.gradle', 'pom.xml'}), + -- init_options = {bundles = bundles} + -- on_attach = require'lsp'.common_on_attach +} + +-- require('jdtls').start_or_attach({ +-- on_attach = on_attach, +-- cmd = {DATA_PATH .. "/lspinstall/java/jdtls.sh"}, +-- root_dir = require('jdtls.setup').find_root({'build.gradle', 'pom.xml', '.git'}), +-- init_options = {bundles = bundles} +-- }) diff --git a/lua/lv-autocommands/init.lua b/lua/lv-autocommands/init.lua index 91d266c9..c5b70cc3 100644 --- a/lua/lv-autocommands/init.lua +++ b/lua/lv-autocommands/init.lua @@ -41,7 +41,7 @@ utils.define_augroups({ -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, }, _java = { - {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, + -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, {'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'} }, _go = { diff --git a/lua/lv-lspinstall/init.lua b/lua/lv-lspinstall/init.lua index 34a9fe62..bc1469a5 100644 --- a/lua/lv-lspinstall/init.lua +++ b/lua/lv-lspinstall/init.lua @@ -5,15 +5,15 @@ require'lspconfig/configs'.jdtls = nil -- important, unset the loaded config aga -- config.default_config.cmd[1] = "./node_modules/.bin/bash-language-server" -- 2. extend the config with an install_script and (optionally) uninstall_script -require'lspinstall/servers'.jdtls = vim.tbl_extend('error', config, { - -- lspinstall will automatically create/delete the install directory for every server - install_script = [[ - git clone https://github.com/eclipse/eclipse.jdt.ls.git - cd eclipse.jdt.ls - ./mvnw clean verify - ]], - uninstall_script = nil -- can be omitted -}) +-- require'lspinstall/servers'.jdtls = vim.tbl_extend('error', config, { +-- -- lspinstall will automatically create/delete the install directory for every server +-- install_script = [[ +-- git clone https://github.com/eclipse/eclipse.jdt.ls.git +-- cd eclipse.jdt.ls +-- ./mvnw clean verify +-- ]], +-- uninstall_script = nil -- can be omitted +-- }) require'lspinstall/servers'.kotlin = vim.tbl_extend('error', config, { install_script = [[ |