add scala
This commit is contained in:
parent
1c40a98a2f
commit
42fcaf144d
3
init.lua
3
init.lua
|
|
@ -974,7 +974,8 @@ require('lazy').setup({
|
|||
-- Here are some example plugins that I've included in the Kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
|
||||
--
|
||||
require 'kickstart.plugins.debug',
|
||||
require 'kickstart.plugins.debug_python',
|
||||
require 'kickstart.plugins.debug_scala',
|
||||
-- require 'kickstart.plugins.indent_line',
|
||||
-- require 'kickstart.plugins.lint',
|
||||
-- require 'kickstart.plugins.autopairs',
|
||||
|
|
|
|||
|
|
@ -24,57 +24,16 @@ return {
|
|||
'mfussenegger/nvim-dap-python',
|
||||
},
|
||||
keys = {
|
||||
-- Basic debugging keymaps, feel free to change to your liking!
|
||||
{
|
||||
'<F5>',
|
||||
function()
|
||||
require('dap').continue()
|
||||
end,
|
||||
desc = 'Debug: Start/Continue',
|
||||
},
|
||||
{
|
||||
'<F1>',
|
||||
function()
|
||||
require('dap').step_into()
|
||||
end,
|
||||
desc = 'Debug: Step Into',
|
||||
},
|
||||
{
|
||||
'<F2>',
|
||||
function()
|
||||
require('dap').step_over()
|
||||
end,
|
||||
desc = 'Debug: Step Over',
|
||||
},
|
||||
{
|
||||
'<F3>',
|
||||
function()
|
||||
require('dap').step_out()
|
||||
end,
|
||||
desc = 'Debug: Step Out',
|
||||
},
|
||||
{
|
||||
'<leader>b',
|
||||
function()
|
||||
require('dap').toggle_breakpoint()
|
||||
end,
|
||||
desc = 'Debug: Toggle Breakpoint',
|
||||
},
|
||||
{
|
||||
'<leader>B',
|
||||
function()
|
||||
require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ')
|
||||
end,
|
||||
desc = 'Debug: Set Breakpoint',
|
||||
},
|
||||
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
|
||||
{
|
||||
'<F7>',
|
||||
function()
|
||||
require('dapui').toggle()
|
||||
end,
|
||||
desc = 'Debug: See last session result.',
|
||||
},
|
||||
-- Keymaps aligned with debug_scala.lua
|
||||
{ '<leader>dc', function() require('dap').continue() end, desc = 'Debug: Start/Continue' },
|
||||
{ '<leader>dr', function() require('dap').repl.toggle() end, desc = 'Debug: Toggle REPL' },
|
||||
{ '<leader>dK', function() require('dap.ui.widgets').hover() end, desc = 'Debug: Hover Widget' },
|
||||
{ '<leader>dt', function() require('dap').toggle_breakpoint() end, desc = 'Debug: Toggle Breakpoint' },
|
||||
{ '<leader>dso', function() require('dap').step_over() end, desc = 'Debug: Step Over' },
|
||||
{ '<leader>dsi', function() require('dap').step_into() end, desc = 'Debug: Step Into' },
|
||||
{ '<leader>dl', function() require('dap').run_last() end, desc = 'Debug: Run Last' },
|
||||
{ '<leader>du', function() require('dapui').toggle() end, desc = 'Debug: Toggle DAP UI' },
|
||||
{ '<leader>dB', function() require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, desc = 'Debug: Set Conditional Breakpoint' },
|
||||
},
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
return {
|
||||
'scalameta/nvim-metals',
|
||||
dependencies = {
|
||||
{
|
||||
'j-hui/fidget.nvim',
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
'mfussenegger/nvim-dap',
|
||||
config = function(self, opts)
|
||||
-- Debug settings if you're using nvim-dap
|
||||
local dap = require 'dap'
|
||||
|
||||
dap.configurations.scala = {
|
||||
{
|
||||
type = 'scala',
|
||||
request = 'launch',
|
||||
name = 'RunOrTest',
|
||||
metals = {
|
||||
runType = 'runOrTestFile',
|
||||
--args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example
|
||||
},
|
||||
},
|
||||
{
|
||||
type = 'scala',
|
||||
request = 'launch',
|
||||
name = 'Test Target',
|
||||
metals = {
|
||||
runType = 'testTarget',
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
ft = { 'scala', 'sbt', 'java' },
|
||||
opts = function()
|
||||
local metals_config = require('metals').bare_config()
|
||||
|
||||
-- Example of settings
|
||||
metals_config.settings = {
|
||||
showImplicitArguments = true,
|
||||
gradleScript = vim.fn.getcwd() .. '/gradlew',
|
||||
customProjectRoot = vim.fn.getcwd(),
|
||||
excludedPackages = { 'akka.actor.typed.javadsl', 'com.github.swagger.akka.javadsl' },
|
||||
}
|
||||
|
||||
-- *READ THIS*
|
||||
-- I *highly* recommend setting statusBarProvider to either "off" or "on"
|
||||
--
|
||||
-- "off" will enable LSP progress notifications by Metals and you'll need
|
||||
-- to ensure you have a plugin like fidget.nvim installed to handle them.
|
||||
--
|
||||
-- "on" will enable the custom Metals status extension and you *have* to have
|
||||
-- a have settings to capture this in your statusline or else you'll not see
|
||||
-- any messages from metals. There is more info in the help docs about this
|
||||
metals_config.init_options.statusBarProvider = 'off'
|
||||
|
||||
-- Example if you are using cmp how to make sure the correct capabilities for snippets are set
|
||||
metals_config.capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
metals_config.on_attach = function(client, bufnr)
|
||||
require('metals').setup_dap()
|
||||
|
||||
-- LSP mappings
|
||||
map('n', 'gD', vim.lsp.buf.definition)
|
||||
map('n', 'K', vim.lsp.buf.hover)
|
||||
map('n', 'gi', vim.lsp.buf.implementation)
|
||||
map('n', 'gr', vim.lsp.buf.references)
|
||||
map('n', 'gds', vim.lsp.buf.document_symbol)
|
||||
map('n', 'gws', vim.lsp.buf.workspace_symbol)
|
||||
map('n', '<leader>cl', vim.lsp.codelens.run)
|
||||
map('n', '<leader>sh', vim.lsp.buf.signature_help)
|
||||
map('n', '<leader>rn', vim.lsp.buf.rename)
|
||||
map('n', '<leader>f', vim.lsp.buf.format)
|
||||
map('n', '<leader>ca', vim.lsp.buf.code_action)
|
||||
|
||||
map('n', '<leader>ws', function()
|
||||
require('metals').hover_worksheet()
|
||||
end)
|
||||
|
||||
-- all workspace diagnostics
|
||||
map('n', '<leader>aa', vim.diagnostic.setqflist)
|
||||
|
||||
-- all workspace errors
|
||||
map('n', '<leader>ae', function()
|
||||
vim.diagnostic.setqflist { severity = 'E' }
|
||||
end)
|
||||
|
||||
-- all workspace warnings
|
||||
map('n', '<leader>aw', function()
|
||||
vim.diagnostic.setqflist { severity = 'W' }
|
||||
end)
|
||||
|
||||
-- buffer diagnostics only
|
||||
map('n', '<leader>d', vim.diagnostic.setloclist)
|
||||
|
||||
map('n', '[c', function()
|
||||
vim.diagnostic.goto_prev { wrap = false }
|
||||
end)
|
||||
|
||||
map('n', ']c', function()
|
||||
vim.diagnostic.goto_next { wrap = false }
|
||||
end)
|
||||
|
||||
-- Example mappings for usage with nvim-dap. If you don't use that, you can
|
||||
-- skip these
|
||||
map('n', '<leader>dc', function() require('dap').continue() end, { desc = 'Debug: Start/Continue' })
|
||||
map('n', '<leader>dr', function() require('dap').repl.toggle() end, { desc = 'Debug: Toggle REPL' })
|
||||
map('n', '<leader>dK', function() require('dap.ui.widgets').hover() end, { desc = 'Debug: Hover Widget' })
|
||||
map('n', '<leader>dt', function() require('dap').toggle_breakpoint() end, { desc = 'Debug: Toggle Breakpoint' })
|
||||
map('n', '<leader>dso', function() require('dap').step_over() end, { desc = 'Debug: Step Over' })
|
||||
map('n', '<leader>dsi', function() require('dap').step_into() end, { desc = 'Debug: Step Into' })
|
||||
map('n', '<leader>dl', function() require('dap').run_last() end, { desc = 'Debug: Run Last' })
|
||||
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,
|
||||
}
|
||||
Loading…
Reference in New Issue