Last active
March 21, 2025 05:11
-
-
Save ravitemer/dc8825c67259dc717cbd4adf12c7daf6 to your computer and use it in GitHub Desktop.
minimal config file with snacks for mcphub.nvim plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ---@diagnostic disable: missing-fields | |
| --[[ | |
| NOTE: Set the config path to enable the copilot adapter to work. | |
| It will search the following paths for a token: | |
| - "$CODECOMPANION_TOKEN_PATH/github-copilot/hosts.json" | |
| - "$CODECOMPANION_TOKEN_PATH/github-copilot/apps.json" | |
| --]] | |
| vim.env["CODECOMPANION_TOKEN_PATH"] = vim.fn.expand("~/.config") | |
| vim.env.LAZY_STDPATH = ".repro" | |
| load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))() | |
| -- Basic keymaps | |
| local function map(mode, lhs, rhs, opts) | |
| opts = opts or {} | |
| opts.silent = opts.silent ~= false | |
| vim.keymap.set(mode, lhs, rhs, opts) | |
| end | |
| -- Set leader key to space | |
| vim.g.mapleader = " " | |
| -- Better escape using fj in insert mode | |
| map("i", "fj", "<ESC>") | |
| -- Use ; as : | |
| map("n", ";", ":") | |
| -- Better window navigation | |
| map("n", "<C-h>", "<C-w>h") | |
| map("n", "<C-j>", "<C-w>j") | |
| map("n", "<C-k>", "<C-w>k") | |
| map("n", "<C-l>", "<C-w>l") | |
| -- MCPHub keymap | |
| map("n", "<leader>am", "<cmd>MCPHub<CR>") | |
| -- AvanteChat keymap | |
| map("n", "<leader>aa", "<cmd>AvanteChat<CR>") | |
| map("n", "<leader>ac", "<cmd>CodeCompanionChat Toggle<CR>") | |
| -- Your CodeCompanion setup | |
| local plugins = { | |
| { | |
| -- Snacks as default configuration | |
| "folke/snacks.nvim", | |
| priority = 1000, | |
| lazy = false, | |
| ---@type snacks.Config | |
| opts = { | |
| bigfile = { enabled = true }, | |
| dashboard = { | |
| enabled = true, | |
| sections = { | |
| { section = "header" }, | |
| { icon = " ", title = "Keymaps", section = "keys", indent = 2, padding = 1 }, | |
| { icon = " ", title = "Recent Files", section = "recent_files", indent = 2, padding = 1 }, | |
| { icon = " ", title = "Projects", section = "projects", indent = 2, padding = 1 }, | |
| { | |
| icon = " ", | |
| title = "Git Status", | |
| section = "terminal", | |
| enabled = function() | |
| return Snacks.git.get_root() ~= nil | |
| end, | |
| cmd = "git status --short --branch --renames", | |
| height = 5, | |
| padding = 1, | |
| ttl = 5 * 60, | |
| indent = 2, | |
| }, | |
| { section = "startup" }, | |
| }, | |
| }, | |
| explorer = { enabled = true }, | |
| picker = { | |
| enabled = true, | |
| hidden = true, | |
| }, | |
| notifier = { | |
| enabled = true, | |
| timeout = 2000, | |
| }, | |
| quickfile = { enabled = true }, | |
| }, | |
| }, | |
| { | |
| "ravitemer/mcphub.nvim", | |
| dependencies = { | |
| "nvim-lua/plenary.nvim", | |
| }, | |
| build = "npm install -g mcp-hub@latest", | |
| config = function() | |
| require("mcphub").setup({ | |
| port = 5999, | |
| config = vim.fn.expand("~/.config/lvim/lvim-mcp-servers.json"), | |
| }) | |
| end, | |
| }, | |
| { | |
| "yetone/avante.nvim", | |
| event = "VeryLazy", | |
| version = false, -- Never set this value to "*"! Never! | |
| opts = { | |
| -- for example | |
| provider = "copilot", | |
| copilot = { | |
| model = "claude-3.5-sonnet", -- your desired model (or use gpt-4o, etc.) | |
| }, | |
| -- The system_prompt type supports both a string and a function that returns a string. Using a function here allows dynamically updating the prompt with mcphub | |
| system_prompt = function() | |
| local hub = require("mcphub").get_hub_instance() | |
| return hub:get_active_servers_prompt() | |
| end, | |
| -- The custom_tools type supports both a list and a function that returns a list. Using a function here prevents requiring mcphub before it's loaded | |
| custom_tools = function() | |
| return { | |
| require("mcphub.extensions.avante").mcp_tool(), | |
| } | |
| end, | |
| }, | |
| -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` | |
| build = "make", | |
| -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows | |
| dependencies = { | |
| "nvim-treesitter/nvim-treesitter", | |
| "stevearc/dressing.nvim", | |
| "nvim-lua/plenary.nvim", | |
| "MunifTanjim/nui.nvim", | |
| --- The below dependencies are optional, | |
| "echasnovski/mini.pick", -- for file_selector provider mini.pick | |
| "nvim-telescope/telescope.nvim", -- for file_selector provider telescope | |
| "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions | |
| "ibhagwan/fzf-lua", -- for file_selector provider fzf | |
| "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons | |
| { | |
| "zbirenbaum/copilot.lua", | |
| config = function() | |
| require("copilot").setup({}) | |
| end, | |
| build = ":Copilot auth", | |
| }, | |
| { | |
| -- support for image pasting | |
| "HakonHarnes/img-clip.nvim", | |
| event = "VeryLazy", | |
| opts = { | |
| -- recommended settings | |
| default = { | |
| embed_image_as_base64 = false, | |
| prompt_for_file_name = false, | |
| drag_and_drop = { | |
| insert_mode = true, | |
| }, | |
| -- required for Windows users | |
| use_absolute_path = true, | |
| }, | |
| }, | |
| }, | |
| { | |
| -- Make sure to set this up properly if you have lazy=true | |
| "MeanderingProgrammer/render-markdown.nvim", | |
| opts = { | |
| file_types = { "markdown", "Avante" }, | |
| }, | |
| ft = { "markdown", "Avante" }, | |
| }, | |
| }, | |
| }, | |
| { | |
| "olimorris/codecompanion.nvim", | |
| dependencies = { | |
| { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, | |
| { "nvim-lua/plenary.nvim" }, | |
| -- Test with blink.cmp | |
| { | |
| "saghen/blink.cmp", | |
| lazy = false, | |
| version = "*", | |
| opts = { | |
| keymap = { | |
| preset = "enter", | |
| ["<S-Tab>"] = { "select_prev", "fallback" }, | |
| ["<Tab>"] = { "select_next", "fallback" }, | |
| }, | |
| cmdline = { sources = { "cmdline" } }, | |
| sources = { | |
| default = { "lsp", "path", "buffer", "codecompanion" }, | |
| }, | |
| }, | |
| }, | |
| -- Test with nvim-cmp | |
| -- { "hrsh7th/nvim-cmp" }, | |
| }, | |
| opts = { | |
| --Refer to: https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/config.lua | |
| strategies = { | |
| --NOTE: Change the adapter as required | |
| chat = { | |
| adapter = "copilot", | |
| tools = { | |
| ["mcp"] = { | |
| callback = function() | |
| return require("mcphub.extensions.codecompanion") | |
| end, | |
| description = "Call tools and resources from the MCP Servers", | |
| opts = { | |
| requires_approval = true, | |
| }, | |
| }, | |
| }, | |
| }, | |
| inline = { adapter = "copilot" }, | |
| }, | |
| opts = { | |
| log_level = "DEBUG", | |
| }, | |
| }, | |
| }, | |
| } | |
| require("lazy.minit").repro({ spec = plugins }) | |
| -- Setup Tree-sitter | |
| local ts_status, treesitter = pcall(require, "nvim-treesitter.configs") | |
| if ts_status then | |
| treesitter.setup({ | |
| ensure_installed = { "lua", "markdown", "markdown_inline", "yaml" }, | |
| highlight = { enable = true }, | |
| }) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment