diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/default-config.lua | 1 | ||||
| -rw-r--r-- | lua/lang/scala.lua | 80 | ||||
| -rw-r--r-- | lua/plugins.lua | 7 | 
3 files changed, 88 insertions, 0 deletions
| diff --git a/lua/default-config.lua b/lua/default-config.lua index e880e2b6..3a019042 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -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() diff --git a/lua/lang/scala.lua b/lua/lang/scala.lua new file mode 100644 index 00000000..081c74bf --- /dev/null +++ b/lua/lang/scala.lua @@ -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 diff --git a/lua/plugins.lua b/lua/plugins.lua index a867cfbe..0aa29d17 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -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) | 
