add ollama functionality

This commit is contained in:
♥ Minnie ♥ 2024-05-07 20:41:52 +08:00
parent d4982e7460
commit 1304b279bb
2 changed files with 64 additions and 1 deletions

View file

@ -1,4 +1,41 @@
return {
--
-- Ollama Workflows
--
{
'nomnivore/ollama.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'stevearc/dressing.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 = "llama3:8b",
}
},
--
-- LSP Configuration
--

View file

@ -26,7 +26,25 @@ return {
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
-- Define a function to check that ollama is installed and working
local function get_condition()
return package.loaded["ollama"] and require("ollama").status ~= nil
end
-- Define a function to check the status and return the corresponding icon
local function get_status_icon()
local status = require("ollama").status()
if status == "IDLE" then
return "OLLAMA IDLE"
elseif status == "WORKING" then
return "OLLAMA BUSY"
end
end
require('lualine').setup {
options = {
icons_enabled = true,
@ -41,6 +59,14 @@ return {
tabline = {
lualine_a = {'buffers'},
};
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = { { 'filename', path = 1 } },
lualine_x = { get_status_icon, get_condition, 'encoding', 'fileformat', 'filetype' },
lualine_y = { "progress" },
lualine_z = { "location" },
},
}
end,
},
@ -55,6 +81,6 @@ return {
config = function()
require('gitsigns').setup()
end
}
},
}