neovim: added gitsigns, moved color stuff into colors.lua, modified telescope and fyler
This commit is contained in:
parent
1d6eec78f0
commit
c2a581e1be
8 changed files with 296 additions and 82 deletions
|
|
@ -7,6 +7,7 @@ vim.opt.colorcolumn = "80"
|
|||
|
||||
require("plugins")
|
||||
require("lsp")
|
||||
require("colors")
|
||||
|
||||
vim.keymap.set("n", "<A-h>", function()
|
||||
vim.cmd("wincmd h")
|
||||
|
|
@ -20,74 +21,3 @@ end)
|
|||
vim.keymap.set("n", "<A-l>", function()
|
||||
vim.cmd("wincmd l")
|
||||
end)
|
||||
|
||||
local uv = vim.loop
|
||||
local colorscheme_filepath = "/home/aurora/.cache/nvim/neovim-colors"
|
||||
local colors = {}
|
||||
|
||||
-- function to load colors
|
||||
local function load_colors()
|
||||
local new_colors = {}
|
||||
for line in io.lines(colorscheme_filepath) do
|
||||
table.insert(new_colors, line)
|
||||
end
|
||||
|
||||
-- ensure the table has enough entries to avoid indexing issues
|
||||
if #new_colors >= 18 then
|
||||
colors = new_colors
|
||||
require("base16-colorscheme").setup({
|
||||
base00 = colors[17],
|
||||
base01 = colors[1],
|
||||
base02 = colors[3],
|
||||
base03 = colors[3],
|
||||
base04 = colors[5],
|
||||
base05 = colors[8],
|
||||
base06 = colors[5],
|
||||
base07 = colors[8],
|
||||
base08 = colors[18],
|
||||
base09 = colors[4],
|
||||
base0A = colors[11],
|
||||
base0B = colors[5],
|
||||
base0C = colors[6],
|
||||
base0D = colors[7],
|
||||
base0E = colors[6],
|
||||
base0F = colors[16],
|
||||
})
|
||||
|
||||
-- set colors for blink.cmp's completion menu
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpMenu", { bg = colors[17] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { bg = colors[17], fg = colors[13] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpMenuSelection", { bg = colors[15], fg = colors[17] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpScrollBarThumb", { bg = colors[18] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpKind", { bg = colors[17], fg = colors[14] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabel", { bg = colors[17], fg = colors[18] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabelMatch", { bg = colors[17], fg = colors[18] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabelDetail", { bg = colors[17], fg = colors[18] })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabelDescription", { bg = colors[17], fg = colors[18] })
|
||||
else
|
||||
print("Error: Not enough colors in file")
|
||||
end
|
||||
end
|
||||
|
||||
-- initial load
|
||||
load_colors()
|
||||
|
||||
-- vim.defer_fn(load_colors, 1)
|
||||
|
||||
-- set up a file watcher
|
||||
local function watch_colorscheme()
|
||||
local handle
|
||||
handle = uv.new_fs_event()
|
||||
if handle then
|
||||
uv.fs_event_start(handle, colorscheme_filepath, {}, function(err, _, _)
|
||||
if err then
|
||||
print("Error watching colorscheme file:", err)
|
||||
return
|
||||
end
|
||||
-- debounce by adding a slight delay before reloading
|
||||
vim.defer_fn(load_colors, 100)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
watch_colorscheme()
|
||||
|
|
|
|||
220
homes/modules/programs/neovim/lua/colors.lua
Normal file
220
homes/modules/programs/neovim/lua/colors.lua
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
local colorscheme_filepath = "/home/aurora/.cache/nvim/neovim-colors"
|
||||
local colors = {}
|
||||
|
||||
local function hex_to_int(hex)
|
||||
hex = hex:gsub("#", "")
|
||||
return tonumber(hex:sub(1, 2), 16) * 0x10000 + tonumber(hex:sub(3, 4), 16) * 0x100 + tonumber(hex:sub(5, 6), 16)
|
||||
end
|
||||
|
||||
-- TODO: change to use lab color space
|
||||
local function blend_colors(c1, c2, t)
|
||||
local r1 = math.floor(c1 / 0x10000)
|
||||
local g1 = math.floor((c1 % 0x10000) / 0x100)
|
||||
local b1 = c1 % 0x100
|
||||
|
||||
local r2 = math.floor(c2 / 0x10000)
|
||||
local g2 = math.floor((c2 % 0x10000) / 0x100)
|
||||
local b2 = c2 % 0x100
|
||||
|
||||
return math.floor(r1 + (r2 - r1) * t) * 0x10000
|
||||
+ math.floor(g1 + (g2 - g1) * t) * 0x100
|
||||
+ math.floor(b1 + (b2 - b1) * t)
|
||||
end
|
||||
|
||||
-- function to load colors
|
||||
local function load_colors()
|
||||
local new_colors = {}
|
||||
for line in io.lines(colorscheme_filepath) do
|
||||
table.insert(new_colors, line)
|
||||
end
|
||||
|
||||
-- ensure the table has enough entries to avoid indexing issues
|
||||
if #new_colors == 18 then
|
||||
colors = new_colors
|
||||
require("base16-colorscheme").setup({
|
||||
base00 = colors[18],
|
||||
base01 = colors[1],
|
||||
base02 = colors[3],
|
||||
base03 = colors[3],
|
||||
base04 = colors[5],
|
||||
base05 = colors[8],
|
||||
base06 = colors[5],
|
||||
base07 = colors[8],
|
||||
base08 = colors[17],
|
||||
base09 = colors[4],
|
||||
base0A = colors[11],
|
||||
base0B = colors[5],
|
||||
base0C = colors[6],
|
||||
base0D = colors[7],
|
||||
base0E = colors[6],
|
||||
base0F = colors[16],
|
||||
})
|
||||
|
||||
-- colors ------------------------------------------------------------------
|
||||
|
||||
local color_00 = colors[1]
|
||||
local color_01 = colors[2]
|
||||
local color_02 = colors[3]
|
||||
local color_03 = colors[4]
|
||||
local color_04 = colors[5]
|
||||
local color_05 = colors[6]
|
||||
local color_06 = colors[7]
|
||||
local color_07 = colors[8]
|
||||
|
||||
local color_08 = colors[9]
|
||||
local color_09 = colors[10]
|
||||
local color_10 = colors[11]
|
||||
local color_11 = colors[12]
|
||||
local color_12 = colors[13]
|
||||
local color_13 = colors[14]
|
||||
local color_14 = colors[15]
|
||||
local color_15 = colors[16]
|
||||
|
||||
local fg = colors[17]
|
||||
local bg = colors[18]
|
||||
|
||||
local bg_90 = blend_colors(hex_to_int("#000000"), hex_to_int(bg), 0.90)
|
||||
|
||||
-- blink.cmp ---------------------------------------------------------------
|
||||
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpMenu", { bg = bg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { fg = color_12, bg = bg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpMenuSelection", { fg = bg, bg = color_14 })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpScrollBarThumb", { bg = fg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpKind", { fg = fg, bg = bg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabel", { fg = fg, bg = bg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabelMatch", { fg = fg, bg = bg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabelDetail", { fg = fg, bg = bg })
|
||||
vim.api.nvim_set_hl(0, "BlinkCmpLabelDescription", { fg = fg, bg = bg })
|
||||
|
||||
-- telescope :3 ------------------------------------------------------------
|
||||
|
||||
vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptNormal", { bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopeResultsNormal", { bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopePreviewNormal", { bg = bg_90 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "TelescopeBorder", { fg = color_15, bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptBorder", { fg = color_14, bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopeResultsBorder", { fg = color_13, bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopePreviewBorder", { fg = color_12, bg = bg_90 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptTitle", { fg = color_15, bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopeResultsTitle", { fg = color_15, bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopePreviewTitle", { fg = color_15, bg = bg_90 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptPrefix", { fg = color_14, bg = bg_90 })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptCounter", { fg = color_13, bg = bg_90 })
|
||||
|
||||
-- gitsigns.nvim -----------------------------------------------------------
|
||||
|
||||
vim.api.nvim_set_hl(0, "GitSignsAdd", { fg = color_13 })
|
||||
vim.api.nvim_set_hl(0, "GitSignsChange", { fg = color_11 })
|
||||
vim.api.nvim_set_hl(0, "GitSignsDelete", { fg = color_09 })
|
||||
|
||||
local blame_palette = {
|
||||
color_13,
|
||||
color_11,
|
||||
color_09,
|
||||
color_06,
|
||||
color_05,
|
||||
color_04,
|
||||
color_03,
|
||||
color_12,
|
||||
}
|
||||
|
||||
local blame_group = vim.api.nvim_create_augroup("GitSignsBlameColors", { clear = true })
|
||||
|
||||
local function get_heatmap_palette()
|
||||
local c1 = hex_to_int(color_13) -- old
|
||||
local c2 = hex_to_int(color_14) -- recent
|
||||
|
||||
local palette = {}
|
||||
for i = 0, 7 do
|
||||
palette[i] = blend_colors(c1, c2, i / 7)
|
||||
end
|
||||
|
||||
return palette
|
||||
end
|
||||
|
||||
local heatmap_palette = get_heatmap_palette()
|
||||
|
||||
local function set_blame_colors()
|
||||
local highlights = vim.api.nvim_exec2("highlight", { output = true }).output
|
||||
|
||||
local i = 1
|
||||
for hl_name in highlights:gmatch("(GitSignsBlameColor%.[%x]+)") do
|
||||
local color = blame_palette[(i - 1) % #blame_palette + 1]
|
||||
vim.api.nvim_set_hl(0, hl_name, { fg = color })
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
i = 1
|
||||
for hl_name in highlights:gmatch("(GitSignsColorTemp%.fg%.[%d]+)") do
|
||||
local color = heatmap_palette[(i - 1) % #heatmap_palette + 1]
|
||||
vim.api.nvim_set_hl(0, hl_name, { fg = color })
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
set_blame_colors()
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = blame_group,
|
||||
pattern = "gitsigns-blame",
|
||||
callback = function()
|
||||
set_blame_colors()
|
||||
end,
|
||||
})
|
||||
|
||||
-- fyler.nvim --------------------------------------------------------------
|
||||
|
||||
vim.api.nvim_set_hl(0, "FylerBlue", { fg = color_06 })
|
||||
vim.api.nvim_set_hl(0, "FylerGreen", { fg = color_02 })
|
||||
vim.api.nvim_set_hl(0, "FylerGrey", { fg = color_08 })
|
||||
vim.api.nvim_set_hl(0, "FylerRed", { fg = color_01 })
|
||||
vim.api.nvim_set_hl(0, "FylerYellow", { fg = color_03 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "FylerFSDirectoryIcon", { fg = color_06 })
|
||||
vim.api.nvim_set_hl(0, "FylerFSDirectoryName", { fg = fg })
|
||||
vim.api.nvim_set_hl(0, "FylerFSFile", { fg = color_15 })
|
||||
vim.api.nvim_set_hl(0, "FylerFSLink", { fg = color_08 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "FylerGitAdded", { fg = color_04 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitConflict", { fg = color_03 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitDeleted", { fg = color_03 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitIgnored", { fg = color_08 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitModified", { fg = color_05 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitRenamed", { fg = color_05 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitStaged", { fg = color_04 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitUnstaged", { fg = color_05 })
|
||||
vim.api.nvim_set_hl(0, "FylerGitUntracked", { fg = color_06 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "FylerWinPick", { fg = color_15, bg = fg })
|
||||
else
|
||||
print("Error: Not enough colors in file")
|
||||
end
|
||||
end
|
||||
|
||||
-- initial load
|
||||
load_colors()
|
||||
|
||||
-- vim.defer_fn(load_colors, 1)
|
||||
|
||||
-- set up a file watcher
|
||||
local function watch_colorscheme()
|
||||
local handle
|
||||
handle = vim.loop.new_fs_event()
|
||||
if handle then
|
||||
vim.loop.fs_event_start(handle, colorscheme_filepath, {}, function(err, _, _)
|
||||
if err then
|
||||
print("Error watching colorscheme file:", err)
|
||||
return
|
||||
end
|
||||
-- debounce by adding a slight delay before reloading
|
||||
vim.defer_fn(load_colors, 100)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
watch_colorscheme()
|
||||
|
|
@ -38,7 +38,7 @@ function M.on_attach(_, bufnr)
|
|||
end -- TODO: someone who knows the builtin versions of these to do instead help me out please.
|
||||
|
||||
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
|
||||
nmap("<leader>e", vim.diagnostic.open_float, "Show [E]rror")
|
||||
nmap("<leader>E", vim.diagnostic.open_float, "Show [E]rror")
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ return {
|
|||
cmd = { "Fyler" },
|
||||
keys = {
|
||||
{
|
||||
"<leader>tf",
|
||||
"<leader>e",
|
||||
function()
|
||||
return require("fyler").toggle({ kind = "split_right" })
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "Open [F]yler",
|
||||
desc = "Open File [E]xplorer (Fyler)",
|
||||
},
|
||||
},
|
||||
load = function(name)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
return {
|
||||
{
|
||||
"vim-fugitive",
|
||||
enabled = nixCats("git") or false,
|
||||
enabled = nixCats("git.merge") or false,
|
||||
cmd = { "Git", "Gvdiffsplit" },
|
||||
},
|
||||
{
|
||||
"resolve-nvim",
|
||||
enabled = nixCats("git") or false,
|
||||
enabled = nixCats("git.merge") or false,
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
after = function(plugin)
|
||||
require("resolve").setup({
|
||||
|
|
@ -21,4 +21,45 @@ return {
|
|||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"gitsigns.nvim",
|
||||
enabled = nixCats("git.gitsigns") or false,
|
||||
after = function(plugin)
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { text = "┃" },
|
||||
change = { text = "┇" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
untracked = { text = "╎" },
|
||||
},
|
||||
signs_staged = {
|
||||
add = { text = "┃" },
|
||||
change = { text = "┇" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
untracked = { text = "╎" },
|
||||
},
|
||||
on_attach = function(bufnr)
|
||||
local gitsigns = require("gitsigns")
|
||||
|
||||
-- toggle git blame
|
||||
vim.keymap.set("n", "<leader>gb", function()
|
||||
local wins = vim.api.nvim_list_wins()
|
||||
for _, win in ipairs(wins) do
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
local ft = vim.api.nvim_get_option_value("filetype", { buf = buf })
|
||||
if ft == "gitsigns-blame" then
|
||||
vim.api.nvim_win_close(win, true)
|
||||
return
|
||||
end
|
||||
end
|
||||
vim.cmd("Gitsigns blame")
|
||||
end)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,14 @@ return {
|
|||
mode = { "n" },
|
||||
desc = "[T]elescope search [B]uffers",
|
||||
},
|
||||
{
|
||||
"<leader>th",
|
||||
function()
|
||||
return require("telescope.builtin").highlights()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "[T]elescope [H]ighlights",
|
||||
},
|
||||
},
|
||||
load = function(name)
|
||||
vim.cmd.packadd(name)
|
||||
|
|
@ -62,6 +70,13 @@ return {
|
|||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
border = true,
|
||||
borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||
-- borderchars = {
|
||||
-- prompt = { "─", " ", " ", " ", "─", "─", " ", " " },
|
||||
-- results = { " " },
|
||||
-- preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||
-- },
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
||||
|
|
|
|||
|
|
@ -162,10 +162,15 @@ in {
|
|||
comment = [
|
||||
comment-nvim
|
||||
];
|
||||
git = [
|
||||
resolve-nvim
|
||||
vim-fugitive
|
||||
];
|
||||
git = {
|
||||
merge = [
|
||||
resolve-nvim
|
||||
vim-fugitive
|
||||
];
|
||||
gitsigns = [
|
||||
gitsigns-nvim
|
||||
];
|
||||
};
|
||||
lang = {
|
||||
java = [
|
||||
nvim-jdtls
|
||||
|
|
@ -247,7 +252,10 @@ in {
|
|||
format = true;
|
||||
comment = true;
|
||||
|
||||
git = false; # not really setup yet
|
||||
git = {
|
||||
merge = false; # not really setup yet.. </3
|
||||
gitsigns = true;
|
||||
};
|
||||
|
||||
lang = {
|
||||
lua.lsp = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue