Skip to content

Commit

Permalink
Merge pull request #101 from ziboh/master
Browse files Browse the repository at this point in the history
Add highlighting for Icon
  • Loading branch information
luozhiya authored Jul 21, 2024
2 parents be422c2 + 45225e6 commit 46b9bc2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,39 @@ require('cmp').setup({
})
```

### Highlighting & Icon
FittenCode's cmp source now has a builtin highlight group CmpItemKindFittencode. To add an icon to FittenCode for lspkind, simply add FittenCode to your lspkind symbol map.

``` lua
-- lspkind.lua
local lspkind = require("lspkind")
lspkind.init({
symbol_map = {
FittenCode = "",
},
})

vim.api.nvim_set_hl(0, "CmpItemKindFittenCode", {fg ="#6CC644"})

```
Alternatively, you can add FittemCode to the lspkind symbol_map within the cmp format function.
```lua
-- cmp.lua
cmp.setup {
...
formatting = {
format = lspkind.cmp_format({
mode = "symbol",
max_width = 50,
symbol_map = { FittenCode = "" }
})
}
...
}
```

If you do not use lspkind, simply add the custom icon however you normally handle kind formatting and it will integrate as if it was any other normal lsp completion kind.

## 🚀 Usage

- Optional parameters are enclosed in square brackets `[]`.
Expand Down
1 change: 1 addition & 0 deletions lua/fittencode/sources/cmp/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ local function convert_to_lsp_completion_response(line, character, cursor_before
},
insertTextMode = 1,
cmp = {
kind_hl_group = 'CmpItemKindFittenCode',
kind_text = 'FittenCode',
},
})
Expand Down

0 comments on commit 46b9bc2

Please sign in to comment.