neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

commit 4f8ce7ab03656085c18673c03503d7e9d50faac3
parent 7b1e426673dac6dd4ec4aa91e2095ea698cf9432
Author: Tomas Nemec <owl@gtms.dev>
Date:   Sat, 22 Jul 2023 02:05:44 +0200

update: Codeium

Diffstat:
Mafter/plugin/cmp.lua | 24+++++++++++++-----------
Aafter/plugin/codeium.lua | 32++++++++++++++++++++++++++++++++
Mcolors/base16.lua | 2++
Mlua/plugins.lua | 9+++++----
Alua/tms/p/codeium.lua | 37+++++++++++++++++++++++++++++++++++++
5 files changed, 89 insertions(+), 15 deletions(-)

diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua @@ -31,6 +31,7 @@ local kind_icons = { } local cmp = require('cmp') +local Codeium = require('tms.p.codeium') -- local compare = require('cmp.config.compare') -- require('cmp_dictionary').setup({ -- dic = { -- @@ -43,19 +44,20 @@ local cmp = require('cmp') -- async = true, -- }) -- cmp.register_source('exe', require('tms.p.cmp.exe_source').new()) - local function close() return function(fallback) - if pcall(require, 'copilot') then - local copilot = require('copilot.suggestion') - if copilot.is_visible() then - fallback = copilot.dismiss - end + -- if pcall(require, 'copilot') then + -- local copilot = require('copilot.suggestion') + -- if copilot.is_visible() then + -- fallback = copilot.dismiss + -- end + -- end + + if Codeium.Completions() then + fallback = Codeium.Clear end - if cmp.visible() then - cmp.abort() - else + if not cmp.close() then fallback() end end @@ -94,8 +96,8 @@ cmp.setup({ ['<c-y>'] = cmp.mapping.confirm({ select = true }), ['<c-u>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), ['<c-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - ['<c-p>'] = cmp.mapping({ i = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }) }), - ['<c-n>'] = cmp.mapping({ i = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }) }), + ['<c-n>'] = cmp.mapping({ i = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }) }), + ['<c-p>'] = cmp.mapping({ i = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }) }), ['<c-space>'] = cmp.mapping({ i = cmp.mapping.complete() }), }, sources = cmp.config.sources({ diff --git a/after/plugin/codeium.lua b/after/plugin/codeium.lua @@ -0,0 +1,32 @@ +vim.g.codeium_disable_bindings = true +vim.g.codeium_no_map_tab = true + +local Codeium = require('tms.p.codeium') + +vim.keymap.set('i', '<c-y>', Codeium.Accept, { expr = true, desc = 'Codeium Accept' }) +vim.keymap.set('i', '<c-e>', Codeium.Clear, { expr = true, desc = 'Codeium Clear' }) +vim.keymap.set('i', '<c-n>', Codeium.Next, { expr = true, desc = 'Codeium Next' }) +vim.keymap.set('i', '<c-p>', Codeium.Prev, { expr = true, desc = 'Codeium Prev' }) + +local toggle = require('tms.toggle') +toggle.fn('p', function() + if Codeium.isEnabled() then + Codeium.Disable() + else + Codeium.Enable() + end +end, 'Codeium Toggle') + +-- if pcall(require, 'cmp') then +-- local cmp = require('cmp') +-- cmp.event:on('menu_opened', function() +-- Codeium.DisableBuffer() +-- if Codeium.Completions() then +-- Codeium.Clear() +-- end +-- end) +-- cmp.event:on('menu_closed', function() +-- Codeium.EnableBuffer() +-- Codeium.Complete(); +-- end) +-- end diff --git a/colors/base16.lua b/colors/base16.lua @@ -326,6 +326,8 @@ vim.api.nvim_set_hl(0, 'GitGutterChange', { fg = gui0D, bg = gui00 }) vim.api.nvim_set_hl(0, 'GitGutterDelete', { fg = gui08, bg = gui00 }) vim.api.nvim_set_hl(0, 'GitGutterChangeDelete', { fg = gui0E, bg = gui00 }) +vim.api.nvim_set_hl(0, 'CodeiumSuggestion', { link = 'Comment' }) + -- Hide all semantic highlights -- for _, group in ipairs(vim.fn.getcompletion('@lsp', 'highlight')) do -- vim.api.nvim_set_hl(0, group, {}) diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -29,8 +29,8 @@ return packer.startup { use 'tpope/vim-repeat' use 'kylechui/nvim-surround' use 'chaoren/vim-wordmotion' -- word counts with _,.,-,... - use 'romgrk/equal.operator' -- equal text object `lefthand = righthand` - use 'godlygeek/tabular' -- align + use 'romgrk/equal.operator' -- equal text object `lefthand = righthand` + use 'godlygeek/tabular' -- align -- use 'windwp/nvim-autopairs' use 'numToStr/Comment.nvim' use 'mbbill/undotree' @@ -97,7 +97,7 @@ return packer.startup { 'hrsh7th/cmp-calc', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-nvim-lsp', - 'zbirenbaum/copilot-cmp', + -- 'zbirenbaum/copilot-cmp', 'hrsh7th/cmp-nvim-lsp-signature-help', 'hrsh7th/cmp-nvim-lua', 'hrsh7th/cmp-path', @@ -124,7 +124,8 @@ return packer.startup { use { 'jose-elias-alvarez/null-ls.nvim', requires = { 'nvim-lua/plenary.nvim' } } use 'lvimuser/lsp-inlayhints.nvim' - use 'zbirenbaum/copilot.lua' + -- use 'zbirenbaum/copilot.lua' + use 'Exafunction/codeium.vim' -- dap use 'mfussenegger/nvim-dap' diff --git a/lua/tms/p/codeium.lua b/lua/tms/p/codeium.lua @@ -0,0 +1,37 @@ +local M = {} + +M.Accept = vim.fn['codeium#Accept'] + +M.Clear = vim.fn['codeium#Clear'] + +M.Next = vim.fn['codeium#CycleOrComplete'] + +function M.Prev() + vim.fn['codeium#CycleCompletions'](-1) +end + +function M.Disable() + vim.cmd.Codeium('Disable') +end + +function M.DisableBuffer() + vim.cmd.Codeium('DisableBuffer') +end + +function M.Enable() + vim.cmd.Codeium('Enable') +end + +function M.EnableBuffer() + vim.cmd.Codeium('EnableBuffer') +end + +function M.Completions() + return vim.b['_codeium_completions'] +end + +M.isEnabled = vim.fn['codeium#Enabled'] + +M.Complete = vim.fn['codeium#Complete'] + +return M