r/lunarvim • • Feb 20 '23

Copilot behaviour

Hi

I am really liking LunarVim but there are a few things I'd like to customize for github copilot and I'm not an expert with Lua.

Currently Copilot gives me suggestions for single lines. It also only autocompletes when I've started the line of code already.

In vanilla nvim it autocompletes entire functions from a comment on the previous line and will autocomplete starting from a blank line. Is it possible to get this behaviour? Ideally I would like to use this with a key binding so I can still use tab on a blank line.

Thanks

9 Upvotes

3 comments sorted by

1

u/[deleted] Mar 03 '23

It sounds like you enabled cmp completion for it as described in the docs. What you're describing you did in neovim is virtual text which can be enabled by passing it in the config to copilot setup exactly like you did for neovim. The docs do need updating, this is the superior setup imo.

1

u/pljusak Mar 08 '23

Thanks for your response!

With neovim I think I used a vimscript config rather than a .lua file.

Do yo know how I would adjust my current config to get this setting? I've pasted the relevant part of my current config

-- Additional Plugins
lvim.plugins = {
{ "zbirenbaum/copilot.lua",
event = { "VimEnter" },
config = function()
vim.defer_fn(function()
require("copilot").setup {
plugin_manager_path = get_runtime_dir() .. "/site/pack/packer",
}
end, 100)
end,
},
{ "zbirenbaum/copilot-cmp",
after = { "copilot.lua" },
config = function()
require("copilot_cmp").setup()
end,
},
{ 'shaeinst/roshnivim-cs' },
{ 'Mofiqul/dracula.nvim' },
{ 'frenzyexists/aquarium-vim' },
{ 'luisiacc/gruvbox-baby' },
{ 'kdheepak/lazygit.nvim' },
{
"max397574/better-escape.nvim",
config = function()
require("better_escape").setup()
end,
},
-- { 'nvim-lua/plenary.nvim' },
{ 'folke/todo-comments.nvim' },
{ 'brooth/far.vim' },
{ 'windwp/nvim-spectre' },
{
"folke/trouble.nvim",
cmd = "TroubleToggle",
},
}
-- Can not be placed into the config method of the plugins.
lvim.builtin.cmp.formatting.source_names["copilot"] = "(Copilot)"
table.insert(lvim.builtin.cmp.sources, 1, { name = "copilot" })

1

u/[deleted] Mar 08 '23

Look at the copilot plugin readme for the virtual text setting and pass it.