Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9556df285 | |||
| e8275c583d |
@@ -3,11 +3,10 @@ import = ["~/.config/alacritty/themes/noctalia.toml"]
|
||||
|
||||
[font]
|
||||
size = 13
|
||||
offset = { x = 0, y = 3 }
|
||||
offset = { x = 0, y = 6 }
|
||||
normal = { family = "JetBrainsMono Nerd Font", style = "Regular" }
|
||||
|
||||
[window]
|
||||
# startup_mode = "Maximized"
|
||||
padding.x = 10
|
||||
padding.y = 10
|
||||
|
||||
|
||||
+19
-21
@@ -1,13 +1,11 @@
|
||||
require("vim._core.ui2").enable({})
|
||||
map = vim.keymap.set
|
||||
vim.o.termguicolors = true
|
||||
vim.o.showmode = false
|
||||
vim.o.showmode = true
|
||||
vim.o.laststatus = 3
|
||||
vim.o.nu = true
|
||||
vim.o.swapfile = false
|
||||
vim.o.winborder = "single"
|
||||
vim.o.winblend = 0
|
||||
vim.o.pumblend = 0
|
||||
vim.o.scrolloff = 20
|
||||
vim.o.shiftwidth = 4
|
||||
vim.o.tabstop = 4
|
||||
@@ -19,19 +17,16 @@ vim.o.hlsearch = true
|
||||
vim.o.mouse = "a"
|
||||
vim.o.path = "**"
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
vim.o.foldenable = true
|
||||
vim.o.foldmethod = "expr"
|
||||
vim.o.foldlevel = 99
|
||||
vim.o.splitright = true
|
||||
vim.o.splitbelow = true
|
||||
vim.o.signcolumn = "yes"
|
||||
vim.o.completeopt = "menu,menuone,noselect,popup,fuzzy"
|
||||
vim.o.autoread = true
|
||||
vim.o.undofile = true
|
||||
vim.o.undodir = vim.fn.stdpath("state") .. "/undo"
|
||||
vim.o.errorformat = "%f(%l:%c) %m,%-G%.%#"
|
||||
-- -----------------------------
|
||||
-- @BINDS
|
||||
-- -----------------------------
|
||||
map("t", "<ESC><ESC>", "<C-\\><C-n>")
|
||||
map({"t", "n"}, "<C-h>", "<C-\\><C-n><C-w><C-h>")
|
||||
map({"t", "n"}, "<C-j>", "<C-\\><C-n><C-w><C-j>")
|
||||
@@ -43,19 +38,16 @@ map("v", "J", ":m '>+1<CR>gv=gv")
|
||||
map("v", "K", ":m '<-2<CR>gv=gv")
|
||||
map("v", "<S-Tab>", "<gv")
|
||||
map("v", "<Tab>" , ">gv")
|
||||
map("n", "<C-p>", ":find ")
|
||||
map("n", "<C-e>", ":Lex<CR>")
|
||||
map("n", "<C-backspace>", ":bd<CR>")
|
||||
map("i", "<C-h>", vim.lsp.buf.signature_help)
|
||||
-- -----------------------------
|
||||
-- @PLUGINS
|
||||
-- -----------------------------
|
||||
require("plugins")
|
||||
require("theme").load()
|
||||
require("theme").watch()
|
||||
-- -----------------------------
|
||||
-- @EXTRAS
|
||||
require("extra/lsp")
|
||||
require("extra/terminal")
|
||||
require("extra/build")
|
||||
-- -----------------------------
|
||||
-- @AUTOCMDS
|
||||
-- -----------------------------
|
||||
-- Terminals should open with insert mode
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "TermEnter", "WinEnter" }, {
|
||||
pattern = "term://*",
|
||||
@@ -84,11 +76,17 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
vim.fn.setpos(".", save_cursor)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_augroup('AutoResizeWindows', { clear = true })
|
||||
vim.api.nvim_create_autocmd('VimResized', {
|
||||
group = 'AutoResizeWindows',
|
||||
callback = function()
|
||||
vim.cmd('wincmd =')
|
||||
-- Restore cursor to file position in previous editing session
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
callback = function(args)
|
||||
local mark = vim.api.nvim_buf_get_mark(args.buf, '"')
|
||||
local line_count = vim.api.nvim_buf_line_count(args.buf)
|
||||
if mark[1] > 0 and mark[1] <= line_count then
|
||||
vim.api.nvim_win_set_cursor(0, mark)
|
||||
-- defer centering slightly so it's applied after render
|
||||
vim.schedule(function()
|
||||
vim.cmd("normal! zz")
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
-- ------------------------------------------------------------
|
||||
-- BUILD SYSTEM
|
||||
-- ------------------------------------------------------------
|
||||
local function build(args)
|
||||
if vim.fn.filereadable("build.sh") == 0 then
|
||||
vim.notify("No build.sh found in current directory.", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
vim.cmd("wall")
|
||||
|
||||
local command = "./build.sh"
|
||||
|
||||
if #args > 0 then
|
||||
command = command .. " " .. table.concat(args, " ")
|
||||
end
|
||||
|
||||
send("clear && " .. command)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command(
|
||||
"Build",
|
||||
function(opts) build(opts.fargs) end,
|
||||
{
|
||||
nargs = "*",
|
||||
desc = "Run project build.sh",
|
||||
}
|
||||
)
|
||||
map("n", "<C-Space>", function() build({}) end, { desc = "Build project", })
|
||||
map("t", "<C-Space>", function() build({}) end, { desc = "Build project", })
|
||||
@@ -0,0 +1,11 @@
|
||||
-- ------------------------------------------------------------
|
||||
-- LSP
|
||||
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||
vim.lsp.config("gopls", { capabilities = capabilities, })
|
||||
vim.lsp.config("ols", { capabilities = capabilities, })
|
||||
vim.lsp.enable({ "gopls", "ols", })
|
||||
map("n", "gd", vim.lsp.buf.definition)
|
||||
map("i", "<C-h>", vim.lsp.buf.signature_help)
|
||||
|
||||
vim.api.nvim_create_user_command("Rename", function() vim.lsp.buf.rename() end, {})
|
||||
vim.api.nvim_create_user_command("Actions", function() vim.lsp.buf.code_action() end, {})
|
||||
@@ -0,0 +1,90 @@
|
||||
-- ------------------------------------------------------------
|
||||
-- TERMINAL SYSTEM
|
||||
-- ------------------------------------------------------------
|
||||
local term_buf = nil
|
||||
|
||||
local function open_term_split()
|
||||
vim.cmd("botright vsplit")
|
||||
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
|
||||
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
|
||||
vim.api.nvim_win_set_buf(win, term_buf)
|
||||
else
|
||||
vim.cmd("terminal")
|
||||
term_buf = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
vim.api.nvim_win_set_width(win, math.floor(vim.o.columns * 0.37))
|
||||
vim.cmd("startinsert")
|
||||
end
|
||||
|
||||
local function toggle_term()
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
if vim.api.nvim_win_get_buf(win) == term_buf then
|
||||
vim.api.nvim_win_close(win, false)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
open_term_split()
|
||||
end
|
||||
|
||||
local function open_term_fullscreen()
|
||||
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
|
||||
vim.api.nvim_set_current_buf(term_buf)
|
||||
else
|
||||
vim.cmd("terminal")
|
||||
term_buf = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
vim.cmd("startinsert")
|
||||
end
|
||||
|
||||
local function prev_non_term_buf()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
local buffers = vim.fn.getbufinfo({ buflisted = 1 })
|
||||
local candidates = {}
|
||||
|
||||
for _, buffer in ipairs(buffers) do
|
||||
if buffer.bufnr ~= current and vim.bo[buffer.bufnr].buftype ~= "terminal" then
|
||||
table.insert(candidates, buffer)
|
||||
end
|
||||
end
|
||||
|
||||
if #candidates == 0 then
|
||||
print("No previous non-terminal buffer")
|
||||
return
|
||||
end
|
||||
|
||||
table.sort(candidates, function(a, b)
|
||||
return a.lastused > b.lastused
|
||||
end)
|
||||
|
||||
vim.api.nvim_set_current_buf(candidates[1].bufnr)
|
||||
end
|
||||
|
||||
function send(command)
|
||||
local terminal_visible = false
|
||||
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
if term_buf and vim.api.nvim_win_get_buf(win) == term_buf then
|
||||
terminal_visible = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not terminal_visible then
|
||||
open_term_split()
|
||||
end
|
||||
|
||||
local job = vim.b[term_buf].terminal_job_id
|
||||
|
||||
if job then
|
||||
vim.api.nvim_chan_send(job, command .. "\n")
|
||||
end
|
||||
end
|
||||
map("n", "<C-j>", toggle_term, { desc = "Toggle terminal split", })
|
||||
map("n", "<C-o>", open_term_fullscreen, { desc = "Open terminal fullscreen", })
|
||||
map("t", "<C-j>", toggle_term, { desc = "Toggle terminal split", })
|
||||
map("t", "<C-o>", prev_non_term_buf, { desc = "Return to previous buffer", })
|
||||
@@ -5,307 +5,82 @@ vim.pack.add({
|
||||
{ src = 'https://github.com/neovim/nvim-lspconfig' },
|
||||
{ src = 'https://github.com/romus204/tree-sitter-manager.nvim' },
|
||||
{ src = 'https://github.com/lukas-reineke/indent-blankline.nvim' },
|
||||
{ src = 'https://github.com/xiyaowong/transparent.nvim' },
|
||||
{ src = 'hIdentlinesttps://github.com/xiyaowong/transparent.nvim' },
|
||||
{ src = 'https://github.com/nvim-lua/plenary.nvim' },
|
||||
{ src = 'https://github.com/NeogitOrg/neogit' },
|
||||
{ src = 'https://github.com/kvrohit/rasmus.nvim' },
|
||||
})
|
||||
-- ------------------------------------------------------------
|
||||
-- TREE SITTER MANAGER
|
||||
-- ------------------------------------------------------------
|
||||
|
||||
-- Colorscheme
|
||||
vim.cmd [[colorscheme rasmus]]
|
||||
|
||||
-- Treesitter
|
||||
require("tree-sitter-manager").setup()
|
||||
-- ------------------------------------------------------------
|
||||
-- FUZZY FINDERS
|
||||
-- ------------------------------------------------------------
|
||||
|
||||
-- Identlines
|
||||
require("ibl").setup({
|
||||
indent = {
|
||||
char = "│",
|
||||
},
|
||||
scope = {
|
||||
show_start = false,
|
||||
show_end = false,
|
||||
},
|
||||
})
|
||||
|
||||
-- Fuzzy Finders
|
||||
require("fzf-lua").setup({})
|
||||
map("n", "<C-p>", "<Cmd>FzfLua files<CR>")
|
||||
map("n", "<C-m>", "<Cmd>FzfLua buffers<CR>")
|
||||
map("n", "<C-i>", "<Cmd>FzfLua diagnostics_workspace<CR>")
|
||||
map("n", "<C-f>", "<Cmd>FzfLua live_grep<CR>")
|
||||
map("n", "<C-b>", "<Cmd>FzfLua grep_curbuf<CR>")
|
||||
-- ------------------------------------------------------------
|
||||
-- BLINK COMPLETION
|
||||
-- ------------------------------------------------------------
|
||||
|
||||
-- autocomplete
|
||||
require("blink.cmp").setup({
|
||||
keymap = {
|
||||
["<Tab>"] = {
|
||||
"select_next",
|
||||
"fallback",
|
||||
},
|
||||
|
||||
["<S-Tab>"] = {
|
||||
"select_prev",
|
||||
"fallback",
|
||||
},
|
||||
|
||||
["<C-n>"] = {
|
||||
"select_next",
|
||||
"fallback",
|
||||
},
|
||||
|
||||
["<C-p>"] = {
|
||||
"select_prev",
|
||||
"fallback",
|
||||
},
|
||||
|
||||
["<CR>"] = {
|
||||
"accept",
|
||||
"fallback",
|
||||
},
|
||||
|
||||
["<C-Space>"] = {
|
||||
"show",
|
||||
"show_documentation",
|
||||
"hide_documentation",
|
||||
},
|
||||
|
||||
["<Esc>"] = {
|
||||
"hide",
|
||||
"fallback",
|
||||
},
|
||||
},
|
||||
|
||||
appearance = {
|
||||
nerd_font_variant = "normal",
|
||||
},
|
||||
|
||||
appearance = { nerd_font_variant = "normal", },
|
||||
completion = {
|
||||
menu = {
|
||||
border = "single",
|
||||
},
|
||||
|
||||
menu = { border = "single", },
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 200,
|
||||
|
||||
window = {
|
||||
border = "single",
|
||||
window = { border = "single" },
|
||||
},
|
||||
ghost_text = { enabled = false },
|
||||
},
|
||||
|
||||
ghost_text = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
|
||||
signature = {
|
||||
enabled = true,
|
||||
},
|
||||
|
||||
signature = { enabled = false },
|
||||
sources = {
|
||||
default = {
|
||||
"lsp",
|
||||
"path",
|
||||
"buffer",
|
||||
default = { "lsp", "path", "buffer" },
|
||||
},
|
||||
},
|
||||
|
||||
fuzzy = { implementation = "lua", },
|
||||
})
|
||||
-- ------------------------------------------------------------
|
||||
-- LSP
|
||||
-- ------------------------------------------------------------
|
||||
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||
vim.lsp.config("gopls", { capabilities = capabilities, })
|
||||
vim.lsp.config("ols", { capabilities = capabilities, })
|
||||
vim.lsp.enable({ "gopls", "ols", })
|
||||
|
||||
map("n", "gd", vim.lsp.buf.definition)
|
||||
map("n", "gD", vim.lsp.buf.declaration)
|
||||
map("n", "gi", vim.lsp.buf.implementation)
|
||||
map("n", "gr", vim.lsp.buf.references)
|
||||
map("n", "K", vim.lsp.buf.hover)
|
||||
map("i", "<C-h>", vim.lsp.buf.signature_help)
|
||||
map("n", "<leader>rn", vim.lsp.buf.rename)
|
||||
map("n", "<leader>ca", vim.lsp.buf.code_action)
|
||||
map("n", "[d", vim.diagnostic.goto_prev)
|
||||
map("n", "]d", vim.diagnostic.goto_next)
|
||||
map("n", "<leader>d", vim.diagnostic.open_float)
|
||||
map("n", "<leader>q", vim.diagnostic.setloclist)
|
||||
-- ------------------------------------------------------------
|
||||
-- INDENT LINES
|
||||
-- ------------------------------------------------------------
|
||||
require("ibl").setup({
|
||||
indent = {
|
||||
char = "│",
|
||||
},
|
||||
|
||||
scope = {
|
||||
show_start = false,
|
||||
show_end = false,
|
||||
},
|
||||
})
|
||||
-- ------------------------------------------------------------
|
||||
-- NEOGIT
|
||||
-- ------------------------------------------------------------
|
||||
require("neogit").setup({
|
||||
kind = "vsplit", -- matches your terminal split habit
|
||||
graph_style = "unicode",
|
||||
commit_editor = { kind = "vsplit" },
|
||||
commit_select_view = { kind = "vsplit" },
|
||||
log_view = { kind = "vsplit" },
|
||||
rebase_editor = { kind = "vsplit" },
|
||||
reflog_view = { kind = "vsplit" },
|
||||
merge_editor = { kind = "vsplit" },
|
||||
tag_editor = { kind = "vsplit" },
|
||||
preview_buffer = { kind = "split" },
|
||||
popup = { kind = "split" },
|
||||
signs = {
|
||||
hunk = { "", "" },
|
||||
item = { ">", "v" },
|
||||
section = { ">", "v" },
|
||||
},
|
||||
integrations = {
|
||||
telescope = false,
|
||||
diffview = false,
|
||||
},
|
||||
|
||||
disable_insert_on_commit = "auto",
|
||||
})
|
||||
-- ------------------------------------------------------------
|
||||
-- TERMINAL SYSTEM
|
||||
-- ------------------------------------------------------------
|
||||
local term_buf = nil
|
||||
|
||||
local function open_term_split()
|
||||
vim.cmd("botright vsplit")
|
||||
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
|
||||
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
|
||||
vim.api.nvim_win_set_buf(win, term_buf)
|
||||
else
|
||||
vim.cmd("terminal")
|
||||
term_buf = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
vim.api.nvim_win_set_width(win, math.floor(vim.o.columns * 0.37))
|
||||
vim.cmd("startinsert")
|
||||
end
|
||||
|
||||
local function toggle_term()
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
if vim.api.nvim_win_get_buf(win) == term_buf then
|
||||
vim.api.nvim_win_close(win, false)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
open_term_split()
|
||||
end
|
||||
|
||||
local function open_term_fullscreen()
|
||||
if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
|
||||
vim.api.nvim_set_current_buf(term_buf)
|
||||
else
|
||||
vim.cmd("terminal")
|
||||
term_buf = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
vim.cmd("startinsert")
|
||||
end
|
||||
|
||||
local function prev_non_term_buf()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
local buffers = vim.fn.getbufinfo({ buflisted = 1 })
|
||||
local candidates = {}
|
||||
|
||||
for _, buffer in ipairs(buffers) do
|
||||
if buffer.bufnr ~= current and vim.bo[buffer.bufnr].buftype ~= "terminal" then
|
||||
table.insert(candidates, buffer)
|
||||
end
|
||||
end
|
||||
|
||||
if #candidates == 0 then
|
||||
print("No previous non-terminal buffer")
|
||||
return
|
||||
end
|
||||
|
||||
table.sort(candidates, function(a, b)
|
||||
return a.lastused > b.lastused
|
||||
end)
|
||||
|
||||
vim.api.nvim_set_current_buf(candidates[1].bufnr)
|
||||
end
|
||||
|
||||
function send(command)
|
||||
local terminal_visible = false
|
||||
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
if term_buf and vim.api.nvim_win_get_buf(win) == term_buf then
|
||||
terminal_visible = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not terminal_visible then
|
||||
open_term_split()
|
||||
end
|
||||
|
||||
local job = vim.b[term_buf].terminal_job_id
|
||||
|
||||
if job then
|
||||
vim.api.nvim_chan_send(job, command .. "\n")
|
||||
end
|
||||
end
|
||||
map("n", "<C-j>", toggle_term, { desc = "Toggle terminal split", })
|
||||
map("n", "<C-o>", open_term_fullscreen, { desc = "Open terminal fullscreen", })
|
||||
map("t", "<C-j>", toggle_term, { desc = "Toggle terminal split", })
|
||||
map("t", "<C-o>", prev_non_term_buf, { desc = "Return to previous buffer", })
|
||||
-- ------------------------------------------------------------
|
||||
-- BUILD SYSTEM
|
||||
-- ------------------------------------------------------------
|
||||
local function build(args)
|
||||
if vim.fn.filereadable("build.sh") == 0 then
|
||||
vim.notify("No build.sh found in current directory.", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
vim.cmd("wall")
|
||||
|
||||
local command = "./build.sh"
|
||||
|
||||
if #args > 0 then
|
||||
command = command .. " " .. table.concat(args, " ")
|
||||
end
|
||||
|
||||
send("clear && " .. command)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command(
|
||||
"Build",
|
||||
function(opts) build(opts.fargs) end,
|
||||
{
|
||||
nargs = "*",
|
||||
desc = "Run project build.sh",
|
||||
}
|
||||
)
|
||||
|
||||
map("n", "<C-Space>", function() build({}) end, { desc = "Build project", })
|
||||
map("t", "<C-Space>", function() build({}) end, { desc = "Build project", })
|
||||
-- ------------------------------------------------------------
|
||||
-- Setup Alacritty colorscheme from Neovim
|
||||
-- ------------------------------------------------------------
|
||||
local function set_alacritty_colorscheme(name)
|
||||
-- The name of the Alacritty colorscheme placed in the theme directory
|
||||
-- MUST be the same as the name of the colorscheme in Neovim
|
||||
local config_dir = vim.fn.expand("$XDG_CONFIG_HOME/alacritty")
|
||||
local config = config_dir .. "/alacritty.toml"
|
||||
local source = config_dir .. "/themes/" .. name .. ".toml"
|
||||
local dest = config_dir .. "/colorscheme.toml"
|
||||
local cmd = "ln -sf " .. source .. " " .. dest .. " && touch " .. config
|
||||
|
||||
vim.fn.jobstart(cmd, {
|
||||
on_exit = function(_, code, _)
|
||||
if code ~= 0 then
|
||||
vim.notify("Failed to set Alacritty color scheme", vim.log.levels.ERROR)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
group = vim.api.nvim_create_augroup("config_alacritty_colorscheme", { clear = true }),
|
||||
callback = function(args)
|
||||
set_alacritty_colorscheme(args.match)
|
||||
end,
|
||||
fuzzy = { implementation = "lua" },
|
||||
})
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
-- lua/theme.lua
|
||||
-- Reads Noctalia's generated Alacritty theme (~/.config/alacritty/themes/noctalia.toml)
|
||||
-- and applies matching highlight groups in Neovim, including Treesitter captures.
|
||||
-- Monotone palette: only keywords, functions, parameters, strings, and comments
|
||||
-- carry a distinct color. Everything else (variables, types, constants,
|
||||
-- punctuation, operators, tags, numbers, booleans) sits in foreground or gray.
|
||||
local M = {}
|
||||
|
||||
local THEME_PATH = vim.fn.expand("~/.config/alacritty/themes/noctalia.toml")
|
||||
|
||||
local function parse_alacritty_colors(path)
|
||||
local f = io.open(path, "r")
|
||||
if not f then return nil end
|
||||
|
||||
local colors = { primary = {}, normal = {}, bright = {} }
|
||||
local section
|
||||
|
||||
for line in f:lines() do
|
||||
local sec = line:match("^%[colors%.(%a+)%]")
|
||||
if sec then
|
||||
-- only track top-level sections we care about (primary, normal, bright);
|
||||
-- nested ones like [colors.search.matches] won't match %a+ and are skipped
|
||||
section = colors[sec] and sec or nil
|
||||
elseif section then
|
||||
local key, val = line:match("^(%a+)%s*=%s*['\"](#%x+)['\"]")
|
||||
if key and val then
|
||||
colors[section][key] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
f:close()
|
||||
return colors
|
||||
end
|
||||
|
||||
function M.load()
|
||||
local c = parse_alacritty_colors(THEME_PATH)
|
||||
if not c or not c.primary.background or not c.primary.foreground then
|
||||
vim.notify("noctalia theme not found or unparsable: " .. THEME_PATH, vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
local bg, fg = c.primary.background, c.primary.foreground
|
||||
local n, b = c.normal, c.bright
|
||||
local hl = vim.api.nvim_set_hl
|
||||
|
||||
local gray_dim = "#5a5a5a" -- comments, punctuation, gutter — de-emphasized
|
||||
local gray_mid = "#7a7a7a" -- line numbers
|
||||
|
||||
-- The five accent colors — everything else stays monotone
|
||||
local c_keyword = n.magenta
|
||||
local c_function = n.blue
|
||||
local c_parameter = b.white -- subtly brighter than fg, not a hue, keeps "args" scannable
|
||||
local c_string = n.green
|
||||
local c_comment = "#968466"
|
||||
|
||||
-- Base UI
|
||||
hl(0, "Normal", { fg = fg, bg = bg })
|
||||
hl(0, "NormalFloat", { fg = fg, bg = bg })
|
||||
hl(0, "CursorLine", { bg = n.black })
|
||||
hl(0, "Visual", { bg = n.black, fg = fg })
|
||||
hl(0, "Pmenu", { fg = fg, bg = n.black })
|
||||
hl(0, "PmenuSel", { fg = bg, bg = b.white })
|
||||
hl(0, "LineNr", { fg = gray_mid })
|
||||
hl(0, "CursorLineNr", { fg = b.white, bold = true })
|
||||
hl(0, "SignColumn", { bg = bg })
|
||||
hl(0, "VertSplit", { fg = n.black })
|
||||
hl(0, "WinSeparator", { fg = n.black })
|
||||
hl(0, "StatusLine", { fg = fg, bg = n.black })
|
||||
hl(0, "StatusLineNC", { fg = gray_mid, bg = n.black })
|
||||
hl(0, "Search", { fg = "#161616", bg = gray_mid })
|
||||
hl(0, "IncSearch", { fg = "#161616", bg = b.white })
|
||||
|
||||
-- Treesitter capture groups — the five accented categories
|
||||
hl(0, "@comment", { fg = c_comment, italic = true })
|
||||
|
||||
hl(0, "@keyword", { fg = c_keyword })
|
||||
hl(0, "@keyword.function", { fg = c_keyword })
|
||||
hl(0, "@keyword.return", { fg = c_keyword })
|
||||
hl(0, "@conditional", { fg = c_keyword })
|
||||
hl(0, "@repeat", { fg = c_keyword })
|
||||
|
||||
hl(0, "@function", { fg = c_function })
|
||||
hl(0, "@function.builtin", { fg = c_function })
|
||||
hl(0, "@function.call", { fg = c_function })
|
||||
hl(0, "@method", { fg = c_function })
|
||||
hl(0, "@method.call", { fg = c_function })
|
||||
|
||||
hl(0, "@parameter", { fg = c_parameter, italic = true })
|
||||
|
||||
hl(0, "@string", { fg = c_string })
|
||||
hl(0, "@string.escape", { fg = c_string, bold = true })
|
||||
|
||||
-- Everything else — monotone, falls back to fg or gray
|
||||
hl(0, "@variable", { fg = fg })
|
||||
hl(0, "@variable.builtin", { fg = fg })
|
||||
hl(0, "@type", { fg = fg })
|
||||
hl(0, "@type.builtin", { fg = fg })
|
||||
hl(0, "@constructor", { fg = fg })
|
||||
hl(0, "@constant", { fg = fg })
|
||||
hl(0, "@constant.builtin", { fg = fg })
|
||||
hl(0, "@property", { fg = fg })
|
||||
hl(0, "@field", { fg = fg })
|
||||
hl(0, "@number", { fg = fg })
|
||||
hl(0, "@boolean", { fg = fg })
|
||||
hl(0, "@tag", { fg = fg })
|
||||
hl(0, "@tag.attribute", { fg = fg })
|
||||
hl(0, "@operator", { fg = gray_mid })
|
||||
hl(0, "@punctuation.delimiter", { fg = gray_dim })
|
||||
hl(0, "@punctuation.bracket", { fg = gray_dim })
|
||||
|
||||
-- Legacy / non-Treesitter syntax groups (classic :syntax highlighting —
|
||||
-- used by filetypes with no Treesitter parser, or plugins that still
|
||||
-- rely on regex-based syntax files). Mirrors the same monotone scheme.
|
||||
hl(0, "Comment", { fg = c_comment, italic = true })
|
||||
|
||||
hl(0, "Statement", { fg = c_keyword })
|
||||
hl(0, "Keyword", { fg = c_keyword })
|
||||
hl(0, "Conditional", { fg = c_keyword })
|
||||
hl(0, "Repeat", { fg = c_keyword })
|
||||
hl(0, "Label", { fg = c_keyword })
|
||||
hl(0, "Exception", { fg = c_keyword })
|
||||
|
||||
hl(0, "Function", { fg = c_function })
|
||||
|
||||
hl(0, "String", { fg = c_string })
|
||||
hl(0, "Character", { fg = c_string })
|
||||
|
||||
-- Everything else — monotone, no separate hue
|
||||
hl(0, "Identifier", { fg = fg })
|
||||
hl(0, "Constant", { fg = fg })
|
||||
hl(0, "Number", { fg = fg })
|
||||
hl(0, "Boolean", { fg = fg })
|
||||
hl(0, "Float", { fg = fg })
|
||||
hl(0, "Type", { fg = fg })
|
||||
hl(0, "StorageClass", { fg = fg })
|
||||
hl(0, "Structure", { fg = fg })
|
||||
hl(0, "Typedef", { fg = fg })
|
||||
hl(0, "PreProc", { fg = fg })
|
||||
hl(0, "Include", { fg = fg })
|
||||
hl(0, "Define", { fg = fg })
|
||||
hl(0, "Macro", { fg = fg })
|
||||
hl(0, "PreCondit", { fg = fg })
|
||||
hl(0, "Special", { fg = fg })
|
||||
hl(0, "SpecialChar", { fg = fg })
|
||||
hl(0, "SpecialComment", { fg = c_comment, italic = true })
|
||||
hl(0, "Tag", { fg = fg })
|
||||
hl(0, "Debug", { fg = fg })
|
||||
hl(0, "Underlined", { fg = fg, underline = true })
|
||||
hl(0, "Ignore", { fg = gray_dim })
|
||||
|
||||
hl(0, "Operator", { fg = gray_mid })
|
||||
hl(0, "Delimiter", { fg = gray_dim })
|
||||
|
||||
-- Kept distinct: these are signals, not syntax decoration
|
||||
hl(0, "Todo", { fg = n.yellow, bold = true })
|
||||
hl(0, "Error", { fg = n.red, bold = true })
|
||||
|
||||
-- Diagnostics stay colored — functional signal, not syntax decoration
|
||||
hl(0, "DiagnosticError", { fg = n.red })
|
||||
hl(0, "DiagnosticWarn", { fg = n.yellow })
|
||||
hl(0, "DiagnosticInfo", { fg = n.blue })
|
||||
hl(0, "DiagnosticHint", { fg = n.cyan })
|
||||
end
|
||||
|
||||
-- Reapply automatically whenever Noctalia regenerates the Alacritty theme
|
||||
-- (e.g. on a theme switch), without needing to restart Neovim.
|
||||
function M.watch()
|
||||
local w = vim.uv.new_fs_event()
|
||||
if not w then return end
|
||||
w:start(THEME_PATH, {}, vim.schedule_wrap(function()
|
||||
M.load()
|
||||
end))
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user