From 186fdb4c24e6bb8abbcea93825971a1cf10e95e9 Mon Sep 17 00:00:00 2001 From: Adriel Perkins Date: Mon, 24 Jun 2024 15:27:18 -0400 Subject: [PATCH] feat: add gen.nvim and oil.nvim --- .config/nvim/lua/core/mappings.lua | 2 +- .config/nvim/lua/plugins/config/whichkey.lua | 1 + .config/nvim/lua/plugins/init.lua | 257 +++++++++++-------- 3 files changed, 148 insertions(+), 112 deletions(-) diff --git a/.config/nvim/lua/core/mappings.lua b/.config/nvim/lua/core/mappings.lua index 089e103..cf17224 100644 --- a/.config/nvim/lua/core/mappings.lua +++ b/.config/nvim/lua/core/mappings.lua @@ -27,7 +27,7 @@ keymap("n", "u", ":UndotreeShow", opts) keymap("n", "C", ":let @/ = ''", opts) keymap("n", "so", ":so %", opts) keymap("t", "", "", term_opts) -keymap("n", "n", ":Ex", opts) +-- keymap("n", "n", ":Ex", opts) -- keymap("n", "zz", opts) -- keymap("n", "zz", opts) diff --git a/.config/nvim/lua/plugins/config/whichkey.lua b/.config/nvim/lua/plugins/config/whichkey.lua index 1623886..5f2aaaf 100644 --- a/.config/nvim/lua/plugins/config/whichkey.lua +++ b/.config/nvim/lua/plugins/config/whichkey.lua @@ -33,6 +33,7 @@ local options = { local wk = require("which-key") wk.register({ + n = {"Oil", " Open Oil"}, f = { name = " File", f = { "Telescope find_files", " Find File" }, diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index 668149b..47850c5 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -2,28 +2,28 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) -- Plugins I use local plugs = { - -- Essential Plugins - --'tpope/vim-fugitive', - { - 'windwp/nvim-autopairs', - init = function() - require('nvim-autopairs').setup{} - end - }, - 'mbbill/undotree', + -- Essential Plugins + --'tpope/vim-fugitive', + { + 'windwp/nvim-autopairs', + init = function() + require('nvim-autopairs').setup{} + end + }, + 'mbbill/undotree', { 'nvim-lualine/lualine.nvim', dependencies = { @@ -31,105 +31,105 @@ local plugs = { } }, - -- 'vim-airline/vim-airline', - 'github/copilot.vim', - { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate' - }, - - {'nvim-treesitter/playground'}, - 'theprimeagen/harpoon', - { - 'nvim-telescope/telescope.nvim', - dependencies = { - 'nvim-lua/plenary.nvim' - } - }, - -- Theme - { - 'catppuccin/nvim', - name = 'catppuccin', - lazy = false, - priority = 1000, - opts = { - transparent_background = true - }, - init = function() - vim.cmd.colorscheme 'catppuccin-mocha' - end - }, - -- LSP - { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - dependencies = { - -- LSP Support - {'neovim/nvim-lspconfig'}, - { - 'williamboman/mason.nvim', - build = function() - -- vim.cmd 'MasonUpdate' - -- vim.cmd, 'MasonUpdate' - pcall(vim.cmd, 'MasonUpdate') - end, - }, - {'williamboman/mason-lspconfig.nvim'}, - - -- Autocompletion - {'hrsh7th/nvim-cmp'}, - {'hrsh7th/cmp-nvim-lsp'}, - {'L3MON4D3/LuaSnip'} - - -- Optionals - -- {'hrsh7th/cmp-buffer'}, - -- {'hrsh7th/cmp-path'}, - -- {'saadparwaiz1/cmp_luasnip'}, - -- {'hrsh7th/cmp-nvim-lua'}, - -- {'rafamadriz/friendly-snippets'}, - } - }, - -- Only load whichkey after all the gui - { - "folke/which-key.nvim", - opts = function() - return require ('plugins.config.whichkey') - end, - config = function(_, opts) - vim.o.timeout = true - vim.o.timeoutlen = 300 - require("which-key").setup(opts) - end, - }, + -- 'vim-airline/vim-airline', + 'github/copilot.vim', { - "darrikonn/vim-gofmt", + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate' }, + + {'nvim-treesitter/playground'}, + 'theprimeagen/harpoon', { - "arnamak/stay-centered.nvim", - init = function() - require('stay-centered').setup{} - end + 'nvim-telescope/telescope.nvim', + dependencies = { + 'nvim-lua/plenary.nvim' + } }, - -- See the docs for more information - -- https://github.com/huynle/ogpt.nvim + -- Theme { - "huynle/ogpt.nvim", - event = "VeryLazy", + 'catppuccin/nvim', + name = 'catppuccin', + lazy = false, + priority = 1000, opts = { - default_provider = "ollama", - providers = { - ollama = { - api_host = os.getenv("OLLAMA_API_HOST") or "http://localhost:11434", - api_key = os.getenv("OLLAMA_API_KEY") or "", - } - } + transparent_background = true }, + init = function() + vim.cmd.colorscheme 'catppuccin-mocha' + end + }, + -- LSP + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', dependencies = { - "MunifTanjim/nui.nvim", - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim" + -- LSP Support + {'neovim/nvim-lspconfig'}, + { + 'williamboman/mason.nvim', + build = function() + -- vim.cmd 'MasonUpdate' + -- vim.cmd, 'MasonUpdate' + pcall(vim.cmd, 'MasonUpdate') + end, + }, + {'williamboman/mason-lspconfig.nvim'}, + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'L3MON4D3/LuaSnip'} + + -- Optionals + -- {'hrsh7th/cmp-buffer'}, + -- {'hrsh7th/cmp-path'}, + -- {'saadparwaiz1/cmp_luasnip'}, + -- {'hrsh7th/cmp-nvim-lua'}, + -- {'rafamadriz/friendly-snippets'}, } }, + -- Only load whichkey after all the gui + { + "folke/which-key.nvim", + opts = function() + return require ('plugins.config.whichkey') + end, + config = function(_, opts) + vim.o.timeout = true + vim.o.timeoutlen = 300 + require("which-key").setup(opts) + end, + }, + { + "darrikonn/vim-gofmt", + }, + { + "arnamak/stay-centered.nvim", + init = function() + require('stay-centered').setup{} + end + }, + -- See the docs for more information + -- https://github.com/huynle/ogpt.nvim + -- { + -- "huynle/ogpt.nvim", + -- event = "VeryLazy", + -- opts = { + -- default_provider = "ollama", + -- providers = { + -- ollama = { + -- api_host = os.getenv("OLLAMA_API_HOST") or "http://localhost:11434", + -- api_key = os.getenv("OLLAMA_API_KEY") or "", + -- } + -- } + -- }, + -- dependencies = { + -- "MunifTanjim/nui.nvim", + -- "nvim-lua/plenary.nvim", + -- "nvim-telescope/telescope.nvim" + -- } + -- }, -- NeoGit, a replacement for Vim Fugitive { "NeogitOrg/neogit", @@ -142,14 +142,49 @@ local plugs = { }, -- Lua { - "folke/zen-mode.nvim", + "folke/zen-mode.nvim", }, - { - "numToStr/Comment.nvim", + { + "numToStr/Comment.nvim", config = function() - require ('Comment').setup() + require ('Comment').setup() end, - } + }, + { + 'stevearc/oil.nvim', + -- opts = {}, + -- Optional dependencies + dependencies = { "nvim-tree/nvim-web-devicons" }, + init = function() + require('oil').setup{} + end + }, + { + 'David-Kunz/gen.nvim', + opts = { + model = "llama3", -- The default model to use. + host = "localhost", -- The host running the Ollama service. + port = "11434", -- The port on which the Ollama service is listening. + quit_map = "q", -- set keymap for close the response window + retry_map = "", -- set keymap to re-send the current prompt + init = function(options) pcall(io.popen, "ollama serve > /dev/null 2>&1 &") end, + -- Function to initialize Ollama + command = function(options) + local body = {model = options.model, stream = true} + return "curl --silent --no-buffer -X POST http://" .. options.host .. ":" .. options.port .. "/api/chat -d $body" + end, + -- The command for the Ollama service. You can use placeholders $prompt, $model and $body (shellescaped). + -- This can also be a command string. + -- The executed command must return a JSON object with { response, context } + -- (context property is optional). + -- list_models = '', -- Retrieves a list of model names + display_mode = "float", -- The display mode. Can be "float" or "split" or "horizontal-split". + show_prompt = false, -- Shows the prompt submitted to Ollama. + show_model = false, -- Displays which model you are using at the beginning of your chat session. + no_auto_close = false, -- Never closes the window automatically. + debug = false -- Prints errors and the command which is run. + } + } } -- can add opts to .setup(plugs)