
### Description I am the author of this [PR](https://github.com/LazyVim/LazyVim/pull/2890). While reviewing my own code and checking the LazyVim official website, I noticed some inconsistencies 😓 , so I created a small PR to address them: ### Changes 1.Each optional plugin has a comment message indicating that the plugin is optional, but DAP does not (as shown in the image). Since the official website already has an "optional" in title. **I removed the comment messages regarding "optional" to avoid confusion**. <img width="300" alt="Screenshot 2024-05-23 at 10 31 38 PM" src="https://github.com/LazyVim/LazyVim/assets/82575487/441979fc-20dd-4599-a91d-f27bc0841d79"> --- 2. I changed the DAP to use local variables for DAP to maintain consistency, even though both require statements reference the same module.
118 lines
3.2 KiB
Lua
118 lines
3.2 KiB
Lua
return {
|
|
recommended = function()
|
|
return LazyVim.extras.wants({
|
|
ft = "kotlin",
|
|
root = {
|
|
"settings.gradle", -- Gradle (multi-project)
|
|
"settings.gradle.kts", -- Gradle (multi-project)
|
|
"build.xml", -- Ant
|
|
"pom.xml", -- Maven
|
|
"build.gradle", -- Gradle
|
|
"build.gradle.kts", -- Gradle
|
|
},
|
|
})
|
|
end,
|
|
-- Add packages(linting, debug adapter)
|
|
{
|
|
"williamboman/mason.nvim",
|
|
opts = function(_, opts)
|
|
vim.list_extend(opts.ensure_installed or {}, { "ktlint" })
|
|
end,
|
|
},
|
|
-- Add syntax highlighting
|
|
{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
opts = function(_, opts)
|
|
vim.list_extend(opts.ensure_installed or {}, { "kotlin" })
|
|
end,
|
|
},
|
|
-- Add language server
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
opts = {
|
|
servers = {
|
|
kotlin_language_server = {},
|
|
},
|
|
},
|
|
},
|
|
-- Add linting
|
|
{
|
|
"mfussenegger/nvim-lint",
|
|
optional = true,
|
|
dependencies = "williamboman/mason.nvim",
|
|
opts = {
|
|
linters_by_ft = { kotlin = { "ktlint" } },
|
|
},
|
|
},
|
|
-- Add formatting
|
|
{
|
|
"stevearc/conform.nvim",
|
|
optional = true,
|
|
opts = {
|
|
formatters_by_ft = { kotlin = { "ktlint" } },
|
|
},
|
|
},
|
|
-- Add formatting and linting
|
|
{
|
|
"nvimtools/none-ls.nvim",
|
|
optional = true,
|
|
opts = function(_, opts)
|
|
local nls = require("null-ls")
|
|
opts.sources = vim.list_extend(opts.sources or {}, {
|
|
nls.builtins.formatting.ktlint,
|
|
nls.builtins.diagnostics.ktlint,
|
|
})
|
|
end,
|
|
},
|
|
-- Add debugger
|
|
{
|
|
"mfussenegger/nvim-dap",
|
|
optional = true,
|
|
dependencies = "williamboman/mason.nvim",
|
|
opts = function()
|
|
local dap = require("dap")
|
|
if not dap.adapters.kotlin then
|
|
dap.adapters.kotlin = {
|
|
type = "executable",
|
|
command = "kotlin-debug-adapter",
|
|
options = { auto_continue_if_many_stopped = false },
|
|
}
|
|
end
|
|
|
|
dap.configurations.kotlin = {
|
|
{
|
|
type = "kotlin",
|
|
request = "launch",
|
|
name = "This file",
|
|
-- may differ, when in doubt, whatever your project structure may be,
|
|
-- it has to correspond to the class file located at `build/classes/`
|
|
-- and of course you have to build before you debug
|
|
mainClass = function()
|
|
local root = vim.fs.find("src", { path = vim.uv.cwd(), upward = true, stop = vim.env.HOME })[1] or ""
|
|
local fname = vim.api.nvim_buf_get_name(0)
|
|
-- src/main/kotlin/websearch/Main.kt -> websearch.MainKt
|
|
return fname:gsub(root, ""):gsub("main/kotlin/", ""):gsub(".kt", "Kt"):gsub("/", "."):sub(2, -1)
|
|
end,
|
|
projectRoot = "${workspaceFolder}",
|
|
jsonLogFile = "",
|
|
enableJsonLogging = false,
|
|
},
|
|
{
|
|
-- Use this for unit tests
|
|
-- First, run
|
|
-- ./gradlew --info cleanTest test --debug-jvm
|
|
-- then attach the debugger to it
|
|
type = "kotlin",
|
|
request = "attach",
|
|
name = "Attach to debugging session",
|
|
port = 5005,
|
|
args = {},
|
|
projectRoot = vim.fn.getcwd,
|
|
hostName = "localhost",
|
|
timeout = 2000,
|
|
},
|
|
}
|
|
end,
|
|
},
|
|
}
|