From d1c002183f37f1633c753509d06ce47b7bc3f8b8 Mon Sep 17 00:00:00 2001 From: Daniel Carrillo Date: Mon, 12 Feb 2024 20:46:40 +0100 Subject: [PATCH] [neovim] Add copilot --- .config/nvim/lazy-lock.json | 19 +++++++++--------- .config/nvim/lua/core/keymaps.lua | 18 +++++++++++++++-- .config/nvim/lua/core/lazy.lua | 26 +++++++++++++++++++++---- .config/nvim/lua/plugins/bufferline.lua | 2 +- .config/nvim/lua/plugins/cmp.lua | 4 ++-- .config/nvim/lua/plugins/codeium.lua | 1 - .config/nvim/lua/plugins/copilot.lua | 17 ++++++++++++++++ .config/nvim/lua/plugins/init.lua | 2 +- .config/nvim/lua/plugins/lualine.lua | 1 + .config/nvim/lua/plugins/neotest.lua | 6 ++---- 10 files changed, 72 insertions(+), 24 deletions(-) delete mode 100644 .config/nvim/lua/plugins/codeium.lua create mode 100644 .config/nvim/lua/plugins/copilot.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 1958640..75a02cf 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,6 +1,5 @@ { "Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" }, - "DAPInstall.nvim": { "branch": "main", "commit": "8798b4c36d33723e7bba6ed6e2c202f84bb300de" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, "auto-save.nvim": { "branch": "main", "commit": "4b59610e1318f8a89501cee9d47a0e8650f0a4d5" }, @@ -10,19 +9,19 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "codeium.nvim": { "branch": "main", "commit": "f871000e91faa9ed334da2bfa4eadbf54d0e1047" }, + "codeium.nvim": { "branch": "main", "commit": "ad6705cacce51df32c9fd72b66f38cb242a95485" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, "friendly-snippets": { "branch": "main", "commit": "b8fae73a479ae0a1c54f5c98fa687ae8a0addc53" }, "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, "git-blame.nvim": { "branch": "master", "commit": "196602b570b1d754b7b8f9a9f75fa7bd88f12ef8" }, "github-nvim-theme": { "branch": "main", "commit": "d92e1143e5aaa0d7df28a26dd8ee2102df2cadd8" }, "gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" }, - "go.nvim": { "branch": "master", "commit": "096f65692034022c963b55f493961a8a1d861ba4" }, + "go.nvim": { "branch": "master", "commit": "d748e79011437d5b080006b896b3c296656641d7" }, "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, "karen-yank.nvim": { "branch": "main", "commit": "817f50c9464ce557c8f7f8f4d4c8d2f7b81fc40c" }, "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, - "leap.nvim": { "branch": "main", "commit": "e285f3c9a3fb11367f859faf553d28f332da0a2c" }, + "leap.nvim": { "branch": "main", "commit": "46e9b1a1d7438ac72794b0857b20cad4390b827c" }, "lspsaga.nvim": { "branch": "main", "commit": "2198c07124bef27ef81335be511c8abfd75db933" }, "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, @@ -33,7 +32,7 @@ "mini.starter": { "branch": "main", "commit": "0ee58ac8975a929e90c8b104987fabfd13015e25" }, "neo-tree.nvim": { "branch": "v2.x", "commit": "e578fe7a5832421b0d2c5b3c0a7a1e40e0f6a47a" }, "neotest": { "branch": "master", "commit": "89a5b1fc22ee5d459262955fe564c3d14e35fd67" }, - "neotest-go": { "branch": "main", "commit": "22513619bcb156939c22ea7cd1a99f754fcb1fde" }, + "neotest-go": { "branch": "main", "commit": "17579611af5d47bea5ff4d77e6493a6d647d3a15" }, "neovim-project": { "branch": "main", "commit": "e7868b38f402be94e859d479002df1418bc1e954" }, "neovim-session-manager": { "branch": "master", "commit": "07bb62583769abd9d32f88f428ea58248730ac7a" }, "noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" }, @@ -42,22 +41,24 @@ "nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" }, "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, "nvim-dap": { "branch": "master", "commit": "9d81c11fd185a131f81841e64941859305f6c42d" }, + "nvim-dap-python": { "branch": "master", "commit": "f5b6f3a90aae0284b61fb3565e575267c19a16e6" }, "nvim-dap-ui": { "branch": "master", "commit": "0b4816e5ad5f3219e8e3ec9cce07f61b770c1974" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "d4542ac257d3c7ee4131350db6179ae6340ce40b" }, - "nvim-lspconfig": { "branch": "master", "commit": "d12140c5687a1186b95b3f42dbc6cc769df0cf0d" }, - "nvim-treesitter": { "branch": "master", "commit": "4fbf150a1621d52f17b099506e1a32f107079210" }, + "nvim-lspconfig": { "branch": "master", "commit": "41f40dc4b86f3e166cf08115f621001972565a20" }, + "nvim-treesitter": { "branch": "master", "commit": "9860fceb73eb85a9ad424513fe163e6506dfb1fd" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, "nvim-ufo": { "branch": "main", "commit": "b0741a647efd98d9abb6cb653e056d24a07e4581" }, - "nvim-web-devicons": { "branch": "master", "commit": "aaec87dbdaa776bfa0a13c8694bec9bcb7454719" }, + "nvim-web-devicons": { "branch": "master", "commit": "7f30f2da3c3641841ceb0e2c150281f624445e8f" }, "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "promise-async": { "branch": "main", "commit": "94f6f03c6c1e2aab551aacdf0c1e597a7269abb6" }, "statuscol.nvim": { "branch": "main", "commit": "3b629754420919575a9e5758027d6e1831dbf2aa" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "7b5c5f56a21e82fdcfe5b250278b8dfc4b1cbab4" }, + "telescope.nvim": { "branch": "master", "commit": "0f865f17af4f9bc1587a0132414cdfd32d91852e" }, "tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" }, "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, "typescript-tools.nvim": { "branch": "master", "commit": "c43d9580c3ff5999a1eabca849f807ab33787ea7" }, + "venv-selector.nvim": { "branch": "main", "commit": "fcb30164f2c4f8a34a305ead3247954a1fd8634f" }, "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, "vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" }, "vim-kitty-navigator": { "branch": "master", "commit": "20abf8613aa228a5def1ae02cd9da0f2d210352a" }, diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index fd31ef4..ca7a406 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -122,7 +122,7 @@ keymap( keymap( "n", "lr", - "Lspsaga rename", + "Lspsaga rename mode=n", vim.tbl_extend("force", opts, { desc = "Open a dialog to rename a code element" }) ) keymap( @@ -132,7 +132,7 @@ keymap( vim.tbl_extend("force", opts, { desc = "Peek the definition of the directive under the cursor" }) ) keymap( - {"n", "v"}, + { "n", "v" }, "lf", "lua vim.lsp.buf.format{ async=true }", vim.tbl_extend("force", opts, { desc = "Format the current buffer or selection" }) @@ -152,6 +152,20 @@ keymap( vim.tbl_extend("force", opts, { desc = "Run tests on the current file" }) ) +-- Copilot +keymap( + "n", + "coe", + "CopilotChatExplain", + vim.tbl_extend("force", opts, { desc = "CopilotChat - Explain code" }) +) +keymap( + "n", + "cot", + "CopilotChatTests", + vim.tbl_extend("force", opts, { desc = "CopilotChat - Generate tests" }) +) + -- Better paste keymap("v", "p", "P", vim.tbl_extend("force", opts, { desc = "Paste" })) diff --git a/.config/nvim/lua/core/lazy.lua b/.config/nvim/lua/core/lazy.lua index 35c573a..53afd28 100644 --- a/.config/nvim/lua/core/lazy.lua +++ b/.config/nvim/lua/core/lazy.lua @@ -168,10 +168,10 @@ require("lazy").setup({ "hrsh7th/cmp-nvim-lsp", }, }, - { - "Exafunction/codeium.nvim", - event = "BufEnter", - }, + -- { + -- "Exafunction/codeium.nvim", + -- event = "BufEnter", + -- }, -- Snippets { "L3MON4D3/LuaSnip", version = "v2.*", event = "InsertEnter" }, @@ -283,6 +283,24 @@ require("lazy").setup({ ft = { "markdown" }, }, + -- Copilot + { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + event = "InsertEnter", + }, + { "zbirenbaum/copilot-cmp" }, + { "AndreM222/copilot-lualine" }, + { + "copilotc-nvim/copilotchat.nvim", + opts = { + show_help = "yes", + debug = false, + disable_extra_info = "yes", + }, + event = "VeryLazy", + }, + -- Folding { "kevinhwang91/nvim-ufo", diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua index 9278b7d..897c998 100644 --- a/.config/nvim/lua/plugins/bufferline.lua +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -35,7 +35,7 @@ bufferline.setup({ text = "  " .. string.gsub(vim.loop.cwd(), "^" .. os.getenv("HOME"), "~") .. "  " end - return { { text = text, fg = "#636E7B" } } + return { { text = text, fg = "#adbac7" } } end, }, }, diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 16cae51..ed255e2 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -103,7 +103,7 @@ cmp.setup({ nvim_lsp = "[lsp]", luasnip = "[snip]", buffer = "[local]", - codeium = "[AI]", + copilot = "[AI]", path = "", emoji = "", })[entry.source.name] @@ -115,7 +115,7 @@ cmp.setup({ { name = "luasnip" }, { name = "buffer" }, { name = "path" }, - { name = "codeium" }, + { name = "copilot" }, }, confirm_opts = { behavior = cmp.ConfirmBehavior.Replace, diff --git a/.config/nvim/lua/plugins/codeium.lua b/.config/nvim/lua/plugins/codeium.lua deleted file mode 100644 index b5fe92d..0000000 --- a/.config/nvim/lua/plugins/codeium.lua +++ /dev/null @@ -1 +0,0 @@ -require("codeium").setup({}) diff --git a/.config/nvim/lua/plugins/copilot.lua b/.config/nvim/lua/plugins/copilot.lua new file mode 100644 index 0000000..8850aa2 --- /dev/null +++ b/.config/nvim/lua/plugins/copilot.lua @@ -0,0 +1,17 @@ +require("copilot").setup({ + suggestion = { enabled = false }, + panel = { enabled = false }, + filetypes = { + javascript = true, + typescript = true, + go = true, + lua = true, + python = true, + sh = true, + yaml = true, + json = true, + ["*"] = false, + }, +}) + +require("copilot_cmp").setup() diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index 9bb1e4c..a0197c7 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -1,5 +1,5 @@ require("plugins.cmp") -require("plugins.codeium") +require("plugins.copilot") require("plugins.telescope") require("plugins.starter") require("plugins.treesitter") diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 863e121..e4c93c6 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -98,6 +98,7 @@ require("lualine").setup({ return true end, }, + "copilot", lsp_progress, { require("noice").api.status.search.get, diff --git a/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua index f151a84..c370b05 100644 --- a/.config/nvim/lua/plugins/neotest.lua +++ b/.config/nvim/lua/plugins/neotest.lua @@ -15,7 +15,6 @@ vim.api.nvim_create_user_command("CopyDirectoryPath", function() vim.notify('Copied "' .. path .. '" to the clipboard!') end, {}) - local neotest = require("neotest") neotest.setup({ @@ -30,11 +29,10 @@ neotest.setup({ }, }) - vim.api.nvim_create_user_command("RunTest", function() - neotest.run.run() + neotest.run.run() end, {}) vim.api.nvim_create_user_command("RunTestFile", function() - neotest.run.run(vim.fn.expand('%')) + neotest.run.run(vim.fn.expand("%")) end, {})