mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-02 00:56:02 +02:00
add scala and sbt support (#986)
This commit is contained in:
parent
cf0a558fe5
commit
fe48ed9ef9
6 changed files with 98 additions and 0 deletions
1
ftplugin/sbt.lua
Symbolic link
1
ftplugin/sbt.lua
Symbolic link
|
@ -0,0 +1 @@
|
|||
scala.lua
|
4
ftplugin/scala.lua
Normal file
4
ftplugin/scala.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
require("lang.scala").format()
|
||||
require("lang.scala").lint()
|
||||
require("lang.scala").lsp()
|
||||
require("lang.scala").dap()
|
|
@ -156,6 +156,7 @@ require("lang.php").config()
|
|||
require("lang.python").config()
|
||||
require("lang.ruby").config()
|
||||
require("lang.rust").config()
|
||||
require("lang.scala").config()
|
||||
require("lang.sh").config()
|
||||
require("lang.terraform").config()
|
||||
require("lang.tex").config()
|
||||
|
|
80
lua/lang/scala.lua
Normal file
80
lua/lang/scala.lua
Normal file
|
@ -0,0 +1,80 @@
|
|||
local M = {}
|
||||
|
||||
M.config = function()
|
||||
O.lang.scala = {
|
||||
metals = {
|
||||
active = false,
|
||||
server_version = "0.10.5",
|
||||
excluded_packages = {},
|
||||
show_implicit_arguments = false,
|
||||
show_inferred_type = true,
|
||||
status_bar_provider = false,
|
||||
},
|
||||
formatter = {
|
||||
exe = "scalafmt",
|
||||
args = { "--stdin" },
|
||||
stdin = true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
M.format = function()
|
||||
O.formatters.filetype["scala"] = {
|
||||
function()
|
||||
return {
|
||||
exe = O.lang.scala.formatter.exe,
|
||||
args = O.lang.scala.formatter.args,
|
||||
stdin = O.lang.scala.formatter.stdin,
|
||||
}
|
||||
end,
|
||||
}
|
||||
O.formatters.filetype["sbt"] = O.formatters.filetype["scala"]
|
||||
-- To understand sbt files on stdin, scalafmt needs to assume any old filename
|
||||
-- that ends in .sbt. Using a dummy filename instead of the actual one is
|
||||
-- required to support buffers of sbt filetype without the extension.
|
||||
O.formatters.filetype["sbt"].args = { "--stdin", "--assume-filename", "foo.sbt" }
|
||||
|
||||
require("formatter.config").set_defaults {
|
||||
logging = false,
|
||||
filetype = O.formatters.filetype,
|
||||
}
|
||||
end
|
||||
|
||||
M.lint = function()
|
||||
-- TODO: implement linters (if applicable)
|
||||
return "No linters configured!"
|
||||
end
|
||||
|
||||
M.lsp = function()
|
||||
-- enable metal server integration
|
||||
if O.lang.scala.metals.active then
|
||||
vim.g["metals_server_version"] = O.lang.scala.metals.server_version
|
||||
-- https://github.com/scalameta/nvim-metals#prerequisites
|
||||
vim.opt_global.shortmess:remove("F"):append "c"
|
||||
local metals_config = require("metals").bare_config
|
||||
metals_config.on_attach = function()
|
||||
require("completion").on_attach()
|
||||
end
|
||||
metals_config.handlers["textDocument/publishDiagnostics"] =
|
||||
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = {
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
metals_config.settings = {
|
||||
showImplicitArguments = O.lang.scala.metals.show_implicit_arguments,
|
||||
showInferredType = O.lang.scala.metals.show_inferred_type,
|
||||
excludedPackages = O.lang.scala.metals.excluded_packages,
|
||||
}
|
||||
metals_config.init_options.statusBarProvider = O.lang.scala.metals.status_bar_provider
|
||||
require "lsp"
|
||||
require("metals").initialize_or_attach(metals_config)
|
||||
end
|
||||
end
|
||||
|
||||
M.dap = function()
|
||||
-- TODO: implement dap
|
||||
return "No DAP configured!"
|
||||
end
|
||||
|
||||
return M
|
|
@ -249,12 +249,19 @@ return require("packer").startup(function(use)
|
|||
},
|
||||
}
|
||||
|
||||
-- Java
|
||||
use {
|
||||
"mfussenegger/nvim-jdtls",
|
||||
-- ft = { "java" },
|
||||
disable = not O.lang.java.java_tools.active,
|
||||
}
|
||||
|
||||
-- Scala
|
||||
use {
|
||||
"scalameta/nvim-metals",
|
||||
disable = not O.lang.scala.metals.active,
|
||||
}
|
||||
|
||||
-- Install user plugins
|
||||
for _, plugin in pairs(O.user_plugins) do
|
||||
packer.use(plugin)
|
||||
|
|
|
@ -47,11 +47,16 @@ O.lang.python.analysis.use_library_code_types = true
|
|||
O.lang.tsserver.linter = nil
|
||||
|
||||
-- rust
|
||||
-- O.lang.rust.rust_tools = true
|
||||
-- O.lang.rust.formatter = {
|
||||
-- exe = "rustfmt",
|
||||
-- args = {"--emit=stdout", "--edition=2018"},
|
||||
-- }
|
||||
|
||||
-- scala
|
||||
-- O.lang.scala.metals.active = true
|
||||
-- O.lang.scala.metals.server_version = "0.10.2+33-c6441eb4-SNAPSHOT",
|
||||
|
||||
--LaTeX
|
||||
-- Options: https://github.com/latex-lsp/texlab/blob/master/docs/options.md
|
||||
O.lang.latex.active = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue