diff --git a/README.md b/README.md index ffd0811..142a135 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ The `ignore_filetypes` table is used to ignore filetypes when using supermaven-n `suggestion_color` and `cterm` options can be used to set the color of the suggestion text. +`suggestion_group` is used to set the highlight group for the suggestion text. If `suggestion_group` is set, it will override `suggestion_color` and `cterm` values. + ```lua require("supermaven-nvim").setup({ keymaps = { @@ -49,6 +51,7 @@ require("supermaven-nvim").setup({ color = { suggestion_color = "#ffffff", cterm = 244, + suggestion_group = "Comment", -- if `suggestion_group` is set, it will override `suggestion_color` and `cterm` }, disable_inline_completion = false, -- disables inline completion for use with cmp disable_keymaps = false -- disables built in keymaps for more manual control diff --git a/lua/supermaven-nvim/completion_preview.lua b/lua/supermaven-nvim/completion_preview.lua index 382ea98..9af8bd2 100644 --- a/lua/supermaven-nvim/completion_preview.lua +++ b/lua/supermaven-nvim/completion_preview.lua @@ -1,9 +1,15 @@ local u = require("supermaven-nvim.util") +local config = require("supermaven-nvim.config") + +local suggestion_group = "Comment" +if config.color ~= nil then + suggestion_group = config.color.suggestion_group or "Comment" +end local CompletionPreview = { inlay_instance = nil, ns_id = vim.api.nvim_create_namespace("supermaven"), - suggestion_group = "Comment", + suggestion_group = suggestion_group, disable_inline_completion = false, } diff --git a/lua/supermaven-nvim/document_listener.lua b/lua/supermaven-nvim/document_listener.lua index f0a450c..d77d0e8 100644 --- a/lua/supermaven-nvim/document_listener.lua +++ b/lua/supermaven-nvim/document_listener.lua @@ -40,15 +40,21 @@ M.setup = function() end, }) - if config.color and config.color.suggestion_color and config.color.cterm then + if config.color then vim.api.nvim_create_autocmd({ "VimEnter", "ColorScheme" }, { group = M.augroup, pattern = "*", callback = function(event) - vim.api.nvim_set_hl(0, "SupermavenSuggestion", { - fg = config.color.suggestion_color, - ctermfg = config.color.cterm, - }) + if config.color.suggestion_group then + vim.api.nvim_set_hl(0, "SupermavenSuggestion", { + link = config.color.suggestion_group, + }) + elseif config.color.suggestion_color and config.color.cterm then + vim.api.nvim_set_hl(0, "SupermavenSuggestion", { + fg = config.color.suggestion_color, + ctermfg = config.color.cterm, + }) + end preview.suggestion_group = "SupermavenSuggestion" end, })