From 0860e967f34f991a323c9d72950ef45e810de460 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Sat, 11 Oct 2025 12:49:37 -0700 Subject: [PATCH] update to nixvim scala metals and copilot configs --- .claude/settings.local.json | 10 +++++++++ programs/nixvim/README.md | 9 ++++++++ programs/nixvim/autocommands.nix | 7 ++++++ programs/nixvim/keymappings.nix | 5 +++++ programs/nixvim/plugins/ai.nix | 25 ++++++++++++++++++--- programs/nixvim/plugins/lsp/servers.nix | 30 +++++++++++++++++++++++-- 6 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..0b0dade --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,10 @@ +{ + "permissions": { + "allow": [ + "WebFetch(domain:github.com)", + "WebFetch(domain:raw.githubusercontent.com)" + ], + "deny": [], + "ask": [] + } +} diff --git a/programs/nixvim/README.md b/programs/nixvim/README.md index 31581fa..31a628d 100644 --- a/programs/nixvim/README.md +++ b/programs/nixvim/README.md @@ -230,6 +230,15 @@ Adjust these in `options.nix` and `completion.nix` respectively. | `j` | Normal | Next diagnostic | | `k` | Normal | Previous diagnostic | +### Metals (Scala Development) + +| Key | Mode | Action | +|-----|------|--------| +| `ws` | Normal | Hover Metals Worksheet | +| `sm` | Normal | Telescope Metals Commands | +| `tt` | Normal | Toggle tree view | +| `tr` | Normal | Reveal in tree | + ### Terminal (Floaterm) | Key | Mode | Action | diff --git a/programs/nixvim/autocommands.nix b/programs/nixvim/autocommands.nix index 71cf023..4900037 100644 --- a/programs/nixvim/autocommands.nix +++ b/programs/nixvim/autocommands.nix @@ -30,5 +30,12 @@ pattern = ["swift" "json" "lua" "nix"]; command = "setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab"; } + + # Metals (Scala) - Refresh codelens + { + event = ["BufEnter" "CursorHold" "InsertLeave"]; + pattern = ["*.scala" "*.sbt" "*.java"]; + command = "lua vim.lsp.codelens.refresh()"; + } ]; } diff --git a/programs/nixvim/keymappings.nix b/programs/nixvim/keymappings.nix index 23e0df3..b4075df 100644 --- a/programs/nixvim/keymappings.nix +++ b/programs/nixvim/keymappings.nix @@ -30,6 +30,11 @@ "" = ":vertical resize -2"; "" = ":move-2"; "" = ":move+"; + # Metals (Scala) keybindings + "ws" = "lua require('metals').hover_worksheet()"; + "sm" = "lua require('telescope').extensions.metals.commands()"; + "tt" = "lua require('metals.tvp').toggle_tree_view()"; + "tr" = "lua require('metals.tvp').reveal_in_tree()"; }; visual = lib.mapAttrsToList diff --git a/programs/nixvim/plugins/ai.nix b/programs/nixvim/plugins/ai.nix index b887537..0f1e653 100644 --- a/programs/nixvim/plugins/ai.nix +++ b/programs/nixvim/plugins/ai.nix @@ -4,14 +4,33 @@ programs.nixvim = { plugins = { # GitHub Copilot - copilot-vim.enable = true; + copilot-vim = { + enable = true; + }; # Avante AI assistant (imported from separate file) # avante config is in avante.nix }; globals = { - copilot_node_command = lib.mkForce "${pkgs.nodejs-slim}/bin/node"; + copilot_node_command = lib.mkForce "${pkgs.nodejs}/bin/node"; + copilot_no_tab_map = true; + copilot_assume_mapped = true; }; + + # Copilot keymapping - use Ctrl+J to accept suggestion + keymaps = [ + { + mode = "i"; + key = ""; + action = "copilot#Accept(\"\\\")"; + options = { + silent = true; + script = true; + expr = true; + replace_keycodes = false; + }; + } + ]; }; -} \ No newline at end of file +} diff --git a/programs/nixvim/plugins/lsp/servers.nix b/programs/nixvim/plugins/lsp/servers.nix index 6e35c82..5cd1de7 100644 --- a/programs/nixvim/plugins/lsp/servers.nix +++ b/programs/nixvim/plugins/lsp/servers.nix @@ -52,7 +52,33 @@ marksman.enable = true; # Scala - metals.enable = true; + metals = { + enable = true; + settings.settings = { + bloopSbtAlreadyInstalled = true; + defaultBspToBuildTool = true; + enableBestEffort = true; + excludedPackages = [ + "akka.actor.typed.javadsl" + "com.github.swagger.akka.javadsl" + ]; + initOptions = { + statusBarProvider = "on"; + }; + inlayHints = { + typeParameters.enable = true; + hintsInPatternMatch.enable = true; + }; + mcpClient = "claude"; + serverVersion = "latest.snapshot"; + showImplicitArguments = true; + showImplicitConversionsAndClasses = true; + showInferredType = true; + startMcpServer = true; + superMethodLensesEnabled = true; + useGlobalExecutable = true; + }; + }; # Nix nil_ls.enable = true; @@ -76,4 +102,4 @@ tinymist.enable = true; }; }; -} \ No newline at end of file +}