Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We are using [Lazy.nvim](https://github.com/folke/lazy.nvim) to manage plugins.
These are some of the plugins that are currently installed, we recommend you to read their documentation to get the most out of them:

- [catppuccin](https://github.com/catppuccin/nvim)
- [copilot.vim](https://github.com/github/copilot.vim)
- [copilot.lua](https://github.com/zbirenbaum/copilot.lua)
- [snacks.nvim](https://github.com/folke/snacks.nvim)
- [vim-bundler](https://github.com/tpope/vim-bundler)
- [vim-endwise](https://github.com/tpope/vim-endwise)
Expand Down
55 changes: 44 additions & 11 deletions lua/plugins/completions.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
return {
"hrsh7th/nvim-cmp",
version = false,
enabled = false,
enabled = true,
event = { "InsertEnter" },
dependencies = {
"hrsh7th/cmp-nvim-lsp",
Expand All @@ -16,6 +16,12 @@ return {
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
local auto_select = true
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil
end

return {
completion = {
completeopt = "menu,menuone,noinsert"
Expand All @@ -25,7 +31,7 @@ return {
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<CR>"] = cmp.mapping.confirm(),
["<Tab>"] = cmp.mapping.confirm(),
["<C-CR>"] = function(fallback)
cmp.abort()
fallback()
Expand All @@ -40,9 +46,10 @@ return {
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
{ name = "copilot", group_index = 2},
}, {
{ name = "buffer" },
}),
{ name = "buffer" },
}),
formatting = {
format = function(entry, item)
local icons = {
Expand Down Expand Up @@ -105,13 +112,39 @@ return {
return item
end,
},
sorting = defaults.sorting,
},
cmp.setup({
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
sorting = {
priority_weight = 2,
comparators = {
require("copilot_cmp.comparators").prioritize,

-- Below is the default comparitor list and order for nvim-cmp
cmp.config.compare.offset,
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.recently_used,
cmp.config.compare.locality,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
})
cmp.setup({
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = {
["<Tab>"] = vim.schedule_wrap(function(fallback)
if cmp.visible() and has_words_before() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
else
fallback()
end
end),
},
})
}
end,
}
6 changes: 6 additions & 0 deletions lua/plugins/copilot-cmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
"zbirenbaum/copilot-cmp",
config = function ()
require("copilot_cmp").setup()
end
}
11 changes: 11 additions & 0 deletions lua/plugins/copilot.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
suggestion = { enabled = false },
panel = { enabled = false },
})
end,
}
1 change: 0 additions & 1 deletion lua/plugins/plugins.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
return {
"airblade/vim-gitgutter",
"github/copilot.vim",
"pangloss/vim-javascript",
"tpope/vim-endwise",
"tpope/vim-rails",
Expand Down