Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#49): exposing suggestion_group in config settings #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion lua/supermaven-nvim/completion_preview.lua
Original file line number Diff line number Diff line change
@@ -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,
}

Expand Down
16 changes: 11 additions & 5 deletions lua/supermaven-nvim/document_listener.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down