From 1304b279bbbce1a658c3a78bc955c85e5d3ef283 Mon Sep 17 00:00:00 2001 From: sajenim Date: Tue, 7 May 2024 20:41:52 +0800 Subject: [PATCH] add ollama functionality --- .../nvim/config/lua/plugins/coding.lua | 37 +++++++++++++++++++ .../features/nvim/config/lua/plugins/ui.lua | 28 +++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/home-manager/sajenim/features/nvim/config/lua/plugins/coding.lua b/home-manager/sajenim/features/nvim/config/lua/plugins/coding.lua index 2562594..04eca89 100644 --- a/home-manager/sajenim/features/nvim/config/lua/plugins/coding.lua +++ b/home-manager/sajenim/features/nvim/config/lua/plugins/coding.lua @@ -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 is important for selections to work properly. + { + "oo", + ":lua require('ollama').prompt()", + desc = "ollama prompt", + mode = { "n", "v" }, + }, + + -- Sample keybind for direct prompting. Note that the is important for selections to work properly. + { + "oG", + ":lua require('ollama').prompt('Generate_Code')", + desc = "ollama Generate Code", + mode = { "n", "v" }, + }, + }, + + ---@type Ollama.Config + opts = { + model = "llama3:8b", + } + }, + -- -- LSP Configuration -- diff --git a/home-manager/sajenim/features/nvim/config/lua/plugins/ui.lua b/home-manager/sajenim/features/nvim/config/lua/plugins/ui.lua index 23e3dbb..48f3ba0 100644 --- a/home-manager/sajenim/features/nvim/config/lua/plugins/ui.lua +++ b/home-manager/sajenim/features/nvim/config/lua/plugins/ui.lua @@ -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 - } + }, }