Nvim: use blink instead of cmp
This commit is contained in:
@@ -1,175 +1,185 @@
|
||||
return {
|
||||
{ 'JoseConseco/cmp-ai', dependencies = 'nvim-lua/plenary.nvim', enabled = false},
|
||||
{ 'petertriho/cmp-git', enabled = true},
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- follow latest release.
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
dependencies = {
|
||||
--'saadparwaiz1/cmp_luasnip'
|
||||
{
|
||||
"nomnivore/ollama.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
|
||||
-- All the user commands added by the plugin
|
||||
cmd = { "Ollama", "OllamaModel", "OllamaServe", "OllamaServeStop" },
|
||||
|
||||
keys = {
|
||||
-- Sample keybind for prompt menu. Note that the <c-u> is important for selections to work properly.
|
||||
{
|
||||
"<leader>oo",
|
||||
":<c-u>lua require('ollama').prompt()<cr>",
|
||||
desc = "ollama prompt",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
|
||||
-- Sample keybind for direct prompting. Note that the <c-u> is important for selections to work properly.
|
||||
{
|
||||
"<leader>oG",
|
||||
":<c-u>lua require('ollama').prompt('Generate_Code')<cr>",
|
||||
desc = "ollama Generate Code",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
},
|
||||
|
||||
---@type Ollama.Config
|
||||
opts = {
|
||||
model = "qwen2.5-coder",
|
||||
url = "http://192.168.10.99:11434",
|
||||
-- your configuration overrides
|
||||
},
|
||||
enabled = false
|
||||
},
|
||||
-- install jsregexp (optional!).
|
||||
build = "make install_jsregexp",
|
||||
config = function()
|
||||
local ls = require("luasnip")
|
||||
end
|
||||
},
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
dependencies = {
|
||||
{
|
||||
"mireq/luasnip-snippets",
|
||||
dependencies = {
|
||||
"L3MON4D3/LuaSnip"
|
||||
},
|
||||
config = function()
|
||||
require('luasnip_snippets.common.snip_utils').setup()
|
||||
end,
|
||||
enabled = false
|
||||
},
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
--'mstanciu552/cmp-matlab',
|
||||
'petertriho/cmp-git',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-nvim-lsp-signature-help',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-calc',
|
||||
'JoseConseco/cmp-ai'
|
||||
dependencies = {
|
||||
"saadparwaiz1/cmp_luasnip"
|
||||
},
|
||||
-- follow latest release.
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
-- install jsregexp (optional!).
|
||||
build = "make install_jsregexp",
|
||||
config = function()
|
||||
-- Mandatory setup function
|
||||
local luasnip = require("luasnip")
|
||||
luasnip.setup({
|
||||
load_ft_func = require('luasnip_snippets.common.snip_utils').load_ft_func,
|
||||
ft_func = require('luasnip_snippets.common.snip_utils').ft_func,
|
||||
-- To enable auto expansin
|
||||
enable_autosnippets = true,
|
||||
})
|
||||
vim.keymap.set({"i", "s"}, "<Tab>", function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else vim.api.nvim_input('<C-V><Tab>') end end, {silent = true})
|
||||
vim.keymap.set({"i", "s"}, "<S-Tab>", function() luasnip.jump(-1) end, {silent = true})
|
||||
vim.keymap.set({"i", "s"}, "<C-E>", function() if luasnip.choice_active() then luasnip.change_choice(1) end end, {silent = true})
|
||||
end,
|
||||
enabled = false
|
||||
},
|
||||
{
|
||||
'tzachar/cmp-ai',
|
||||
dependencies = 'nvim-lua/plenary.nvim',
|
||||
enabled = false
|
||||
},
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/nvim-cmp',
|
||||
'L3MON4D3/LuaSnip',
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
'tzachar/cmp-ai',
|
||||
},
|
||||
config = function()
|
||||
local cmp = require 'cmp'
|
||||
local cmp_ai = require('cmp_ai.config')
|
||||
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
local cmp = require'cmp'
|
||||
--local cmp_ai = require('cmp_ai.config')
|
||||
local luasnip = require('luasnip')
|
||||
cmp_ai:setup({
|
||||
max_lines = 100,
|
||||
provider = 'Ollama',
|
||||
provider_options = {
|
||||
base_url = 'http://192.168.10.99:11434/api/generate',
|
||||
model = 'qwen2.5-coder:latest',
|
||||
prompt = function(lines_before, lines_after)
|
||||
return "<|fim_prefix|>" .. lines_before .. "<|fim_suffix|>" .. lines_after .. "<|fim_middle|>"
|
||||
end,
|
||||
},
|
||||
notify = true,
|
||||
notify_callback = function(msg)
|
||||
vim.notify(msg)
|
||||
end,
|
||||
run_on_every_keystroke = true,
|
||||
})
|
||||
|
||||
-- cmp_ai:setup({
|
||||
-- max_lines = 100,
|
||||
-- provider = 'Ollama',
|
||||
-- provider_options = {
|
||||
-- model = 'codellama',
|
||||
-- base_url = 'http://batman.local:11434/api/generate',
|
||||
-- prompt = function(lines_before, lines_after)
|
||||
-- -- prompt depends on the model you use. Here is an example for deepseek coder
|
||||
-- return '<PRE> ' .. lines_before .. ' <SUF>' .. lines_after .. ' <MID>' -- for codellama
|
||||
-- end,
|
||||
-- },
|
||||
-- debounce_delay = 600, -- ms llama may be GPU hungry, wait x ms after last key input, before sending request to it
|
||||
-- notify = true,
|
||||
-- notify_callback = function(msg)
|
||||
-- vim.notify(msg)
|
||||
-- end,
|
||||
-- run_on_every_keystroke = true,
|
||||
-- ignored_file_types = {
|
||||
-- -- default is not to ignore
|
||||
-- -- uncomment to ignore in lua:
|
||||
-- -- lua = true
|
||||
-- },
|
||||
-- })
|
||||
|
||||
local default_cmp_sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'nvim_lsp_signature_help' },
|
||||
{ name = 'path' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'calc' },
|
||||
--{ name = 'cmp_git' },
|
||||
--{ name = 'cmp_ai' },
|
||||
})
|
||||
|
||||
local bufIsBig = function(bufnr)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = vim.loop.fs_stat(vim.api.nvim_buf_get_name(bufnr))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
-- If a file is too large, I don't want to add to it's cmp sources treesitter, see:
|
||||
-- https://github.com/hrsh7th/nvim-cmp/issues/1522
|
||||
vim.api.nvim_create_autocmd('BufReadPre', {
|
||||
callback = function(t)
|
||||
local sources = default_cmp_sources
|
||||
if not bufIsBig(t.buf) then
|
||||
sources[#sources+1] = {name = 'treesitter', group_index = 2}
|
||||
end
|
||||
cmp.setup.buffer {
|
||||
sources = sources
|
||||
}
|
||||
end
|
||||
})
|
||||
|
||||
cmp.setup({
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
--vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
-- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<C-y>'] = cmp.mapping(function(fallback)
|
||||
cmp.confirm({ select = true })
|
||||
end)
|
||||
--cmp.mapping.confirm({ select = true }),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'nvim_lsp_signature_help' },
|
||||
{ name = 'path' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'calc' },
|
||||
{ name = 'cmp_git' },
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
--{ name = 'cmp_ai' }
|
||||
}, {
|
||||
{ name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
--sources = sources,
|
||||
sorting = {
|
||||
priority_weight = 2,
|
||||
comparators = {
|
||||
--require('cmp_ai.compare'),
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.recently_used,
|
||||
require("clangd_extensions.cmp_scores"),
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
})
|
||||
performance = {
|
||||
fetching_timeout = 20,
|
||||
debounce = 10,
|
||||
throttle = 10,
|
||||
async_budget = 20000,
|
||||
max_view_entries = 10,
|
||||
confirm_resolve_timeout = 10,
|
||||
filtering_context_budget = 10
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline({'/', '?'}, {
|
||||
-- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below
|
||||
-- Set configuration for specific filetype.
|
||||
--[[ cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
require("cmp_git").setup() ]]
|
||||
--
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{name = 'cmp_git' },
|
||||
}, {
|
||||
{name = 'buffer' }
|
||||
})
|
||||
})
|
||||
|
||||
require("cmp_git").setup()
|
||||
end,
|
||||
enabled = true
|
||||
}
|
||||
{ name = 'cmdline' }
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false }
|
||||
})
|
||||
end,
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user