Skip to content

Commit

Permalink
feat: Add supermaven support (#88)
Browse files Browse the repository at this point in the history
* feat: Add supermaven support

* align with new config structure and add autostart flag

* add TODO regarding supermaven and lualine

---------

Co-authored-by: Michael <[email protected]>
  • Loading branch information
partounian and Allaman authored Jul 9, 2024
1 parent 62dc73a commit c7448bb
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 🚀
Expand Down
2 changes: 1 addition & 1 deletion lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" },
"yazi.nvim": { "branch": "master", "commit": "1efb48847944c4036bfd4114590bd617b274adf9" },
"zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" }
}
}
11 changes: 10 additions & 1 deletion lua/core/plugins/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ 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

local format = {
mode = "symbol_text",
max_width = 50,
-- TODO how to keep defaults and insert "Copilot"?
symbol_map = {
Text = "󰉿",
Method = "󰆧",
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lua/core/plugins/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
34 changes: 34 additions & 0 deletions lua/core/plugins/supermaven.lua
Original file line number Diff line number Diff line change
@@ -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 = {
{ "<leader>mC", "<cmd>SupermavenToggle<cr>", 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,
}
1 change: 1 addition & 0 deletions lua/utils/icons.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
apps = {
Copilot = "",
Supermaven = "",
},
arrows = {
ArrowRight = "",
Expand Down

0 comments on commit c7448bb

Please sign in to comment.