superbo / lsp-ai.nvim Goto Github PK
View Code? Open in Web Editor NEWLSP-AI plugin for Neovim
License: MIT License
LSP-AI plugin for Neovim
License: MIT License
How would you advise configuring FIM with "end", as seen in this example?
{
"memory": {
"file_store": {}
},
"models": {
"model1": {
"type": "ollama",
"model": "deepseek-coder"
}
},
"completion": {
"model": "model1",
"parameters": {
"fim": {
"start": "<|fim▁begin|>",
"middle": "<|fim▁hole|>",
"end": "<|fim▁end|>"
},
"max_context": 2000,
"options": {
"num_predict": 32
}
}
}
}
It does not quite work with Lua:
This seems to work, but not the most beautiful:
local function ollama_fim_example()
local server = {
memory = {
file_store = {},
},
models = {
model1 = {
type = "ollama",
model = "codegemma",
},
},
completion = {
model = "model1",
parameters = {
start = "<|fim▁begin|>",
middle = "<|fim▁hole|>",
-- end = "<|fim▁end|>",
},
max_context = 2000,
options = {
num_predict = 32,
},
},
}
server.completion.parameters["end"] = "<|fim▁end|>" -- NOTE: workaround
return server
end
return {
{
-- Invoke with `:LSPAIComplete`
"SuperBo/lsp-ai.nvim",
dependencies = { "neovim/nvim-lspconfig" },
opts = {
-- autostart = true,
server = ollama_fim_example(),
},
config = function(_, opts)
require("lsp_ai").setup(opts)
end,
},
Hey again 😄👋
It would be awesome to define which keymaps you wish to use for accepting or cancelling the generated code. As an example, I use the copilot.lua defaults for accepting code snippets (<M-l>
) and would like to use the same keymap with lsp-ai.
Is it possible that the desired model is hardcoded to model1
?
I've got this config:
return {
{
"SuperBo/lsp-ai.nvim",
dependencies = { "neovim/nvim-lspconfig" },
opts = {
autostart = true,
server = {
memory = {
file_store = {},
},
models = {
llama_cpp = {
type = "llama_cpp",
file_path = vim.fn.expand("~/code/public/CodeQwen1.5-7B-Chat-GGUF/codeqwen-1_5-7b-chat-q4_k_m.gguf"),
n_ctx = 1024 * 4,
n_gpu_layers = 500,
},
ollama = {
type = "ollama",
model = "llama3",
},
},
},
completion = {
model = "ollama",
parameters = {
messages = {
{
role = "system",
content = "You are a programming completion tool. Replace <CURSOR> with the correct code.",
},
{
role = "user",
content = "{CODE}",
},
},
},
max_context_size = 1024 * 4,
},
},
config = function(_, opts)
require("lsp_ai").setup(opts)
end,
},
}
And I get this error:
Error 16:06:45 notify.error [LSP-AI] can't find model: model1
If I instead rename e.g. the ollama
key into model1
, I don't get the error and the completion works:
return {
{
"SuperBo/lsp-ai.nvim",
dependencies = { "neovim/nvim-lspconfig" },
opts = {
autostart = true,
server = {
memory = {
file_store = {},
},
models = {
llama_cpp = {
type = "llama_cpp",
file_path = vim.fn.expand("~/code/public/CodeQwen1.5-7B-Chat-GGUF/codeqwen-1_5-7b-chat-q4_k_m.gguf"),
n_ctx = 1024 * 4,
n_gpu_layers = 500,
},
- ollama = {
+ model1 = {
type = "ollama",
model = "llama3",
},
},
},
completion = {
- model = "ollama",
+ model = "model1",
parameters = {
messages = {
{
role = "system",
content = "You are a programming completion tool. Replace <CURSOR> with the correct code.",
},
{
role = "user",
content = "{CODE}",
},
},
},
max_context_size = 1024 * 4,
},
},
config = function(_, opts)
require("lsp_ai").setup(opts)
end,
},
}
error:
Warning: Failed searching manifest: Failed downloading https://nvim-neorocks.github.io/rocks-binaries/dev/manifest-5.1 - failed downloading https://nvim-neorocks.github.io/rocks-binaries/dev/manifest-5.1
Error: No results matching query were found for Lua 5.1.
To check if it is available for other Lua versions, use --check-lua-versions.
Failed installing lsp-ai.nvim with `luarocks`.
--------------------------------------------------------------------------------
Trying to build from source.
Missing dependencies for lsp-ai.nvim scm-1:
nvim-lspconfig >= 0.1.6 (not installed)
lsp-ai.nvim scm-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)
lsp-ai.nvim scm-1 depends on nvim-lspconfig >= 0.1.6 (not installed)
Installing https://luarocks.org/nvim-lspconfig-0.1.8-1.src.rock
nvim-lspconfig 0.1.8-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)
No existing manifest. Attempting to rebuild...
Looks like lua version is hardcoded to 5.1. But I use 5.4.
And this link :https://nvim-neorocks.github.io/rocks-binaries/dev/manifest-5.1 is a 404 page.
Looks like you are using luarocks, a package manager. what benifits it brings?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.