feat: added copilot

This commit is contained in:
Raj 2024-07-15 14:19:03 +05:30
parent bf51fdcc62
commit de2b3a73dd
5 changed files with 123 additions and 110 deletions

View File

@ -1,7 +1,7 @@
{ {
"AstroNvim": { "branch": "main", "commit": "699229855ae26777f19d02821a484ccf379efe79" }, "AstroNvim": { "branch": "main", "commit": "699229855ae26777f19d02821a484ccf379efe79" },
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"aerial.nvim": { "branch": "master", "commit": "4d10acbcb760802ea74381ac3ed98cbb6e5f7805" }, "aerial.nvim": { "branch": "master", "commit": "4d10acbcb760802ea74381ac3ed98cbb6e5f7805" },
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
"astrocommunity": { "branch": "main", "commit": "09a82e154d407d75e8781889d86a4557f1328250" }, "astrocommunity": { "branch": "main", "commit": "09a82e154d407d75e8781889d86a4557f1328250" },
@ -17,19 +17,19 @@
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "cd75be867f2331b22905f47d28c0c270a69466aa" }, "conform.nvim": { "branch": "master", "commit": "cd75be867f2331b22905f47d28c0c270a69466aa" },
"copilot": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" }, "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" },
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" }, "dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
"friendly-snippets": { "branch": "main", "commit": "45a1b96e46efe5fce8af325d4bed45feb9d29d0f" }, "friendly-snippets": { "branch": "main", "commit": "45a1b96e46efe5fce8af325d4bed45feb9d29d0f" },
"gitsigns.nvim": { "branch": "main", "commit": "375c44bdfdde25585466a966f00c2e291db74f2d" }, "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" },
"guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" }, "guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" },
"heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" },
"indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
"lazy.nvim": { "branch": "main", "commit": "d1de92dffab5a862332fdd1892889d362369c12f" }, "lazy.nvim": { "branch": "main", "commit": "f918318d21956b0874a65ab35ce3d94d9057aabf" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
"mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" }, "mason-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" },
"mason.nvim": { "branch": "main", "commit": "f96a31855fa8aea55599cea412fe611b85a874ed" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mini.bufremove": { "branch": "main", "commit": "e6044aa28e61d4dd9ec86194d6f81743eced0c1c" }, "mini.bufremove": { "branch": "main", "commit": "e6044aa28e61d4dd9ec86194d6f81743eced0c1c" },
"neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" }, "neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" },
"neoconf.nvim": { "branch": "main", "commit": "e34cf5e359500e3c5fc35d5b137335fba94ed501" }, "neoconf.nvim": { "branch": "main", "commit": "e34cf5e359500e3c5fc35d5b137335fba94ed501" },
@ -42,9 +42,9 @@
"nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" }, "nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" },
"nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" }, "nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" },
"nvim-lspconfig": { "branch": "master", "commit": "cf97d2485fc3f6d4df1b79a3ea183e24c272215e" }, "nvim-lspconfig": { "branch": "master", "commit": "cf97d2485fc3f6d4df1b79a3ea183e24c272215e" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-treesitter": { "branch": "master", "commit": "e9ec8b4658880ab41986dba3cf8eaf1f805659bb" }, "nvim-treesitter": { "branch": "master", "commit": "d5969c481e811958123f25c2c559cb7b4b6ca217" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-ts-autotag": { "branch": "main", "commit": "323a3e16ed603e2e17b26b1c836d1e86c279f726" }, "nvim-ts-autotag": { "branch": "main", "commit": "323a3e16ed603e2e17b26b1c836d1e86c279f726" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" },
@ -56,9 +56,9 @@
"resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" }, "resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" },
"smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" }, "smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "bfcc7d5c6f12209139f175e6123a7b7de6d9c18a" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"todo-comments.nvim": { "branch": "main", "commit": "313b04e5b02d29ab9275c9295ff5e2b73921b0eb" }, "todo-comments.nvim": { "branch": "main", "commit": "313b04e5b02d29ab9275c9295ff5e2b73921b0eb" },
"toggleterm.nvim": { "branch": "main", "commit": "066cccf48a43553a80a210eb3be89a15d789d6e6" }, "toggleterm.nvim": { "branch": "main", "commit": "066cccf48a43553a80a210eb3be89a15d789d6e6" },
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
"which-key.nvim": { "branch": "main", "commit": "af4ded85542d40e190014c732fa051bdbf88be3d" } "which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }
} }

View File

@ -7,4 +7,20 @@ return {
"AstroNvim/astrocommunity", "AstroNvim/astrocommunity",
{ import = "astrocommunity.pack.lua" }, { import = "astrocommunity.pack.lua" },
-- import/override with your plugins folder -- import/override with your plugins folder
{ import = "astrocommunity.completion.copilot-lua" },
{
"copilot.lua",
opts = {
suggestion = {
keymap = {
accept = "<A-k>",
accept_word = "<C-e>",
accept_line = "<C-L>",
next = "<A-l>",
prev = "<A-h>",
dismiss = "<C/>",
},
},
},
},
} }

View File

@ -3,99 +3,102 @@
---@type LazySpec ---@type LazySpec
return { return {
"AstroNvim/astrolsp", "AstroNvim/astrolsp",
---@type AstroLSPOpts ---@type AstroLSPOpts
opts = { opts = {
-- Configuration table of features provided by AstroLSP -- Configuration table of features provided by AstroLSP
features = { features = {
codelens = true, -- enable/disable codelens refresh on start codelens = true, -- enable/disable codelens refresh on start
inlay_hints = false, -- enable/disable inlay hints on start inlay_hints = false, -- enable/disable inlay hints on start
semantic_tokens = true, -- enable/disable semantic token highlighting semantic_tokens = true, -- enable/disable semantic token highlighting
}, },
-- customize lsp formatting options -- customize lsp formatting options
formatting = { formatting = {
-- control auto formatting on save -- control auto formatting on save
format_on_save = { format_on_save = {
enabled = true, -- enable or disable format on save globally enabled = true, -- enable or disable format on save globally
allow_filetypes = { -- enable format on save for specified filetypes only allow_filetypes = { -- enable format on save for specified filetypes only
-- "go", "go",
}, },
ignore_filetypes = { -- disable format on save for specified filetypes ignore_filetypes = { -- disable format on save for specified filetypes
-- "python", -- "python",
}, },
}, },
disabled = { -- disable formatting capabilities for the listed language servers disabled = { -- disable formatting capabilities for the listed language servers
-- disable lua_ls formatting capability if you want to use StyLua to format your lua code -- disable lua_ls formatting capability if you want to use StyLua to format your lua code
-- "lua_ls", -- "lua_ls",
}, },
timeout_ms = 1000, -- default format timeout timeout_ms = 1000, -- default format timeout
-- filter = function(client) -- fully override the default formatting function -- filter = function(client) -- fully override the default formatting function
-- return true -- return true
-- end -- end
}, },
-- enable servers that you already have installed without mason -- enable servers that you already have installed without mason
servers = { servers = {
-- "pyright" -- "pyright"
}, },
-- customize language server configuration options passed to `lspconfig` -- customize language server configuration options passed to `lspconfig`
---@diagnostic disable: missing-fields ---@diagnostic disable: missing-fields
config = { config = {
-- clangd = { capabilities = { offsetEncoding = "utf-8" } }, -- clangd = { capabilities = { offsetEncoding = "utf-8" } },
}, },
-- customize how language servers are attached -- customize how language servers are attached
handlers = { handlers = {
-- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server
-- function(server, opts) require("lspconfig")[server].setup(opts) end -- function(server, opts) require("lspconfig")[server].setup(opts) end
-- the key is the server that is being setup with `lspconfig` -- the key is the server that is being setup with `lspconfig`
-- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server
-- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed
}, },
-- Configure buffer local auto commands to add when attaching a language server -- Configure buffer local auto commands to add when attaching a language server
autocmds = { autocmds = {
-- first key is the `augroup` to add the auto commands to (:h augroup) -- first key is the `augroup` to add the auto commands to (:h augroup)
lsp_codelens_refresh = { lsp_codelens_refresh = {
-- Optional condition to create/delete auto command group -- Optional condition to create/delete auto command group
-- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean`
-- condition will be resolved for each client on each execution and if it ever fails for all clients, -- condition will be resolved for each client on each execution and if it ever fails for all clients,
-- the auto commands will be deleted for that buffer -- the auto commands will be deleted for that buffer
cond = "textDocument/codeLens", cond = "textDocument/codeLens",
-- cond = function(client, bufnr) return client.name == "lua_ls" end, -- cond = function(client, bufnr) return client.name == "lua_ls" end,
-- list of auto commands to set -- list of auto commands to set
{ {
-- events to trigger -- events to trigger
event = { "InsertLeave", "BufEnter" }, event = { "InsertLeave", "BufEnter" },
-- the rest of the autocmd options (:h nvim_create_autocmd) -- the rest of the autocmd options (:h nvim_create_autocmd)
desc = "Refresh codelens (buffer)", desc = "Refresh codelens (buffer)",
callback = function(args) callback = function(args)
if require("astrolsp").config.features.codelens then vim.lsp.codelens.refresh { bufnr = args.buf } end if require("astrolsp").config.features.codelens then
end, vim.lsp.codelens.refresh({ bufnr = args.buf })
}, end
}, end,
}, },
-- mappings to be set up on attaching of a language server },
mappings = { },
n = { -- mappings to be set up on attaching of a language server
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean mappings = {
gD = { n = {
function() vim.lsp.buf.declaration() end, -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
desc = "Declaration of current symbol", gD = {
cond = "textDocument/declaration", function() vim.lsp.buf.declaration() end,
}, desc = "Declaration of current symbol",
["<Leader>uY"] = { cond = "textDocument/declaration",
function() require("astrolsp.toggles").buffer_semantic_tokens() end, },
desc = "Toggle LSP semantic highlight (buffer)", ["<Leader>uY"] = {
cond = function(client) function() require("astrolsp.toggles").buffer_semantic_tokens() end,
return client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil desc = "Toggle LSP semantic highlight (buffer)",
end, cond = function(client)
}, return client.supports_method("textDocument/semanticTokens/full")
}, and vim.lsp.semantic_tokens ~= nil
}, end,
-- A custom `on_attach` function to be run after the default `on_attach` function },
-- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) },
on_attach = function(client, bufnr) },
-- this would disable semanticTokensProvider for all clients -- A custom `on_attach` function to be run after the default `on_attach` function
-- client.server_capabilities.semanticTokensProvider = nil -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
end, on_attach = function(client, bufnr)
}, -- this would disable semanticTokensProvider for all clients
-- client.server_capabilities.semanticTokensProvider = nil
end,
},
} }

View File

@ -1,7 +0,0 @@
return {
{
"zbirenbaum/copilot.lua",
name = "copilot",
config = function() require("copilot").setup() end,
},
}

View File

@ -10,6 +10,7 @@ return {
ensure_installed = { ensure_installed = {
"lua_ls", "lua_ls",
"tsserver", "tsserver",
"gopls",
-- add more arguments for adding more language servers -- add more arguments for adding more language servers
}, },
}, },