refactor: temp code for better fzf_colors

This commit is contained in:
Folke Lemaitre 2024-06-10 17:10:25 +02:00
parent 26254487fb
commit 6a07e6522a
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 24 additions and 22 deletions

View file

@ -162,27 +162,27 @@ return {
Separator = "FzfColorsBorder", Separator = "FzfColorsBorder",
} }
for name, link in pairs(links) do for name, link in pairs(links) do
name = "FzfColors" .. name name = "FzfLuaColors" .. name
vim.api.nvim_set_hl(0, name, { link = link, default = true }) vim.api.nvim_set_hl(0, name, { link = link, default = true })
end end
opts.fzf_colors = { opts.fzf_colors = {
["fg"] = { "fg", "FzfColorsNormal" }, ["fg"] = { "fg", "FzfLuaColorsNormal" },
["bg"] = { "bg", "FzfColorsNormal" }, ["bg"] = { "bg", "FzfLuaColorsNormal" },
["hl"] = { "fg", "FzfColorsMatch" }, ["hl"] = { "fg", "FzfLuaColorsMatch" },
["fg+"] = { "fg", "FzfColorsCursorLine" }, ["fg+"] = { "fg", "FzfLuaColorsCursorLine" },
["bg+"] = { "bg", "FzfColorsCursorLine" }, ["bg+"] = { "bg", "FzfLuaColorsCursorLine" },
["hl+"] = { "fg", "FzfColorsMatch" }, ["hl+"] = { "fg", "FzfLuaColorsMatch" },
["info"] = { "fg", "FzfColorsInfo" }, ["info"] = { "fg", "FzfLuaColorsInfo" },
["border"] = { "fg", "FzfColorsBorder" }, ["border"] = { "fg", "FzfLuaColorsBorder" },
["separator"] = { "fg", "FzfColorsSeparator" }, ["separator"] = { "fg", "FzfLuaColorsSeparator" },
["scrollbar"] = { "fg", "FzfColorsScrollbar" }, ["scrollbar"] = { "fg", "FzfLuaColorsScrollbar" },
["gutter"] = { "bg", "FzfColorsGutter" }, ["gutter"] = { "bg", "FzfLuaColorsGutter" },
["query"] = { "fg", "FzfColorsQuery", "regular" }, ["query"] = { "fg", "FzfLuaColorsQuery", "regular" },
["prompt"] = { "fg", "FzfColorsPrompt" }, ["prompt"] = { "fg", "FzfLuaColorsPrompt" },
["pointer"] = { "fg", "FzfColorsPointer" }, ["pointer"] = { "fg", "FzfLuaColorsPointer" },
["marker"] = { "fg", "FzfColorsMarker" }, ["marker"] = { "fg", "FzfLuaColorsMarker" },
["spinner"] = { "fg", "FzfColorsSpinner" }, ["spinner"] = { "fg", "FzfLuaColorsSpinner" },
["header"] = { "fg", "FzfColorsHeader" }, ["header"] = { "fg", "FzfLuaColorsHeader" },
} }
end, end,
}, },

View file

@ -9,6 +9,7 @@ local M = setmetatable({}, {
---@class lazyvim.util.pick.Opts: table<string, any> ---@class lazyvim.util.pick.Opts: table<string, any>
---@field root? boolean ---@field root? boolean
---@field cwd? string ---@field cwd? string
---@field buf? number
---@field show_untracked? boolean ---@field show_untracked? boolean
---@type table<string, string> ---@type table<string, string>
@ -30,7 +31,7 @@ function M.open(command, opts)
end end
if not opts.cwd and opts.root ~= false then if not opts.cwd and opts.root ~= false then
opts.cwd = LazyVim.root() opts.cwd = LazyVim.root({ buf = opts.buf })
end end
local cwd = opts.cwd or vim.uv.cwd() local cwd = opts.cwd or vim.uv.cwd()

View file

@ -168,13 +168,14 @@ end
-- * lsp root_dir -- * lsp root_dir
-- * root pattern of filename of the current buffer -- * root pattern of filename of the current buffer
-- * root pattern of cwd -- * root pattern of cwd
---@param opts? {normalize?:boolean} ---@param opts? {normalize?:boolean, buf?:number}
---@return string ---@return string
function M.get(opts) function M.get(opts)
local buf = vim.api.nvim_get_current_buf() opts = opts or {}
local buf = opts.buf or vim.api.nvim_get_current_buf()
local ret = M.cache[buf] local ret = M.cache[buf]
if not ret then if not ret then
local roots = M.detect({ all = false }) local roots = M.detect({ all = false, buf = buf })
ret = roots[1] and roots[1].paths[1] or vim.uv.cwd() ret = roots[1] and roots[1].paths[1] or vim.uv.cwd()
M.cache[buf] = ret M.cache[buf] = ret
end end