From 31e6909cf1398311406d55fef6a71e7621a32d09 Mon Sep 17 00:00:00 2001 From: Rawley Fowler <75388349+rawleyfowler@users.noreply.github.com> Date: Fri, 27 May 2022 14:52:29 -0600 Subject: [PATCH] Update init.lua --- neovim/init.lua | 65 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index eb53518..745ee29 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -26,6 +26,8 @@ plug('tree-sitter/tree-sitter') plug('tpope/vim-surround') plug('neovim/nvim-lsp') plug('neovim/nvim-lspconfig') +plug('williamboman/nvim-lsp-installer') +plug('mfussenegger/nvim-jdtls') plug('junegunn/goyo.vim', {['for'] = 'markdown'}) plug('junegunn/fzf', {['dir'] = '~/.fzf', ['do'] = './install --all'}) plug('junegunn/fzf.vim') @@ -39,7 +41,7 @@ plug('saadparwaiz1/cmp_luasnip') plug('l3mon4d3/luasnip') plug('leafgarland/typescript-vim', {['for'] = 'typescript'}) vim.call('plug#end') -pcall(require, 'nvim_utils') +pcall(require, 'nvim_utils') local cmp = require('cmp') -- Basic editor configurations set.tabstop = 4 @@ -95,10 +97,10 @@ vim.cmd('colo gruvbox') vim.o.background = 'light' -- Rainbow Parens for Clojure, and Lisp vim.cmd([[ - filetype on - filetype plugin on - filetype plugin indent on - autocmd Filetype clojure,clj,lisp,lsp,cl,l :RainbowToggle +filetype on +filetype plugin on +filetype plugin indent on +autocmd Filetype clojure,clj,lisp,lsp,cl,l :RainbowToggle ]]) -- Auto complete local opts = { noremap=true, silent=true } @@ -107,24 +109,24 @@ map('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) map('n', ']d', 'lua vim.diagnostic.goto_next()', opts) map('n', 'q', 'lua vim.diagnostic.setloclist()', opts) local on_attach = function(client, bufnr) - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.formatting()', opts) end local cmp_capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) local servers = { 'clojure_lsp', 'gopls', 'clangd', 'tsserver' } -for _, lsp in pairs(servers) do +for _, lsp in pairs(servers) do require('lspconfig')[lsp].setup { on_attach = on_attach, capabilities = cmp_capabilities, @@ -133,8 +135,29 @@ for _, lsp in pairs(servers) do } } end +-- Java auto complete/LSP +local jdtls_cfg = { + cmd = { + 'java', + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultStartLevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Dlog.level=ALL', + '-Xms1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + '-jar', '~/.local/share/nvim/lsp_servers/jdtls/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.2.400.v20211117-0650.jar', + '-configuration', '~/.local/share/nvim/lsp_servers/jdtls/config_mac' + }, + root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}) +} +if vim.bo.filetype == 'java' then + require('jdtls').start_or_attach(jdtls_cfg) +end -- 2 Tab space standard languages -- Clojure and Common Lisp style is 2 space indent vim.cmd([[ - autocmd Filetype clojure,clj,lisp,lsp,cl,l,javascript,js,typescript,ts setlocal tabstop=2 shiftwidth=2 +autocmd Filetype clojure,clj,lisp,lsp,cl,l,javascript,js,typescript,ts setlocal tabstop=2 shiftwidth=2 ]])