summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorChris <[email protected]>2021-03-15 23:11:39 -0400
committerChris <[email protected]>2021-03-15 23:11:39 -0400
commite26b5c51ed152ea1047bd94093f514d95b167a3e (patch)
tree533c3d94cc85f07e112a1032d81fc2d6d1857510 /lua
parent51aa582272fc3b5f327ed481acd34125848f9ca2 (diff)
update LSP get nvim-jdtls working with Java
Diffstat (limited to 'lua')
-rw-r--r--lua/lsp/java-ls.lua15
-rw-r--r--lua/lsp/json-ls.lua10
-rw-r--r--lua/lsp/python-ls.lua2
-rw-r--r--lua/lsp/yaml-ls.lua2
-rw-r--r--lua/nv-vscode/init.vim4
-rw-r--r--lua/utils.lua1
6 files changed, 34 insertions, 0 deletions
diff --git a/lua/lsp/java-ls.lua b/lua/lsp/java-ls.lua
new file mode 100644
index 00000000..72ce5104
--- /dev/null
+++ b/lua/lsp/java-ls.lua
@@ -0,0 +1,15 @@
+-- In Vimscript
+-- augroup lsp
+-- au!
+-- au FileType java lua require('jdtls').start_or_attach({cmd = {'java-linux-ls'}})
+-- 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
+require('jdtls').start_or_attach({cmd = {JAVA_LS_EXECUTABLE}, root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})})
diff --git a/lua/lsp/json-ls.lua b/lua/lsp/json-ls.lua
new file mode 100644
index 00000000..d13fed3f
--- /dev/null
+++ b/lua/lsp/json-ls.lua
@@ -0,0 +1,10 @@
+-- npm install -g vscode-json-languageserver
+require'lspconfig'.jsonls.setup {
+ commands = {
+ Format = {
+ function()
+ vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
+ end
+ }
+ }
+}
diff --git a/lua/lsp/python-ls.lua b/lua/lsp/python-ls.lua
new file mode 100644
index 00000000..11eeef91
--- /dev/null
+++ b/lua/lsp/python-ls.lua
@@ -0,0 +1,2 @@
+-- npm i -g pyright
+require'lspconfig'.pyright.setup{}
diff --git a/lua/lsp/yaml-ls.lua b/lua/lsp/yaml-ls.lua
new file mode 100644
index 00000000..904f20ea
--- /dev/null
+++ b/lua/lsp/yaml-ls.lua
@@ -0,0 +1,2 @@
+-- npm install -g yaml-language-server
+require'lspconfig'.yamlls.setup{}
diff --git a/lua/nv-vscode/init.vim b/lua/nv-vscode/init.vim
index 9ca19a3b..746d189d 100644
--- a/lua/nv-vscode/init.vim
+++ b/lua/nv-vscode/init.vim
@@ -103,3 +103,7 @@ xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
+
+" Simulate same TAB behavior in VSCode
+ nmap <Tab> :Tabnext<CR>
+ nmap <S-Tab> :Tabprev<CR>
diff --git a/lua/utils.lua b/lua/utils.lua
index 277ca728..22fe415a 100644
--- a/lua/utils.lua
+++ b/lua/utils.lua
@@ -26,6 +26,7 @@ define_augroups(
{'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
+ {'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'},
},
}
)