mirror of
https://github.com/Baipyrus/nvim-config.git
synced 2024-12-26 05:11:45 +00:00
Compare commits
2 Commits
6e9877e959
...
c3569c1b51
Author | SHA1 | Date | |
---|---|---|---|
c3569c1b51 | |||
ad214db84e |
@ -29,6 +29,9 @@ return {
|
|||||||
|
|
||||||
-- Allows extra capabilities provided by nvim-cmp
|
-- Allows extra capabilities provided by nvim-cmp
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
|
||||||
|
-- Needed to explore Workspace in Java
|
||||||
|
'stevearc/oil.nvim',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
-- Brief aside: **What is LSP?**
|
-- Brief aside: **What is LSP?**
|
||||||
@ -224,54 +227,6 @@ return {
|
|||||||
-- set default config according to sysname
|
-- set default config according to sysname
|
||||||
local config_path = install_path .. '/config_' .. sysname
|
local config_path = install_path .. '/config_' .. sysname
|
||||||
|
|
||||||
-- START SEARCH FOR PROCESSING --
|
|
||||||
-- detect install path based on system
|
|
||||||
local is_windows = vim.fn.has 'win32' == 1
|
|
||||||
local cmds = is_windows and {
|
|
||||||
'(gcm processing.exe).source',
|
|
||||||
} or {
|
|
||||||
'whereis',
|
|
||||||
'processing.exe',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- run syscall and process output
|
|
||||||
local output = vim.system(cmds, { text = true }):wait()
|
|
||||||
local path = output.stdout or ''
|
|
||||||
if not is_windows then
|
|
||||||
-- on linux, get substr starting with path
|
|
||||||
local start_idx = string.find(path, '/')
|
|
||||||
path = (start_idx ~= nil) and string.sub(path, start_idx) or ''
|
|
||||||
end
|
|
||||||
|
|
||||||
-- for windows, remove backslashes
|
|
||||||
path = string.gsub(path, '\\', '/')
|
|
||||||
-- remove filename at end of path
|
|
||||||
local end_idx = string.find(path, '/[^/]*$')
|
|
||||||
path = string.sub(path, 1, end_idx)
|
|
||||||
|
|
||||||
-- in case of chocolatey install, navigate to binaries
|
|
||||||
local is_chocolatey = string.find(path, 'chocolatey')
|
|
||||||
if is_chocolatey then
|
|
||||||
path = path .. '../lib/processing/tools/'
|
|
||||||
-- list directories for program version
|
|
||||||
cmds = is_windows and {
|
|
||||||
'ls',
|
|
||||||
path,
|
|
||||||
'|select name',
|
|
||||||
'|Out-String',
|
|
||||||
} or {
|
|
||||||
'ls',
|
|
||||||
'-l',
|
|
||||||
path,
|
|
||||||
}
|
|
||||||
|
|
||||||
output = vim.system(cmds, { text = true }):wait()
|
|
||||||
local version = string.match(output.stdout, 'processing[^%s]*')
|
|
||||||
path = path .. version
|
|
||||||
end
|
|
||||||
-- set path to processing-core library
|
|
||||||
path = path .. '/core/library/core.jar'
|
|
||||||
|
|
||||||
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
|
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
|
||||||
local config = {
|
local config = {
|
||||||
-- The command that starts the language server
|
-- The command that starts the language server
|
||||||
@ -308,13 +263,7 @@ return {
|
|||||||
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||||
-- for a list of options
|
-- for a list of options
|
||||||
settings = {
|
settings = {
|
||||||
java = {
|
java = {},
|
||||||
project = {
|
|
||||||
referencedLibraries = {
|
|
||||||
is_windows and string.gsub(path, '/', '\\') or path,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Language server `initializationOptions`
|
-- Language server `initializationOptions`
|
||||||
@ -327,11 +276,15 @@ return {
|
|||||||
end
|
end
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
pattern = 'java',
|
pattern = 'java',
|
||||||
callback = function()
|
callback = function(opt)
|
||||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||||
-- calculate workspace dir
|
-- calculate workspace dir
|
||||||
local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name
|
local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name
|
||||||
require('jdtls').start_or_attach(generate_config(workspace_dir))
|
require('jdtls').start_or_attach(generate_config(workspace_dir))
|
||||||
|
vim.keymap.set('n', '<leader>we', '<cmd>Oil ' .. workspace_dir .. '<cr>', {
|
||||||
|
desc = '[W]orkspace [E]xplorer',
|
||||||
|
buffer = opt.buf,
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user