Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
feat(ui)!: unify UI components: cmp, wilder, floats (ayamir#772)
Browse files Browse the repository at this point in the history
* feat(ui)!: unify UI components: cmp, wilder, floats

---------

Signed-off-by: Jint-lzxy <[email protected]>
Co-authored-by: huge-pancake <[email protected]>

* fix entry tags

* fixup! fix entry tags

---------

Signed-off-by: Jint-lzxy <[email protected]>
Co-authored-by: huge-pancake <[email protected]>
  • Loading branch information
2 people authored and leavers committed May 31, 2023
1 parent 53a5231 commit 255070a
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 256 deletions.
17 changes: 0 additions & 17 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
if not vim.g.vscode then
require("core")

-- Release note
vim.schedule(function()
vim.notify_once(
[[
We've released version v3.0.0!
Visit https://github.com/ayamir/nvimdots/releases to see the release notes.
If you have icons that can't be rendered correctly (e.g., 𑨩 and � ) or icons with incorrect size, be sure to read this!
To silence this message, remove it from `init.lua` at the config's root directory.
To check the glyphs size, make sure the following icons are very close to the crosses but there is no overlap:
XXXXXXXXX
]],
vim.log.levels.WARN
)
end)
end
22 changes: 11 additions & 11 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"LuaSnip": { "branch": "master", "commit": "a83e4b1ba7edc6fecdad09e39753a7d5eee1d01c" },
"accelerated-jk.nvim": { "branch": "main", "commit": "8fb5dad4ccc1811766cebf16b544038aeeb7806f" },
"alpha-nvim": { "branch": "main", "commit": "1838ae926e8d49fe5330d1498ee8289ae2c340bc" },
"auto-session": { "branch": "main", "commit": "571ecb873654554109f63eac3193b133aec2f90c" },
"autoclose.nvim": { "branch": "main", "commit": "fec0b890ea2d2ab9e62c4ab48d097a0382226999" },
"auto-session": { "branch": "main", "commit": "b6bac3accc9a753be830aa059f834b787efe2f79" },
"autoclose.nvim": { "branch": "main", "commit": "6695f308c0141239ab28494e76f8aceed748e179" },
"better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" },
"bigfile.nvim": { "branch": "main", "commit": "a34e42616c20bfd52943ed5d6632bb28d22b057e" },
"bufferline.nvim": { "branch": "main", "commit": "32d74d5d044f7cc89892d4781a83d55ee4ed552a" },
"catppuccin": { "branch": "main", "commit": "1d3eda15703ba70f57e94e6451db55914ff7017f" },
"catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "c0f7432052a837c6295a7770e39fdc07ede3305c" },
"clever-f.vim": { "branch": "master", "commit": "6a3ac5e3688598af9411ab741737f98c47370c22" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" },
Expand All @@ -17,12 +17,12 @@
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp-spell": { "branch": "master", "commit": "60584cb75e5e8bba5a0c9e4c3ab0791e0698bffa" },
"cmp-tmux": { "branch": "main", "commit": "984772716f66d8ee88535a6bf3f94c4b4e1301f5" },
"cmp-treesitter": { "branch": "master", "commit": "389eadd48c27aa6dc0e6b992644704f026802a2e" },
"cmp-treesitter": { "branch": "master", "commit": "c8e3a74b51597d69d240085a258636972ce98e15" },
"cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"codeium.nvim": { "branch": "main", "commit": "29195dc9e58232b2dbd18669db206218188a321f" },
"copilot-cmp": { "branch": "master", "commit": "c2cdb3c0f5078b0619055af192295830a7987790" },
"copilot.lua": { "branch": "master", "commit": "653bbdc44cd569a5fd0617e5a9d3df2b1359e230" },
"copilot.lua": { "branch": "master", "commit": "77e3a4907928f0813024e573b882dc879dfc0c6b" },
"crates.nvim": { "branch": "main", "commit": "3648f8787656d7572740560331553abdaa8cb982" },
"csv.vim": { "branch": "master", "commit": "15ff93edf5b26c466affbb356e0696b7d6a3b499" },
"diffview.nvim": { "branch": "main", "commit": "bff58a6ea3e081ca50049700f9848b2f84ea57be" },
Expand All @@ -33,9 +33,9 @@
"gitsigns.nvim": { "branch": "main", "commit": "f868d82a36f7f7f5e110eb0a9659993984f59875" },
"hop.nvim": { "branch": "v2", "commit": "90db1b2c61b820e230599a04fedcd2679e64bd07" },
"indent-blankline.nvim": { "branch": "master", "commit": "ceaf730b13e332cd76600d9795722413c236c684" },
"lazy.nvim": { "branch": "main", "commit": "a93d8983c4335b6ae7d6e7d516a191d929186d5b" },
"lazy.nvim": { "branch": "main", "commit": "ebdd0499551765e6a7aba220cc8ae4e0cdb6be69" },
"lsp_signature.nvim": { "branch": "master", "commit": "7a26ebaa7e36aa2aefa6c1994b2b866c96de32e6" },
"lspsaga.nvim": { "branch": "main", "commit": "01b9633aefd010f272d6c7e3d8293c44fcfe7696" },
"lspsaga.nvim": { "branch": "main", "commit": "4c557ed5c7cf3284bcd8fb926f329f24a0f141bf" },
"lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
"markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "f0ce33f4794a2364eb08d09d09380e8b04ec5e6a" },
Expand All @@ -44,18 +44,18 @@
"neodim": { "branch": "master", "commit": "89c16fccccfdb5b7e6ad3a6e8286736debc11705" },
"neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" },
"nord.nvim": { "branch": "master", "commit": "fab04b2dd4b64f4b1763b9250a8824d0b5194b8f" },
"null-ls.nvim": { "branch": "main", "commit": "77e53bc3bac34cc273be8ed9eb9ab78bcf67fa48" },
"null-ls.nvim": { "branch": "main", "commit": "4b055d84be42c90a7240785d3c83340d259d3d46" },
"nvim-bufdel": { "branch": "main", "commit": "96c4f7ab053ddab0025bebe5f7c71e4795430e47" },
"nvim-cmp": { "branch": "main", "commit": "1088b3743b83ffd8973ad65e6b5fed010da0ffd2" },
"nvim-cmp": { "branch": "main", "commit": "b43bfaf3229d6b39d8baaa567b13c6be0623bf12" },
"nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" },
"nvim-dap": { "branch": "master", "commit": "56118cee6af15cb9ddba9d080880949d8eeb0c9f" },
"nvim-dap-ui": { "branch": "master", "commit": "c693e80f8d7b6369f4152e7fdab10db4847c5c71" },
"nvim-lspconfig": { "branch": "master", "commit": "465042c0f786992212284311ebb5da1f89479774" },
"nvim-lspconfig": { "branch": "master", "commit": "9166622781a39a829878d1fd24c174529d996838" },
"nvim-notify": { "branch": "master", "commit": "f3024b912073774111202f5fa6518b0cd2a74432" },
"nvim-scrollview": { "branch": "main", "commit": "4a04039b80c270f6bd2075935cd3c7943f6ad140" },
"nvim-tree.lua": { "branch": "master", "commit": "e2a4c9d09d205ebe5f071264f43f73a0077c43a3" },
"nvim-treehopper": { "branch": "master", "commit": "5a28bff46c05d28bdb4bcaef67e046eb915a9390" },
"nvim-treesitter": { "branch": "master", "commit": "a76db88548bb7fe008cd7e4f2d2ec2ccc080dede" },
"nvim-treesitter": { "branch": "master", "commit": "1d670b0c906716b1543270b3b087d44b09f3b523" },
"nvim-treesitter-context": { "branch": "master", "commit": "7cd5ac1c384b89e7e607238a936f13963f97ba32" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "95b76b95eff25e1e64f363938cd853852355d70a" },
"nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" },
Expand Down
93 changes: 39 additions & 54 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ return function()

local border = function(hl)
return {
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
{ "", hl },
}
end
Expand All @@ -32,47 +32,18 @@ return function()
return (diff < 0)
end

local function cmp_format(opts)
opts = opts or {}

return function(entry, vim_item)
if opts.before then
vim_item = opts.before(entry, vim_item)
end

local kind_symbol = opts.symbol_map[vim_item.kind] or icons.kind.Undefined
local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.undefined

vim_item.menu = " " .. source_symbol .. " |"
vim_item.kind = string.format(" 〔 %s %s 〕", kind_symbol, vim_item.kind)

if opts.maxwidth ~= nil then
if opts.ellipsis_char == nil then
vim_item.abbr = string.sub(vim_item.abbr, 1, opts.maxwidth)
else
local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, opts.maxwidth)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. opts.ellipsis_char
end
end
end
return vim_item
end
end

local cmp = require("cmp")
cmp.setup({
preselect = cmp.PreselectMode.Item,
window = {
completion = {
border = border("Normal"),
max_width = 80,
max_height = 20,
border = border("PmenuBorder"),
winhighlight = "Normal:Pmenu,CursorLine:PmenuSel,Search:PmenuSel",
scrollbar = false,
},
documentation = {
border = border("CmpDocBorder"),
winhighlight = "Normal:CmpDoc",
},
},
sorting = {
Expand All @@ -96,14 +67,38 @@ return function()
},
},
formatting = {
fields = { "menu", "abbr", "kind" },
fields = { "abbr", "kind", "menu" },
format = function(entry, vim_item)
local kind_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp)
local kind = cmp_format({
maxwidth = 50,
symbol_map = kind_map,
})(entry, vim_item)
return kind
local lspkind_icons = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp)
-- load lspkind icons
vim_item.kind =
string.format(" %s %s", lspkind_icons[vim_item.kind] or icons.cmp.undefined, vim_item.kind or "")

vim_item.menu = setmetatable({
cmp_tabnine = "[TN]",
copilot = "[CPLT]",
buffer = "[BUF]",
orgmode = "[ORG]",
nvim_lsp = "[LSP]",
nvim_lua = "[LUA]",
path = "[PATH]",
tmux = "[TMUX]",
treesitter = "[TS]",
luasnip = "[SNIP]",
spell = "[SPELL]",
}, {
__index = function()
return "[BTN]" -- builtin/unknown source names
end,
})[entry.source.name]

local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, 80)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. "..."
end

return vim_item
end,
},
matching = {
Expand Down Expand Up @@ -151,17 +146,7 @@ return function()
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "path" },
{
name = "treesitter",
entry_filter = function(entry)
local ignore_list = {
"Error",
"Comment",
}
local kind = entry:get_completion_item().cmp.kind_text
return not vim.tbl_contains(ignore_list, kind)
end,
},
{ name = "treesitter" },
{ name = "spell" },
{ name = "tmux" },
{ name = "orgmode" },
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ return function()
local mason = require("mason")
local mason_lspconfig = require("mason-lspconfig")

require("lspconfig.ui.windows").default_options.border = "single"
require("lspconfig.ui.windows").default_options.border = "rounded"

local icons = {
ui = require("modules.utils.icons").get("ui", true),
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/servers/clangd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ return function(options)
"--header-insertion-decorators",
"--header-insertion=iwyu",
"--limit-references=3000",
"--limit-results=350",
"--limit-results=270",
},
commands = {
ClangdSwitchSourceHeader = {
Expand Down
10 changes: 5 additions & 5 deletions lua/modules/configs/tool/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ return function()
show = {
file = true,
folder = true,
folder_arrow = false,
folder_arrow = true,
git = true,
},
padding = " ",
Expand All @@ -81,10 +81,10 @@ return function()
ignored = icons.git.Ignore, --
},
folder = {
-- arrow_open = "",
-- arrow_closed = "",
arrow_open = "",
arrow_closed = "",
arrow_open = icons.ui.ArrowOpen,
arrow_closed = icons.ui.ArrowClosed,
-- arrow_open = "",
-- arrow_closed = "",
default = icons.ui.Folder,
open = icons.ui.FolderOpen,
empty = icons.ui.EmptyFolder,
Expand Down
11 changes: 7 additions & 4 deletions lua/modules/configs/tool/toggleterm.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
return function()
local colors = require("modules.utils").get_palette()
local floatborder_hl = require("modules.utils").hl_to_rgb("FloatBorder", false, colors.blue)

require("toggleterm").setup({
-- size can be a number or function which is passed the current terminal
size = function(term)
Expand All @@ -18,8 +15,14 @@ return function()
vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" })
end,
highlights = {
Normal = {
link = "Normal",
},
NormalFloat = {
link = "NormalFloat",
},
FloatBorder = {
guifg = floatborder_hl,
link = "FloatBorder",
},
},
open_mapping = false, -- [[<c-\>]],
Expand Down
8 changes: 3 additions & 5 deletions lua/modules/configs/tool/wilder.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
return function()
local wilder = require("wilder")
local colors = require("modules.utils").get_palette()
local icons = { ui = require("modules.utils.icons").get("ui") }

wilder.setup({ modes = { ":", "/", "?" } })
Expand All @@ -25,13 +24,12 @@ return function()
),
})

local match_hl = require("modules.utils").hl_to_rgb("String", false, colors.green)

local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_border_theme({
border = "rounded",
highlights = {
border = "Title", -- highlight to use for the border
accent = wilder.make_hl("WilderAccent", "Pmenu", { { a = 0 }, { a = 0 }, { foreground = match_hl } }),
default = "Pmenu",
border = "PmenuBorder", -- highlight to use for the border
accent = wilder.make_hl("WilderAccent", "CmpItemAbbr", "CmpItemAbbrMatch"),
},
empty_message = wilder.popupmenu_empty_message_with_spinner(),
highlighter = wilder.lua_fzy_highlighter(),
Expand Down
6 changes: 3 additions & 3 deletions lua/modules/configs/ui/alpha.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ return function()
cursor = 5,
width = 50,
align_shortcut = "right",
hl = "AlphaButton",
hl_shortcut = "AlphaAttr",
hl = "AlphaButtons",
hl_shortcut = "AlphaShortcut",
}

if nil == keybind then
Expand Down Expand Up @@ -118,7 +118,7 @@ return function()
end,
}),
}
dashboard.section.buttons.opts.hl = "AlphaButton"
dashboard.section.buttons.opts.hl = "AlphaButtons"

local function footer()
local stats = require("lazy").stats()
Expand Down
Loading

0 comments on commit 255070a

Please sign in to comment.