Skip to content

Commit

Permalink
Latest updates...got java debug working
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua committed Oct 19, 2023
1 parent 6afb21f commit 39243a0
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 30 deletions.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,38 @@ A repo containing any items needed for configuring a usable windows dev environm
- Alacritty: https://github.com/alacritty/alacritty
- Git: https://git-scm.com/
- Posh Git: https://github.com/dahlbyk/posh-git
- Gnu Tools: curl,fd,grep,make,ripgrep,sed & optionall mingw (use `choco install <package>`)
- MinGW: https://www.mingw-w64.org/
- Various tools (GNU & Others): awk, fd, fzf, ripgrep, sed, etc.
- Neovim: https://neovim.io/

# Install
1. Update any certs (or add http.sslVerify = false to your git config `git config --global http.sslVerify false`)
2. Install fzf binary: `choco install fzf -y`
3. Update Powershell `iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"`
4. Launch PowerShell. It should create a profile in Windows Terminal for you. I always run as admin.
5. Create your Powershell profile `New-Item -Path $profile -Type File -Force` (you can run `echo $profile` to find the location)
6. Install poshgit `choco install poshgit -y`
Install the PS module: `Install-Module posh-git -Scope CurrentUser -Force` `
Add: `Import-Module posh-git` to your powershell profile (see #5 above)
7. Install Terminal Icons module:`Install-Module -Name Terminal-Icons -Repository PSGallery`
Add: `Import-Module -Name Terminal-Icons` to your powershell profile (see #5 above)
8. Add fzf module: `Install-Module -Name PSFzf -Scope CurrentUser -Force`
Add: `Import-Module PSFzf` and `Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r'` to your powershell profile (see #5 above)
9. Install the Z module: `Install-Module -Name z –Force`
Add: `Import-module -Name z` to your powershell profile (see #5 above)
10. Install the PSReadLine module: `Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck`
Add: `Import-Module -Name PSReadLine` to your powershell profile (see #5 above)
10. Install MinGw `choco install mingw -y`
11. Install cmake and make `choco install cmake make -y`
12. Install Lua `choco install lua -y`
13. Install Node JS `choco install nodejs -y`
14. Install Python 3 (optional) `choco install python2 -y`
15. Install Zig (optional) `choco install zig -y`
16. Install Go (optional) `choco install golang -y`
17. Install awk, curl, fd, gzip, jq, ripgrep, sed, unzip, wget `choco install awk curl fd gzip jq ripgrep sed unzip wget -y`
18. Install Neovim `choco install neovim -y`
19. Install lazygit `choco install lazygit`
20. Install JDK 20 to `C:\TrustedApps\Java`
21. Update M2_HOME to MVN_HOME and add JAVA_HOME env vars
22. Copy your <MVN_HOME>/conf/settings.xml to <user>/.m2/settings.xml
23. Modify
2 changes: 1 addition & 1 deletion home/AppData/Local/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vim.opt.rtp:prepend(LAZY_PATH)

require("lazy").setup({
spec = {
{ import = "plugins" },
{ import = "plugins" },
},
})

8 changes: 4 additions & 4 deletions home/AppData/Local/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ keymap("n", "<A-j>", "<Esc>:m .+1<CR>", { desc = "Move line down one line" })
keymap("n", "<A-k>", "<Esc>:m .-2<CR>", { desc = "Move line up one line" })

-- Resize windows
keymap("n", "<C-Up>", ":resize -2<CR>", { desc = "Resize window up" })
keymap("n", "<C-Down>", ":resize +2<CR>", { desc = "Resize window down" })
keymap("n", "<C-Left>", ":vertical resize +2<CR>", { desc = "Resize window left" })
keymap("n", "<C-Right>", ":vertical resize -2<CR>", { desc = "Resize window right" })
keymap("n", "<C-Up>", ":resize +2<CR>", { desc = "Resize window up" })
keymap("n", "<C-Down>", ":resize -2<CR>", { desc = "Resize window down" })
keymap("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Resize window left" })
keymap("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Resize window right" })

-------------------
-- Terminal Mode --
Expand Down
61 changes: 54 additions & 7 deletions home/AppData/Local/nvim/lua/plugins/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,58 @@ return {
format = lspkind.cmp_format({
ellipsis_char = "", -- Use this to truncate when maxwidth is reached
maxwidth = 75, -- Limit the number of characters that can appear in cmp popup
mode = "symbol_text", -- Show only symbol_text annotations
mode = "symbol_text", -- Show only symbol_text annotations
-- The function below will be called before any lspkind modifications occur
before = function (entry, vim_item)
return vim_item
end
})
},
mapping = {
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
["<C-e"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
["<C-j>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { "i", "s" }),
["<Down>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { "i", "s" }),
["<PgDown>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.scroll_docs(-4)
else
fallback()
end
end, { "i", "s" }),
["<C-k>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
["<Up>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
["<PgUp>"] = cmp.mapping(function (fallback)
if cmp.visible() then
cmp.scroll_docs(4)
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{
Expand Down Expand Up @@ -67,6 +104,15 @@ return {
luasnip.lsp_expand(args.body)
end,
},
window = {
documentation = cmp.config.window.bordered(),
}
})

cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
sources = {
{ name = "dap" },
},
})
end,
dependencies = {
Expand All @@ -80,6 +126,7 @@ return {
"onsails/lspkind.nvim",
"rafamadriz/friendly-snippets",
"saadparwaiz1/cmp_luasnip",
"nvim-tree/nvim-web-devicons",
},
event = "InsertEnter", -- Load the plugin when we enter insert mode
}
Expand Down
29 changes: 29 additions & 0 deletions home/AppData/Local/nvim/lua/plugins/dap.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
return {
{
"mfussenegger/nvim-dap",
config = function ()
local dap_ui = require("dapui")
local keymap = require("lua.config.utils").keymap

require("neodev").setup({
library = {
plugins = {
"nvim-dap-ui"
},
types = true,
},
})

dap_ui.setup()
keymap("n", "<leader>dt", ":lua require('dapui').toggle()<CR>", { desc = "Debug UI: Toggle Debugger UI" })

-- Debugger
keymap("n", "<F5>", ":lua require('dap').continue()<CR>", { desc = "Debug: Continue" })
keymap("n", "<F6>", ":lua require('dap').step_over()<CR>", { desc = "Debug: Step Over" })
keymap("n", "<F7>", ":lua require('dap').step_into()<CR>", { desc = "Debug: Step Into" })
keymap("n", "<F8>", ":lua require('dap').step_out()<CR>", { desc = "Debug: Step Out" })
keymap("n", "<leader>b", ":lua require('dap').toggle_breakpoint()<CR>", { desc = "Debug: Toggle Breakpoint" })
keymap("n", "<leader>B", ":lua require('dap').set_breakpoint(vim.fn.input('Breakpoint Condition: ')<CR>", { desc = "Debug: Toggle Conditional Breakpoint" })
end,
dependencies = {
"folke/neodev.nvim",
"rcarriga/cmp-dap",
"rcarriga/nvim-dap-ui",
}
}
}

60 changes: 46 additions & 14 deletions home/AppData/Local/nvim/lua/plugins/jdtls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ return {
local path_to_lombok = jdtls_dir .. "/lombok.jar"
local path_to_jar = vim.fn.glob(jdtls_dir .. "/plugins/org.eclipse.equinox.launcher_*.jar")
local config_dir = jdtls_dir .. "/config_win"
local path_to_java_debug = vim.fn.stdpath("data") .. "/mason/packages/java-debug-adapter/extension/server"
local path_to_java_test = vim.fn.stdpath("data") .. "/mason/packages/java-test/extension/server"

local bundles = {
vim.fn.glob(path_to_java_debug .. "/com.microsoft.java.debug.plugin-*.jar", true),
}
vim.list_extend(bundles, vim.split(vim.fn.glob(path_to_java_test .. "/*.jar", true), "\n"))

local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
local workspace_dir = vim.fn.stdpath("data") .. "/site/java/workspace-root/" .. project_name
print("Workspace dir: " .. workspace_dir)
os.execute("mkdir " .. workspace_dir)

local cmd = {
"C:/EngTools/Java/jdk-20/bin/java",
"C:/TrustedApps/Java/jdk-20/bin/java",
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
Expand All @@ -49,8 +57,12 @@ return {
runtimes = {
{
name = "JavaSE-1.8",
path = "C:/EngTools/Java/OpenJdk-8",
path = "C:/TrustedApps/Java/OpenJdk-8",
},
-- {
-- name = "JavaSE-20",
-- path = "C:/TrustedApps/Java/jdk-20",
-- },
},
updateBuildConfiguration = "interactive",
},
Expand All @@ -61,11 +73,10 @@ return {
enabled = true,
settings = {
profile = "GoogleStyle",
url = "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"
-- vim.fn.stdpath("config") .. "/lang-servers/intellij-java-google-style.xml",
url = "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
},
},
home = "C:/EngTools/Java/jdk1.8.0_152",
home = "C:/TrustedApps/Java/OpenJdk-8",
implementationsCodeLens = {
enabled = true,
},
Expand Down Expand Up @@ -97,10 +108,13 @@ return {
importOrder = {
"java",
"javax",
"com",
"org",
"com",
},
},
contentProvider = {
preferred = "fernflower",
},
java = java,
signatureHelp = {
enabled = true,
Expand Down Expand Up @@ -134,31 +148,49 @@ return {
keymap("n", "<leader>ev", ":lua require('jdtls').extract_variable()<CR>", { desc = "JDTLS: Extract Variable" })
keymap("n", "<leader>oi", ":lua require('jdtls').organize_imports()<CR>", { desc = "JDTLS: Organize Imports" })

-- Need nvim-dap for the following two shortcuts
keymap("n", "<leader>tc", ":lua require('jdtls').test_class()<CR>", { desc = "JDTLS: Test Class" })
keymap("n", "<leader>tm", ":lua require('jdtls').test_nearest_method()<CR>", { desc = "JDTLS: Test Nearest Method" })

-- DAP setup
function Attach_To_Karaf()
local dap = require("dap")

dap.configurations.java = {
{
type = "java",
request = "attach",
name = "Attach To Karaf",
hostName = "localhost",
port = "5005",
},
}

dap.continue()
end

keymap("n", "<leader>ad", ":lua Attach_To_Karaf()<CR>")

jdtls.start_or_attach({
capabilities = capabilities,
cmd = cmd,
extendedClientCapabilities = extendedClientCapabilities,
flags = {
allow_incremental_sync = true,
},
init_options = {
bundles = {},
bundles = bundles,
extendedClientCapabilities = extendedClientCapabilities,
},
-- on_attach = function ()
-- jdtls.setup.add_commands()
-- end,
root_dir = jdtls.setup.find_root({ "build.gradle", "pom.xml" }),
on_attach = function(client, bufnr)
jdtls.setup_dap({ hotcodereplace = "auto" })
end,
root_dir = jdtls.setup.find_root({ ".git", "build.gradle", "gradlew", "mvnw", "pom.xml" }),
settings = settings,
})
end,
group = group,
pattern = "java",
})
end
end,
},
}

2 changes: 1 addition & 1 deletion home/AppData/Local/nvim/lua/plugins/lazygit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ return {
local keymap = require("lua.config.utils").keymap

keymap("n", "<leader>lg", ":LazyGit<CR>", { desc = "Open LazyGit" })
keymap("n", "<leader>lgc", ":LazyGitConfig<CR>", { desc = "Open LazyGit Config File" })
keymap("n", "<leader>clg", ":LazyGitConfig<CR>", { desc = "Open LazyGit Config File" })
end,
dependencies = {
"nvim-lua/plenary.nvim",
Expand Down
1 change: 1 addition & 0 deletions home/AppData/Local/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ return {
local lsp_servers = {
gopls = {},
jsonls = {},
lemminx = {},
lua_ls = {
settings = {
Lua = {
Expand Down
2 changes: 1 addition & 1 deletion home/AppData/Local/nvim/lua/plugins/sonarlint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ return {
},
server = {
cmd = {
"C:/EngTools/Java/jdk-20/bin/java",
"C:/TrustedApps/Java/jdk-20/bin/java",
"-jar",
vim.fn.stdpath("data") .. "/mason/packages/sonarlint-language-server/extension/server/sonarlint-ls.jar",
"-stdio",
Expand Down
8 changes: 7 additions & 1 deletion home/AppData/Local/nvim/lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ return {
mappings = {
i = { ["<c-t>"] = trouble.open_with_trouble },
n = { ["<c-t>"] = trouble.open_with_trouble },
}
},
path_display = function (opts, path)
local file_name = require("telescope.utils").path_tail(path)

return string.format("%s … %s", file_name, path)
end,

},
extensions = {
file_browser = {
Expand Down
16 changes: 16 additions & 0 deletions home/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
Remove-Item alias:curl
Set-Alias wcurl Invoke-WebRequest

Import-Module posh-git
Import-Module -Name Terminal-Icons
Import-Module -Name z
Import-Module -Name PSReadLine

Import-Module PSFzf
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r'

function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}

function touch ($filename) {
# TODO: Check for actual path
New-Item -Path . -Name $filename -ItemType "file"
}

0 comments on commit 39243a0

Please sign in to comment.