mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-24 12:28:32 +00:00
Merge 78a52d75ca
into e77632e4eb
This commit is contained in:
commit
716d404fd9
5 changed files with 165 additions and 0 deletions
|
@ -68,6 +68,7 @@ isMaximal: {
|
||||||
lsp.server = "clangd";
|
lsp.server = "clangd";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scala.enable = isMaximal;
|
||||||
rust = {
|
rust = {
|
||||||
enable = isMaximal;
|
enable = isMaximal;
|
||||||
crates.enable = isMaximal;
|
crates.enable = isMaximal;
|
||||||
|
|
17
flake.lock
generated
17
flake.lock
generated
|
@ -1149,6 +1149,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-nvim-metals": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1728033462,
|
||||||
|
"narHash": "sha256-XqOkZ/5eex1mrNUf6vrJjDjibBbb0bSMYSciKAoVD0A=",
|
||||||
|
"owner": "ksonj",
|
||||||
|
"repo": "nvim-metals",
|
||||||
|
"rev": "4d86c32f6c028de197e28dab0f6a0250c0d1c16a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ksonj",
|
||||||
|
"repo": "nvim-metals",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-nvim-navbuddy": {
|
"plugin-nvim-navbuddy": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -1863,6 +1879,7 @@
|
||||||
"plugin-nvim-docs-view": "plugin-nvim-docs-view",
|
"plugin-nvim-docs-view": "plugin-nvim-docs-view",
|
||||||
"plugin-nvim-lightbulb": "plugin-nvim-lightbulb",
|
"plugin-nvim-lightbulb": "plugin-nvim-lightbulb",
|
||||||
"plugin-nvim-lspconfig": "plugin-nvim-lspconfig",
|
"plugin-nvim-lspconfig": "plugin-nvim-lspconfig",
|
||||||
|
"plugin-nvim-metals": "plugin-nvim-metals",
|
||||||
"plugin-nvim-navbuddy": "plugin-nvim-navbuddy",
|
"plugin-nvim-navbuddy": "plugin-nvim-navbuddy",
|
||||||
"plugin-nvim-navic": "plugin-nvim-navic",
|
"plugin-nvim-navic": "plugin-nvim-navic",
|
||||||
"plugin-nvim-neoclip": "plugin-nvim-neoclip",
|
"plugin-nvim-neoclip": "plugin-nvim-neoclip",
|
||||||
|
|
|
@ -206,6 +206,11 @@
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
plugin-nvim-metals = {
|
||||||
|
url = "github:ksonj/nvim-metals";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# Copying/Registers
|
# Copying/Registers
|
||||||
plugin-registers = {
|
plugin-registers = {
|
||||||
url = "github:tversteeg/registers.nvim";
|
url = "github:tversteeg/registers.nvim";
|
||||||
|
|
|
@ -19,6 +19,7 @@ in {
|
||||||
./python.nix
|
./python.nix
|
||||||
./r.nix
|
./r.nix
|
||||||
./rust.nix
|
./rust.nix
|
||||||
|
./scala.nix
|
||||||
./sql.nix
|
./sql.nix
|
||||||
./svelte.nix
|
./svelte.nix
|
||||||
./tailwind.nix
|
./tailwind.nix
|
||||||
|
|
141
modules/plugins/languages/scala.nix
Normal file
141
modules/plugins/languages/scala.nix
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) types optionalString;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
|
||||||
|
mkBinding = binding: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${binding.action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})";
|
||||||
|
|
||||||
|
listCommandsBinding = {
|
||||||
|
value = cfg.lsp.extraMappings.listCommands;
|
||||||
|
description = "List Metals commands";
|
||||||
|
action =
|
||||||
|
if config.vim.telescope.enable
|
||||||
|
then ''require("telescope").extensions.metals.commands()''
|
||||||
|
else ''require("metals").commands()'';
|
||||||
|
};
|
||||||
|
|
||||||
|
cfg = config.vim.languages.scala;
|
||||||
|
|
||||||
|
usingDap = config.vim.debugger.nvim-dap.enable && cfg.dap.enable;
|
||||||
|
usingLualine = config.vim.statusline.lualine.enable;
|
||||||
|
in {
|
||||||
|
options.vim.languages.scala = {
|
||||||
|
enable = mkEnableOption "Scala language support";
|
||||||
|
treesitter = {
|
||||||
|
enable = mkEnableOption "Scala treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
package = mkGrammarOption pkgs "scala";
|
||||||
|
};
|
||||||
|
lsp = {
|
||||||
|
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;};
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.metals;
|
||||||
|
description = ''
|
||||||
|
metals package to use
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
extraMappings = {
|
||||||
|
listCommands = mkMappingOption "List Metals commands" "<leader>lc";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Scala Debug Adapter support";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
config = mkOption {
|
||||||
|
description = "Lua configuration for dap";
|
||||||
|
type = types.str;
|
||||||
|
default = ''
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable (
|
||||||
|
mkMerge [
|
||||||
|
(mkIf cfg.treesitter.enable {
|
||||||
|
vim.treesitter.enable = true;
|
||||||
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
|
})
|
||||||
|
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||||
|
vim = {
|
||||||
|
startPlugins = ["nvim-metals"];
|
||||||
|
luaConfigRC.nvim-metals = entryAfter ["lsp-setup"] ''
|
||||||
|
-- Scala nvim-metals config
|
||||||
|
local metals_caps = capabilities -- from lsp-setup
|
||||||
|
|
||||||
|
local attach_metals_keymaps = function(client, bufnr)
|
||||||
|
attach_keymaps(client, bufnr) -- from lsp-setup
|
||||||
|
${mkBinding listCommandsBinding}
|
||||||
|
end
|
||||||
|
|
||||||
|
metals_config = require('metals').bare_config()
|
||||||
|
${optionalString usingLualine "metals_config.init_options.statusBarProvider = 'on'"}
|
||||||
|
|
||||||
|
metals_config.capabilities = metals_caps
|
||||||
|
metals_config.on_attach = function(client, bufnr)
|
||||||
|
${optionalString usingDap "require('metals').setup_dap()"}
|
||||||
|
attach_metals_keymaps(client, bufnr)
|
||||||
|
end
|
||||||
|
metals_config.settings = {
|
||||||
|
metalsBinaryPath = "${cfg.lsp.package}/bin/metals",
|
||||||
|
showImplicitArguments = true,
|
||||||
|
showImplicitConversionsAndClasses = true,
|
||||||
|
showInferredType = true,
|
||||||
|
excludedPackages = {
|
||||||
|
"akka.actor.typed.javadsl",
|
||||||
|
"com.github.swagger.akka.javadsl"
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
|
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
|
virtual_text = {
|
||||||
|
prefix = '⚠',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
-- without doing this, autocommands that deal with filetypes prohibit messages from being shown
|
||||||
|
vim.opt_global.shortmess:remove("F")
|
||||||
|
|
||||||
|
vim.cmd([[augroup lsp]])
|
||||||
|
vim.cmd([[autocmd!]])
|
||||||
|
vim.cmd([[autocmd FileType java,scala,sbt lua require('metals').initialize_or_attach(metals_config)]])
|
||||||
|
vim.cmd([[augroup end]])
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue