diff --git a/lazy-lock.json b/lazy-lock.json index 725c65f..5eaf777 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,15 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "Eva-Theme.nvim": { "branch": "master", "commit": "80d9229ea010774610cec71921afc0defbbd3822" }, - "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, - "alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" }, + "Eva-Theme.nvim": { "branch": "master", "commit": "5e0ee05b7b803cbd781612d484b0796c45946a3d" }, + "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, + "LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" }, + "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, "auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, + "auto-java-project.nvim": { "branch": "main", "commit": "796bbee285c5eaed8784b8d91edd0ea5d25a3856" }, + "auto-jdtls.nvim": { "branch": "main", "commit": "050da8d68c51a6e02a08d91329b7a848887927e7" }, "auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" }, - "auto-lsp.nvim": { "branch": "main", "commit": "352e1a55a10026525f6b7489055b5fbe56d15703" }, + "auto-lsp.nvim": { "branch": "main", "commit": "1f3ef04741972c107187a07be5615ff210888184" }, "auto-lualine.nvim": { "branch": "main", "commit": "fc8557f61dc1da12a8b90167a49420958b991d8c" }, "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, "bufferline.nvim": { "branch": "main", "commit": "5cc447cb2b463cb499c82eaeabbed4f5fa6a0a44" }, @@ -18,52 +21,57 @@ "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" }, + "conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" }, + "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, - "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, + "gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" }, "inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" }, - "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, - "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, - "lualine.nvim": { "branch": "master", "commit": "640260d7c2d98779cab89b1e7088ab14ea354a02" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "indent-blankline.nvim": { "branch": "master", "commit": "7871a88056f7144defca9c931e311a3134c5d509" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "cab00668464d2914d0752b86168b4a431cc93eb2" }, "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" }, - "noice.nvim": { "branch": "main", "commit": "73d38cc939db6553b87e5f72ff732447046bced1" }, + "minty": { "branch": "main", "commit": "a3d69bd63fc98f640815f94b797bf978e9193022" }, + "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, + "neotest-java": { "branch": "main", "commit": "320f31c71b183f2c584198f33f93542fd0e5a768" }, + "noice.nvim": { "branch": "main", "commit": "221ffbc499d322699ea079fcd878a2399529e775" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, - "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-colorizer.lua": { "branch": "master", "commit": "f134063618a65cad4d7415fddbd96ff7e0c5b4ae" }, - "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, + "nvim-dap": { "branch": "master", "commit": "29d1f8814fa4fcc194ec574de998a42a22ebbe4a" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, + "nvim-jdtls": { "branch": "master", "commit": "c4279b8ffce9b64eb302056d78dfebc2968a49bc" }, "nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" }, - "nvim-lspconfig": { "branch": "master", "commit": "52302604e3c667cfdf33aadf89088e96eb3c5da3" }, + "nvim-lspconfig": { "branch": "master", "commit": "87c7c83ce62971e0bdb29bb32b8ad2b19c8f95d0" }, "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-tree.lua": { "branch": "master", "commit": "28eac2801b201f301449e976d7a9e8cfde053ba3" }, + "nvim-treesitter": { "branch": "master", "commit": "20e10ca6914f65cf1410232433fb58de70ab6b39" }, "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" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "f22496dfdd46da4d571f5254c72eff65ff5a1c27" }, "refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" }, - "smart-splits.nvim": { "branch": "master", "commit": "11600d75e1b57e9fe1f3ca880a917485fc399e8c" }, + "smart-splits.nvim": { "branch": "master", "commit": "ea4702652cb1d18811d60f2e206787602a2e946c" }, + "symbols-outline.nvim": { "branch": "master", "commit": "964c5902243446124417a3a9e9454f5ef032cc36" }, + "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "a39fa4c92268832f6034306793b8acbfec2a7549" }, - "toggleterm.nvim": { "branch": "main", "commit": "5969229c0352ff1ed7f6e24aba9c6554e1842939" }, + "toggleterm.nvim": { "branch": "main", "commit": "87b2d6a3cab8e2bd9a0255427074285f0365398d" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, - "virt-column.nvim": { "branch": "master", "commit": "b62b4ef0774d19452d4ed18e473e824c7a756f2f" }, - "volt": { "branch": "main", "commit": "ff954757fdaf72da0dedd77bdf74718ea846f989" }, + "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, + "volt": { "branch": "main", "commit": "2cf7e86f3bc7f41cbb6d0a8d0d84fc759c0dae86" }, "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" }, - "yanky.nvim": { "branch": "main", "commit": "73215b77d22ebb179cef98e7e1235825431d10e4" }, + "yanky.nvim": { "branch": "main", "commit": "f9b905994cccf3c55f41af3a0a1f4c76c844e411" }, "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } } diff --git a/lua/auto-jdtls2/create_gradle_project.lua b/lua/auto-jdtls2/create_gradle_project.lua new file mode 100644 index 0000000..1867635 --- /dev/null +++ b/lua/auto-jdtls2/create_gradle_project.lua @@ -0,0 +1,88 @@ +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 dari pengguna untuk menentukan direktori proyek + local project_dir, canceled = get_user_input("Enter project directory: ", vim.fn.getcwd()) + if canceled then + return + end + + -- Ambil input dari pengguna untuk Gradle + local project_name, canceled_name = get_user_input("Enter project name: ", "myjavaproject") + if canceled_name then + return + end + + project_dir = project_dir .. "\\" .. project_name + + -- 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") + + -- Ambil input package name + local package_name, canceled_package = get_user_input("Enter package name: ", "com.example." .. project_name) + if canceled_package then + return + end + + -- Format perintah Gradle berdasarkan input pengguna + local command = string.format( + "gradle init --type java-application --dsl groovy --project-name %s --package %s", + project_name, + package_name + ) + + -- Fungsi untuk menjalankan perintah Gradle dan menampilkan outputnya + local function run_gradle_command(cmd, dir, 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") + local main_class_path = string.format("%s/app/src/main/java/%s/App.java", dir, pkg:gsub("%.", "/")) + if vim.fn.filereadable(main_class_path) == 1 then + vim.cmd(":edit " .. main_class_path) + end + vim.cmd(":NvimTreeFindFileToggle") + end + end + + -- Jalankan perintah Gradle dan buka proyek + run_gradle_command(command, project_dir, package_name) +end + +vim.api.nvim_create_user_command("GradleNewProject", gradle_new_project, {}) diff --git a/lua/auto-jdtls2/create_maven_project.lua b/lua/auto-jdtls2/create_maven_project.lua new file mode 100644 index 0000000..bbfd05c --- /dev/null +++ b/lua/auto-jdtls2/create_maven_project.lua @@ -0,0 +1,113 @@ +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 + 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") + -- 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, canceled_artifact = get_user_input("Enter artifactId: ", "myproject") + if canceled_artifact then + return + end + 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") + 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, {}) diff --git a/lua/auto-jdtls2/create_springboot_project.lua b/lua/auto-jdtls2/create_springboot_project.lua new file mode 100644 index 0000000..42b4915 --- /dev/null +++ b/lua/auto-jdtls2/create_springboot_project.lua @@ -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") + end + + create_notif("Project created successfully!", "info") +end + +vim.api.nvim_create_user_command("SpringBootNewProject", springboot_new_project, {}) diff --git a/lua/auto-jdtls2/generate_java_class.lua b/lua/auto-jdtls2/generate_java_class.lua new file mode 100644 index 0000000..0a57941 --- /dev/null +++ b/lua/auto-jdtls2/generate_java_class.lua @@ -0,0 +1,115 @@ +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( + [[ +/* + * This Java source file. + */ +package %s; + +public class %s { + /** + * + */ + public %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 class created: " .. file_path, "info") +end + +vim.api.nvim_create_user_command("CreateJavaClass", create_java_class, {}) diff --git a/lua/auto-jdtls2/generate_java_interface.lua b/lua/auto-jdtls2/generate_java_interface.lua new file mode 100644 index 0000000..2e567d0 --- /dev/null +++ b/lua/auto-jdtls2/generate_java_interface.lua @@ -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, {}) diff --git a/lua/auto-jdtls2/generate_java_main_class.lua b/lua/auto-jdtls2/generate_java_main_class.lua new file mode 100644 index 0000000..cd8878a --- /dev/null +++ b/lua/auto-jdtls2/generate_java_main_class.lua @@ -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, {}) diff --git a/lua/auto-jdtls2/init.lua b/lua/auto-jdtls2/init.lua new file mode 100644 index 0000000..83cc941 --- /dev/null +++ b/lua/auto-jdtls2/init.lua @@ -0,0 +1,15 @@ +local M = {} + +M.setup = function(opt) + opt = opt or {} + require("auto-jdtls.utils").install() + require("auto-jdtls.create_gradle_project") + require("auto-jdtls.create_maven_project") + require("auto-jdtls.create_springboot_project") + require("auto-jdtls.generate_java_class") + require("auto-jdtls.generate_java_interface") + require("auto-jdtls.generate_java_main_class") + require("auto-jdtls.utils").attach_jdtls(opt) +end + +return M diff --git a/lua/auto-jdtls2/utils.lua b/lua/auto-jdtls2/utils.lua new file mode 100644 index 0000000..67c63e3 --- /dev/null +++ b/lua/auto-jdtls2/utils.lua @@ -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" }, "l", "", { desc = "LSP" }) + -- Set vim motion for + l + h to show code documentation about the code the cursor is currently over if available + vim.keymap.set("n", "lh", vim.lsp.buf.hover, { desc = "Code Hover Documentation" }) + -- Set vim motion for + l + d to go where the code/variable under the cursor was defined + vim.keymap.set("n", "ld", vim.lsp.buf.definition, { desc = "Code Goto Definition" }) + -- Set vim motion for + l + a for display code action suggestions for code diagnostics in both normal and visual mode + vim.keymap.set({ "n", "v" }, "la", vim.lsp.buf.code_action, { desc = "Code Actions" }) + -- Set vim motion for + l + r to display references to the code under the cursor + vim.keymap.set("n", "lr", require("telescope.builtin").lsp_references, { desc = "Code Goto References" }) + -- Set vim motion for + l + i to display implementations to the code under the cursor + vim.keymap.set("n", "li", require("telescope.builtin").lsp_implementations, { desc = "Code Goto Implementations" }) + -- Set a vim motion for + l + R to smartly rename the code under the cursor + vim.keymap.set("n", "lR", vim.lsp.buf.rename, { desc = "Code Rename" }) + -- Set a vim motion for + l + D to go to where the code/object was declared in the project (class file) + vim.keymap.set("n", "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', 'J', "", { desc = "Java" }) + -- Set a Vim motion to + J + o to organize imports in normal mode + vim.keymap.set('n', 'Jo', " lua require('jdtls').organize_imports()", { desc = "Java Organize Imports" }) + -- Set a Vim motion to + J + v to extract the code under the cursor to a variable + vim.keymap.set('n', 'Jv', " lua require('jdtls').extract_variable()", { desc = "Java Extract Variable" }) + -- Set a Vim motion to + J + v to extract the code selected in visual mode to a variable + vim.keymap.set('v', 'Jv', " lua require('jdtls').extract_variable(true)", { desc = "Java Extract Variable" }) + -- Set a Vim motion to + J + C to extract the code under the cursor to a static variable + vim.keymap.set('n', 'JC', " lua require('jdtls').extract_constant()", { desc = "Java Extract Constant" }) + -- Set a Vim motion to + J + C to extract the code selected in visual mode to a static variable + vim.keymap.set('v', 'JC', " lua require('jdtls').extract_constant(true)", { desc = "Java Extract Constant" }) + -- Set a Vim motion to + J + t to run the test method currently under the cursor + vim.keymap.set('n', 'Jt', " lua require('jdtls').test_nearest_method()", { desc = "Java Test Method" }) + -- Set a Vim motion to + J + t to run the test method that is currently selected in visual mode + vim.keymap.set('v', 'Jt', " lua require('jdtls').test_nearest_method(true)", { desc = "Java Test Method" }) + -- Set a Vim motion to + J + T to run an entire test suite (class) + vim.keymap.set('n', 'JT', " lua require('jdtls').test_class()", { desc = "Java Test Class" }) + -- Set a Vim motion to + J + u to update the project configuration + vim.keymap.set('n', 'Ju', " JdtUpdateConfig", { 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 diff --git a/lua/pcode/config/lazy_lib.lua b/lua/pcode/config/lazy_lib.lua index 985c124..ab355f9 100644 --- a/lua/pcode/config/lazy_lib.lua +++ b/lua/pcode/config/lazy_lib.lua @@ -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 diff --git a/lua/pcode/plugins/_lsp.lua b/lua/pcode/plugins/_lsp.lua index c2d85a4..1dc2e4e 100644 --- a/lua/pcode/plugins/_lsp.lua +++ b/lua/pcode/plugins/_lsp.lua @@ -1,111 +1,95 @@ return { - { - "williamboman/mason-lspconfig.nvim", - event = { "VeryLazy", "BufReadPre", "BufNewFile", "BufRead" }, - dependencies = { - { "pojokcodeid/auto-lsp.nvim", lazy = true }, - { - "neovim/nvim-lspconfig", - lazy = true, - cmd = { - "LspInfo", - "LspInstall", - "LspUninstall", - }, - config = function() - require("lspconfig.ui.windows").default_options.border = "rounded" - end, - }, - { - "williamboman/mason.nvim", - lazy = true, - build = ":MasonUpdate", - opts_extend = { "ensure_installed" }, - cmd = { - "Mason", - "MasonInstall", - "MasonUninstall", - "MasonUninstallAll", - "MasonLog", - }, - opts = function(_, opts) - local icons = require("pcode.user.icons").ui - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "stylua" }) - opts.ui = { - -- border = "none", - border = icons.Border, - icons = { - package_pending = icons.Pending, - package_installed = icons.CheckCircle, - package_uninstalled = icons.BlankCircle, - }, - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - }, - } - opts.log_level = vim.log.levels.INFO - opts.max_concurrent_installers = 4 - return opts - end, - config = function(_, opts) - require("mason").setup(opts) - 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) + { + "williamboman/mason-lspconfig.nvim", + event = { "VeryLazy", "BufReadPre", "BufNewFile", "BufRead" }, + dependencies = { + { "pojokcodeid/auto-lsp.nvim", lazy = true }, + { + "neovim/nvim-lspconfig", + lazy = true, + cmd = { + "LspInfo", + "LspInstall", + "LspUninstall", + }, + config = function() + require("lspconfig.ui.windows").default_options.border = "rounded" + end, + }, + { + "williamboman/mason.nvim", + lazy = true, + build = ":MasonUpdate", + opts_extend = { "ensure_installed" }, + cmd = { + "Mason", + "MasonInstall", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + }, + opts = function(_, opts) + local icons = require("pcode.user.icons").ui + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "stylua" }) + opts.ui = { + -- border = "none", + border = icons.Border, + icons = { + package_pending = icons.Pending, + package_installed = icons.CheckCircle, + package_uninstalled = icons.BlankCircle, + }, + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + }, + } + opts.log_level = vim.log.levels.INFO + opts.max_concurrent_installers = 4 + return opts + end, + config = function(_, opts) + require("mason").setup(opts) + 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(opts.ensure_installed) do - local p = mr.get_package(tool) - if not p:is_installed() then - p:install() - end - end - end) - end, - }, - }, - opts = function(_, opts) - opts.skip_config = opts.skip_config or {} - opts.ensure_installed = opts.ensure_installed or {} - opts.automatic_installation = true - vim.list_extend(opts.ensure_installed, { "lua_ls" }) - opts.format_on_save = true -- if use none-ls set true - opts.virtual_text = true - opts.timeout_ms = 5000 - return opts - end, - config = function(_, opts) - require("auto-lsp").setup(opts) - end, - -- stylua: ignore - keys = { - { "l", "", desc = "  LSP", mode = "n" }, - { "la", "lua vim.lsp.buf.code_action()", desc = "Code Action", mode = "n" }, - { "ld", "Telescope diagnostics bufnr=0", desc = "Document Diagnostics", mode = "n" }, - { "lw", "Telescope diagnostics", desc = "Workspace Diagnostics", mode = "n" }, - { "li", "LspInfo", desc = "Info", mode = "n" }, - { "lI", "Mason", desc = "Mason", mode = "n" }, - { "lj", "lua vim.lsp.diagnostic.goto_next()", desc = "Next Diagnostic", mode = "n" }, - { "lk", "lua vim.lsp.diagnostic.goto_prev()", desc = "Prev Diagnostic", mode = "n" }, - { "ll", "lua vim.lsp.codelens.run()", desc = "Code Lens Action", mode = "n" }, - { "lq", "lua vim.diagnostic.setloclist()", desc = "Quickfix", mode = "n" }, - { "lr", "lua vim.lsp.buf.rename()", desc = "Rename", mode = "n" }, - { "ls", "Telescope lsp_document_symbols", desc = "Document Symbols", mode = "n" }, - { "lS", "Telescope lsp_dynamic_workspace_symbols", desc = "Workspace Symbols", mode = "n"}, - }, - }, + mr.refresh(function() + for _, tool in ipairs(opts.ensure_installed) do + local p = mr.get_package(tool) + if not p:is_installed() then + p:install() + end + end + end) + end, + }, + }, + opts = function(_, opts) + opts.skip_config = opts.skip_config or {} + opts.ensure_installed = opts.ensure_installed or {} + opts.automatic_installation = true + vim.list_extend(opts.ensure_installed, { "lua_ls" }) + opts.format_on_save = true -- if use none-ls set true + opts.virtual_text = true + opts.timeout_ms = 5000 + return opts + end, + config = function(_, opts) + require("auto-lsp").setup(opts) + end, + }, } diff --git a/lua/pcode/plugins/extras/lspsignatur.lua b/lua/pcode/plugins/extras/lspsignatur.lua new file mode 100644 index 0000000..436e687 --- /dev/null +++ b/lua/pcode/plugins/extras/lspsignatur.lua @@ -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 uH to toggle inlay hints. + toggle_key_flip_floatwin_setting = is_enabled, + } + end, + config = function(_, opts) + require("lsp_signature").setup(opts) + end, +} diff --git a/lua/pcode/plugins/extras/navic.lua b/lua/pcode/plugins/extras/navic.lua index e65a5f0..eb1a1da 100644 --- a/lua/pcode/plugins/extras/navic.lua +++ b/lua/pcode/plugins/extras/navic.lua @@ -16,7 +16,7 @@ function M.config() require("nvim-navic").setup({ icons = icons, lsp = { - auto_attach = false, + auto_attach = true, preference = nil, }, highlight = false, diff --git a/lua/pcode/plugins/extras/telescopetreesiterinfo.lua b/lua/pcode/plugins/extras/telescopetreesiterinfo.lua new file mode 100644 index 0000000..487b930 --- /dev/null +++ b/lua/pcode/plugins/extras/telescopetreesiterinfo.lua @@ -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 = { + { "p", "Telescope treesitter_info", desc = "Treesitter Info" }, + }, +} diff --git a/lua/pcode/plugins/lang/java.lua b/lua/pcode/plugins/lang/java.lua index 5f4fdd1..aaba41c 100644 --- a/lua/pcode/plugins/lang/java.lua +++ b/lua/pcode/plugins/lang/java.lua @@ -1,254 +1,56 @@ 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", - opts = function(_, opts) - opts.skip_config = opts.skip_config or {} - vim.list_extend(opts.skip_config, { "jdtls" }) - 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, - { "cx", group = "extract" }, - { "cxv", require("jdtls").extract_variable_all, desc = "Extract Variable" }, - { "cxc", require("jdtls").extract_constant, desc = "Extract Constant" }, - { "gs", require("jdtls").super_implementation, desc = "Goto Super" }, - { "co", require("jdtls").organize_imports, desc = "Organize Imports" }, - }, - }) - wk.add({ - { - mode = "v", - buffer = args.buf, - { "cx", group = "extract" }, - { - "cxm", - [[lua require('jdtls').extract_method(true)]], - desc = "Extract Method", - }, - { - "cxv", - [[lua require('jdtls').extract_variable_all(true)]], - desc = "Extract Variable", - }, - { - "cxc", - [[lua require('jdtls').extract_constant(true)]], - 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({ - -- ["t"] = { name = "+test" }, - -- ["tt"] = { require("jdtls.dap").test_class, "Run All Test" }, - -- ["tr"] = { require("jdtls.dap").test_nearest_method, "Run Nearest Test" }, - -- ["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", - 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() - 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", - }), - }, - }) - end, + { + "williamboman/mason-lspconfig.nvim", + opts = function(_, opts) + opts.skip_config = opts.skip_config or {} + vim.list_extend(opts.skip_config, { "jdtls" }) + end, + }, + { + "pojokcodeid/auto-java-project.nvim", + event = "VeryLazy", + config = function() + require("auto-java-project").setup() + vim.keymap.set("n", "Jc", ":CreateJavaClass", { desc = "Create Java Class" }) + vim.keymap.set("n", "Jm", ":CreateJavaMainClass", { desc = "Create Java Main Class" }) + vim.keymap.set("n", "Ji", ":CreateJavaInterface", { 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", "rM", ":RunMvnSpringBoot", { desc = "Run Maven Sping Boot" }) + vim.keymap.set("n", "rG", ":RunGradleSpringBoot", { desc = "Run Gradle Sping Boot" }) + vim.keymap.set("n", "rm", ":RunMaven", { desc = "Run Maven Project" }) + vim.keymap.set("n", "rg", ":RunGradle", { desc = "Run Gradle Project" }) + end, + }, + { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "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"), + }, + }) + end, -- stylua: ignore keys = { { "T","",desc="  Test"}, @@ -260,50 +62,50 @@ M = { { "To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" }, { "TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, { "TS", function() require("neotest").run.stop() end, desc = "Stop" }, - { "rg", "terminalgradle run", 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 = { - { "S", "SymbolsOutline", desc = "Toggle Outline" }, - }, - }, + }, + { + "rockerBOO/symbols-outline.nvim", + cmd = "SymbolsOutline", + config = function() + local icons = require("pcode.user.icons").kind + require("symbols-outline").setup({ + symbols = { + 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 = { + { "Js", "SymbolsOutline", desc = "Toggle Outline" }, + }, + }, } return M diff --git a/lua/pcode/plugins/lang/java2.lua b/lua/pcode/plugins/lang/java2.lua new file mode 100644 index 0000000..8ed35bf --- /dev/null +++ b/lua/pcode/plugins/lang/java2.lua @@ -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 = { + { "rg", "", desc = "Gradle" }, + { "rgp", "JavaProfile", desc = "Java Profile" }, + { "rgg", "terminalgradle run", desc = "Run Gradle" }, + { "rgb", "JavaBuildBuildWorkspace", desc = "Java Build Workspace" }, + { "rgd", "JavaDapConfig", desc = "Java Configure DAP" }, + { "T", "", desc = "Test" }, + { "Tc", "JavaTestRunCurrentClass", desc = "Test Current Class" }, + { "Tm", "JavaTestRunCurrentMethod", desc = "Test Current Method" }, + { "Th", "JavaTestViewLastReport", desc = "View Test Last Report" }, + }, +} diff --git a/lua/pcode/plugins/lang/java3.lua b/lua/pcode/plugins/lang/java3.lua new file mode 100644 index 0000000..4da43c5 --- /dev/null +++ b/lua/pcode/plugins/lang/java3.lua @@ -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 + l + h to show code documentation about the code the cursor is currently over if available + vim.keymap.set("n", "lh", vim.lsp.buf.hover, { desc = "Code Hover Documentation" }) + -- Set vim motion for + l + d to go where the code/variable under the cursor was defined + vim.keymap.set("n", "ld", vim.lsp.buf.definition, { desc = "Code Goto Definition" }) + -- Set vim motion for + l + a for display code action suggestions for code diagnostics in both normal and visual mode + vim.keymap.set({ "n", "v" }, "la", vim.lsp.buf.code_action, { desc = "Code Actions" }) + -- Set vim motion for + l + r to display references to the code under the cursor + vim.keymap.set("n", "lr", require("telescope.builtin").lsp_references, { desc = "Code Goto References" }) + -- Set vim motion for + l + i to display implementations to the code under the cursor + vim.keymap.set("n", "li", require("telescope.builtin").lsp_implementations, { desc = "Code Goto Implementations" }) + -- Set a vim motion for + l + R to smartly rename the code under the cursor + vim.keymap.set("n", "lR", vim.lsp.buf.rename, { desc = "Code Rename" }) + -- Set a vim motion for + l + D to go to where the code/object was declared in the project (class file) + vim.keymap.set("n", "lD", vim.lsp.buf.declaration, { desc = "Code Goto Declaration" }) + end, + keys = { + { "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', 'J', "", { desc = "Java" }) + -- Set a Vim motion to + J + o to organize imports in normal mode + vim.keymap.set('n', 'Jo', " lua require('jdtls').organize_imports()", { desc = "Java Organize Imports" }) + -- Set a Vim motion to + J + v to extract the code under the cursor to a variable + vim.keymap.set('n', 'Jv', " lua require('jdtls').extract_variable()", { desc = "Java Extract Variable" }) + -- Set a Vim motion to + J + v to extract the code selected in visual mode to a variable + vim.keymap.set('v', 'Jv', " lua require('jdtls').extract_variable(true)", { desc = "Java Extract Variable" }) + -- Set a Vim motion to + J + C to extract the code under the cursor to a static variable + vim.keymap.set('n', 'JC', " lua require('jdtls').extract_constant()", { desc = "Java Extract Constant" }) + -- Set a Vim motion to + J + C to extract the code selected in visual mode to a static variable + vim.keymap.set('v', 'JC', " lua require('jdtls').extract_constant(true)", { desc = "Java Extract Constant" }) + -- Set a Vim motion to + J + t to run the test method currently under the cursor + vim.keymap.set('n', 'Jt', " lua require('jdtls').test_nearest_method()", { desc = "Java Test Method" }) + -- Set a Vim motion to + J + t to run the test method that is currently selected in visual mode + vim.keymap.set('v', 'Jt', " lua require('jdtls').test_nearest_method(true)", { desc = "Java Test Method" }) + -- Set a Vim motion to + J + T to run an entire test suite (class) + vim.keymap.set('n', 'JT', " lua require('jdtls').test_class()", { desc = "Java Test Class" }) + -- Set a Vim motion to + J + u to update the project configuration + vim.keymap.set('n', 'Ju', " JdtUpdateConfig", { 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 = { + { "T","",desc="  Test"}, + { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, + { "Tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, + { "TT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" }, + { "Tl", function() require("neotest").run.run_last() end, desc = "Run Last" }, + { "Ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" }, + { "To", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" }, + { "TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, + { "TS", function() require("neotest").run.stop() end, desc = "Stop" }, + { "rg", "terminalgradle run", 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 = { + { "S", "SymbolsOutline", desc = "Toggle Outline" }, + }, + }, +} + +return M diff --git a/lua/pcode/plugins/lang/java4.lua b/lua/pcode/plugins/lang/java4.lua new file mode 100644 index 0000000..cb144cf --- /dev/null +++ b/lua/pcode/plugins/lang/java4.lua @@ -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", + }, + }, +} diff --git a/lua/pcode/plugins/notify.lua b/lua/pcode/plugins/notify.lua index 639d0de..1c4ae83 100644 --- a/lua/pcode/plugins/notify.lua +++ b/lua/pcode/plugins/notify.lua @@ -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.3) end, render = "wrapped-compact", -- background_colour = "#00000000", diff --git a/lua/pcode/plugins/theme/github.lua b/lua/pcode/plugins/theme/github.lua new file mode 100644 index 0000000..99f226c --- /dev/null +++ b/lua/pcode/plugins/theme/github.lua @@ -0,0 +1,108 @@ +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 = { + 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, +} diff --git a/lua/pcode/plugins/theme/gruvbox.lua b/lua/pcode/plugins/theme/gruvbox.lua new file mode 100644 index 0000000..909d896 --- /dev/null +++ b/lua/pcode/plugins/theme/gruvbox.lua @@ -0,0 +1,28 @@ +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" }, + }, + } + end, + config = function(_, opts) + vim.o.background = "dark" + require("gruvbox").setup(opts) + end, +} diff --git a/lua/pcode/user/autocmd.lua b/lua/pcode/user/autocmd.lua index b793758..54ff66b 100644 --- a/lua/pcode/user/autocmd.lua +++ b/lua/pcode/user/autocmd.lua @@ -115,3 +115,12 @@ 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", "rg", "terminalgradle run", { noremap = true, silent = true }) +-- end, +-- }) diff --git a/lua/pcode/user/custom.lua b/lua/pcode/user/custom.lua index 095ee2e..cd0e85c 100644 --- a/lua/pcode/user/custom.lua +++ b/lua/pcode/user/custom.lua @@ -46,7 +46,7 @@ return { { "williamboman/mason-lspconfig.nvim", opts = function(_, opts) - vim.list_extend(opts.skip_config, { "jdtls" }) + vim.list_extend(opts.skip_config, {}) opts.virtual_text = true end, }, diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 60dd38a..ada123c 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -5,7 +5,10 @@ pcode.lang = { sql = false, deno = false, golang = false, - java = false, + java = true, + java2 = false, + java3 = false, + java4 = false, javascript = false, kotlin = false, markdown = false, @@ -42,13 +45,15 @@ pcode.extras = { visualmulti = true, yanky = true, zenmode = true, + lspsignatur = false, + telescopetreesiterinfo = 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,6 +84,12 @@ 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 diff --git a/lua/pcode/user/icons.lua b/lua/pcode/user/icons.lua index d7f7076..50e7964 100644 --- a/lua/pcode/user/icons.lua +++ b/lua/pcode/user/icons.lua @@ -1,194 +1,196 @@ return { - kind = { - Boolean = "󰨙", - Color = "", - Codeium = "󰘦", - Control = "", - Collapsed = " ", - Copilot = "", - CopilotOff = "", - Folder = "󰉋", - Keyword = "", - Reference = "", - Snippet = "", - TabNine = "󰏚", - Text = "", - Unit = "", - Value = "", - File = "", - Module = "", - Namespace = "", - Package = "", - Class = "", - Method = "", - Property = "", - Field = "", - Constructor = "", - Enum = "", - Interface = "", - Function = "", - Variable = "", - Constant = "", - String = "", - Number = "", - Array = "", - Object = "", - Key = "", - Null = "", - EnumMember = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", - }, - git = { - LineAdded = "", - LineModified = "", - LineRemoved = "", - FileDeleted = "", - FileIgnored = "", - FileRenamed = "", - FileStaged = "S", - FileUnmerged = "", - FileUnstaged = "", - FileUntracked = "U", - Diff = "", - Repo = "", - Octoface = "", - Branch = "", - Branch2 = "", - Branch3 = "󰘬", - NoBranch = "󱓌", - }, - ui = { - ArrowCircleDown = "", - ArrowCircleLeft = "", - ArrowCircleRight = "", - ArrowCircleUp = "", - BoldArrowDown = "", - BoldArrowLeft = "", - BoldArrowRight = "", - BoldArrowUp = "", - BoldClose = "", - BoldDividerLeft = "", - BoldDividerRight = "", - BoldLineLeft = "▎", - BookMark = "", - BoxChecked = "", - Bug = "", - Stacks = "", - Scopes = "", - Watches = "󰂥", - DebugConsole = "", - Calendar = "", - Check = "", - ChevronRight = "", - ChevronShortDown = "", - ChevronShortLeft = "", - ChevronShortRight = "", - ChevronShortUp = "", - ChevronShortDown2 = " ", - ChevronShortLeft2 = "", - ChevronShortRight2 = "", - ChevronShortUp2 = "", - Circle = " ", - Close = "󰅖", - CloudDownload = "", - Code = "", - Comment = "", - Dashboard = "", - DividerLeft = "", - DividerRight = "", - DoubleChevronRight = "»", - Ellipsis = "", - EmptyFolder = "󰉖", - EmptyFolderOpen = "󰷏", - File = "", - FileSymlink = "", - Files = "", - FindFile = "󰈞", - FindText = "󰊄", - Fire = "", - Folder = "󰉋", - FolderOpen = "󰝰", - FolderSymlink = "", - Forward = "", - Gear = "", - History = "", - Lightbulb = "", - LineLeft = "▏", - LineMiddle = "│", - List = "", - Lock = "", - NewFile = "", - Note = "", - Package = "", - Pencil = "󰏫", - Plus = "", - Project = "", - Search = "", - SignIn = "", - SignOut = "", - Tab = "󰌒", - Table = "", - Target = "󰀘", - Telescope = "", - Text = "", - Tree = "", - Triangle = "󰐊", - TriangleShortArrowDown = "", - TriangleShortArrowLeft = "", - TriangleShortArrowRight = "", - TriangleShortArrowUp = "", - Neovim = "", - Pending = " ", - BlankCircle = " ", - CheckCircle = " ", - DotCircle = " ", - Border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, - ProjekFolder = "󱧶", - Bell = "󰂠", - ft = "", - not_loaded = "", - Paint = "", - }, - folding = { - vert = "▕", -- alternatives │ - fold = " ", - eob = " ", -- suppress ~ at EndOfBuffer - diff = "╱", -- alternatives = ⣿ ░ ─ - msgsep = "‾", - foldopen = "▾", - foldsep = "│", - foldclose = "▸", - plusBox = "󰜄", - plusSircle = "󰐙", - plus = "󰐕", - minusBox = "󰛲", - minusSircle = "󰍷", - minus = "󰍴", - }, - diagnostics = { - BoldError = "", - Error = "", - BoldWarning = "", - Warning = "", - BoldInformation = "", - Information = "", - BoldQuestion = "", - Question = "", - BoldHint = "", - Hint = "󰌶", - Debug = "", - Trace = "✎", - }, - misc = { - Robot = "󰚩", - Squirrel = "", - Tag = "", - Watch = "", - Smiley = "", - Package = "", - CircuitBoard = "", - }, + kind = { + Boolean = "󰨙", + Color = "", + Codeium = "󰘦", + Control = "", + Collapsed = " ", + Component = "󰅴", + Copilot = "", + CopilotOff = "", + Folder = "󰉋", + Keyword = "", + Reference = "", + Snippet = "", + TabNine = "󰏚", + Text = "", + Unit = "", + Value = "", + File = "", + Module = "", + Namespace = "", + Package = "", + Class = "", + Method = "", + Property = "", + Field = "", + Constructor = "", + Enum = "", + Interface = "", + Function = "", + Fragment = "󰅴", + Variable = "", + Constant = "", + String = "", + Number = "", + Array = "", + Object = "", + Key = "", + Null = "", + EnumMember = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + }, + git = { + LineAdded = "", + LineModified = "", + LineRemoved = "", + FileDeleted = "", + FileIgnored = "", + FileRenamed = "", + FileStaged = "S", + FileUnmerged = "", + FileUnstaged = "", + FileUntracked = "U", + Diff = "", + Repo = "", + Octoface = "", + Branch = "", + Branch2 = "", + Branch3 = "󰘬", + NoBranch = "󱓌", + }, + ui = { + ArrowCircleDown = "", + ArrowCircleLeft = "", + ArrowCircleRight = "", + ArrowCircleUp = "", + BoldArrowDown = "", + BoldArrowLeft = "", + BoldArrowRight = "", + BoldArrowUp = "", + BoldClose = "", + BoldDividerLeft = "", + BoldDividerRight = "", + BoldLineLeft = "▎", + BookMark = "", + BoxChecked = "", + Bug = "", + Stacks = "", + Scopes = "", + Watches = "󰂥", + DebugConsole = "", + Calendar = "", + Check = "", + ChevronRight = "", + ChevronShortDown = "", + ChevronShortLeft = "", + ChevronShortRight = "", + ChevronShortUp = "", + ChevronShortDown2 = " ", + ChevronShortLeft2 = "", + ChevronShortRight2 = "", + ChevronShortUp2 = "", + Circle = " ", + Close = "󰅖", + CloudDownload = "", + Code = "", + Comment = "", + Dashboard = "", + DividerLeft = "", + DividerRight = "", + DoubleChevronRight = "»", + Ellipsis = "", + EmptyFolder = "󰉖", + EmptyFolderOpen = "󰷏", + File = "", + FileSymlink = "", + Files = "", + FindFile = "󰈞", + FindText = "󰊄", + Fire = "", + Folder = "󰉋", + FolderOpen = "󰝰", + FolderSymlink = "", + Forward = "", + Gear = "", + History = "", + Lightbulb = "", + LineLeft = "▏", + LineMiddle = "│", + List = "", + Lock = "", + NewFile = "", + Note = "", + Package = "", + Pencil = "󰏫", + Plus = "", + Project = "", + Search = "", + SignIn = "", + SignOut = "", + Tab = "󰌒", + Table = "", + Target = "󰀘", + Telescope = "", + Text = "", + Tree = "", + Triangle = "󰐊", + TriangleShortArrowDown = "", + TriangleShortArrowLeft = "", + TriangleShortArrowRight = "", + TriangleShortArrowUp = "", + Neovim = "", + Pending = " ", + BlankCircle = " ", + CheckCircle = " ", + DotCircle = " ", + Border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + ProjekFolder = "󱧶", + Bell = "󰂠", + ft = "", + not_loaded = "", + Paint = "", + }, + folding = { + vert = "▕", -- alternatives │ + fold = " ", + eob = " ", -- suppress ~ at EndOfBuffer + diff = "╱", -- alternatives = ⣿ ░ ─ + msgsep = "‾", + foldopen = "▾", + foldsep = "│", + foldclose = "▸", + plusBox = "󰜄", + plusSircle = "󰐙", + plus = "󰐕", + minusBox = "󰛲", + minusSircle = "󰍷", + minus = "󰍴", + }, + diagnostics = { + BoldError = "", + Error = "", + BoldWarning = "", + Warning = "", + BoldInformation = "", + Information = "", + BoldQuestion = "", + Question = "", + BoldHint = "", + Hint = "󰌶", + Debug = "", + Trace = "✎", + }, + misc = { + Robot = "󰚩", + Squirrel = "", + Tag = "", + Watch = "", + Smiley = "", + Package = "", + CircuitBoard = "", + }, }