initial config push
This commit is contained in:
98
lua/core/options.lua
Normal file
98
lua/core/options.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
local opt = vim.opt
|
||||
|
||||
-- Line numbers
|
||||
opt.number = true
|
||||
opt.relativenumber = false
|
||||
|
||||
-- Search
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.hlsearch = true
|
||||
opt.incsearch = true
|
||||
|
||||
-- Tabs / indentation
|
||||
opt.expandtab = true
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
opt.smartindent = true
|
||||
|
||||
-- Undo
|
||||
opt.undofile = true
|
||||
|
||||
-- UI
|
||||
opt.termguicolors = true
|
||||
opt.signcolumn = "yes"
|
||||
opt.scrolloff = 8
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
opt.equalalways = false
|
||||
opt.cursorline = true
|
||||
|
||||
-- Per-window buffer tabs (winbar)
|
||||
-- Track which buffers were opened in each window
|
||||
_G.win_bufs = {}
|
||||
|
||||
function _G.track_buf()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if not vim.bo[buf].buflisted or vim.bo[buf].filetype == "oil" then return end
|
||||
if not _G.win_bufs[win] then _G.win_bufs[win] = {} end
|
||||
-- Remove if already tracked, then add to end
|
||||
for i, b in ipairs(_G.win_bufs[win]) do
|
||||
if b == buf then table.remove(_G.win_bufs[win], i) break end
|
||||
end
|
||||
table.insert(_G.win_bufs[win], buf)
|
||||
end
|
||||
|
||||
function _G.get_win_bufs()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local bufs = {}
|
||||
for _, buf in ipairs(_G.win_bufs[win] or {}) do
|
||||
if vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted then
|
||||
table.insert(bufs, buf)
|
||||
end
|
||||
end
|
||||
_G.win_bufs[win] = bufs
|
||||
return bufs
|
||||
end
|
||||
|
||||
function _G.winbar_tabs()
|
||||
local bufs = _G.get_win_bufs()
|
||||
if #bufs == 0 then return "" end
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
local parts = {}
|
||||
for _, buf in ipairs(bufs) do
|
||||
local name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(buf), ":t")
|
||||
if name == "" then name = "[No Name]" end
|
||||
local mod = vim.bo[buf].modified and " +" or ""
|
||||
if buf == current then
|
||||
table.insert(parts, "%#TabLineSel# " .. name .. mod .. " %#WinBar#")
|
||||
else
|
||||
table.insert(parts, " " .. name .. mod .. " ")
|
||||
end
|
||||
end
|
||||
return table.concat(parts, "|")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
group = vim.api.nvim_create_augroup("track_win_bufs", { clear = true }),
|
||||
callback = function() _G.track_buf() end,
|
||||
})
|
||||
|
||||
opt.winbar = "%{%v:lua.winbar_tabs()%}"
|
||||
|
||||
-- Clipboard (system)
|
||||
opt.clipboard = "unnamedplus"
|
||||
|
||||
-- Statusline (with git branch)
|
||||
function _G.git_branch()
|
||||
local branch = vim.fn.system("git -C " .. vim.fn.shellescape(vim.fn.expand("%:p:h")) .. " branch --show-current 2>/dev/null")
|
||||
branch = branch:gsub("%s+", "")
|
||||
if branch == "" then return "" end
|
||||
return " " .. branch .. " |"
|
||||
end
|
||||
opt.statusline = " %f %m%r%=%{v:lua.git_branch()} %l:%c %p%% "
|
||||
|
||||
-- Misc
|
||||
opt.updatetime = 250
|
||||
opt.mouse = "a"
|
||||
Reference in New Issue
Block a user