mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
nvim: refactor scala configuration
This commit is contained in:
parent
83a83630db
commit
35787ab423
4 changed files with 26 additions and 43 deletions
2
.config/nvim/ftplugin/sbt.lua
Normal file
2
.config/nvim/ftplugin/sbt.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
local metals_config = require("lsp.scala")
|
||||||
|
require("metals").initialize_or_attach(metals_config)
|
||||||
2
.config/nvim/ftplugin/scala.lua
Normal file
2
.config/nvim/ftplugin/scala.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
local metals_config = require("lsp.scala")
|
||||||
|
require("metals").initialize_or_attach(metals_config)
|
||||||
22
.config/nvim/lua/lsp/scala.lua
Normal file
22
.config/nvim/lua/lsp/scala.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
local mylsp = require("lsp")
|
||||||
|
local capabilities = mylsp.capabilities
|
||||||
|
local on_attach = mylsp.on_attach
|
||||||
|
|
||||||
|
local metals = require("metals")
|
||||||
|
local config = metals.bare_config()
|
||||||
|
config.capabilities = capabilities
|
||||||
|
|
||||||
|
-- I think this is for nix
|
||||||
|
config.settings.useGlobalExecutable = true
|
||||||
|
|
||||||
|
config.on_attach = function(client, bufnr)
|
||||||
|
-- local function nnoremap(bind, callback, userargs)
|
||||||
|
-- local args = userargs or {}
|
||||||
|
-- args.buffer = bufnr
|
||||||
|
-- vim.keymap.set("n", bind, callback, args)
|
||||||
|
-- end
|
||||||
|
-- nnoremap("<leader>ws", metals.hover_worksheet)
|
||||||
|
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -143,46 +143,3 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||||
callback = function() require("jdtls").start_or_attach(config) end,
|
callback = function() require("jdtls").start_or_attach(config) end,
|
||||||
group = jdtls_group,
|
group = jdtls_group,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Scala
|
|
||||||
local metals = require("metals")
|
|
||||||
local metals_config = metals.bare_config()
|
|
||||||
metals_config.capabilities = mylsp.capabilities
|
|
||||||
metals_config.settings.useGlobalExecutable = true
|
|
||||||
|
|
||||||
require("dap").configurations.scala = {
|
|
||||||
{
|
|
||||||
type = "scala",
|
|
||||||
request = "launch",
|
|
||||||
name = "RunOrTest",
|
|
||||||
metals = { runType = "runOrTestFile" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type = "scala",
|
|
||||||
request = "launch",
|
|
||||||
name = "Test Target",
|
|
||||||
metals = { runType = "testTarget" },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
metals_config.on_attach = function(client, bufnr)
|
|
||||||
metals.setup_dap()
|
|
||||||
|
|
||||||
map("n", "<leader>ws", metals.hover_worksheet)
|
|
||||||
|
|
||||||
map("n", "<leader>dc", require("dap").continue)
|
|
||||||
map("n", "<leader>dr", require("dap").repl.toggle)
|
|
||||||
map("n", "<leader>dK", require("dap.ui.widgets").hover)
|
|
||||||
map("n", "<leader>dt", require("dap").toggle_breakpoint)
|
|
||||||
map("n", "<leader>dso", require("dap").step_over)
|
|
||||||
map("n", "<leader>dsi", require("dap").step_into)
|
|
||||||
map("n", "<leader>dl", require("dap").run_last)
|
|
||||||
|
|
||||||
mylsp.on_attach(client, bufnr)
|
|
||||||
end
|
|
||||||
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
pattern = { "scala", "sbt" },
|
|
||||||
callback = function() require("metals").initialize_or_attach(metals_config) end,
|
|
||||||
group = nvim_metals_group,
|
|
||||||
})
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue