update nvim to use packer

This commit is contained in:
ksyasuda
2022-10-28 12:36:08 -07:00
parent 227a06e002
commit 851ae5a1a2
9 changed files with 890 additions and 263 deletions

View File

@@ -15,7 +15,7 @@ require('bufferline').setup {
-- NOTE: this plugin is designed with this icon in mind,
-- and so changing this is NOT recommended, this is intended
-- as an escape hatch for people who cannot bear it for whatever reason
indicator_icon = '',
indicator_style = '',
buffer_close_icon = '',
modified_icon = '',
close_icon = '',

View File

@@ -0,0 +1,38 @@
require('copilot').setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<S-CR>"
},
},
suggestion = {
enabled = true,
auto_trigger = false,
debounce = 75,
keymap = {
accept = "<M-l>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
filetypes = {
yaml = false,
markdown = false,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = 'node', -- Node version must be < 18
plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer",
server_opts_overrides = {},
})

View File

@@ -0,0 +1,8 @@
-- lspkind.lua
local lspkind = require("lspkind")
lspkind.init({
symbol_map = {
Copilot = ""
},
})
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", {fg ="#6CC644"})

View File

@@ -8,6 +8,12 @@ capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- luasnip setup
local luasnip = require 'luasnip'
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
cmp.setup({
snippet = {
expand = function(args)
@@ -38,26 +44,22 @@ cmp.setup({
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
select = false,
},
-- ['<Tab>'] = function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- else
-- fallback()
-- end
-- end,
-- ['<S-Tab>'] = function(fallback)
-- if cmp.visible() then
-- cmp.select_prev_item()
-- elseif luasnip.jumpable(-1) then
-- luasnip.jump(-1)
-- else
-- fallback()
-- end
-- end,
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
end
end, { "i", "s"}),
},
formatting = {
format = lspkind.cmp_format({
@@ -101,3 +103,11 @@ for _, lsp in ipairs(servers) do
capabilities = capabilities,
}
end
cmp.event:on("menu_opened", function()
vim.b.copilot_suggestion_hidden = true
end)
cmp.event:on("menu_closed", function()
vim.b.copilot_suggestion_hidden = false
end)