From 8a87841d6161777630e10b9369ec2574f2d8b809 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 30 Jun 2025 10:22:32 -0500 Subject: [PATCH] wip: update neovim stuff --- nix/base-system/flake.lock | 6 +++--- nix/base-system/flake.nix | 6 ++---- nix/base-system/init.lua | 27 ++++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/nix/base-system/flake.lock b/nix/base-system/flake.lock index 0331a44..ca2a2f6 100644 --- a/nix/base-system/flake.lock +++ b/nix/base-system/flake.lock @@ -1711,11 +1711,11 @@ }, "unstable": { "locked": { - "lastModified": 1747312588, - "narHash": "sha256-MmJvj6mlWzeRwKGLcwmZpKaOPZ5nJb/6al5CXqJsgjo=", + "lastModified": 1751349533, + "narHash": "sha256-5XRh0mB06/7WYDLu9ZXsx1GhyvvNVZDtPyg34sUCLJs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b1bebd0fe266bbd1820019612ead889e96a8fa2d", + "rev": "bdfd0f2afcf764e531d0960c821ab070a6174b15", "type": "github" }, "original": { diff --git a/nix/base-system/flake.nix b/nix/base-system/flake.nix index 044ce87..97f7970 100644 --- a/nix/base-system/flake.nix +++ b/nix/base-system/flake.nix @@ -116,15 +116,13 @@ nixpkgs.overlays = [ (final: prev: { lorri = unstablePkgs.lorri; - avante-nvim = unstablePkgs.vimPlugins.avante-nvim; - copilot-lua = unstablePkgs.vimPlugins.copilot-lua; }) ]; - programs = with pkgs; { + programs = with unstablePkgs; { neovim.enable = true; neovim.vimAlias = true; neovim.viAlias = true; - #neovim.package = pkgs.custom-neovim; + neovim.package = unstablePkgs.neovim-unwrapped; neovim.configure = { customRC = "lua << EOF ${builtins.readFile ./init.lua} diff --git a/nix/base-system/init.lua b/nix/base-system/init.lua index 56ba4cd..4bc87f6 100644 --- a/nix/base-system/init.lua +++ b/nix/base-system/init.lua @@ -283,7 +283,6 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'InsertLeave', 'CursorHold' }, { -- LSP Diagnostics Options Setup vim.diagnostic.config({ virtual_text = false, - signs = true, update_in_insert = true, underline = true, severity_sort = false, @@ -715,7 +714,7 @@ function get_server_list_prompt(hub_instance) for _, server in ipairs(servers) do mcp_tool_prompt = mcp_tool_prompt .. "## server name: `" .. server.name .. "`\n\n" - if server.capabilities.tools and #server.capabilities.tools > 0 then + if server.capabilities and server.capabilities.tools and #server.capabilities.tools > 0 then mcp_tool_prompt = mcp_tool_prompt .. "Available tools:\n\n" for _, tool in ipairs(server.capabilities.tools) do mcp_tool_prompt = mcp_tool_prompt .. "- tool name: `" .. tool.name .. "`\n" @@ -745,7 +744,29 @@ end vim.keymap.set("n", "ab", function() require('avante').get().file_selector:add_buffer_files() end) vim.keymap.set("n", "af", function() require('avante').get().file_selector:add_current_buffer() end) -require('copilot').setup() +get_root_dir = function() + -- First try to get the root path from LSP + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients({ bufnr = bufnr }) + + -- Check if we have an active LSP client with a root_dir + for _, client in ipairs(clients) do + if client.config and client.config.root_dir then + return client.config.root_dir + end + end + + -- Fall back to file-based detection + local root_file = vim.fs.find(function(name, path) + return name:match('(pyproject.toml|.sln|Cargo.toml|.git)$') + end, { upward = true })[1] + + return root_file and vim.fs.dirname(root_file) or vim.fn.getcwd() +end + +require('copilot').setup({ + root_dir = get_root_dir, +}) require('avante').setup({ provider = "claude",