config.nvim

NeoVim config
git clone git://popovic.xyz/nvim.config.git/
Log | Files | Refs

commit def6bbb739299765e29ddec2b976edf8223ceba6
parent 245555e22829a513703b9a0c6508a6cc35492e0a
Author: Milutin Popovic <milutin@popovic.xyz>
Date:   Sun, 12 Apr 2026 14:21:16 +0100

colors + git status line

Diffstat:
Alazy-lock.json | 26++++++++++++++++++++++++++
Mlua/config/init.lua | 14++++----------
Mlua/config/lazy.lua | 1+
Alua/config/status.lua | 160+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlua/plugins/color.lua | 91++++++++++++++++++++++++++++++++++++-------------------------------------------
Mlua/plugins/floaterm.lua | 2+-
6 files changed, 233 insertions(+), 61 deletions(-)

diff --git a/lazy-lock.json b/lazy-lock.json @@ -0,0 +1,26 @@ +{ + "CopilotChat.nvim": { "branch": "main", "commit": "0b3133ffbb470b1616c47170b544d0b9a3bbcf5b" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "blink-copilot": { "branch": "main", "commit": "7ad8209b2f880a2840c94cdcd80ab4dc511d4f39" }, + "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, + "conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" }, + "copilot.lua": { "branch": "master", "commit": "ad7e729e9a6348f7da482be0271d452dbc4c8e2c" }, + "fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0a3b42c3e503df87aef6d6513e13148381495c3a" }, + "mason.nvim": { "branch": "main", "commit": "b03fb0f20bc1d43daf558cda981a2be22e73ac42" }, + "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, + "nvim-highlight-colors": { "branch": "main", "commit": "e2cb22089cc2358b2b995c09578224f142de6039" }, + "nvim-lsp-endhints": { "branch": "main", "commit": "a86e7ca7a92ef003008d7eb5d153c63bcc89f79c" }, + "nvim-lspconfig": { "branch": "master", "commit": "d27cf1d2ad1af19633ecff8b38eac6d5a899f2ff" }, + "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "rose-pine": { "branch": "main", "commit": "9504524e5ed0e326534698f637f9d038ba4cd0ee" }, + "rustaceanvim": { "branch": "master", "commit": "7b8dd7abb9a7f442b356aa03714aefce09610339" }, + "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, + "telescope.nvim": { "branch": "master", "commit": "f7c673b8e46e8f233ff581d3624a517d33a7e264" }, + "vim-floaterm": { "branch": "master", "commit": "0ab5eb8135dc884bc543a819ac7033c15e72a76b" }, + "vimtex": { "branch": "master", "commit": "9306903316c3ddd250676b7cf97c84a84c9c8f99" } +} diff --git a/lua/config/init.lua b/lua/config/init.lua @@ -1,12 +1,6 @@ ---@diagnostic disable: undefined-global -require("config.keymaps") -require("config.set") -require("config.autocmd") -require("config.diagnostics") -require("config.native") - -local lazyconfpath = vim.fn.stdpath("config") .. "/lua/config/lazy.lua" -local pluginspath = vim.fn.stdpath("config") .. "/lua/plugins" -if vim.uv.fs_stat(lazyconfpath) and vim.uv.fs_stat(pluginspath) then - require("config.lazy") +for name, t in vim.fs.dir(vim.fn.stdpath("config") .. "/lua/config") do + if t == "file" and name:sub(-4) == ".lua" and name ~= "init.lua" then + require("config." .. name:gsub("%.lua$", "")) + end end diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-global local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" diff --git a/lua/config/status.lua b/lua/config/status.lua @@ -0,0 +1,160 @@ +---@diagnostic disable: undefined-global + +local M = {} + +local function buf_dir(bufnr) + local name = vim.api.nvim_buf_get_name(bufnr) + if name == '' then + return nil + end + return vim.fn.fnamemodify(name, ':p:h') +end + +local function set_git(bufnr, info) + local function apply() + vim.b[bufnr].status_git = info + vim.cmd('redrawstatus') + end + + if vim.in_fast_event and vim.in_fast_event() then + vim.schedule(apply) + else + apply() + end +end + +local function parse_git_status(stdout) + local info = { + branch = '', + ahead = 0, + behind = 0, + staged = 0, + unstaged = 0, + untracked = 0, + } + + local head, oid + + for line in (stdout or ''):gmatch('[^\n]+') do + head = head or line:match('^# branch%.head%s+(.+)$') + oid = oid or line:match('^# branch%.oid%s+([0-9a-f]+)$') + + local a = line:match('^# branch%.ab%s+%+(%d+)%s+%-(%d+)$') + if a then + info.ahead, info.behind = tonumber(line:match('%+(%d+)')) or 0, tonumber(line:match('%-(%d+)')) or 0 + end + + local xy = line:match('^[12]%s+(..)%s') + if xy then + local x, y = xy:sub(1, 1), xy:sub(2, 2) + if x ~= '.' then + info.staged = info.staged + 1 + end + if y ~= '.' then + info.unstaged = info.unstaged + 1 + end + elseif line:match('^%?%s') then + info.untracked = info.untracked + 1 + end + end + + if head and head ~= '' then + if head == '(detached)' then + if oid and oid ~= '' and oid ~= '(initial)' then + info.branch = oid:sub(1, 7) + end + else + info.branch = head + end + end + + return info +end + +function M.update_git_branch(bufnr) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local dir = buf_dir(bufnr) + if not dir then + return set_git(bufnr, { branch = '' }) + end + + local function on_status(code, stdout) + if code ~= 0 then + return set_git(bufnr, { branch = '' }) + end + local info = parse_git_status(stdout) + if not info.branch or info.branch == '' then + return set_git(bufnr, { branch = '' }) + end + set_git(bufnr, info) + end + + if vim.system then + vim.system({ 'git', 'status', '--porcelain=2', '-b' }, { cwd = dir, text = true }, function(obj) + on_status(obj.code, obj.stdout) + end) + else + local out = vim.fn.system({ 'git', '-C', dir, 'status', '--porcelain=2', '-b' }) + on_status(vim.v.shell_error, out) + end +end + +function M.git_component() + local info = vim.b.status_git + if info == nil then + M.update_git_branch(0) + return '' + end + + local branch = info.branch or '' + if branch == '' then + return '' + end + + local parts = { string.format(' %s', branch) } + + if (info.ahead or 0) > 0 then + parts[#parts + 1] = string.format('↑%d', info.ahead) + end + if (info.behind or 0) > 0 then + parts[#parts + 1] = string.format('↓%d', info.behind) + end + if (info.staged or 0) > 0 then + parts[#parts + 1] = string.format('+%d', info.staged) + end + if (info.unstaged or 0) > 0 then + parts[#parts + 1] = string.format('~%d', info.unstaged) + end + if (info.untracked or 0) > 0 then + parts[#parts + 1] = string.format('?%d', info.untracked) + end + + return table.concat(parts, ' ') +end + +function M.file_component() + local name = vim.fn.expand('%:~:.') + if name == '' then + return '[No Name]' + end + + local max = math.floor((vim.o.columns or 120) * 0.45) + if #name > max then + name = vim.fn.pathshorten(name) + end + + return name +end + +vim.o.statusline = table.concat({ + "%{v:lua.require'config.status'.git_component()}", + " - ", + "%{v:lua.require'config.status'.file_component()}", + " %m", + "%=", + "%y", + " · ", + "%l:%c", +}) + +return M diff --git a/lua/plugins/color.lua b/lua/plugins/color.lua @@ -1,59 +1,50 @@ ---@diagnostic disable: undefined-global -function ColorMyPencils(color) - color = color or "rose-pine-moon" - vim.cmd.colorscheme(color) - vim.opt.cursorline = true +return { + "rose-pine/neovim", + name = "rose-pine", + config = function() + require("rose-pine").setup({ + dark_variant = "main", + dim_inactive_windows = true, + disable_background = true, + disable_nc_background = true, + disable_float_background = true, + extend_background_behind_borders = true, + enable = { + terminal = true, + legacy_highlights = true, + migrations = true, + }, + styles = { + bold = true, + italic = true, + transparency = false, + }, + }) - vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) - vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" }) - vim.api.nvim_set_hl(0, "MatchParen", { bg = "darkred" }) - vim.api.nvim_set_hl(0, "SpellBad", { bold = true, underline = true, fg = "red" }) + vim.cmd.colorscheme("rose-pine-moon") + vim.opt.cursorline = true - -- separators - vim.api.nvim_set_hl(0, "WinSeparator", { fg = "#A96C8A", bold = true }) - vim.api.nvim_set_hl(0, "StatusLine", { fg = "#6CA98A" }) + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" }) + vim.api.nvim_set_hl(0, "MatchParen", { bg = "darkred" }) + vim.api.nvim_set_hl(0, "SpellBad", { bold = true, underline = true, fg = "red" }) - vim.fn.matchadd("ExtraWhiteSpace", '\\v\\s+$') - vim.api.nvim_set_hl(0, "ExtraWhiteSpace", { ctermbg = "red", bg = "red" }) - local nontexthl = vim.api.nvim_get_hl_by_name("NonText", true) + vim.api.nvim_set_hl(0, "WinSeparator", { bold = true }) + vim.api.nvim_set_hl(0, "StatusLine", { bold = true }) - -- colpilot chat - vim.api.nvim_set_hl(0, 'CopilotChatHeader', { fg = '#7C3AED', bold = true }) - vim.api.nvim_set_hl(0, 'CopilotChatSeparator', { fg = '#374151' }) + vim.fn.matchadd("ExtraWhiteSpace", "\\v\\s+$") + vim.api.nvim_set_hl(0, "ExtraWhiteSpace", { ctermbg = "red", bg = "red" }) - -- TelescopeBorder - vim.api.nvim_set_hl(0, 'TelescopeBorder', { fg = '#A96C8A', bold = true }) - vim.api.nvim_set_hl(0, 'TelescopeTitle', { fg = '#6CA98A', bold = true }) + vim.api.nvim_set_hl(0, "CopilotChatHeader", { fg = "#7C3AED", bold = true }) + vim.api.nvim_set_hl(0, "CopilotChatSeparator", { fg = "#374151" }) - -- lsp hints - vim.api.nvim_set_hl(0, "LspInlayHint", { bg = "none", fg = nontexthl.foreground }) - vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none", fg = "#6CA98A", bold = true }) -end + vim.api.nvim_set_hl(0, "TelescopeBorder", { bold = true }) + vim.api.nvim_set_hl(0, "TelescopeTitle", { bold = true }) -return { - { - "rose-pine/neovim", - name = "rose-pine", - config = function() - require('rose-pine').setup({ - dark_variant = "main", - dim_inactive_windows = true, - disable_background = true, - disable_nc_background = true, - disable_float_background = true, - extend_background_behind_borders = true, - enable = { - terminal = true, - legacy_highlights = true, - migrations = true, - }, - styles = { - bold = true, - italic = true, - transparency = false, - }, - }) - ColorMyPencils(); - end - }, + vim.api.nvim_set_hl(0, "LspInlayHint", { + bg = "none", + fg = vim.api.nvim_get_hl_by_name("NonText", true).foreground, + }) + end, } diff --git a/lua/plugins/floaterm.lua b/lua/plugins/floaterm.lua @@ -2,7 +2,7 @@ return { "voldikss/vim-floaterm", config = function() - vim.keymap.set('n', "<leader>ft", ":FloatermNew --name=myfloat --height=0.6 --width=0.7 --autoclose=2 zsh<CR> ") + vim.keymap.set('n', "<leader>ft", ":FloatermNew --name=myfloat --height=0.8 --width=0.8 --autoclose=2 zsh<CR> ") vim.keymap.set('n', "t", ":FloatermToggle myfloat<CR>") vim.keymap.set('t', "<C-t>", "<C-\\><C-n>:q<CR>") end