From c7448bb92d5f8c8eaa859fdfd2ada91982ca67e0 Mon Sep 17 00:00:00 2001 From: Patrick Artounian <2541595+partounian@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:37:09 -0700 Subject: [PATCH] feat: Add supermaven support (#88) * feat: Add supermaven support * align with new config structure and add autostart flag * add TODO regarding supermaven and lualine --------- Co-authored-by: Michael --- README.md | 2 +- lazy-lock.json | 2 +- lua/core/plugins/cmp.lua | 11 ++++++++++- lua/core/plugins/lualine.lua | 1 + lua/core/plugins/supermaven.lua | 34 +++++++++++++++++++++++++++++++++ lua/utils/icons.lua | 1 + 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 lua/core/plugins/supermaven.lua diff --git a/README.md b/README.md index 5550cbb6..77a05c90 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ I decided to move to my own fresh Lua based Neovim from my good old vimrc trying - Better writing with [ltex-ls](https://valentjn.github.io/ltex/index.html) - Dashboard via [alpha.nvim](https://github.com/goolord/alpha-nvim) - Multiple preconfigured themes like [catppuccin](https://github.com/catppuccin/nvim), [tokyonight](https://github.com/folke/tokyonight.nvim), [nightfox](https://github.com/EdenEast/nightfox.nvim), and more -- AI assistance with [ChatGPT.nvim](https://github.com/jackMort/ChatGPT.nvim), [gp.nvim](https://github.com/Robitx/gp.nvim), and [copilot.lua](https://github.com/zbirenbaum/copilot.lua) (optionally) +- AI assistance with [ChatGPT.nvim](https://github.com/jackMort/ChatGPT.nvim), [gp.nvim](https://github.com/Robitx/gp.nvim), [copilot.lua](https://github.com/zbirenbaum/copilot.lua) (optionally), and [supermave-nvim](https://github.com/supermaven-inc/supermaven-nvim) (optionally) - Health check via `checkhealth core` - Lazy loading plugins (19 of 95 in my case) - Startup <= 40 ms 🚀 diff --git a/lazy-lock.json b/lazy-lock.json index 351dbac5..3ca6f5a7 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -90,4 +90,4 @@ "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }, "yazi.nvim": { "branch": "master", "commit": "1efb48847944c4036bfd4114590bd617b274adf9" }, "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } -} \ No newline at end of file +} diff --git a/lua/core/plugins/cmp.lua b/lua/core/plugins/cmp.lua index 18733920..21ce4846 100644 --- a/lua/core/plugins/cmp.lua +++ b/lua/core/plugins/cmp.lua @@ -27,6 +27,10 @@ local M = { table.insert(sources, { name = "copilot", group_index = 2 }) end + if vim.g.config.plugins.supermaven.enabled then + table.insert(sources, { name = "supermaven" }) + end + if vim.g.config.plugins.emoji.enable then table.insert(sources, { name = "emoji" }) end @@ -34,7 +38,6 @@ local M = { local format = { mode = "symbol_text", max_width = 50, - -- TODO how to keep defaults and insert "Copilot"? symbol_map = { Text = "󰉿", Method = "󰆧", @@ -69,6 +72,12 @@ local M = { table.insert(format.symbol_map, { Copilot = icons.apps.Copilot }) end + if vim.g.config.plugins.supermaven.enabled then + local icons = require("utils.icons") + table.insert(format.symbol_map, { Supermaven = icons.apps.Supermaven }) + vim.api.nvim_set_hl(0, "CmpItemKindSupermaven", { fg = "#6CC644" }) + end + local has_words_before = function() if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false diff --git a/lua/core/plugins/lualine.lua b/lua/core/plugins/lualine.lua index 3176771d..40bb5c7c 100644 --- a/lua/core/plugins/lualine.lua +++ b/lua/core/plugins/lualine.lua @@ -28,6 +28,7 @@ local default_options = { } local function default_config_function(opts) + -- TODO: Add supermaven if vim.g.config.plugins.copilot.enable then local lsp_utils = require("core.plugins.lsp.utils") local utils = require("utils.functions") diff --git a/lua/core/plugins/supermaven.lua b/lua/core/plugins/supermaven.lua new file mode 100644 index 00000000..4f42f7c0 --- /dev/null +++ b/lua/core/plugins/supermaven.lua @@ -0,0 +1,34 @@ +-- https://github.com/supermaven-inc/supermaven-nvim +local user_config = vim.g.config.plugins.supermaven or {} + +local default_config = { + enabled = false, + autostart = false, + opts = { + disable_inline_completion = true, -- disables inline completion for use with cmp + }, + keys = { + { "mC", "SupermavenToggle", desc = "Toggle Supermaven" }, + }, +} + +local config = vim.tbl_deep_extend("force", default_config, user_config) + +return { + "supermaven-inc/supermaven-nvim", + enabled = config.enabled, + event = "InsertEnter", + dependencies = "hrsh7th/nvim-cmp", + opts = config.opts, + keys = config.keys, + config = function(_, opts) + require("supermaven-nvim").setup(opts) + local api = require("supermaven-nvim.api") + if not config.autostart then + if api.is_running() then + api.stop() + return + end + end + end, +} diff --git a/lua/utils/icons.lua b/lua/utils/icons.lua index a75a3326..812d9ca1 100644 --- a/lua/utils/icons.lua +++ b/lua/utils/icons.lua @@ -1,6 +1,7 @@ return { apps = { Copilot = "", + Supermaven = "", }, arrows = { ArrowRight = "❯",