Skip to content

Commit

Permalink
feat(scala): add scala support
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Nehrig committed Dec 30, 2024
1 parent dd6ba61 commit b591c58
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" },
"neotest-rust": { "branch": "main", "commit": "e1cb22ecf0341fb894ef2ebde344389fe6e6fc8e" },
"no-neck-pain.nvim": { "branch": "main", "commit": "2a786bf7130cce20449885fb799f3c7f4ce93595" },
"noice.nvim": { "branch": "main", "commit": "03c6a75661e68012e30b0ed81f050358b1e2233c" },
"noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
"nvim-bqf": { "branch": "main", "commit": "68d3c20f6bee49105dcfde3df1f7ec972529f2a3" },
Expand All @@ -60,11 +60,12 @@
"nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" },
"nvim-jdtls": { "branch": "master", "commit": "8f14aa1922ee5491ded1079a6576fae834535658" },
"nvim-lspconfig": { "branch": "master", "commit": "8b15a1a597a59f4f5306fad9adfe99454feab743" },
"nvim-metals": { "branch": "main", "commit": "e6b02c99161b43c67cfe1d6e5f9a9b9a0bb4701c" },
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
"nvim-notify": { "branch": "master", "commit": "c3797193536711b5d8983975791c4b11dc35ab3a" },
"nvim-pqf": { "branch": "main", "commit": "148ee2ca8b06d83fd9bf6f9b9497724ad39a07d6" },
"nvim-tree.lua": { "branch": "master", "commit": "68fc4c20f5803444277022c681785c5edd11916d" },
"nvim-treesitter": { "branch": "master", "commit": "a295ba13d27684e8904e8e51876b84ee85135cf1" },
"nvim-treesitter": { "branch": "master", "commit": "4b222913486ec0a5983efa82b0649a2ab87cf1f0" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-treesitter-textsubjects": { "branch": "master", "commit": "a8d2844bba925d9450ef7ab215f3b054028288ca" },
"nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" },
Expand Down
2 changes: 1 addition & 1 deletion lua/config/plugins/configs/gitsigns/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function M.init()
map("n", "<Leader>hS", gs.stage_buffer, { desc = "Stage Buffer" })
map("n", "<Leader>hR", gs.reset_buffer, { desc = "Reset Buffer" })
map("n", "<Leader>hP", gs.preview_hunk, { desc = "Preview Hunk" })
map("n", "<Leader>hs", gs.select_hunk, { desc = "Select Hunk" })
map("n", "<Leader>hz", gs.select_hunk, { desc = "Select Hunk" })
map("n", "<Leader>hu", gs.undo_stage_hunk, { desc = "Undo Stage" })
map("n", "<Leader>hR", gs.reset_hunk, { desc = "Reset Hunk" })
map("n", "<Leader>hp", gs.preview_hunk, { desc = "Preview Hunk" })
Expand Down
10 changes: 10 additions & 0 deletions lua/config/plugins/configs/lspconfig/efm/scalafmt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local fs = require("config.core.fs")
local formatter = 'scalafmt'
local args = '--stdin'
local command = string.format('%s %s', fs.executable(formatter), args)

return {
formatCanRange = true,
formatCommand = command,
formatStdin = true,
}
3 changes: 3 additions & 0 deletions lua/config/plugins/configs/lspconfig/servers/efm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local gofmt = require("config.plugins.configs.lspconfig.efm.gofmt")
local goimports = require("config.plugins.configs.lspconfig.efm.goimports")
local golines = require("config.plugins.configs.lspconfig.efm.golines")
local sql = require("config.plugins.configs.lspconfig.efm.sql")
local scalafmt = require("config.plugins.configs.lspconfig.efm.scalafmt")

-- formatting and linting with efm
lspconfig.efm.setup({
Expand Down Expand Up @@ -82,6 +83,7 @@ lspconfig.efm.setup({
python = { python },
bash = { shellcheck, shfmt },
sh = { shellcheck, shfmt },
scala = { scalafmt },
},
},
filetypes = {
Expand All @@ -92,6 +94,7 @@ lspconfig.efm.setup({
"json",
"toml",
"sql",
"scala",
"go",
"txt",
"org",
Expand Down
33 changes: 33 additions & 0 deletions lua/config/plugins/modules/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,39 @@ M.lsp = {
require("lsp-lens").setup({})
end,
},
["scalameta/nvim-metals"] = {
dependencies = {
"nvim-lua/plenary.nvim",
},
ft = { "scala", "sbt", "java" },
opts = function()
local metals_config = require("metals").bare_config()
metals_config.settings.serverVersion = "1.2.0"
local lsp = require("config.plugins.configs.lspconfig")
metals_config.on_attach = function(client, bufnr)
local n_present, navic = pcall(require, "nvim-navic")
if n_present then
if client.supports_method("textDocument/documentSymbol") then
navic.attach(client, bufnr)
end
end

lsp.on_attach(client, bufnr)
end

return metals_config
end,
config = function(self, metals_config)
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = self.ft,
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
end
},
--- INFO: neoconf load lsp specific infos from a conf file used for projects for instance
["folke/neoconf.nvim"] = {
config = true,
Expand Down

0 comments on commit b591c58

Please sign in to comment.