mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
Compare commits
45 commits
Author | SHA1 | Date | |
---|---|---|---|
|
dc19ff45d8 | ||
|
5df3f7b2ab | ||
|
82d6ba2889 | ||
|
bf60de3aa1 | ||
|
d31ffccdca | ||
|
d41d9b4cf5 | ||
|
f3761c699a | ||
|
04f3bfc8a3 | ||
|
56982c3434 | ||
|
65b1300677 | ||
|
5b2d06cf97 | ||
|
af0923e403 | ||
|
b727898cf3 | ||
|
69d6dd962d | ||
|
8e0228505a | ||
|
c2fbd57469 | ||
|
5dc5c723b2 | ||
|
b3f841d25c | ||
|
11a88eb681 | ||
|
c66913e4c2 | ||
|
16264d0b0d | ||
|
3c9cf18933 | ||
|
4af6a3dec6 | ||
|
26cb34e301 | ||
|
353e5a66c7 | ||
|
e0a4367eb0 | ||
|
d186be6aec | ||
|
835b1706b2 | ||
|
0c56a139ec | ||
|
273f3ebcb7 | ||
|
422efe87ce | ||
|
e9e0ca3e88 | ||
|
b3f5ec5619 | ||
|
db41fc7e00 | ||
|
5ab63cdf43 | ||
|
292e79137f | ||
|
17aee6c301 | ||
|
5146726772 | ||
|
35348c069a | ||
|
826cbfe9f8 | ||
|
177cf190df | ||
|
b3d4f8b8a1 | ||
|
5a64a2e380 | ||
|
fe846f291e | ||
|
c8d51254d4 |
49 changed files with 3483 additions and 1282 deletions
26
README.md
26
README.md
|
@ -67,14 +67,14 @@
|
|||
## Basic Requirement
|
||||
|
||||
2. Install Neovim 0.95+ https://github.com/neovim/neovim/releases/tag/stable
|
||||
3. C++ https://www.msys2.org/
|
||||
4. GIT https://git-scm.com/download/win
|
||||
5. NodeJs https://nodejs.org/en/
|
||||
6. Ripgrep https://github.com/BurntSushi/ripgrep
|
||||
7. Lazygit https://github.com/jesseduffield/lazygit
|
||||
8. Nerd Font https://www.nerdfonts.com/ or https://github.com/ryanoasis/nerd-fonts
|
||||
9. Windows Terminal (Windows) https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-id&gl=id
|
||||
10. Powershell (windows) https://apps.microsoft.com/store/detail/powershell/9MZ1SNWT0N5D?hl=en-id&gl=id
|
||||
1. C++ https://www.msys2.org/
|
||||
1. GIT https://git-scm.com/download/win
|
||||
1. NodeJs https://nodejs.org/en/
|
||||
1. Ripgrep https://github.com/BurntSushi/ripgrep
|
||||
1. Lazygit https://github.com/jesseduffield/lazygit
|
||||
1. Nerd Font https://www.nerdfonts.com/ or https://github.com/ryanoasis/nerd-fonts
|
||||
1. Windows Terminal (Windows) https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-id&gl=id
|
||||
1. Powershell (windows) https://apps.microsoft.com/store/detail/powershell/9MZ1SNWT0N5D?hl=en-id&gl=id
|
||||
|
||||
# Windows
|
||||
|
||||
|
@ -92,15 +92,21 @@ git clone https://github.com/pojokcodeid/neovim-starter.git ~/.config/nvim
|
|||
# Uninstall
|
||||
|
||||
```bash
|
||||
# Linux / Macos (unix)
|
||||
# Linux / MacOS (unix)
|
||||
rm -rf ~/.config/nvim
|
||||
rm -rf ~/.local/state/nvim
|
||||
rm -rf ~/.local/share/nvim
|
||||
|
||||
# Flatpak (linux)
|
||||
rm -rf ~/.var/app/io.neovim.nvim/config/nvim
|
||||
rm -rf ~/.var/app/io.neovim.nvim/data/nvim
|
||||
rm -rf ~/.var/app/io.neovim.nvim/.local/state/nvim
|
||||
|
||||
# Windows CMD
|
||||
rd -r ~\AppData\Local\nvim
|
||||
rd -r ~\AppData\Local\nvim-data
|
||||
|
||||
# Window PowerShell
|
||||
# Windows PowerShell
|
||||
rm -Force ~\AppData\Local\nvim
|
||||
rm -Force ~\AppData\Local\nvim-data
|
||||
```
|
||||
|
|
125
lazy-lock.json
125
lazy-lock.json
|
@ -1,74 +1,75 @@
|
|||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
|
||||
"Eva-Theme.nvim": { "branch": "master", "commit": "80d9229ea010774610cec71921afc0defbbd3822" },
|
||||
"Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" },
|
||||
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
|
||||
"LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" },
|
||||
"alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" },
|
||||
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
|
||||
"alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" },
|
||||
"auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" },
|
||||
"auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" },
|
||||
"auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" },
|
||||
"auto-lsp.nvim": { "branch": "main", "commit": "352e1a55a10026525f6b7489055b5fbe56d15703" },
|
||||
"auto-lualine.nvim": { "branch": "main", "commit": "fc8557f61dc1da12a8b90167a49420958b991d8c" },
|
||||
"auto-lsp.nvim": { "branch": "main", "commit": "ea80aef3ac630d310c2643047aaa7d7747d207a1" },
|
||||
"auto-lualine.nvim": { "branch": "main", "commit": "c889473aef975bf3b17a770dfb2039bb2a0cd41c" },
|
||||
"breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "5cc447cb2b463cb499c82eaeabbed4f5fa6a0a44" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
|
||||
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||
"code_runner.nvim": { "branch": "main", "commit": "dcedccbf969a0f3bc00db446172b4966e83101dd" },
|
||||
"codeium.vim": { "branch": "main", "commit": "8c01979323b2b480c8bf160d3ff85bd1668baa49" },
|
||||
"conform.nvim": { "branch": "master", "commit": "d28ccf945374edd9f1c34a82f6c22261dbd8ab98" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "6ef1ca479d37d4ff66f13eed44d08912caff483a" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" },
|
||||
"inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" },
|
||||
"laravel.nvim": { "branch": "main", "commit": "2e7c08c0511234d5816166c1204e2240edac99b5" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "640260d7c2d98779cab89b1e7088ab14ea354a02" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" },
|
||||
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
|
||||
"menu": { "branch": "main", "commit": "657bfc91382c0928453d9a4d0a10ec92db5de2bb" },
|
||||
"mini.indentscope": { "branch": "main", "commit": "da9af64649e114aa79480c238fd23f6524bc0903" },
|
||||
"minty": { "branch": "main", "commit": "1b604ed0d741294cfb56c0ce3aa6161e9ae7dd8b" },
|
||||
"neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" },
|
||||
"neotest-phpunit": { "branch": "main", "commit": "baae8dfa0a3aaacd9f0bb6845d6348f5bcdc48bb" },
|
||||
"noice.nvim": { "branch": "main", "commit": "73d38cc939db6553b87e5f72ff732447046bced1" },
|
||||
"nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "f134063618a65cad4d7415fddbd96ff7e0c5b4ae" },
|
||||
"nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" },
|
||||
"nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" },
|
||||
"nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "52302604e3c667cfdf33aadf89088e96eb3c5da3" },
|
||||
"code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" },
|
||||
"codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" },
|
||||
"conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "f54e3c11fc9ebfcfc27e696182b0295b071d0811" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
|
||||
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
|
||||
"menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" },
|
||||
"mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" },
|
||||
"minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" },
|
||||
"neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" },
|
||||
"neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" },
|
||||
"neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" },
|
||||
"neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" },
|
||||
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
|
||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" },
|
||||
"nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" },
|
||||
"nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" },
|
||||
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
|
||||
"nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "0112e1f77983141e1453bd37d124302f1c876c46" },
|
||||
"nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" },
|
||||
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
||||
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
|
||||
"nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" },
|
||||
"nvim-scrollview": { "branch": "main", "commit": "f7f611330a8f7cd00dc81538fec369611be678ed" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "610a1c189bdb2b9b936169b2ea9d1838f971fa2b" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "0722f23886d7de2c702ca54a72d94d6171715cb7" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
|
||||
"rainbow-delimiters.nvim": { "branch": "master", "commit": "e0f9b3efe150724af2d2ed59997d5ece373840e3" },
|
||||
"refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" },
|
||||
"smart-splits.nvim": { "branch": "master", "commit": "11600d75e1b57e9fe1f3ca880a917485fc399e8c" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" },
|
||||
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "a39fa4c92268832f6034306793b8acbfec2a7549" },
|
||||
"toggleterm.nvim": { "branch": "main", "commit": "5969229c0352ff1ed7f6e24aba9c6554e1842939" },
|
||||
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
|
||||
"nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" },
|
||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||
"nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" },
|
||||
"nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
||||
"rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" },
|
||||
"showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" },
|
||||
"smart-splits.nvim": { "branch": "master", "commit": "0098e376638602bc6aaf779bb8531b840a3fe26e" },
|
||||
"telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" },
|
||||
"telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
|
||||
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" },
|
||||
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
|
||||
"vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" },
|
||||
"vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" },
|
||||
"virt-column.nvim": { "branch": "master", "commit": "b62b4ef0774d19452d4ed18e473e824c7a756f2f" },
|
||||
"volt": { "branch": "main", "commit": "ff954757fdaf72da0dedd77bdf74718ea846f989" },
|
||||
"vscode-php-debug": { "branch": "main", "commit": "6193fbc1c819437325df3dad43e254d8e5c416e5" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" },
|
||||
"yanky.nvim": { "branch": "main", "commit": "73215b77d22ebb179cef98e7e1235825431d10e4" },
|
||||
"zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" }
|
||||
"virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" },
|
||||
"volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" },
|
||||
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }
|
||||
}
|
||||
|
|
76
lua/auto-jdtls2/create_gradle_project.lua
Normal file
76
lua/auto-jdtls2/create_gradle_project.lua
Normal file
|
@ -0,0 +1,76 @@
|
|||
local function gradle_new_project()
|
||||
local function create_notif(message, level)
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify(message, level)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
-- Fungsi untuk meminta input dari pengguna dengan opsi untuk membatalkan
|
||||
local function get_user_input(prompt, default_value)
|
||||
vim.fn.inputsave()
|
||||
local result = vim.fn.input(prompt, default_value)
|
||||
vim.fn.inputrestore()
|
||||
|
||||
-- Cek apakah pengguna menekan Esc untuk membatalkan input
|
||||
if result == "" then
|
||||
create_notif("Input canceled.", "info")
|
||||
return nil, true
|
||||
end
|
||||
|
||||
return result, false
|
||||
end
|
||||
-- Ambil input Testing
|
||||
local test, canceled_test = get_user_input("Testing (junit,junit-jupiter,testng,spock): ", "junit-jupiter")
|
||||
if canceled_test then
|
||||
return
|
||||
end
|
||||
-- Ambil input DSL
|
||||
local script_dsl, canceled_dsl = get_user_input("Script DSL (kotlin, groovy): ", "groovy")
|
||||
if canceled_dsl then
|
||||
return
|
||||
end
|
||||
-- Ambil input package name
|
||||
local package_name, canceled_package = get_user_input("Enter package name: ", "com.example")
|
||||
if canceled_package then
|
||||
return
|
||||
end
|
||||
|
||||
-- Format perintah Gradle berdasarkan input pengguna
|
||||
local command = string.format(
|
||||
"echo no | gradle init --type java-application --test-framework %s --dsl %s --package %s --no-daemon",
|
||||
test,
|
||||
script_dsl,
|
||||
package_name
|
||||
)
|
||||
|
||||
-- Fungsi untuk menjalankan perintah Gradle dan menampilkan outputnya
|
||||
local function run_gradle_command(cmd, path, pkg)
|
||||
local output = vim.fn.system(cmd)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
create_notif("Error executing: " .. output, "error")
|
||||
else
|
||||
create_notif("Project created successfully!", "info")
|
||||
create_notif("Please Reopen Dir : " .. path, "info")
|
||||
vim.cmd(":NvimTreeFindFileToggle<CR>")
|
||||
local main_class_path = string.format("%s/app/src/main/java/%s/App.java", path, pkg:gsub("%.", "/"))
|
||||
if vim.fn.filereadable(main_class_path) == 1 then
|
||||
vim.cmd(":edit " .. main_class_path)
|
||||
end
|
||||
local function delayed_quit()
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("qa!")
|
||||
end, 4000) -- Delay is set in milliseconds (3,000ms = 3 seconds)
|
||||
end
|
||||
-- Run the delayed quit function
|
||||
delayed_quit()
|
||||
end
|
||||
end
|
||||
|
||||
-- Jalankan perintah Gradle dan buka proyek
|
||||
run_gradle_command(command, vim.fn.getcwd(), package_name)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("GradleNewProject", gradle_new_project, {})
|
123
lua/auto-jdtls2/create_maven_project.lua
Normal file
123
lua/auto-jdtls2/create_maven_project.lua
Normal file
|
@ -0,0 +1,123 @@
|
|||
local function mvn_new_project()
|
||||
local function create_notif(message, level)
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify(message, level)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
-- Fungsi untuk meminta input dari pengguna dengan opsi untuk membatalkan
|
||||
local function get_user_input(prompt, default_value)
|
||||
vim.fn.inputsave()
|
||||
local result = vim.fn.input(prompt, default_value)
|
||||
vim.fn.inputrestore()
|
||||
|
||||
-- Cek apakah pengguna menekan Esc untuk membatalkan input
|
||||
if result == "" then
|
||||
create_notif("Input canceled.", "info")
|
||||
return nil, true
|
||||
end
|
||||
|
||||
return result, false
|
||||
end
|
||||
-- Ambil input dari pengguna untuk menentukan direktori proyek
|
||||
local project_dir, canceled = get_user_input("Enter project directory: ", vim.fn.getcwd())
|
||||
if canceled then
|
||||
return
|
||||
end
|
||||
-- Buat direktori jika belum ada
|
||||
if vim.fn.isdirectory(project_dir) == 0 then
|
||||
if vim.fn.mkdir(project_dir, "p") == 0 then
|
||||
create_notif("Failed to create project directory: " .. project_dir, "error")
|
||||
return
|
||||
end
|
||||
end
|
||||
-- Pindah ke direktori proyek
|
||||
-- Hapus satu level dari path
|
||||
local parent_dir = vim.fn.fnamemodify(project_dir, ":h")
|
||||
local success, err = pcall(vim.fn.chdir, parent_dir)
|
||||
if not success then
|
||||
create_notif("Error changing directory: " .. err, "error")
|
||||
return
|
||||
end
|
||||
|
||||
create_notif("Changed directory to: " .. project_dir, "info")
|
||||
-- Fungsi untuk mendapatkan nama direktori terakhir dari path
|
||||
local function getLastDirName(path)
|
||||
local uname = vim.loop.os_uname().sysname
|
||||
local name
|
||||
if uname == "Windows_NT" then
|
||||
name = path:match("([^\\]+)$")
|
||||
else
|
||||
name = path:match("([^/]+)$")
|
||||
end
|
||||
return name
|
||||
end
|
||||
-- Ambil input dari pengguna untuk Maven
|
||||
local group_id, canceled_group = get_user_input("Enter groupId: ", "com.example")
|
||||
if canceled_group then
|
||||
return
|
||||
end
|
||||
local artifact_id = getLastDirName(project_dir)
|
||||
local archetype_artifact_id, canceled_archetype =
|
||||
get_user_input("Enter archetypeArtifactId: ", "maven-archetype-quickstart")
|
||||
if canceled_archetype then
|
||||
return
|
||||
end
|
||||
local archetype_version, canceled_version = get_user_input("Enter archetypeVersion: ", "1.5")
|
||||
if canceled_version then
|
||||
return
|
||||
end
|
||||
local interactive_mode, canceled_interactive = get_user_input("Enter interactiveMode (true/false): ", "false")
|
||||
if canceled_interactive then
|
||||
return
|
||||
end
|
||||
-- Format perintah Maven berdasarkan input pengguna
|
||||
local command = string.format(
|
||||
[[mvn archetype:generate "-DgroupId=%s" "-DartifactId=%s" "-DarchetypeArtifactId=%s" "-DarchetypeVersion=%s" "-DinteractiveMode=%s"]],
|
||||
group_id,
|
||||
artifact_id,
|
||||
archetype_artifact_id,
|
||||
archetype_version,
|
||||
interactive_mode
|
||||
)
|
||||
|
||||
-- Fungsi untuk menjalankan perintah Maven dan menampilkan outputnya
|
||||
local function run_maven_command(cmd, project_name)
|
||||
local output = vim.fn.system(cmd)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
print("Erro ao executar: " .. output)
|
||||
else
|
||||
local ch_dir = string.format("cd %s", project_name)
|
||||
vim.fn.system(ch_dir)
|
||||
vim.fn.chdir(project_name)
|
||||
-- Cari dan buka file main class
|
||||
local uname = vim.loop.os_uname().sysname
|
||||
if uname == "Windows_NT" then
|
||||
if group_id then
|
||||
group_id = group_id:gsub("%.", "\\")
|
||||
local main_class_path = string.format("src\\main\\java\\%s\\App.java", group_id)
|
||||
if vim.fn.filereadable(main_class_path) == 1 then
|
||||
vim.cmd(":edit " .. main_class_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
if group_id then
|
||||
group_id = group_id:gsub("%.", "/")
|
||||
local main_class_path = string.format("src/main/java/%s/App.java", group_id)
|
||||
if vim.fn.filereadable(main_class_path) == 1 then
|
||||
vim.cmd(":edit " .. main_class_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.cmd(":NvimTreeFindFileToggl<CR>")
|
||||
end
|
||||
end
|
||||
|
||||
-- Jalankan perintah Maven dan buka proyek
|
||||
run_maven_command(command, artifact_id)
|
||||
create_notif("Project created successfully !", "info")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("MavenNewProject", mvn_new_project, {})
|
289
lua/auto-jdtls2/create_springboot_project.lua
Normal file
289
lua/auto-jdtls2/create_springboot_project.lua
Normal file
|
@ -0,0 +1,289 @@
|
|||
local function create_notif(message, level)
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify(message, level)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
local function safe_request(url)
|
||||
local status, request = pcall(function()
|
||||
return vim.system({ "curl", "-s", url }, { text = true }):wait()
|
||||
end)
|
||||
|
||||
if not status then
|
||||
vim.api.nvim_err_writeln("Error making request to " .. url .. ": " .. request)
|
||||
return nil
|
||||
end
|
||||
|
||||
return request
|
||||
end
|
||||
|
||||
local function safe_json_decode(data)
|
||||
local status, decoded = pcall(vim.fn.json_decode, data)
|
||||
|
||||
if not status then
|
||||
vim.api.nvim_err_writeln("Error decoding JSON: " .. decoded)
|
||||
return nil
|
||||
end
|
||||
|
||||
return decoded
|
||||
end
|
||||
|
||||
local function contains(list, element)
|
||||
for _, value in pairs(list) do
|
||||
if value == element then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function list_to_string(list, is_err)
|
||||
local result = ""
|
||||
|
||||
for i, value in ipairs(list) do
|
||||
if is_err then
|
||||
result = result .. "'" .. tostring(value) .. "'"
|
||||
else
|
||||
result = result .. tostring(value)
|
||||
end
|
||||
if i < #list then
|
||||
if is_err then
|
||||
result = result .. " or "
|
||||
else
|
||||
result = result .. "/"
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
local function handle_start_springboot_data(data)
|
||||
local spring_data = {}
|
||||
for _, value in pairs(data.values) do
|
||||
table.insert(spring_data, value.id)
|
||||
end
|
||||
return spring_data
|
||||
end
|
||||
|
||||
local function change_directory()
|
||||
-- Fungsi untuk meminta input dari pengguna dengan opsi untuk membatalkan
|
||||
local function get_user_input(prompt, default_value)
|
||||
vim.fn.inputsave()
|
||||
local result = vim.fn.input(prompt, default_value)
|
||||
vim.fn.inputrestore()
|
||||
|
||||
-- Cek apakah pengguna menekan Esc untuk membatalkan input
|
||||
if result == "" then
|
||||
create_notif("Input canceled.", "info")
|
||||
return nil, true
|
||||
end
|
||||
|
||||
return result, false
|
||||
end
|
||||
|
||||
-- Ambil input dari pengguna untuk menentukan direktori proyek
|
||||
local project_dir, canceled = get_user_input("Enter project directory: ", vim.fn.getcwd())
|
||||
if canceled then
|
||||
return
|
||||
end
|
||||
-- Buat direktori jika belum ada
|
||||
if vim.fn.isdirectory(project_dir) == 0 then
|
||||
if vim.fn.mkdir(project_dir, "p") == 0 then
|
||||
create_notif("Failed to create project directory: " .. project_dir, "error")
|
||||
return
|
||||
end
|
||||
end
|
||||
-- Pindah ke direktori proyek
|
||||
local success, err = pcall(vim.fn.chdir, project_dir)
|
||||
if not success then
|
||||
create_notif("Error changing directory: " .. err, "error")
|
||||
return
|
||||
end
|
||||
|
||||
create_notif("Changed directory to: " .. project_dir, "info")
|
||||
return project_dir
|
||||
end
|
||||
|
||||
local function get_build_type(data_available)
|
||||
local build_type_available = list_to_string(data_available, false)
|
||||
local options_err = list_to_string(data_available, true)
|
||||
local build_type = vim.fn.input("Enter build type (" .. build_type_available .. "): ", "maven")
|
||||
if not contains(data_available, build_type) then
|
||||
create_notif("Invalid build type. Please enter " .. options_err .. ".", "info")
|
||||
return ""
|
||||
end
|
||||
|
||||
return build_type
|
||||
end
|
||||
|
||||
local function get_language(data_available)
|
||||
local language_available = list_to_string(data_available, false)
|
||||
local options_err = list_to_string(data_available, true)
|
||||
|
||||
local language = vim.fn.input("Enter Language (" .. language_available .. "): ", "java")
|
||||
if not contains(data_available, language) then
|
||||
create_notif("Invalid language. Please enter " .. options_err .. ".", "info")
|
||||
return ""
|
||||
end
|
||||
|
||||
return language
|
||||
end
|
||||
|
||||
local function get_java_version(data_available)
|
||||
local version_available = list_to_string(data_available, false)
|
||||
local options_err = list_to_string(data_available, true)
|
||||
|
||||
local java_version = vim.fn.input("Enter Java Version (" .. version_available .. "): ", "21")
|
||||
if not contains(data_available, java_version) then
|
||||
create_notif("Invalid Java version. Please enter a valid version " .. options_err .. ".", "info")
|
||||
return ""
|
||||
end
|
||||
|
||||
return java_version
|
||||
end
|
||||
|
||||
local function get_boot_version(data_available)
|
||||
local version_available = list_to_string(data_available, false)
|
||||
local options_err = list_to_string(data_available, true)
|
||||
|
||||
local versions_table = {}
|
||||
for v in string.gmatch(version_available, "([^/]+)") do
|
||||
table.insert(versions_table, "-> " .. v)
|
||||
end
|
||||
local annotated_versions = table.concat(versions_table, "\n")
|
||||
local boot_version = vim.fn.input(annotated_versions .. "\n: ", "3.3.5.RELEASE")
|
||||
if not contains(data_available, boot_version) then
|
||||
create_notif("Invalid Spring Boot version. Please enter a valid version " .. options_err .. ".", "info")
|
||||
return ""
|
||||
end
|
||||
|
||||
return boot_version
|
||||
end
|
||||
|
||||
local function get_packaging(data_available)
|
||||
local packaging_available = list_to_string(data_available, false)
|
||||
local options_err = list_to_string(data_available, true)
|
||||
|
||||
local packaging = vim.fn.input("Enter Packaging(" .. packaging_available .. "): ", "jar")
|
||||
if packaging ~= "jar" and packaging ~= "war" then
|
||||
create_notif("Invalid packaging. Please enter " .. options_err .. ".", "info")
|
||||
return ""
|
||||
end
|
||||
return packaging
|
||||
end
|
||||
|
||||
local function springboot_new_project()
|
||||
local request = safe_request("https://start.spring.io/metadata/client")
|
||||
|
||||
if not request then
|
||||
vim.api.nvim_err_writeln("Failed to make a request to the URL.")
|
||||
return false
|
||||
end
|
||||
|
||||
local springboot_data = safe_json_decode(request.stdout)
|
||||
|
||||
if not springboot_data then
|
||||
vim.api.nvim_err_writeln("Failed to decode JSON from the request.")
|
||||
return false
|
||||
end
|
||||
local project_dir = change_directory()
|
||||
local build_types = { "maven", "gradle" }
|
||||
local languages = handle_start_springboot_data(springboot_data.language)
|
||||
local java_versions = handle_start_springboot_data(springboot_data.javaVersion)
|
||||
local boot_versions = handle_start_springboot_data(springboot_data.bootVersion)
|
||||
local packagings = handle_start_springboot_data(springboot_data.packaging)
|
||||
local build_type = get_build_type(build_types)
|
||||
|
||||
if build_type:len() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local language = get_language(languages)
|
||||
if language:len() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local java_version = get_java_version(java_versions)
|
||||
if java_version:len() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local boot_version = get_boot_version(boot_versions)
|
||||
if boot_version:len() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local packaging = get_packaging(packagings)
|
||||
if packaging:len() == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local dependencies = vim.fn.input("Enter dependencies (comma separated): ", "devtools,web,data-jpa,h2,thymeleaf")
|
||||
local group_id = vim.fn.input("Enter Group ID: ", "com.example")
|
||||
local artifact_id = vim.fn.input("Enter Artifact ID: ", "myproject")
|
||||
local name = vim.fn.input("Enter project name: ", artifact_id)
|
||||
local package_name = vim.fn.input("Enter package name: ", group_id .. "." .. artifact_id)
|
||||
local description = vim.fn.input("Enter project description: ", "")
|
||||
|
||||
local command = string.format(
|
||||
"spring init --boot-version=%s --java-version=%s --dependencies=%s --groupId=%s --artifactId=%s --name=%s --package-name=%s --description=%s --language=%s --build=%s %s",
|
||||
boot_version,
|
||||
java_version,
|
||||
dependencies,
|
||||
group_id,
|
||||
artifact_id,
|
||||
name,
|
||||
package_name,
|
||||
description, -- Menambahkan deskripsi proyek
|
||||
language, -- Menambahkan bahasa pemrograman (Java, Kotlin, atau Groovy)
|
||||
build_type,
|
||||
name
|
||||
)
|
||||
|
||||
-- Fungsi untuk mengubah teks
|
||||
local function capitalize_first_letter(str)
|
||||
return str:sub(1, 1):upper() .. str:sub(2):lower()
|
||||
end
|
||||
|
||||
local output = vim.fn.system(command)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
create_notif("Erro ao executar: " .. output, "error")
|
||||
else
|
||||
local ch_dir = string.format("cd %s", project_dir .. "/" .. name)
|
||||
vim.fn.system(ch_dir)
|
||||
vim.fn.chdir(project_dir .. "/" .. name)
|
||||
create_notif(name, "info")
|
||||
-- Cari dan buka file main class
|
||||
local uname = vim.loop.os_uname().sysname
|
||||
local pth = package_name
|
||||
if uname == "Windows_NT" then
|
||||
if pth then
|
||||
pth = pth:gsub("%.", "\\")
|
||||
create_notif(pth, "info")
|
||||
local main_class_path =
|
||||
string.format("src\\main\\java\\%s\\" .. capitalize_first_letter(name) .. "Application.java", pth)
|
||||
create_notif(main_class_path, "info")
|
||||
if vim.fn.filereadable(main_class_path) == 1 then
|
||||
vim.cmd(":edit " .. main_class_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
if pth then
|
||||
pth = pth:gsub("%.", "/")
|
||||
local main_class_path =
|
||||
string.format("src/main/java/%s/" .. capitalize_first_letter(name) .. "Application.java", pth)
|
||||
if vim.fn.filereadable(main_class_path) == 1 then
|
||||
vim.cmd(":edit " .. main_class_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.cmd(":NvimTreeFindFileToggl<CR>")
|
||||
end
|
||||
|
||||
create_notif("Project created successfully!", "info")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("SpringBootNewProject", springboot_new_project, {})
|
106
lua/auto-jdtls2/generate_java_class.lua
Normal file
106
lua/auto-jdtls2/generate_java_class.lua
Normal file
|
@ -0,0 +1,106 @@
|
|||
local function create_java_class()
|
||||
local is_maven_project = function()
|
||||
if vim.fn.findfile("pom.xml", vim.fn.getcwd()) == "pom.xml" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function create_notif(message, level)
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify(message, level)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
-- Fungsi untuk meminta input dari pengguna dengan opsi untuk membatalkan
|
||||
local function get_user_input(prompt, default_value)
|
||||
vim.fn.inputsave()
|
||||
local result = vim.fn.input(prompt, default_value)
|
||||
vim.fn.inputrestore()
|
||||
|
||||
-- Cek apakah pengguna menekan Esc untuk membatalkan input
|
||||
if result == "" then
|
||||
create_notif("Input canceled.", "info")
|
||||
return nil, true
|
||||
end
|
||||
|
||||
return result, false
|
||||
end
|
||||
|
||||
-- Fungsi untuk mendapatkan nama package default berdasarkan buffer aktif
|
||||
local function get_default_package()
|
||||
local path = vim.fn.expand("%:p:h")
|
||||
local project_root = vim.fn.getcwd()
|
||||
local relative_path = path:sub(#project_root + 1)
|
||||
relative_path = relative_path:gsub("app\\src\\main\\java\\", "")
|
||||
relative_path = relative_path:gsub("src\\main\\java\\", "")
|
||||
relative_path = relative_path:gsub("app/src/main/java/", "")
|
||||
relative_path = relative_path:gsub("src/main/java/", "")
|
||||
relative_path = relative_path:gsub("\\", ".")
|
||||
relative_path = relative_path:gsub("/", ".")
|
||||
return relative_path:sub(2)
|
||||
end
|
||||
|
||||
-- Ambil input dari pengguna untuk nama package dan nama kelas
|
||||
local package_name, canceled_package = get_user_input("Enter package name: ", get_default_package())
|
||||
if canceled_package then
|
||||
return
|
||||
end
|
||||
|
||||
local class_name, canceled_class = get_user_input("Enter class name: ", "MyClass")
|
||||
if canceled_class then
|
||||
return
|
||||
end
|
||||
|
||||
-- Format direktori dan path file berdasarkan input pengguna
|
||||
local package_dir = nil
|
||||
if package_name then
|
||||
if is_maven_project() then
|
||||
package_dir = string.format("src/main/java/%s", package_name:gsub("%.", "/"))
|
||||
else
|
||||
package_dir = string.format("app/src/main/java/%s", package_name:gsub("%.", "/"))
|
||||
end
|
||||
if vim.fn.isdirectory(package_dir) == 0 then
|
||||
vim.fn.mkdir(package_dir, "p")
|
||||
end
|
||||
else
|
||||
create_notif("Invalid package name: " .. package_name, "error")
|
||||
return
|
||||
end
|
||||
|
||||
local file_path = string.format("%s/%s.java", package_dir, class_name)
|
||||
if vim.fn.filereadable(file_path) == 1 then
|
||||
create_notif("Class already exists: " .. file_path, "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Tulis konten kelas Java ke dalam file
|
||||
local class_content = string.format(
|
||||
[[
|
||||
package %s;
|
||||
|
||||
public class %s {
|
||||
|
||||
}
|
||||
]],
|
||||
package_name,
|
||||
class_name,
|
||||
class_name
|
||||
)
|
||||
|
||||
local file = io.open(file_path, "w")
|
||||
if file then
|
||||
file:write(class_content)
|
||||
file:close()
|
||||
end
|
||||
|
||||
-- Buka file Java yang baru dibuat di Neovim
|
||||
vim.cmd(":edit " .. file_path)
|
||||
create_notif("Java class created: " .. file_path, "info")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("CreateJavaClass", create_java_class, {})
|
109
lua/auto-jdtls2/generate_java_interface.lua
Normal file
109
lua/auto-jdtls2/generate_java_interface.lua
Normal file
|
@ -0,0 +1,109 @@
|
|||
local function create_java_class()
|
||||
local function create_notif(message, level)
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify(message, level)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
local is_maven_project = function()
|
||||
if vim.fn.findfile("pom.xml", vim.fn.getcwd()) == "pom.xml" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Fungsi untuk meminta input dari pengguna dengan opsi untuk membatalkan
|
||||
local function get_user_input(prompt, default_value)
|
||||
vim.fn.inputsave()
|
||||
local result = vim.fn.input(prompt, default_value)
|
||||
vim.fn.inputrestore()
|
||||
|
||||
-- Cek apakah pengguna menekan Esc untuk membatalkan input
|
||||
if result == "" then
|
||||
create_notif("Input canceled.", "info")
|
||||
return nil, true
|
||||
end
|
||||
|
||||
return result, false
|
||||
end
|
||||
|
||||
-- Fungsi untuk mendapatkan nama package default berdasarkan buffer aktif
|
||||
local function get_default_package()
|
||||
local path = vim.fn.expand("%:p:h")
|
||||
local project_root = vim.fn.getcwd()
|
||||
local relative_path = path:sub(#project_root + 1)
|
||||
relative_path = relative_path:gsub("app\\src\\main\\java\\", "")
|
||||
relative_path = relative_path:gsub("src\\main\\java\\", "")
|
||||
relative_path = relative_path:gsub("app/src/main/java/", "")
|
||||
relative_path = relative_path:gsub("src/main/java/", "")
|
||||
relative_path = relative_path:gsub("\\", ".")
|
||||
relative_path = relative_path:gsub("/", ".")
|
||||
return relative_path:sub(2)
|
||||
end
|
||||
|
||||
-- Ambil input dari pengguna untuk nama package dan nama kelas
|
||||
local package_name, canceled_package = get_user_input("Enter package name: ", get_default_package())
|
||||
if canceled_package then
|
||||
return
|
||||
end
|
||||
|
||||
local class_name, canceled_class = get_user_input("Enter interface name: ", "MyInterface")
|
||||
if canceled_class then
|
||||
return
|
||||
end
|
||||
|
||||
-- Format direktori dan path file berdasarkan input pengguna
|
||||
local package_dir = nil
|
||||
if package_name then
|
||||
if is_maven_project() then
|
||||
package_dir = string.format("src/main/java/%s", package_name:gsub("%.", "/"))
|
||||
else
|
||||
package_dir = string.format("app/src/main/java/%s", package_name:gsub("%.", "/"))
|
||||
end
|
||||
if vim.fn.isdirectory(package_dir) == 0 then
|
||||
vim.fn.mkdir(package_dir, "p")
|
||||
end
|
||||
else
|
||||
create_notif("Invalid package name: " .. package_name, "error")
|
||||
return
|
||||
end
|
||||
|
||||
local file_path = string.format("%s/%s.java", package_dir, class_name)
|
||||
if vim.fn.filereadable(file_path) == 1 then
|
||||
create_notif("Class already exists: " .. file_path, "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Tulis konten kelas Java ke dalam file
|
||||
local class_content = string.format(
|
||||
[[
|
||||
/*
|
||||
* This Java source file.
|
||||
*/
|
||||
package %s;
|
||||
|
||||
public interface %s {
|
||||
// Other methods and fields
|
||||
}
|
||||
]],
|
||||
package_name,
|
||||
class_name,
|
||||
class_name
|
||||
)
|
||||
|
||||
local file = io.open(file_path, "w")
|
||||
if file then
|
||||
file:write(class_content)
|
||||
file:close()
|
||||
end
|
||||
|
||||
-- Buka file Java yang baru dibuat di Neovim
|
||||
vim.cmd(":edit " .. file_path)
|
||||
create_notif("Java interface created: " .. file_path, "info")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("CreateJavaInterface", create_java_class, {})
|
115
lua/auto-jdtls2/generate_java_main_class.lua
Normal file
115
lua/auto-jdtls2/generate_java_main_class.lua
Normal file
|
@ -0,0 +1,115 @@
|
|||
local function create_java_main_class()
|
||||
local function create_notif(message, level)
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify(message, level)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
local is_maven_project = function()
|
||||
if vim.fn.findfile("pom.xml", vim.fn.getcwd()) == "pom.xml" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Fungsi untuk meminta input dari pengguna dengan opsi untuk membatalkan
|
||||
local function get_user_input(prompt, default_value)
|
||||
vim.fn.inputsave()
|
||||
local result = vim.fn.input(prompt, default_value)
|
||||
vim.fn.inputrestore()
|
||||
|
||||
-- Cek apakah pengguna menekan Esc untuk membatalkan input
|
||||
if result == "" then
|
||||
create_notif("Input canceled.", "info")
|
||||
return nil, true
|
||||
end
|
||||
|
||||
return result, false
|
||||
end
|
||||
|
||||
-- Fungsi untuk mendapatkan nama package default berdasarkan buffer aktif
|
||||
local function get_default_package()
|
||||
local path = vim.fn.expand("%:p:h")
|
||||
local project_root = vim.fn.getcwd()
|
||||
local relative_path = path:sub(#project_root + 1)
|
||||
relative_path = relative_path:gsub("app\\src\\main\\java\\", "")
|
||||
relative_path = relative_path:gsub("src\\main\\java\\", "")
|
||||
relative_path = relative_path:gsub("app/src/main/java/", "")
|
||||
relative_path = relative_path:gsub("src/main/java/", "")
|
||||
relative_path = relative_path:gsub("\\", ".")
|
||||
relative_path = relative_path:gsub("/", ".")
|
||||
return relative_path:sub(2)
|
||||
end
|
||||
|
||||
-- Ambil input dari pengguna untuk nama package dan nama kelas
|
||||
local package_name, canceled_package = get_user_input("Enter package name: ", get_default_package())
|
||||
if canceled_package then
|
||||
return
|
||||
end
|
||||
|
||||
local class_name, canceled_class = get_user_input("Enter class name: ", "MyMainClass")
|
||||
if canceled_class then
|
||||
return
|
||||
end
|
||||
|
||||
-- Format direktori dan path file berdasarkan input pengguna
|
||||
local package_dir = nil
|
||||
if package_name then
|
||||
if is_maven_project() then
|
||||
package_dir = string.format("src/main/java/%s", package_name:gsub("%.", "/"))
|
||||
else
|
||||
package_dir = string.format("app/src/main/java/%s", package_name:gsub("%.", "/"))
|
||||
end
|
||||
if vim.fn.isdirectory(package_dir) == 0 then
|
||||
vim.fn.mkdir(package_dir, "p")
|
||||
end
|
||||
else
|
||||
create_notif("Invalid package name: " .. package_name, "error")
|
||||
return
|
||||
end
|
||||
|
||||
local file_path = string.format("%s/%s.java", package_dir, class_name)
|
||||
if vim.fn.filereadable(file_path) == 1 then
|
||||
create_notif("Class already exists: " .. file_path, "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Tulis konten kelas Java ke dalam file
|
||||
local class_content = string.format(
|
||||
[[
|
||||
/*
|
||||
* This Java source file.
|
||||
*/
|
||||
package %s;
|
||||
|
||||
public class %s {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
]],
|
||||
package_name,
|
||||
class_name,
|
||||
class_name
|
||||
)
|
||||
|
||||
local file = io.open(file_path, "w")
|
||||
if file then
|
||||
file:write(class_content)
|
||||
file:close()
|
||||
end
|
||||
|
||||
-- Buka file Java yang baru dibuat di Neovim
|
||||
vim.cmd(":edit " .. file_path)
|
||||
create_notif("Java class created: " .. file_path, "info")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("CreateJavaMainClass", create_java_main_class, {})
|
15
lua/auto-jdtls2/init.lua
Normal file
15
lua/auto-jdtls2/init.lua
Normal file
|
@ -0,0 +1,15 @@
|
|||
local M = {}
|
||||
|
||||
M.setup = function(opt)
|
||||
opt = opt or {}
|
||||
require("auto-jdtls2.create_gradle_project")
|
||||
require("auto-jdtls2.create_maven_project")
|
||||
require("auto-jdtls2.create_springboot_project")
|
||||
require("auto-jdtls2.generate_java_class")
|
||||
require("auto-jdtls2.generate_java_interface")
|
||||
require("auto-jdtls2.generate_java_main_class")
|
||||
-- require("auto-jdtls2.utils").install()
|
||||
-- require("auto-jdtls2.utils").attach_jdtls(opt)
|
||||
end
|
||||
|
||||
return M
|
449
lua/auto-jdtls2/utils.lua
Normal file
449
lua/auto-jdtls2/utils.lua
Normal file
|
@ -0,0 +1,449 @@
|
|||
local M = {}
|
||||
M.java_filetypes = { "java" }
|
||||
M.root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
|
||||
|
||||
-- Utility function to extend or override a config table, similar to the way
|
||||
-- that Plugin.opts works.
|
||||
---@param config table
|
||||
---@param custom function | table | nil
|
||||
M.extend_or_override = function(config, custom, ...)
|
||||
if type(custom) == "function" then
|
||||
config = custom(config, ...) or config
|
||||
elseif custom then
|
||||
config = vim.tbl_deep_extend("force", config, custom) --[[@as table]]
|
||||
end
|
||||
return config
|
||||
end
|
||||
|
||||
function M.capabilities()
|
||||
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
if status_ok then
|
||||
return cmp_nvim_lsp.default_capabilities()
|
||||
end
|
||||
|
||||
local CAPABILITIES = vim.lsp.protocol.make_client_capabilities()
|
||||
CAPABILITIES.textDocument.completion.completionItem.snippetSupport = true
|
||||
CAPABILITIES.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits",
|
||||
},
|
||||
}
|
||||
|
||||
return CAPABILITIES
|
||||
end
|
||||
-- stylua: ignore
|
||||
M.lsp_keymaps=function ()
|
||||
vim.keymap.set({ "n", "v" }, "<leader>l", "", { desc = "LSP" })
|
||||
-- Set vim motion for <Space> + l + h to show code documentation about the code the cursor is currently over if available
|
||||
vim.keymap.set("n", "<leader>lh", vim.lsp.buf.hover, { desc = "Code Hover Documentation" })
|
||||
-- Set vim motion for <Space> + l + d to go where the code/variable under the cursor was defined
|
||||
vim.keymap.set("n", "<leader>ld", vim.lsp.buf.definition, { desc = "Code Goto Definition" })
|
||||
-- Set vim motion for <Space> + l + a for display code action suggestions for code diagnostics in both normal and visual mode
|
||||
vim.keymap.set({ "n", "v" }, "<leader>la", vim.lsp.buf.code_action, { desc = "Code Actions" })
|
||||
-- Set vim motion for <Space> + l + r to display references to the code under the cursor
|
||||
vim.keymap.set("n", "<leader>lr", require("telescope.builtin").lsp_references, { desc = "Code Goto References" })
|
||||
-- Set vim motion for <Space> + l + i to display implementations to the code under the cursor
|
||||
vim.keymap.set("n", "<leader>li", require("telescope.builtin").lsp_implementations, { desc = "Code Goto Implementations" })
|
||||
-- Set a vim motion for <Space> + l + <Shift>R to smartly rename the code under the cursor
|
||||
vim.keymap.set("n", "<leader>lR", vim.lsp.buf.rename, { desc = "Code Rename" })
|
||||
-- Set a vim motion for <Space> + l + <Shift>D to go to where the code/object was declared in the project (class file)
|
||||
vim.keymap.set("n", "<leader>lD", vim.lsp.buf.declaration, { desc = "Code Goto Declaration" })
|
||||
end
|
||||
|
||||
M.is_maven_project = function()
|
||||
if vim.fn.findfile("pom.xml", vim.fn.getcwd()) == "pom.xml" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
M.is_gradle_project = function()
|
||||
if
|
||||
vim.fn.findfile("build.gradle", vim.fn.getcwd()) == "build.gradle"
|
||||
or vim.fn.findfile("settings.gradle", vim.fn.getcwd()) == "settings.gradle"
|
||||
or vim.fn.findfile("gradlew", vim.fn.getcwd()) == "gradlew"
|
||||
then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
M.is_main_class = function()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local content = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||
for i, line in ipairs(content) do
|
||||
if line:match("public static void main%s*%(") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
M.run_aven_pring_boot = function()
|
||||
if M.is_maven_project() then
|
||||
vim.cmd("terminal mvn spring-boot:run")
|
||||
else
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify("Project pom.xml not found !", "info")
|
||||
else
|
||||
print("Project pom.xml not found !")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.cmd_maven_spring_boot = function()
|
||||
vim.api.nvim_create_user_command("RunMvnSpringBoot", function()
|
||||
M.run_aven_pring_boot()
|
||||
end, { nargs = 0 })
|
||||
end
|
||||
|
||||
M.run_gradle_spring_boot = function()
|
||||
if M.is_gradle_project() then
|
||||
local uname = vim.loop.os_uname().sysname
|
||||
if uname == "Windows_NT" then
|
||||
vim.cmd("terminal .\\gradlew build --continuous")
|
||||
vim.cmd("terminal .\\gradlew bootRun")
|
||||
else
|
||||
vim.cmd("terminal ./gradlew build --continuous")
|
||||
vim.cmd("terminal ./gradlew bootRun")
|
||||
end
|
||||
else
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify("Project build.gradle not found !", "info")
|
||||
else
|
||||
print("Project build.gradle not found !")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.cmd_gradle_spring_boot = function()
|
||||
vim.api.nvim_create_user_command("RunGradleSpringBoot", function()
|
||||
M.run_gradle_spring_boot()
|
||||
end, { nargs = 0 })
|
||||
end
|
||||
|
||||
M.run_mvn_and_java = function()
|
||||
if M.is_maven_project() then
|
||||
local result = M.is_main_class()
|
||||
if not result then
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify("Please open java main class !", "info")
|
||||
else
|
||||
print("Please open java main class !")
|
||||
end
|
||||
return
|
||||
else
|
||||
-- Fungsi untuk mencari file .jar dalam folder target
|
||||
local function find_jar_file()
|
||||
local target_dir = "target"
|
||||
local jar_file = nil
|
||||
|
||||
local handle = vim.loop.fs_scandir(target_dir)
|
||||
if handle then
|
||||
while true do
|
||||
local name, t = vim.loop.fs_scandir_next(handle)
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
if t == "file" and name:match("%.jar$") then
|
||||
jar_file = name
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return jar_file
|
||||
end
|
||||
local jar_file = find_jar_file()
|
||||
-- Buat fungsi untuk menjalankan perintah secara berurutan dalam mode diam
|
||||
function RunMvnAndJava()
|
||||
-- daptkan path
|
||||
local root = vim.uv.cwd()
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
fname = fname:gsub(root, "")
|
||||
fname = fname:gsub("/src/main/java/", "")
|
||||
fname = fname:gsub("\\src\\main\\java\\", "")
|
||||
fname = fname:gsub(".java", ""):gsub("/", ".")
|
||||
fname = fname:gsub("\\", ".")
|
||||
-- Jalankan perintah mvn package secara diam-diam
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify("Compile Start !", "info")
|
||||
end
|
||||
vim.fn.jobstart("mvn package", {
|
||||
on_exit = function()
|
||||
vim.cmd("terminal java -cp target/" .. jar_file .. " " .. fname)
|
||||
end,
|
||||
})
|
||||
end
|
||||
RunMvnAndJava()
|
||||
end
|
||||
else
|
||||
local notif_ok, notify = pcall(require, "notify")
|
||||
if notif_ok then
|
||||
notify("Project pom.xml not found !", "info")
|
||||
else
|
||||
print("Project pom.xml not found !")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.cmd_mvn_and_java = function()
|
||||
vim.api.nvim_create_user_command("RunMaven", function()
|
||||
M.run_mvn_and_java()
|
||||
end, { nargs = 0 })
|
||||
end
|
||||
|
||||
M.cmd_gradle = function()
|
||||
vim.api.nvim_create_user_command("RunGradle", function()
|
||||
vim.cmd("terminal gradle run")
|
||||
end, { nargs = 0 })
|
||||
end
|
||||
|
||||
-- stylua: ignore
|
||||
M.jdtls_keymaps=function ()
|
||||
-- add keymaps
|
||||
vim.keymap.set('n', '<leader>J', "", { desc = "Java" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + o to organize imports in normal mode
|
||||
vim.keymap.set('n', '<leader>Jo', "<Cmd> lua require('jdtls').organize_imports()<CR>", { desc = "Java Organize Imports" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + v to extract the code under the cursor to a variable
|
||||
vim.keymap.set('n', '<leader>Jv', "<Cmd> lua require('jdtls').extract_variable()<CR>", { desc = "Java Extract Variable" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + v to extract the code selected in visual mode to a variable
|
||||
vim.keymap.set('v', '<leader>Jv', "<Esc><Cmd> lua require('jdtls').extract_variable(true)<CR>", { desc = "Java Extract Variable" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + <Shift>C to extract the code under the cursor to a static variable
|
||||
vim.keymap.set('n', '<leader>JC', "<Cmd> lua require('jdtls').extract_constant()<CR>", { desc = "Java Extract Constant" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + <Shift>C to extract the code selected in visual mode to a static variable
|
||||
vim.keymap.set('v', '<leader>JC', "<Esc><Cmd> lua require('jdtls').extract_constant(true)<CR>", { desc = "Java Extract Constant" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + t to run the test method currently under the cursor
|
||||
vim.keymap.set('n', '<leader>Jt', "<Cmd> lua require('jdtls').test_nearest_method()<CR>", { desc = "Java Test Method" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + t to run the test method that is currently selected in visual mode
|
||||
vim.keymap.set('v', '<leader>Jt', "<Esc><Cmd> lua require('jdtls').test_nearest_method(true)<CR>", { desc = "Java Test Method" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + <Shift>T to run an entire test suite (class)
|
||||
vim.keymap.set('n', '<leader>JT', "<Cmd> lua require('jdtls').test_class()<CR>", { desc = "Java Test Class" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + u to update the project configuration
|
||||
vim.keymap.set('n', '<leader>Ju', "<Cmd> JdtUpdateConfig<CR>", { desc = "Java Update Config" })
|
||||
end
|
||||
|
||||
M.opts = {
|
||||
root_dir = require("jdtls.setup").find_root(M.root_markers),
|
||||
project_name = function()
|
||||
return vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
end,
|
||||
|
||||
get_jdtls = function()
|
||||
local function check_os()
|
||||
local uname = vim.loop.os_uname().sysname
|
||||
if uname == "Darwin" then
|
||||
return "mac"
|
||||
elseif uname == "Windows_NT" then
|
||||
return "win"
|
||||
elseif uname == "Linux" then
|
||||
return "linux"
|
||||
else
|
||||
return "unknown"
|
||||
end
|
||||
end
|
||||
local mason_registry = require("mason-registry")
|
||||
local jdtls = mason_registry.get_package("jdtls")
|
||||
local jdtls_path = jdtls:get_install_path()
|
||||
local launcher = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
|
||||
local SYSTEM = check_os()
|
||||
local config = jdtls_path .. "/config_" .. SYSTEM
|
||||
local lombok = jdtls_path .. "/lombok.jar"
|
||||
return launcher, config, lombok
|
||||
end,
|
||||
|
||||
jdtls_workspace_dir = function(project_name)
|
||||
local function get_workspace()
|
||||
local home = os.getenv("HOME")
|
||||
local workspace_path = home .. "/code/workspace/"
|
||||
local workspace_dir = workspace_path .. project_name
|
||||
return workspace_dir
|
||||
end
|
||||
return get_workspace()
|
||||
end,
|
||||
full_cmd = function(opts)
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
local launcher, os_config, lombok = opts.get_jdtls()
|
||||
local 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",
|
||||
"-Xmx1g",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
"-javaagent:" .. lombok,
|
||||
"-jar",
|
||||
launcher,
|
||||
"-configuration",
|
||||
os_config,
|
||||
"-data",
|
||||
opts.jdtls_workspace_dir(project_name),
|
||||
}
|
||||
return cmd
|
||||
end,
|
||||
|
||||
-- These depend on nvim-dap, but can additionally be disabled by setting false here.
|
||||
dap = { hotcodereplace = "auto", config_overrides = {} },
|
||||
dap_main = {},
|
||||
test = true,
|
||||
settings = {
|
||||
java = {
|
||||
inlayHints = {
|
||||
parameterNames = {
|
||||
enabled = "all",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.attach_jdtls = function(op)
|
||||
M.opts = M.extend_or_override(M.opts, op or {})
|
||||
local opt = vim.opt
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.softtabstop = 4
|
||||
opt.ts = 4
|
||||
opt.expandtab = true
|
||||
|
||||
-- Check Ttriisittrer
|
||||
|
||||
local function ensure_ts_install(lang)
|
||||
local parsers = require("nvim-treesitter.parsers")
|
||||
local installed = parsers.has_parser(lang)
|
||||
|
||||
if not installed then
|
||||
vim.cmd("TSInstall " .. lang)
|
||||
require("notify")("Treesitter parser for " .. lang .. " installed successfully.")
|
||||
end
|
||||
end
|
||||
|
||||
-- Memeriksa dan menginstal atau mengonfirmasi Treesitter untuk Java
|
||||
ensure_ts_install("java")
|
||||
|
||||
local mason_registry = require("mason-registry")
|
||||
if
|
||||
not mason_registry.is_installed("jdtls")
|
||||
or not mason_registry.is_installed("java-debug-adapter")
|
||||
or not mason_registry.is_installed("java-test")
|
||||
then
|
||||
vim.cmd("Mason")
|
||||
require("notify")("Mason Installed Dependency, please restart nvim after installation is completed")
|
||||
return
|
||||
end
|
||||
local bundles = {} ---@type string[]
|
||||
if M.opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
local java_dbg_pkg = mason_registry.get_package("java-debug-adapter")
|
||||
local java_dbg_path = java_dbg_pkg:get_install_path()
|
||||
local jar_patterns = {
|
||||
java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||
}
|
||||
-- java-test also depends on java-debug-adapter.
|
||||
if M.opts.test and mason_registry.is_installed("java-test") then
|
||||
local java_test_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
vim.list_extend(jar_patterns, {
|
||||
java_test_path .. "/extension/server/*.jar",
|
||||
})
|
||||
end
|
||||
for _, jar_pattern in ipairs(jar_patterns) do
|
||||
for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do
|
||||
table.insert(bundles, bundle)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- initialisasi config
|
||||
local function attach_jdtls()
|
||||
-- load user cmd
|
||||
M.cmd_maven_spring_boot()
|
||||
M.cmd_gradle_spring_boot()
|
||||
M.cmd_mvn_and_java()
|
||||
M.cmd_gradle()
|
||||
-- Configuration can be augmented and overridden by opts.jdtls
|
||||
local config = M.extend_or_override({
|
||||
cmd = M.opts.full_cmd(M.opts),
|
||||
root_dir = require("jdtls.setup").find_root(M.root_markers),
|
||||
init_options = {
|
||||
bundles = bundles,
|
||||
},
|
||||
settings = M.opts.settings,
|
||||
-- enable CMP capabilities
|
||||
-- capabilities = require("user.lsp.handlers").capabilities or nil,
|
||||
-- capabilities = require("auto-lsp.lsp.handlers").capabilities or nil,
|
||||
capabilities = M.capabilities() or nil,
|
||||
}, M.opts.jdtls)
|
||||
|
||||
-- Existing server will be reused if the root_dir matches.
|
||||
require("jdtls").start_or_attach(config)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = M.java_filetypes,
|
||||
callback = attach_jdtls,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
-- stylua: ignore
|
||||
if client and client.name == "jdtls" then
|
||||
-- M.jdtls_keymaps()
|
||||
-- M.lsp_keymaps()
|
||||
if M.opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(M.opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(M.opts.dap_main)
|
||||
end
|
||||
|
||||
-- User can set additional keymaps in opts.on_attach
|
||||
if M.opts.on_attach then
|
||||
M.opts.on_attach(args)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
attach_jdtls()
|
||||
end
|
||||
|
||||
M.install = function()
|
||||
local ensure_installed = {
|
||||
"java-debug-adapter",
|
||||
"java-test",
|
||||
"jdtls",
|
||||
}
|
||||
local mr = require("mason-registry")
|
||||
mr:on("package:install:success", function()
|
||||
vim.defer_fn(function()
|
||||
-- trigger FileType event to possibly load this newly installed LSP server
|
||||
require("lazy.core.handler.event").trigger({
|
||||
event = "FileType",
|
||||
buf = vim.api.nvim_get_current_buf(),
|
||||
})
|
||||
end, 100)
|
||||
end)
|
||||
|
||||
mr.refresh(function()
|
||||
for _, tool in ipairs(ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
return M
|
|
@ -14,6 +14,7 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
||||
vim.opt.number = false
|
||||
|
||||
local icons = require("pcode.user.icons").ui
|
||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||
|
|
|
@ -91,21 +91,5 @@ return {
|
|||
config = function(_, opts)
|
||||
require("auto-lsp").setup(opts)
|
||||
end,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>l", "", desc = " LSP", mode = "n" },
|
||||
{ "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", desc = "Code Action", mode = "n" },
|
||||
{ "<leader>ld", "<cmd>Telescope diagnostics bufnr=0<cr>", desc = "Document Diagnostics", mode = "n" },
|
||||
{ "<leader>lw", "<cmd>Telescope diagnostics<cr>", desc = "Workspace Diagnostics", mode = "n" },
|
||||
{ "<leader>li", "<cmd>LspInfo<cr>", desc = "Info", mode = "n" },
|
||||
{ "<leader>lI", "<cmd>Mason<cr>", desc = "Mason", mode = "n" },
|
||||
{ "<leader>lj", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", desc = "Next Diagnostic", mode = "n" },
|
||||
{ "<leader>lk", "<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>", desc = "Prev Diagnostic", mode = "n" },
|
||||
{ "<leader>ll", "<cmd>lua vim.lsp.codelens.run()<cr>", desc = "Code Lens Action", mode = "n" },
|
||||
{ "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<cr>", desc = "Quickfix", mode = "n" },
|
||||
{ "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", desc = "Rename", mode = "n" },
|
||||
{ "<leader>ls", "<cmd>Telescope lsp_document_symbols<cr>", desc = "Document Symbols", mode = "n" },
|
||||
{ "<leader>lS", "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", desc = "Workspace Symbols", mode = "n"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ return {
|
|||
lazy = true,
|
||||
cmd = {
|
||||
"TSInstall",
|
||||
"TSInstallInfo",
|
||||
-- "TSInstallInfo",
|
||||
"TSInstallSync",
|
||||
"TSUpdate",
|
||||
"TSUpdateSync",
|
||||
|
@ -42,6 +42,9 @@ return {
|
|||
end, opts.ensure_installed)
|
||||
end
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
vim.api.nvim_create_user_command("TSInstallInfo", function()
|
||||
vim.cmd("Telescope treesitter_info")
|
||||
end, {})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ return {
|
|||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
event = "InsertEnter",
|
||||
version = "v2.*",
|
||||
build = "make install_jsregexp",
|
||||
opts = {
|
||||
history = true,
|
||||
delete_check_events = "TextChanged",
|
||||
|
|
|
@ -12,15 +12,27 @@ local rfile = {
|
|||
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
|
||||
scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css",
|
||||
javascript = 'node "$dir/$fileName"',
|
||||
go = "go run .",
|
||||
-- go = "go run .",
|
||||
go = "go run $fileName",
|
||||
}
|
||||
|
||||
local runProject = {}
|
||||
local cwd = vim.fn.getcwd()
|
||||
local go_mod_path = cwd .. "/go.mod"
|
||||
if vim.fn.filereadable(go_mod_path) ~= 0 then
|
||||
runProject[cwd] = {
|
||||
name = "Go Project (cwd)",
|
||||
command = "go run .",
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
"CRAG666/code_runner.nvim",
|
||||
lazy = true,
|
||||
cmd = { "RunCode", "RunFile", "RunProject", "RunClose" },
|
||||
opts = {
|
||||
filetype = rfile,
|
||||
project = runProject,
|
||||
mode = "float",
|
||||
focus = true,
|
||||
startinsert = true,
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
return {
|
||||
"stevearc/dressing.nvim",
|
||||
lazy = true,
|
||||
init = function()
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
vim.ui.select = function(...)
|
||||
require("lazy").load({ plugins = { "dressing.nvim" } })
|
||||
return vim.ui.select(...)
|
||||
end
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
vim.ui.input = function(...)
|
||||
require("lazy").load({ plugins = { "dressing.nvim" } })
|
||||
return vim.ui.input(...)
|
||||
end
|
||||
end,
|
||||
opts = {
|
||||
input = {
|
||||
title_pos = "center",
|
||||
relative = "editor",
|
||||
default_prompt = "➤ ",
|
||||
win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" },
|
||||
prefer_width = 30,
|
||||
max_width = { 140, 0.9 },
|
||||
min_width = { 50, 0.2 },
|
||||
},
|
||||
select = {
|
||||
backend = { "telescope", "builtin" },
|
||||
builtin = { win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" } },
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("dressing").setup(opts)
|
||||
end,
|
||||
}
|
35
lua/pcode/plugins/extras/dressing.lua
Normal file
35
lua/pcode/plugins/extras/dressing.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
return {
|
||||
"pojokcodeid/dressing.nvim",
|
||||
lazy = true,
|
||||
init = function()
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
vim.ui.select = function(...)
|
||||
require("lazy").load({ plugins = { "dressing.nvim" } })
|
||||
return vim.ui.select(...)
|
||||
end
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
-- vim.ui.input = function(...)
|
||||
-- require("lazy").load({ plugins = { "dressing.nvim" } })
|
||||
-- return vim.ui.input(...)
|
||||
-- end
|
||||
end,
|
||||
opts = {
|
||||
input = {
|
||||
enabled = false,
|
||||
title_pos = "center",
|
||||
relative = "editor",
|
||||
default_prompt = "➤ ",
|
||||
win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" },
|
||||
prefer_width = 30,
|
||||
max_width = { 140, 0.9 },
|
||||
min_width = { 50, 0.2 },
|
||||
},
|
||||
select = {
|
||||
backend = { "telescope", "builtin" },
|
||||
builtin = { win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" } },
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("dressing").setup(opts)
|
||||
end,
|
||||
}
|
14
lua/pcode/plugins/extras/fidget.lua
Normal file
14
lua/pcode/plugins/extras/fidget.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
return {
|
||||
"j-hui/fidget.nvim",
|
||||
lazy = true,
|
||||
tag = "legacy",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
require("fidget").setup({
|
||||
window = {
|
||||
blend = 0,
|
||||
relative = "editor",
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
23
lua/pcode/plugins/extras/lspsignatur.lua
Normal file
23
lua/pcode/plugins/extras/lspsignatur.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
return {
|
||||
"ray-x/lsp_signature.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
local is_enabled = true
|
||||
return {
|
||||
-- Window mode
|
||||
floating_window = is_enabled, -- Display it as floating window.
|
||||
hi_parameter = "IncSearch", -- Color to highlight floating window.
|
||||
handler_opts = { border = "rounded" }, -- Window style
|
||||
|
||||
-- Hint mode
|
||||
hint_enable = false, -- Display it as hint.
|
||||
hint_prefix = "👈 ",
|
||||
|
||||
-- Additionally, you can use <space>uH to toggle inlay hints.
|
||||
toggle_key_flip_floatwin_setting = is_enabled,
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("lsp_signature").setup(opts)
|
||||
end,
|
||||
}
|
|
@ -16,7 +16,7 @@ function M.config()
|
|||
require("nvim-navic").setup({
|
||||
icons = icons,
|
||||
lsp = {
|
||||
auto_attach = false,
|
||||
auto_attach = true,
|
||||
preference = nil,
|
||||
},
|
||||
highlight = false,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
return {
|
||||
{
|
||||
"nvchad/menu",
|
||||
"nvzone/menu",
|
||||
lazy = true,
|
||||
event = { "VeryLazy" },
|
||||
dependencies = {
|
||||
{ "nvchad/volt", lazy = true },
|
||||
{ "nvzone/volt", lazy = true },
|
||||
{ "nvzone/showkeys", cmd = "ShowkeysToggle", lazy = true },
|
||||
{
|
||||
"nvchad/minty",
|
||||
"nvzone/minty",
|
||||
cmd = { "Shades", "Huefy" },
|
||||
lazy = true,
|
||||
},
|
||||
|
@ -22,10 +23,12 @@ return {
|
|||
end, {})
|
||||
|
||||
-- mouse users + nvimtree users!
|
||||
vim.keymap.set("n", "<RightMouse>", function()
|
||||
vim.keymap.set({ "n", "v" }, "<RightMouse>", function()
|
||||
require("menu.utils").delete_old_menus()
|
||||
vim.cmd.exec('"normal! \\<RightMouse>"')
|
||||
|
||||
local options = vim.bo.ft == "NvimTree" and "nvimtree" or "default"
|
||||
local buf = vim.api.nvim_win_get_buf(vim.fn.getmousepos().winid)
|
||||
local options = vim.bo[buf].ft == "NvimTree" and "nvimtree" or "default"
|
||||
require("menu").open(options, opts)
|
||||
end, {})
|
||||
end,
|
||||
|
|
|
@ -2,6 +2,7 @@ return {
|
|||
"hiphish/rainbow-delimiters.nvim",
|
||||
lazy = true,
|
||||
event = "BufRead",
|
||||
branch = "master",
|
||||
config = function()
|
||||
-- Modul ini berisi beberapa definisi default
|
||||
local rainbow_delimiters = require("rainbow-delimiters")
|
||||
|
|
26
lua/pcode/plugins/extras/telescopediff.lua
Normal file
26
lua/pcode/plugins/extras/telescopediff.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"jemag/telescope-diff.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("telescope").load_extension("diff")
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>sd",
|
||||
function()
|
||||
require("telescope").extensions.diff.diff_files({ hidden = true })
|
||||
end,
|
||||
desc = "Diff 2 Files",
|
||||
},
|
||||
{
|
||||
"<leader>sD",
|
||||
function()
|
||||
require("telescope").extensions.diff.diff_current({ hidden = true })
|
||||
end,
|
||||
desc = "Diff Current File",
|
||||
},
|
||||
},
|
||||
}
|
13
lua/pcode/plugins/extras/telescopetreesiterinfo.lua
Normal file
13
lua/pcode/plugins/extras/telescopetreesiterinfo.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"roycrippen4/telescope-treesitter-info.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("telescope").load_extension("treesitter_info")
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>p", "<cmd>Telescope treesitter_info<cr>", desc = "Treesitter Info" },
|
||||
},
|
||||
}
|
22
lua/pcode/plugins/extras/tinydignostic.lua
Normal file
22
lua/pcode/plugins/extras/tinydignostic.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
return {
|
||||
"rachartier/tiny-inline-diagnostic.nvim",
|
||||
event = "VeryLazy", -- Or `LspAttach`
|
||||
priority = 1000, -- needs to be loaded in first
|
||||
config = function()
|
||||
require("tiny-inline-diagnostic").setup({
|
||||
preset = "powerline",
|
||||
-- signs = {
|
||||
-- left = "",
|
||||
-- right = "",
|
||||
-- diag = "●",
|
||||
-- arrow = " ",
|
||||
-- up_arrow = " ",
|
||||
-- vertical = " │",
|
||||
-- vertical_end = " └",
|
||||
-- },
|
||||
blend = {
|
||||
factor = 0.22,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -21,6 +21,8 @@ return {
|
|||
"WinBar",
|
||||
"WinBarNC",
|
||||
"NotifyBackground",
|
||||
"TabLine",
|
||||
"TabLineFill",
|
||||
},
|
||||
exclude_groups = {
|
||||
-- disable active selection backgroun
|
||||
|
@ -53,6 +55,10 @@ return {
|
|||
-- create auto command to set transparent
|
||||
vim.cmd("TransparentDisable")
|
||||
vim.cmd("TransparentEnable")
|
||||
vim.api.nvim_set_hl(0, "MasonHeader", { bold = true, bg = "NONE", fg = "#838FA7" })
|
||||
vim.api.nvim_set_hl(0, "MasonMutedBlock", { bg = "NONE", fg = "#838FA7" })
|
||||
vim.api.nvim_set_hl(0, "MasonHighlightBlockBold", { bold = true, bg = "NONE", fg = "#ABB2BF" })
|
||||
vim.api.nvim_set_hl(0, "LazyH1", { bold = true, bg = "NONE", fg = "#ABB2BF" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -11,6 +11,46 @@ return {
|
|||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "gopls" })
|
||||
vim.api.nvim_create_user_command("GoRun", function()
|
||||
local filename = vim.fn.expand("%:p") -- path lengkap file aktif
|
||||
if not filename:match("%.go$") then
|
||||
vim.notify("current file is not a go file.", vim.log.levels.WARN, { title = "GoRun" })
|
||||
return
|
||||
end
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local go_runner = Terminal:new({
|
||||
cmd = "go run " .. filename,
|
||||
direction = "float",
|
||||
close_on_exit = false,
|
||||
hidden = true,
|
||||
})
|
||||
|
||||
go_runner:toggle()
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("GoBuild", function()
|
||||
local cwd = vim.fn.getcwd()
|
||||
local go_mod_path = cwd .. "/go.mod"
|
||||
if vim.fn.filereadable(go_mod_path) == 0 then
|
||||
vim.notify("current project is not a go project.", vim.log.levels.WARN, { title = "GoBuild" })
|
||||
return
|
||||
end
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
-- create file exe jika os adalah windows
|
||||
local filename = "output"
|
||||
if vim.fn.has("win32") == 1 then
|
||||
filename = "output.exe"
|
||||
end
|
||||
local go_runner = Terminal:new({
|
||||
cmd = "go build -o " .. filename .. " && ./" .. filename,
|
||||
direction = "float",
|
||||
close_on_exit = false,
|
||||
hidden = true,
|
||||
})
|
||||
|
||||
go_runner:toggle()
|
||||
end, {})
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
@ -26,8 +66,8 @@ return {
|
|||
"pojokcodeid/auto-lint.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft = opts.linters_by_ft or {}
|
||||
vim.list_extend(opts.ensure_installed, { "ast-grep" })
|
||||
opts.linters_by_ft.php = { "ast-grep" }
|
||||
vim.list_extend(opts.ensure_installed, { "golangci-lint" })
|
||||
opts.linters_by_ft.php = { "golangci-lint" }
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,20 +1,4 @@
|
|||
local M = {}
|
||||
local java_filetypes = { "java" }
|
||||
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
|
||||
|
||||
-- Utility function to extend or override a config table, similar to the way
|
||||
-- that Plugin.opts works.
|
||||
---@param config table
|
||||
---@param custom function | table | nil
|
||||
local function extend_or_override(config, custom, ...)
|
||||
if type(custom) == "function" then
|
||||
config = custom(config, ...) or config
|
||||
elseif custom then
|
||||
config = vim.tbl_deep_extend("force", config, custom) --[[@as table]]
|
||||
end
|
||||
return config
|
||||
end
|
||||
|
||||
M = {
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
|
@ -24,200 +8,29 @@ M = {
|
|||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-jdtls",
|
||||
ft = java_filetypes,
|
||||
enabled = true,
|
||||
opts = function()
|
||||
return {
|
||||
root_dir = require("jdtls.setup").find_root(root_markers),
|
||||
project_name = function()
|
||||
return vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
end,
|
||||
|
||||
-- Where are the config and workspace dirs for a project?
|
||||
jdtls_config_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/config"
|
||||
end,
|
||||
jdtls_workspace_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/workspace"
|
||||
end,
|
||||
cmd = { vim.fn.exepath("jdtls") },
|
||||
full_cmd = function(opts)
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
local cmd = vim.deepcopy(opts.cmd)
|
||||
if project_name then
|
||||
vim.list_extend(cmd, {
|
||||
"-configuration",
|
||||
opts.jdtls_config_dir(project_name),
|
||||
"-data",
|
||||
opts.jdtls_workspace_dir(project_name),
|
||||
})
|
||||
end
|
||||
return cmd
|
||||
end,
|
||||
|
||||
-- These depend on nvim-dap, but can additionally be disabled by setting false here.
|
||||
dap = { hotcodereplace = "auto", config_overrides = {} },
|
||||
dap_main = {},
|
||||
test = true,
|
||||
settings = {
|
||||
java = {
|
||||
inlayHints = {
|
||||
parameterNames = {
|
||||
enabled = "all",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
local opt = vim.opt
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.softtabstop = 4
|
||||
opt.ts = 4
|
||||
opt.expandtab = true
|
||||
|
||||
local mason_registry = require("mason-registry")
|
||||
local bundles = {} ---@type string[]
|
||||
if opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
local java_dbg_pkg = mason_registry.get_package("java-debug-adapter")
|
||||
local java_dbg_path = java_dbg_pkg:get_install_path()
|
||||
local jar_patterns = {
|
||||
java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||
}
|
||||
-- java-test also depends on java-debug-adapter.
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
local java_test_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
vim.list_extend(jar_patterns, {
|
||||
java_test_path .. "/extension/server/*.jar",
|
||||
})
|
||||
end
|
||||
for _, jar_pattern in ipairs(jar_patterns) do
|
||||
for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do
|
||||
table.insert(bundles, bundle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function attach_jdtls()
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
|
||||
-- Configuration can be augmented and overridden by opts.jdtls
|
||||
local config = extend_or_override({
|
||||
cmd = opts.full_cmd(opts),
|
||||
root_dir = require("jdtls.setup").find_root(root_markers),
|
||||
init_options = {
|
||||
bundles = bundles,
|
||||
},
|
||||
settings = opts.settings,
|
||||
-- enable CMP capabilities
|
||||
-- capabilities = require("user.lsp.handlers").capabilities or nil,
|
||||
capabilities = require("auto-lsp.lsp.handlers").capabilities or nil,
|
||||
}, opts.jdtls)
|
||||
|
||||
-- Existing server will be reused if the root_dir matches.
|
||||
require("jdtls").start_or_attach(config)
|
||||
-- not need to require("jdtls.setup").add_commands(), start automatically adds commands
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = java_filetypes,
|
||||
callback = attach_jdtls,
|
||||
})
|
||||
|
||||
-- Setup keymap and dap after the lsp is fully attached.
|
||||
-- https://github.com/mfussenegger/nvim-jdtls#nvim-dap-configuration
|
||||
-- https://neovim.io/doc/user/lsp.html#LspAttach
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client and client.name == "jdtls" then
|
||||
local wk = require("which-key")
|
||||
wk.add({
|
||||
{
|
||||
mode = "n",
|
||||
buffer = args.buf,
|
||||
{ "<leader>cx", group = "extract" },
|
||||
{ "<leader>cxv", require("jdtls").extract_variable_all, desc = "Extract Variable" },
|
||||
{ "<leader>cxc", require("jdtls").extract_constant, desc = "Extract Constant" },
|
||||
{ "gs", require("jdtls").super_implementation, desc = "Goto Super" },
|
||||
{ "<leader>co", require("jdtls").organize_imports, desc = "Organize Imports" },
|
||||
},
|
||||
})
|
||||
wk.add({
|
||||
{
|
||||
mode = "v",
|
||||
buffer = args.buf,
|
||||
{ "<leader>cx", group = "extract" },
|
||||
{
|
||||
"<leader>cxm",
|
||||
[[<ESC><CMD>lua require('jdtls').extract_method(true)<CR>]],
|
||||
desc = "Extract Method",
|
||||
},
|
||||
{
|
||||
"<leader>cxv",
|
||||
[[<ESC><CMD>lua require('jdtls').extract_variable_all(true)<CR>]],
|
||||
desc = "Extract Variable",
|
||||
},
|
||||
{
|
||||
"<leader>cxc",
|
||||
[[<ESC><CMD>lua require('jdtls').extract_constant(true)<CR>]],
|
||||
desc = "Extract Constant",
|
||||
},
|
||||
},
|
||||
})
|
||||
if opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main)
|
||||
|
||||
-- Java Test require Java debugger to work
|
||||
-- if opts.test and mason_registry.is_installed("java-test") then
|
||||
-- -- custom keymaps for Java test runner (not yet compatible with neotest)
|
||||
-- wk.register({
|
||||
-- ["<leader>t"] = { name = "+test" },
|
||||
-- ["<leader>tt"] = { require("jdtls.dap").test_class, "Run All Test" },
|
||||
-- ["<leader>tr"] = { require("jdtls.dap").test_nearest_method, "Run Nearest Test" },
|
||||
-- ["<leader>tT"] = { require("jdtls.dap").pick_test, "Run Test" },
|
||||
-- }, { mode = "n", buffer = args.buf })
|
||||
-- end
|
||||
end
|
||||
|
||||
-- User can set additional keymaps in opts.on_attach
|
||||
if opts.on_attach then
|
||||
opts.on_attach(args)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Avoid race condition by calling attach the first time, since the autocmd won't fire.
|
||||
attach_jdtls()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "java" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "jdtls" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"pojokcodeid/auto-conform.nvim",
|
||||
"pojokcodeid/auto-java-project.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
vim.list_extend(opts.ensure_installed, { "java-debug-adapter", "java-test" })
|
||||
opts.formatters_by_ft.java = { "lsp_fmt" }
|
||||
config = function()
|
||||
require("auto-java-project").setup()
|
||||
vim.keymap.set("n", "<leader>Jc", ":CreateJavaClass<cr>", { desc = "Create Java Class" })
|
||||
vim.keymap.set("n", "<leader>Jm", ":CreateJavaMainClass<cr>", { desc = "Create Java Main Class" })
|
||||
vim.keymap.set("n", "<leader>Ji", ":CreateJavaInterface<cr>", { desc = "Create Java Interface" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-jdtls",
|
||||
dependencies = { "pojokcodeid/auto-jdtls.nvim" },
|
||||
ft = { "java" },
|
||||
-- your opts go here
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
require("auto-jdtls").setup(opts)
|
||||
require("auto-jdtls.utils").lsp_keymaps()
|
||||
require("auto-jdtls.utils").jdtls_keymaps()
|
||||
vim.keymap.set("n", "<leader>rM", ":RunMvnSpringBoot<CR>", { desc = "Run Maven Sping Boot" })
|
||||
vim.keymap.set("n", "<leader>rG", ":RunGradleSpringBoot<CR>", { desc = "Run Gradle Sping Boot" })
|
||||
vim.keymap.set("n", "<leader>rm", ":RunMaven<CR>", { desc = "Run Maven Project" })
|
||||
vim.keymap.set("n", "<leader>rg", ":RunGradle<CR>", { desc = "Run Gradle Project" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
@ -229,23 +42,12 @@ M = {
|
|||
"nvim-treesitter/nvim-treesitter",
|
||||
"andy-bell101/neotest-java",
|
||||
},
|
||||
-- enabled = vim.fn.findfile("build.gradle", vim.fn.getcwd()) == "build.gradle" or false,
|
||||
config = function()
|
||||
require("auto-jdtls.create_maven_project")
|
||||
require("neotest").setup({
|
||||
adapters = {
|
||||
require("neotest-java")({
|
||||
-- function to determine which runner to use based on project path
|
||||
determine_runner = function(project_root_path)
|
||||
-- return should be "maven" or "gradle"
|
||||
return "gradle"
|
||||
end,
|
||||
-- override the builtin runner discovery behaviour to always use given
|
||||
-- tool. Default is "nil", so no override
|
||||
force_runner = nil,
|
||||
-- if the automatic runner discovery can't uniquely determine whether
|
||||
-- to use Gradle or Maven, fallback to using this runner. Default is
|
||||
-- "gradle or maven"
|
||||
fallback_runner = "gradle",
|
||||
}),
|
||||
require("neotest-java"),
|
||||
},
|
||||
})
|
||||
end,
|
||||
|
@ -260,48 +62,48 @@ M = {
|
|||
{ "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
|
||||
{ "<Leader>TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
|
||||
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" },
|
||||
{ "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle", mode = "n" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"rockerBOO/symbols-outline.nvim",
|
||||
cmd = "SymbolsOutline",
|
||||
config = function()
|
||||
local icons = require("pcode.user.icons").kind
|
||||
require("symbols-outline").setup({
|
||||
symbols = {
|
||||
File = { icon = "", hl = "@text.uri" },
|
||||
Module = { icon = "", hl = "@namespace" },
|
||||
Namespace = { icon = "", hl = "@namespace" },
|
||||
Package = { icon = "", hl = "@namespace" },
|
||||
Class = { icon = "𝓒", hl = "@type" },
|
||||
Method = { icon = "ƒ", hl = "@method" },
|
||||
Property = { icon = "", hl = "@method" },
|
||||
Field = { icon = "", hl = "@field" },
|
||||
Constructor = { icon = "", hl = "@constructor" },
|
||||
Enum = { icon = "ℰ", hl = "@type" },
|
||||
Interface = { icon = "", hl = "@type" },
|
||||
Function = { icon = "", hl = "@function" },
|
||||
Variable = { icon = "", hl = "@constant" },
|
||||
Constant = { icon = "", hl = "@constant" },
|
||||
String = { icon = "𝓐", hl = "@string" },
|
||||
Number = { icon = "#", hl = "@number" },
|
||||
Boolean = { icon = " ", hl = "@boolean" },
|
||||
Array = { icon = "", hl = "@constant" },
|
||||
Object = { icon = "⦿", hl = "@type" },
|
||||
Key = { icon = "🔐", hl = "@type" },
|
||||
Null = { icon = "NULL", hl = "@type" },
|
||||
EnumMember = { icon = "", hl = "@field" },
|
||||
Struct = { icon = "𝓢", hl = "@type" },
|
||||
Event = { icon = "🗲", hl = "@type" },
|
||||
Operator = { icon = "+", hl = "@operator" },
|
||||
TypeParameter = { icon = "𝙏", hl = "@parameter" },
|
||||
Component = { icon = "", hl = "@function" },
|
||||
Fragment = { icon = "", hl = "@constant" },
|
||||
File = { icon = icons.File, hl = "@text.uri" },
|
||||
Module = { icon = icons.Module, hl = "@namespace" },
|
||||
Namespace = { icon = icons.Namespace, hl = "@namespace" },
|
||||
Package = { icon = icons.Package, hl = "@namespace" },
|
||||
Class = { icon = icons.Class, hl = "@type" },
|
||||
Method = { icon = icons.Method, hl = "@method" },
|
||||
Property = { icon = icons.Property, hl = "@method" },
|
||||
Field = { icon = icons.Field, hl = "@field" },
|
||||
Constructor = { icon = icons.Constructor, hl = "@constructor" },
|
||||
Enum = { icon = icons.Enum, hl = "@type" },
|
||||
Interface = { icon = icons.Interface, hl = "@type" },
|
||||
Function = { icon = icons.Function, hl = "@function" },
|
||||
Variable = { icon = icons.Variable, hl = "@constant" },
|
||||
Constant = { icon = icons.Constant, hl = "@constant" },
|
||||
String = { icon = icons.String, hl = "@string" },
|
||||
Number = { icon = icons.Number, hl = "@number" },
|
||||
Boolean = { icon = icons.Boolean, hl = "@boolean" },
|
||||
Array = { icon = icons.Array, hl = "@constant" },
|
||||
Object = { icon = icons.Object, hl = "@type" },
|
||||
Key = { icon = icons.Key, hl = "@type" },
|
||||
Null = { icon = icons.Null, hl = "@type" },
|
||||
EnumMember = { icon = icons.EnumMember, hl = "@field" },
|
||||
Struct = { icon = icons.Struct, hl = "@type" },
|
||||
Event = { icon = icons.Event, hl = "@type" },
|
||||
Operator = { icon = icons.Operator, hl = "@operator" },
|
||||
TypeParameter = { icon = icons.TypeParameter, hl = "@parameter" },
|
||||
Component = { icon = icons.Component, hl = "@function" },
|
||||
Fragment = { icon = icons.Fragment, hl = "@constant" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>S", "<cmd>SymbolsOutline<cr>", desc = "Toggle Outline" },
|
||||
{ "<leader>Js", "<cmd>SymbolsOutline<cr>", desc = "Toggle Outline" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
47
lua/pcode/plugins/lang/java2.lua
Normal file
47
lua/pcode/plugins/lang/java2.lua
Normal file
|
@ -0,0 +1,47 @@
|
|||
return {
|
||||
"nvim-java/nvim-java",
|
||||
-- event = "VeryLazy",
|
||||
ft = { "java" },
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
"mfussenegger/nvim-dap",
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("java").setup({
|
||||
notifications = {
|
||||
dap = false,
|
||||
},
|
||||
jdk = {
|
||||
auto_install = false,
|
||||
},
|
||||
})
|
||||
require("lspconfig").jdtls.setup({
|
||||
settings = {
|
||||
java = {
|
||||
configuration = {
|
||||
runtimes = {
|
||||
{
|
||||
name = "JavaSE-17",
|
||||
path = os.getenv("JAVA_HOME") or "",
|
||||
default = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>rg", "", desc = "Gradle" },
|
||||
{ "<leader>rgp", "<cmd>JavaProfile<cr>", desc = "Java Profile" },
|
||||
{ "<leader>rgg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle" },
|
||||
{ "<leader>rgb", "<cmd>JavaBuildBuildWorkspace<cr>", desc = "Java Build Workspace" },
|
||||
{ "<leader>rgd", "<cmd>JavaDapConfig<cr>", desc = "Java Configure DAP" },
|
||||
{ "<leader>T", "", desc = "Test" },
|
||||
{ "<leader>Tc", "<cmd>JavaTestRunCurrentClass<cr>", desc = "Test Current Class" },
|
||||
{ "<leader>Tm", "<cmd>JavaTestRunCurrentMethod<cr>", desc = "Test Current Method" },
|
||||
{ "<leader>Th", "<cmd>JavaTestViewLastReport<cr>", desc = "View Test Last Report" },
|
||||
},
|
||||
}
|
327
lua/pcode/plugins/lang/java3.lua
Normal file
327
lua/pcode/plugins/lang/java3.lua
Normal file
|
@ -0,0 +1,327 @@
|
|||
local M = {}
|
||||
local java_filetypes = { "java" }
|
||||
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
|
||||
|
||||
-- Utility function to extend or override a config table, similar to the way
|
||||
-- that Plugin.opts works.
|
||||
---@param config table
|
||||
---@param custom function | table | nil
|
||||
local function extend_or_override(config, custom, ...)
|
||||
if type(custom) == "function" then
|
||||
config = custom(config, ...) or config
|
||||
elseif custom then
|
||||
config = vim.tbl_deep_extend("force", config, custom) --[[@as table]]
|
||||
end
|
||||
return config
|
||||
end
|
||||
|
||||
local function capabilities()
|
||||
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
if status_ok then
|
||||
return cmp_nvim_lsp.default_capabilities()
|
||||
end
|
||||
|
||||
local CAPABILITIES = vim.lsp.protocol.make_client_capabilities()
|
||||
CAPABILITIES.textDocument.completion.completionItem.snippetSupport = true
|
||||
CAPABILITIES.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits",
|
||||
},
|
||||
}
|
||||
|
||||
return CAPABILITIES
|
||||
end
|
||||
|
||||
M = {
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
-- stylua: ignore
|
||||
opts = function(_, opts)
|
||||
opts.skip_config = opts.skip_config or {}
|
||||
vim.list_extend(opts.skip_config, { "jdtls" })
|
||||
-- Set vim motion for <Space> + l + h to show code documentation about the code the cursor is currently over if available
|
||||
vim.keymap.set("n", "<leader>lh", vim.lsp.buf.hover, { desc = "Code Hover Documentation" })
|
||||
-- Set vim motion for <Space> + l + d to go where the code/variable under the cursor was defined
|
||||
vim.keymap.set("n", "<leader>ld", vim.lsp.buf.definition, { desc = "Code Goto Definition" })
|
||||
-- Set vim motion for <Space> + l + a for display code action suggestions for code diagnostics in both normal and visual mode
|
||||
vim.keymap.set({ "n", "v" }, "<leader>la", vim.lsp.buf.code_action, { desc = "Code Actions" })
|
||||
-- Set vim motion for <Space> + l + r to display references to the code under the cursor
|
||||
vim.keymap.set("n", "<leader>lr", require("telescope.builtin").lsp_references, { desc = "Code Goto References" })
|
||||
-- Set vim motion for <Space> + l + i to display implementations to the code under the cursor
|
||||
vim.keymap.set("n", "<leader>li", require("telescope.builtin").lsp_implementations, { desc = "Code Goto Implementations" })
|
||||
-- Set a vim motion for <Space> + l + <Shift>R to smartly rename the code under the cursor
|
||||
vim.keymap.set("n", "<leader>lR", vim.lsp.buf.rename, { desc = "Code Rename" })
|
||||
-- Set a vim motion for <Space> + l + <Shift>D to go to where the code/object was declared in the project (class file)
|
||||
vim.keymap.set("n", "<leader>lD", vim.lsp.buf.declaration, { desc = "Code Goto Declaration" })
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>l", "", desc = "LSP", mode = { "n", "v" } },
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-jdtls",
|
||||
ft = java_filetypes,
|
||||
enabled = true,
|
||||
opts = function()
|
||||
return {
|
||||
root_dir = require("jdtls.setup").find_root(root_markers),
|
||||
project_name = function()
|
||||
return vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
end,
|
||||
|
||||
-- Where are the config and workspace dirs for a project?
|
||||
jdtls_config_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/config"
|
||||
end,
|
||||
jdtls_workspace_dir = function(project_name)
|
||||
return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/workspace"
|
||||
end,
|
||||
cmd = { vim.fn.exepath("jdtls") },
|
||||
full_cmd = function(opts)
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
local cmd = vim.deepcopy(opts.cmd)
|
||||
if project_name then
|
||||
vim.list_extend(cmd, {
|
||||
"-configuration",
|
||||
opts.jdtls_config_dir(project_name),
|
||||
"-data",
|
||||
opts.jdtls_workspace_dir(project_name),
|
||||
})
|
||||
end
|
||||
return cmd
|
||||
end,
|
||||
|
||||
-- These depend on nvim-dap, but can additionally be disabled by setting false here.
|
||||
dap = { hotcodereplace = "auto", config_overrides = {} },
|
||||
dap_main = {},
|
||||
test = true,
|
||||
settings = {
|
||||
java = {
|
||||
inlayHints = {
|
||||
parameterNames = {
|
||||
enabled = "all",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
local opt = vim.opt
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.softtabstop = 4
|
||||
opt.ts = 4
|
||||
opt.expandtab = true
|
||||
|
||||
local mason_registry = require("mason-registry")
|
||||
local bundles = {} ---@type string[]
|
||||
if opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
local java_dbg_pkg = mason_registry.get_package("java-debug-adapter")
|
||||
local java_dbg_path = java_dbg_pkg:get_install_path()
|
||||
local jar_patterns = {
|
||||
java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||
}
|
||||
-- java-test also depends on java-debug-adapter.
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
local java_test_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
vim.list_extend(jar_patterns, {
|
||||
java_test_path .. "/extension/server/*.jar",
|
||||
})
|
||||
end
|
||||
for _, jar_pattern in ipairs(jar_patterns) do
|
||||
for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do
|
||||
table.insert(bundles, bundle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function attach_jdtls()
|
||||
-- Configuration can be augmented and overridden by opts.jdtls
|
||||
local config = extend_or_override({
|
||||
cmd = opts.full_cmd(opts),
|
||||
root_dir = require("jdtls.setup").find_root(root_markers),
|
||||
init_options = {
|
||||
bundles = bundles,
|
||||
},
|
||||
settings = opts.settings,
|
||||
-- enable CMP capabilities
|
||||
-- capabilities = require("user.lsp.handlers").capabilities or nil,
|
||||
-- capabilities = require("auto-lsp.lsp.handlers").capabilities or nil,
|
||||
capabilities = capabilities() or nil,
|
||||
}, opts.jdtls)
|
||||
|
||||
-- Existing server will be reused if the root_dir matches.
|
||||
require("jdtls").start_or_attach(config)
|
||||
-- not need to require("jdtls.setup").add_commands(), start automatically adds commands
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = java_filetypes,
|
||||
callback = attach_jdtls,
|
||||
})
|
||||
|
||||
-- Setup keymap and dap after the lsp is fully attached.
|
||||
-- https://github.com/mfussenegger/nvim-jdtls#nvim-dap-configuration
|
||||
-- https://neovim.io/doc/user/lsp.html#LspAttach
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
-- stylua: ignore
|
||||
if client and client.name == "jdtls" then
|
||||
-- add keymaps
|
||||
vim.keymap.set('n', '<leader>J', "", { desc = "Java" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + o to organize imports in normal mode
|
||||
vim.keymap.set('n', '<leader>Jo', "<Cmd> lua require('jdtls').organize_imports()<CR>", { desc = "Java Organize Imports" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + v to extract the code under the cursor to a variable
|
||||
vim.keymap.set('n', '<leader>Jv', "<Cmd> lua require('jdtls').extract_variable()<CR>", { desc = "Java Extract Variable" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + v to extract the code selected in visual mode to a variable
|
||||
vim.keymap.set('v', '<leader>Jv', "<Esc><Cmd> lua require('jdtls').extract_variable(true)<CR>", { desc = "Java Extract Variable" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + <Shift>C to extract the code under the cursor to a static variable
|
||||
vim.keymap.set('n', '<leader>JC', "<Cmd> lua require('jdtls').extract_constant()<CR>", { desc = "Java Extract Constant" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + <Shift>C to extract the code selected in visual mode to a static variable
|
||||
vim.keymap.set('v', '<leader>JC', "<Esc><Cmd> lua require('jdtls').extract_constant(true)<CR>", { desc = "Java Extract Constant" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + t to run the test method currently under the cursor
|
||||
vim.keymap.set('n', '<leader>Jt', "<Cmd> lua require('jdtls').test_nearest_method()<CR>", { desc = "Java Test Method" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + t to run the test method that is currently selected in visual mode
|
||||
vim.keymap.set('v', '<leader>Jt', "<Esc><Cmd> lua require('jdtls').test_nearest_method(true)<CR>", { desc = "Java Test Method" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + <Shift>T to run an entire test suite (class)
|
||||
vim.keymap.set('n', '<leader>JT', "<Cmd> lua require('jdtls').test_class()<CR>", { desc = "Java Test Class" })
|
||||
-- Set a Vim motion to <Space> + <Shift>J + u to update the project configuration
|
||||
vim.keymap.set('n', '<leader>Ju', "<Cmd> JdtUpdateConfig<CR>", { desc = "Java Update Config" })
|
||||
if opts.dap and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main)
|
||||
end
|
||||
|
||||
-- User can set additional keymaps in opts.on_attach
|
||||
if opts.on_attach then
|
||||
opts.on_attach(args)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Avoid race condition by calling attach the first time, since the autocmd won't fire.
|
||||
attach_jdtls()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "java" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "jdtls" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"pojokcodeid/auto-conform.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
vim.list_extend(opts.ensure_installed, { "java-debug-adapter", "java-test" })
|
||||
opts.formatters_by_ft.java = { "lsp_fmt" }
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
"nvim-neotest/nvim-nio",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"antoinemadec/FixCursorHold.nvim",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"andy-bell101/neotest-java",
|
||||
},
|
||||
config = function()
|
||||
local project_type = "maven"
|
||||
local gradle_file = vim.fn.findfile("build.gradle", vim.fn.getcwd())
|
||||
if gradle_file then
|
||||
project_type = "gradle"
|
||||
end
|
||||
|
||||
require("neotest").setup({
|
||||
adapters = {
|
||||
require("neotest-java")({
|
||||
-- function to determine which runner to use based on project path
|
||||
determine_runner = function(project_root_path)
|
||||
-- return should be "maven" or "gradle"
|
||||
return project_type
|
||||
end,
|
||||
-- override the builtin runner discovery behaviour to always use given
|
||||
-- tool. Default is "nil", so no override
|
||||
force_runner = nil,
|
||||
-- if the automatic runner discovery can't uniquely determine whether
|
||||
-- to use Gradle or Maven, fallback to using this runner. Default is
|
||||
-- "gradle or maven"
|
||||
fallback_runner = project_type,
|
||||
}),
|
||||
},
|
||||
})
|
||||
end,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>T","",desc=" Test"},
|
||||
{ "<leader>Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
|
||||
{ "<leader>Tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
|
||||
{ "<leader>TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
|
||||
{ "<leader>Tl", function() require("neotest").run.run_last() end, desc = "Run Last" },
|
||||
{ "<Leader>Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
|
||||
{ "<leader>To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
|
||||
{ "<Leader>TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
|
||||
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" },
|
||||
{ "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle", mode = "n" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"rockerBOO/symbols-outline.nvim",
|
||||
cmd = "SymbolsOutline",
|
||||
config = function()
|
||||
require("symbols-outline").setup({
|
||||
symbols = {
|
||||
File = { icon = "", hl = "@text.uri" },
|
||||
Module = { icon = "", hl = "@namespace" },
|
||||
Namespace = { icon = "", hl = "@namespace" },
|
||||
Package = { icon = "", hl = "@namespace" },
|
||||
Class = { icon = "𝓒", hl = "@type" },
|
||||
Method = { icon = "ƒ", hl = "@method" },
|
||||
Property = { icon = "", hl = "@method" },
|
||||
Field = { icon = "", hl = "@field" },
|
||||
Constructor = { icon = "", hl = "@constructor" },
|
||||
Enum = { icon = "ℰ", hl = "@type" },
|
||||
Interface = { icon = "", hl = "@type" },
|
||||
Function = { icon = "", hl = "@function" },
|
||||
Variable = { icon = "", hl = "@constant" },
|
||||
Constant = { icon = "", hl = "@constant" },
|
||||
String = { icon = "𝓐", hl = "@string" },
|
||||
Number = { icon = "#", hl = "@number" },
|
||||
Boolean = { icon = " ", hl = "@boolean" },
|
||||
Array = { icon = "", hl = "@constant" },
|
||||
Object = { icon = "⦿", hl = "@type" },
|
||||
Key = { icon = "🔐", hl = "@type" },
|
||||
Null = { icon = "NULL", hl = "@type" },
|
||||
EnumMember = { icon = "", hl = "@field" },
|
||||
Struct = { icon = "𝓢", hl = "@type" },
|
||||
Event = { icon = "🗲", hl = "@type" },
|
||||
Operator = { icon = "+", hl = "@operator" },
|
||||
TypeParameter = { icon = "𝙏", hl = "@parameter" },
|
||||
Component = { icon = "", hl = "@function" },
|
||||
Fragment = { icon = "", hl = "@constant" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>S", "<cmd>SymbolsOutline<cr>", desc = "Toggle Outline" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
32
lua/pcode/plugins/lang/java4.lua
Normal file
32
lua/pcode/plugins/lang/java4.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
return {
|
||||
"nvim-java/nvim-java",
|
||||
-- ft = { "java" },
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
"mfussenegger/nvim-dap",
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
opts = {
|
||||
notifications = {
|
||||
dap = false,
|
||||
},
|
||||
jdk = {
|
||||
auto_install = false,
|
||||
},
|
||||
|
||||
-- NOTE: One of these files must be in your project root directory.
|
||||
-- Otherwise the debugger will end in the wrong directory and fail.
|
||||
root_markers = {
|
||||
"settings.gradle",
|
||||
"settings.gradle.kts",
|
||||
"pom.xml",
|
||||
"build.gradle",
|
||||
"mvnw",
|
||||
"gradlew",
|
||||
"build.gradle",
|
||||
"build.gradle.kts",
|
||||
".git",
|
||||
},
|
||||
},
|
||||
}
|
|
@ -17,7 +17,7 @@ return {
|
|||
return math.floor(vim.o.lines * 0.75)
|
||||
end,
|
||||
max_width = function()
|
||||
return math.floor(vim.o.columns * 0.75)
|
||||
return math.floor(vim.o.columns * 0.4)
|
||||
end,
|
||||
render = "wrapped-compact",
|
||||
-- background_colour = "#00000000",
|
||||
|
|
|
@ -6,9 +6,24 @@ return {
|
|||
},
|
||||
opts = function(_, opts)
|
||||
local icons = require("pcode.user.icons")
|
||||
opts.disable_netrw = true
|
||||
opts.hijack_cursor = true
|
||||
opts.auto_reload_on_write = false
|
||||
opts.disable_netrw = false
|
||||
opts.hijack_cursor = false
|
||||
opts.hijack_netrw = true
|
||||
opts.hijack_unnamed_buffer_when_opening = false
|
||||
opts.sync_root_with_cwd = true
|
||||
opts.sort = {
|
||||
sorter = "name",
|
||||
folders_first = true,
|
||||
files_first = false,
|
||||
}
|
||||
opts.root_dirs = {}
|
||||
opts.prefer_startup_root = false
|
||||
opts.sync_root_with_cwd = true
|
||||
opts.reload_on_bufenter = false
|
||||
opts.respect_buf_cwd = false
|
||||
opts.on_attach = "default"
|
||||
opts.select_prompts = false
|
||||
opts.update_focused_file = {
|
||||
enable = true,
|
||||
update_root = false,
|
||||
|
@ -112,6 +127,44 @@ return {
|
|||
return opts
|
||||
end,
|
||||
config = function(_, opts)
|
||||
if pcode.nvimtree_float then
|
||||
-- set nvimtree float view (default left side)
|
||||
opts.view = {
|
||||
adaptive_size = false,
|
||||
centralize_selection = true,
|
||||
side = "left",
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
float = {
|
||||
enable = true,
|
||||
open_win_config = function()
|
||||
local screen_w = vim.opt.columns:get()
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get()
|
||||
local window_w = screen_w * 0.5
|
||||
local window_h = screen_h * 0.9
|
||||
local window_w_int = math.floor(window_w)
|
||||
local window_h_int = math.floor(window_h)
|
||||
local center_x = (screen_w - window_w) / 2
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get()
|
||||
return {
|
||||
border = "rounded",
|
||||
relative = "editor",
|
||||
row = center_y,
|
||||
col = center_x,
|
||||
width = window_w_int,
|
||||
height = window_h_int,
|
||||
}
|
||||
end,
|
||||
},
|
||||
width = function()
|
||||
return math.floor(vim.opt.columns:get() * 0.5)
|
||||
end,
|
||||
}
|
||||
end
|
||||
require("nvim-tree").setup(opts)
|
||||
local api = require("nvim-tree.api")
|
||||
api.events.subscribe(api.events.Event.FileCreated, function(file)
|
||||
|
|
|
@ -49,6 +49,7 @@ return {
|
|||
Normal = { fg = colors.text, bg = transparent and colors.none or colors.base },
|
||||
NormalNC = { fg = colors.text, bg = transparent and colors.none or colors.base },
|
||||
StatusLine = { fg = colors.text, bg = colors.none },
|
||||
MasonBackdrop = { link = "NormalFloat" },
|
||||
}
|
||||
end,
|
||||
highlight_overrides = {
|
||||
|
|
|
@ -50,6 +50,7 @@ return {
|
|||
LspReferenceWrite = { bg = "#3b4261" },
|
||||
WinBar = { bg = colors.bg },
|
||||
WinBarNC = { fg = colors.fg, bg = colors.bg },
|
||||
MasonBackdrop = { link = "NormalFloat" },
|
||||
},
|
||||
transparent_bg = false,
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ return {
|
|||
hi(0, "WinBar", { bg = color.background })
|
||||
hi(0, "WinBarNC", { bg = color.background })
|
||||
hi(0, "NormalFloat", { bg = color.background })
|
||||
hi(0, "TabLine", { bg = color.background })
|
||||
hi(0, "NormalNC", { bg = color.background })
|
||||
hi(0, "MasonBackdrop", { link = "NormalFloat" })
|
||||
hi(0, "@tag.delimiter.javascript", { fg = color.punctuation })
|
||||
hi(0, "@tag.delimiter.tsx", { fg = color.punctuation })
|
||||
-- git
|
||||
|
|
109
lua/pcode/plugins/theme/github.lua
Normal file
109
lua/pcode/plugins/theme/github.lua
Normal file
|
@ -0,0 +1,109 @@
|
|||
return {
|
||||
"projekt0n/github-nvim-theme",
|
||||
lazy = false, -- make sure we load this during startup if it is your main colorscheme
|
||||
priority = 1000, -- make sure to load this before all the other start plugins
|
||||
config = function()
|
||||
local is_transparent = false
|
||||
local palette = require("github-theme.palette").load(pcode.themes.github or "github_dark_dimmed")
|
||||
require("github-theme").setup({
|
||||
options = {
|
||||
-- Compiled file's destination location
|
||||
compile_path = vim.fn.stdpath("cache") .. "/github-theme",
|
||||
compile_file_suffix = "_compiled", -- Compiled file suffix
|
||||
hide_end_of_buffer = true, -- Hide the '~' character at the end of the buffer for a cleaner look
|
||||
hide_nc_statusline = true, -- Override the underline style for non-active statuslines
|
||||
transparent = is_transparent, -- Disable setting background
|
||||
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
|
||||
dim_inactive = false, -- Non focused panes set to alternative background
|
||||
module_default = true, -- Default enable value for modules
|
||||
styles = { -- Style to be applied to different syntax groups
|
||||
comments = "italic", -- Value is any valid attr-list value `:help attr-list`
|
||||
functions = "italic",
|
||||
keywords = "NONE",
|
||||
variables = "NONE",
|
||||
conditionals = "NONE",
|
||||
constants = "NONE",
|
||||
numbers = "NONE",
|
||||
operators = "NONE",
|
||||
strings = "NONE",
|
||||
types = "NONE",
|
||||
},
|
||||
inverse = { -- Inverse highlight for different types
|
||||
match_paren = false,
|
||||
visual = false,
|
||||
search = false,
|
||||
},
|
||||
darken = { -- Darken floating windows and sidebar-like windows
|
||||
floats = false,
|
||||
sidebars = {
|
||||
enable = true,
|
||||
list = {}, -- Apply dark background to specific windows
|
||||
},
|
||||
},
|
||||
modules = { -- List of various plugins and additional options
|
||||
-- ...
|
||||
},
|
||||
},
|
||||
palettes = {
|
||||
github_dark_dimmed = {
|
||||
bg0 = is_transparent and "NONE" or "bg1",
|
||||
bg1 = is_transparent and "NONE" or "bg",
|
||||
},
|
||||
},
|
||||
specs = {},
|
||||
groups = {
|
||||
all = {
|
||||
MasonBackdrop = { link = "NormalFloat" },
|
||||
illuminatedWord = { bg = "#3b4261" },
|
||||
illuminatedCurWord = { bg = "#3b4261" },
|
||||
IlluminatedWordText = { bg = "#3b4261" },
|
||||
IlluminatedWordRead = { bg = "#3b4261" },
|
||||
IlluminatedWordWrite = { bg = "#3b4261" },
|
||||
["@tag.attribute"] = { fg = "#77bdfb", style = "italic" },
|
||||
["@text.uri"] = { fg = palette.const, style = "italic" },
|
||||
["@keyword.return"] = { fg = "#fa7970", style = "italic" },
|
||||
-- ["@tag.attribute.html"] = { fg = "#faa356", style = "italic" },
|
||||
-- ["@operator.html"] = { fg = "#faa356" },
|
||||
-- ["@tag.html"] = { fg = "#fa7970" },
|
||||
-- ["@tag.delimiter.html"] = { fg = "#faa356" },
|
||||
-- ["@tag.javascript"] = { fg = "#faa356" },
|
||||
-- ["@tag.javascript"] = { fg = "#8ddb8c" },
|
||||
["@tag.builtin.javascript"] = { fg = "#8ddb8c" },
|
||||
-- ["@tag.tsx"] = { fg = "#8ddb8c" },
|
||||
["@string.special.url"] = { fg = palette.const, style = "italic" },
|
||||
["@tag.delimiter.javascript"] = { fg = "fg1" },
|
||||
["@tag.tsx"] = { fg = "#faa356" },
|
||||
["@lsp.type.parameter"] = { fg = "#91cbff" },
|
||||
["@property.lua"] = { fg = "#91cbff", bg = is_transparent and "NONE" or "bg1" },
|
||||
["@lsp.type.property.lua"] = { fg = "fg1", bg = is_transparent and "NONE" or "bg1" },
|
||||
["@lsp.type.variable.lua"] = { fg = "#91cbff", bg = is_transparent and "NONE" or "bg1" },
|
||||
-- sparator new all
|
||||
NvimTreeNormal = { fg = "fg1", bg = is_transparent and "NONE" or "bg1" },
|
||||
NvimTreeSpecialFile = { fg = "#faa356", style = "italic" },
|
||||
NvimTreeIndentMarker = { fg = "#3E4450" },
|
||||
BufferLineFill = { bg = is_transparent and "NONE" or "bg1" },
|
||||
BufferLineUnfocusedFill = { bg = is_transparent and "NONE" or "bg1" },
|
||||
LualineNormal = { bg = is_transparent and "NONE" or "bg1" },
|
||||
StatusLine = { bg = is_transparent and "NONE" or "bg1" },
|
||||
StatusLineTerm = { bg = is_transparent and "NONE" or "bg1" },
|
||||
Pmenu = { bg = is_transparent and "NONE" or "bg1" },
|
||||
PmenuSel = { link = "CursorLine" },
|
||||
WhichKeyFloat = { bg = is_transparent and "NONE" or "bg1" },
|
||||
LazyNormal = { bg = is_transparent and "NONE" or "bg1" },
|
||||
LazyBackground = { bg = is_transparent and "NONE" or "bg1" },
|
||||
NormalSB = { fg = "fg1", bg = is_transparent and "NONE" or "bg1" }, -- normal text
|
||||
NormalFloat = { fg = "fg1", bg = is_transparent and "NONE" or "bg1" },
|
||||
IblIndent = { fg = "#3E4450" },
|
||||
WinBar = { bg = is_transparent and "NONE" or "bg1" },
|
||||
WinBarNC = { bg = is_transparent and "NONE" or "bg1" },
|
||||
},
|
||||
github_dark_high_contrast = {
|
||||
NvimTreeSpecialFile = { fg = "#faa356", style = "italic" },
|
||||
},
|
||||
github_dark_dimmed = {
|
||||
-- As with specs and palettes, a specific style's value will be used over the `all`'s value.
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
29
lua/pcode/plugins/theme/gruvbox.lua
Normal file
29
lua/pcode/plugins/theme/gruvbox.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
return {
|
||||
"ellisonleao/gruvbox.nvim",
|
||||
priority = 1000,
|
||||
opts = function()
|
||||
local color = require("gruvbox").palette
|
||||
return {
|
||||
terminal_colors = true, -- add neovim terminal colors
|
||||
undercurl = false,
|
||||
underline = false,
|
||||
bold = false,
|
||||
contrast = "", -- can be "hard", "soft" or empty string
|
||||
palette_overrides = {},
|
||||
overrides = {
|
||||
["NormalFloat"] = { bg = "NONE" },
|
||||
["NormalNC"] = { bg = "NONE" },
|
||||
["MiniIndentscopeSymbol"] = { fg = color.bright_yellow },
|
||||
["StatusLine"] = { bg = "NONE" },
|
||||
["FoldColumn"] = { bg = "NONE" },
|
||||
["Folded"] = { bg = "NONE" },
|
||||
["SignColumn"] = { bg = "NONE" },
|
||||
["MasonBackdrop"] = { link = "NormalFloat" },
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
vim.o.background = "dark"
|
||||
require("gruvbox").setup(opts)
|
||||
end,
|
||||
}
|
|
@ -33,6 +33,7 @@ return {
|
|||
hi(0, "TelescopePromptNormal", { bg = colors.dark, fg = colors.grey })
|
||||
hi(0, "TelescopePromptPrefix", { bg = colors.dark, fg = colors.red })
|
||||
hi(0, "TelescopeResultsTitle", { bg = colors.olive_green, fg = colors.very_dark_gray })
|
||||
hi(0, "MasonBackdrop", { link = "NormalFloat" })
|
||||
end,
|
||||
})
|
||||
local colorscheme = pcode.themes.jetbrains or "darcula-dark"
|
||||
|
|
|
@ -116,6 +116,7 @@ return {
|
|||
NormalNC = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" },
|
||||
FloatBorder = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" },
|
||||
NonText = { bg = "NONE", fg = "#3E4450" },
|
||||
MasonBackdrop = { link = "NormalFloat" },
|
||||
},
|
||||
})
|
||||
local colorscheme = pcode.themes.onedarkpro or "onedark"
|
||||
|
|
|
@ -12,6 +12,7 @@ return {
|
|||
-- custom hilights
|
||||
local hi = vim.api.nvim_set_hl
|
||||
hi(0, "FoldColumn", { bg = colors.bg2 })
|
||||
hi(0, "MasonBackdrop", { link = "NormalFloat" })
|
||||
end,
|
||||
})
|
||||
end,
|
||||
|
|
|
@ -71,6 +71,7 @@ return {
|
|||
highlights["@tag.attribute"] = { fg = colors.green1, italic = true }
|
||||
-- highlights["@keyword.function"] = { fg = colors.blue, italic = true }
|
||||
-- highlights["@function"] = { fg = colors.blue, italic = true }
|
||||
highlights.MasonBackdrop = { link = "NormalFloat" }
|
||||
end,
|
||||
})
|
||||
end,
|
||||
|
|
|
@ -3,12 +3,12 @@ local api = vim.api
|
|||
-- General Settings
|
||||
api.nvim_create_augroup("_general_settings", { clear = true })
|
||||
|
||||
api.nvim_create_autocmd("TextYankPost", {
|
||||
group = "_general_settings",
|
||||
callback = function()
|
||||
require("vim.highlight").on_yank({ higroup = "Visual", timeout = 200 })
|
||||
end,
|
||||
})
|
||||
-- api.nvim_create_autocmd("TextYankPost", {
|
||||
-- group = "_general_settings",
|
||||
-- callback = function()
|
||||
-- require("vim.highlight").on_yank({ higroup = "Visual", timeout = 200 })
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
api.nvim_create_autocmd("FileType", {
|
||||
group = "_general_settings",
|
||||
|
@ -115,3 +115,243 @@ vim.api.nvim_create_autocmd("ExitPre", {
|
|||
command = "set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175,a:ver90",
|
||||
desc = "Set cursor back to beam when leaving Neovim.",
|
||||
})
|
||||
|
||||
-- Create an autocmd to set keymap for Java files
|
||||
-- vim.api.nvim_create_augroup("java_gradle_run", { clear = true })
|
||||
-- vim.api.nvim_create_autocmd("FileType", {
|
||||
-- pattern = "java",
|
||||
-- callback = function()
|
||||
-- vim.api.nvim_set_keymap("n", "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", { noremap = true, silent = true })
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Extras
|
||||
local function lsp_status()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr })
|
||||
or vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
|
||||
if #clients == 0 then
|
||||
print(" No LSP clients attached")
|
||||
return
|
||||
end
|
||||
|
||||
print(" LSP Status for buffer " .. bufnr .. ":")
|
||||
print("─────────────────────────────────")
|
||||
|
||||
for i, client in ipairs(clients) do
|
||||
print(string.format(" Client %d: %s (ID: %d)", i, client.name, client.id))
|
||||
print(" Root: " .. (client.config.root_dir or "N/A"))
|
||||
print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", "))
|
||||
|
||||
-- Check capabilities
|
||||
local caps = client.server_capabilities
|
||||
local features = {}
|
||||
if caps.completionProvider then
|
||||
table.insert(features, "completion")
|
||||
end
|
||||
if caps.hoverProvider then
|
||||
table.insert(features, "hover")
|
||||
end
|
||||
if caps.definitionProvider then
|
||||
table.insert(features, "definition")
|
||||
end
|
||||
if caps.referencesProvider then
|
||||
table.insert(features, "references")
|
||||
end
|
||||
if caps.renameProvider then
|
||||
table.insert(features, "rename")
|
||||
end
|
||||
if caps.codeActionProvider then
|
||||
table.insert(features, "code_action")
|
||||
end
|
||||
if caps.documentFormattingProvider then
|
||||
table.insert(features, "formatting")
|
||||
end
|
||||
|
||||
print(" Features: " .. table.concat(features, ", "))
|
||||
print("")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LspStatus", lsp_status, { desc = "Show detailed LSP status" })
|
||||
|
||||
local function check_lsp_capabilities()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr })
|
||||
or vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
|
||||
if #clients == 0 then
|
||||
print("No LSP clients attached")
|
||||
return
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
print("Capabilities for " .. client.name .. ":")
|
||||
local caps = client.server_capabilities
|
||||
|
||||
local capability_list = {
|
||||
{ "Completion", caps.completionProvider },
|
||||
{ "Hover", caps.hoverProvider },
|
||||
{ "Signature Help", caps.signatureHelpProvider },
|
||||
{ "Go to Definition", caps.definitionProvider },
|
||||
{ "Go to Declaration", caps.declarationProvider },
|
||||
{ "Go to Implementation", caps.implementationProvider },
|
||||
{ "Go to Type Definition", caps.typeDefinitionProvider },
|
||||
{ "Find References", caps.referencesProvider },
|
||||
{ "Document Highlight", caps.documentHighlightProvider },
|
||||
{ "Document Symbol", caps.documentSymbolProvider },
|
||||
{ "Workspace Symbol", caps.workspaceSymbolProvider },
|
||||
{ "Code Action", caps.codeActionProvider },
|
||||
{ "Code Lens", caps.codeLensProvider },
|
||||
{ "Document Formatting", caps.documentFormattingProvider },
|
||||
{ "Document Range Formatting", caps.documentRangeFormattingProvider },
|
||||
{ "Rename", caps.renameProvider },
|
||||
{ "Folding Range", caps.foldingRangeProvider },
|
||||
{ "Selection Range", caps.selectionRangeProvider },
|
||||
}
|
||||
|
||||
for _, cap in ipairs(capability_list) do
|
||||
local status = cap[2] and "✓" or "✗"
|
||||
print(string.format(" %s %s", status, cap[1]))
|
||||
end
|
||||
print("")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LspCapabilities", check_lsp_capabilities, { desc = "Show LSP capabilities" })
|
||||
|
||||
local function lsp_diagnostics_info()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diagnostics = vim.diagnostic.get(bufnr)
|
||||
|
||||
local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 }
|
||||
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
local severity = vim.diagnostic.severity[diagnostic.severity]
|
||||
counts[severity] = counts[severity] + 1
|
||||
end
|
||||
|
||||
print(" Diagnostics for current buffer:")
|
||||
print(" Errors: " .. counts.ERROR)
|
||||
print(" Warnings: " .. counts.WARN)
|
||||
print(" Info: " .. counts.INFO)
|
||||
print(" Hints: " .. counts.HINT)
|
||||
print(" Total: " .. #diagnostics)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LspDiagnostics", lsp_diagnostics_info, { desc = "Show LSP diagnostics count" })
|
||||
|
||||
local function lsp_info()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr })
|
||||
or vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
|
||||
print("═══════════════════════════════════")
|
||||
print(" LSP INFORMATION ")
|
||||
print("═══════════════════════════════════")
|
||||
print("")
|
||||
|
||||
-- Basic info
|
||||
print(" Language client log: " .. vim.lsp.get_log_path())
|
||||
print(" Detected filetype: " .. vim.bo.filetype)
|
||||
print(" Buffer: " .. bufnr)
|
||||
print(" Root directory: " .. (vim.fn.getcwd() or "N/A"))
|
||||
print("")
|
||||
|
||||
if #clients == 0 then
|
||||
print(" No LSP clients attached to buffer " .. bufnr)
|
||||
print("")
|
||||
print("Possible reasons:")
|
||||
print(" • No language server installed for " .. vim.bo.filetype)
|
||||
print(" • Language server not configured")
|
||||
print(" • Not in a project root directory")
|
||||
print(" • File type not recognized")
|
||||
return
|
||||
end
|
||||
|
||||
print(" LSP clients attached to buffer " .. bufnr .. ":")
|
||||
print("─────────────────────────────────")
|
||||
|
||||
for i, client in ipairs(clients) do
|
||||
print(string.format(" Client %d: %s", i, client.name))
|
||||
print(" ID: " .. client.id)
|
||||
print(" Root dir: " .. (client.config.root_dir or "Not set"))
|
||||
print(" Command: " .. table.concat(client.config.cmd or {}, " "))
|
||||
print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", "))
|
||||
|
||||
-- Server status
|
||||
if client.is_stopped() then
|
||||
print(" Status: Stopped")
|
||||
else
|
||||
print(" Status: Running")
|
||||
end
|
||||
|
||||
-- Workspace folders
|
||||
if client.workspace_folders and #client.workspace_folders > 0 then
|
||||
print(" Workspace folders:")
|
||||
for _, folder in ipairs(client.workspace_folders) do
|
||||
print(" • " .. folder.name)
|
||||
end
|
||||
end
|
||||
|
||||
-- Attached buffers count
|
||||
local attached_buffers = {}
|
||||
for buf, _ in pairs(client.attached_buffers or {}) do
|
||||
table.insert(attached_buffers, buf)
|
||||
end
|
||||
print(" Attached buffers: " .. #attached_buffers)
|
||||
|
||||
-- Key capabilities
|
||||
local caps = client.server_capabilities
|
||||
local key_features = {}
|
||||
if caps.completionProvider then
|
||||
table.insert(key_features, "completion")
|
||||
end
|
||||
if caps.hoverProvider then
|
||||
table.insert(key_features, "hover")
|
||||
end
|
||||
if caps.definitionProvider then
|
||||
table.insert(key_features, "definition")
|
||||
end
|
||||
if caps.documentFormattingProvider then
|
||||
table.insert(key_features, "formatting")
|
||||
end
|
||||
if caps.codeActionProvider then
|
||||
table.insert(key_features, "code_action")
|
||||
end
|
||||
|
||||
if #key_features > 0 then
|
||||
print(" Key features: " .. table.concat(key_features, ", "))
|
||||
end
|
||||
|
||||
print("")
|
||||
end
|
||||
|
||||
-- Diagnostics summary
|
||||
local diagnostics = vim.diagnostic.get(bufnr)
|
||||
if #diagnostics > 0 then
|
||||
print(" Diagnostics Summary:")
|
||||
local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 }
|
||||
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
local severity = vim.diagnostic.severity[diagnostic.severity]
|
||||
counts[severity] = counts[severity] + 1
|
||||
end
|
||||
|
||||
print(" Errors: " .. counts.ERROR)
|
||||
print(" Warnings: " .. counts.WARN)
|
||||
print(" Info: " .. counts.INFO)
|
||||
print(" Hints: " .. counts.HINT)
|
||||
print(" Total: " .. #diagnostics)
|
||||
else
|
||||
print(" No diagnostics")
|
||||
end
|
||||
|
||||
print("")
|
||||
print("Use :LspLog to view detailed logs")
|
||||
print("Use :LspCapabilities for full capability list")
|
||||
end
|
||||
|
||||
-- Create command
|
||||
vim.api.nvim_create_user_command("LspInfo2", lsp_info, { desc = "Show comprehensive LSP information" })
|
||||
|
|
|
@ -46,8 +46,24 @@ return {
|
|||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
opts = function(_, opts)
|
||||
vim.list_extend(opts.skip_config, { "jdtls" })
|
||||
opts.virtual_text = true
|
||||
vim.list_extend(opts.skip_config, {})
|
||||
opts.virtual_text = false
|
||||
vim.diagnostic.config({ virtual_lines = { current_line = true } })
|
||||
-- sample custom diagnostic icon
|
||||
vim.diagnostic.config({
|
||||
underline = false,
|
||||
virtual_text = false,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = " ",
|
||||
[vim.diagnostic.severity.WARN] = " ",
|
||||
[vim.diagnostic.severity.HINT] = " ",
|
||||
[vim.diagnostic.severity.INFO] = " ",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
-- add whichkey mappings
|
||||
|
|
|
@ -4,12 +4,15 @@ pcode.lang = {
|
|||
cpp = false,
|
||||
sql = false,
|
||||
deno = false,
|
||||
golang = false,
|
||||
golang = true,
|
||||
java = false,
|
||||
java2 = false,
|
||||
java3 = false,
|
||||
java4 = false,
|
||||
javascript = false,
|
||||
kotlin = false,
|
||||
markdown = false,
|
||||
php = true,
|
||||
php = false,
|
||||
prisma = false,
|
||||
python = false,
|
||||
rust = false,
|
||||
|
@ -24,12 +27,12 @@ pcode.extras = {
|
|||
minianimate = false,
|
||||
neoscroll = false,
|
||||
nvimufo = false,
|
||||
refactoring = true,
|
||||
refactoring = false,
|
||||
rest = false,
|
||||
treesittercontex = false,
|
||||
codeium = true,
|
||||
colorizer = true,
|
||||
dap = true,
|
||||
dap = false,
|
||||
deviconcolor = true,
|
||||
illuminate = true,
|
||||
indentscupe = true,
|
||||
|
@ -41,14 +44,20 @@ pcode.extras = {
|
|||
verticalcolumn = true,
|
||||
visualmulti = true,
|
||||
yanky = true,
|
||||
zenmode = true,
|
||||
zenmode = false,
|
||||
lspsignatur = false,
|
||||
telescopetreesiterinfo = true,
|
||||
fidget = false,
|
||||
tinydignostic = false,
|
||||
dressing = true,
|
||||
telescopediff = true,
|
||||
}
|
||||
-- activate config themes
|
||||
pcode.themes = {
|
||||
-- note: open remark only one
|
||||
-- **:: Eva Theme ::** --
|
||||
-- evatheme = "Eva-Dark",
|
||||
evatheme = "Eva-Dark-Italic",
|
||||
evatheme = "Eva-Dark",
|
||||
-- evatheme = "Eva-Dark-Italic",
|
||||
-- evatheme = "Eva-Dark-Bold",
|
||||
-- evatheme = "Eva-Light",
|
||||
--
|
||||
|
@ -79,8 +88,15 @@ pcode.themes = {
|
|||
-- catppuccin = "catppuccin-frappe",
|
||||
-- catppuccin = "catppuccin-macchiato",
|
||||
-- catppuccin = "catppuccin-macchiato",
|
||||
--
|
||||
-- **:: Gruvbox Theme ::** --
|
||||
-- gruvbox = "gruvbox",
|
||||
--
|
||||
-- **:: Github Theme ::** --
|
||||
-- github = "github_dark_dimmed",
|
||||
}
|
||||
-- activate config transparent_bg
|
||||
pcode.transparent = false
|
||||
pcode.localcode = true
|
||||
pcode.snippets_path = vim.fn.stdpath("config") .. "/mysnippets"
|
||||
pcode.nvimtree_float = false
|
||||
|
|
|
@ -5,6 +5,7 @@ return {
|
|||
Codeium = "",
|
||||
Control = "",
|
||||
Collapsed = " ",
|
||||
Component = "",
|
||||
Copilot = "",
|
||||
CopilotOff = "",
|
||||
Folder = "",
|
||||
|
@ -27,6 +28,7 @@ return {
|
|||
Enum = "",
|
||||
Interface = "",
|
||||
Function = "",
|
||||
Fragment = "",
|
||||
Variable = "",
|
||||
Constant = "",
|
||||
String = "",
|
||||
|
|
3
lua/pcode/user/java.lua
Normal file
3
lua/pcode/user/java.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
require("auto-jdtls2.create_gradle_project")
|
||||
require("auto-jdtls2.create_maven_project")
|
||||
require("auto-jdtls2.create_springboot_project")
|
|
@ -91,3 +91,80 @@ keymap("n", "<A-l>", "<cmd>terminal live-server<cr>", opts)
|
|||
|
||||
-- close current buffer
|
||||
keymap("n", "<S-t>", "<cmd>lua require('auto-bufferline.configs.utils').bufremove()<cr>", opts)
|
||||
|
||||
-- vim.keymap.set("n", "<leader>ti", function()
|
||||
-- local api = vim.api
|
||||
-- local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
-- local parsers = vim.tbl_keys(parser_configs)
|
||||
-- table.sort(parsers)
|
||||
--
|
||||
-- local choices = {}
|
||||
-- local lookup = {}
|
||||
--
|
||||
-- for _, parser in ipairs(parsers) do
|
||||
-- local is_installed = #api.nvim_get_runtime_file("parser/" .. parser .. ".so", false) > 0
|
||||
--
|
||||
-- local label = (is_installed and "[✓] " or "[✗] ") .. parser
|
||||
-- table.insert(choices, label)
|
||||
-- lookup[label] = parser
|
||||
-- end
|
||||
--
|
||||
-- vim.ui.select(choices, {
|
||||
-- prompt = "Treesitter ([✓]= installed, [✗] = not installed)",
|
||||
-- }, function(choice)
|
||||
-- if choice then
|
||||
-- local parser_name = lookup[choice]
|
||||
-- if parser_name then
|
||||
-- vim.cmd("TSInstall " .. parser_name)
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- end, { desc = "Install Treesitter" })
|
||||
--
|
||||
-- vim.keymap.set("n", "<leader>tu", function()
|
||||
-- local parsers = require("nvim-treesitter.info").installed_parsers()
|
||||
-- table.sort(parsers)
|
||||
-- local choices = {}
|
||||
-- local lookup = {}
|
||||
--
|
||||
-- for _, parser in ipairs(parsers) do
|
||||
-- local label = "[✓] " .. parser
|
||||
-- table.insert(choices, label)
|
||||
-- lookup[label] = parser
|
||||
-- end
|
||||
--
|
||||
-- vim.ui.select(choices, {
|
||||
-- prompt = "Uninstall Treesitter",
|
||||
-- }, function(choice)
|
||||
-- if choice then
|
||||
-- local parser_name = lookup[choice]
|
||||
-- if parser_name then
|
||||
-- vim.cmd("TSUninstall " .. parser_name)
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- end, { desc = "Uninstall Treesitter" })
|
||||
|
||||
vim.api.nvim_create_user_command("TSIsInstalled", function()
|
||||
local parsers = require("nvim-treesitter.info").installed_parsers()
|
||||
table.sort(parsers)
|
||||
local choices = {}
|
||||
local lookup = {}
|
||||
|
||||
for _, parser in ipairs(parsers) do
|
||||
local label = "[✓] " .. parser
|
||||
table.insert(choices, label)
|
||||
lookup[label] = parser
|
||||
end
|
||||
|
||||
vim.ui.select(choices, {
|
||||
prompt = "Uninstall Treesitter",
|
||||
}, function(choice)
|
||||
if choice then
|
||||
local parser_name = lookup[choice]
|
||||
if parser_name then
|
||||
vim.cmd("TSUninstall " .. parser_name)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end, {})
|
||||
|
|
|
@ -61,7 +61,7 @@ vim.loader.enable()
|
|||
|
||||
-- Disable statusline in dashboard
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "dbout", "dbui", "http", "httpResult" },
|
||||
pattern = { "dbout", "dbui", "http", "httpResult", "checkhealth", "qf", "help", "lazy" },
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
opt.number = false -- Print line number
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue