Files
nvim/lua/conf/opts.lua
2025-08-10 13:10:05 -04:00

92 lines
2.3 KiB
Lua

-- make .h files default to c code
vim.filetype.add({ extension = { h = "c", }, })
-- numbers
vim.o.nu = true
vim.o.rnu = true
-- buffer
vim.o.lbr = true -- fix where line is wraped
vim.o.cul = true
vim.o.cc = "80"
-- indents + tabs
local tabwidth = 2
vim.o.ts = tabwidth
vim.o.sw = tabwidth
vim.o.sts = -1
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- (yoinked from kickstart.nvim)
vim.schedule(function()
vim.o.cb = "unnamedplus" -- system clipboard
end)
-- file saving
vim.o.swf = false
vim.o.udf = true
-- searching
vim.o.ic = true
-- make windows look nice
vim.o.winborder = "solid"
-- wild menus
vim.o.ph = 20
vim.o.wic = true
vim.o.wop = "fuzzy,pum,tagfile"
-- completion
vim.o.cot = "menu,menuone,noinsert,fuzzy,popup"
vim.o.cia = "kind,abbr,menu"
-- waiting for https://github.com/neovim/neovim/pull/25541 to land
-- vim.o.completepopup = "border:"..vim.o.winborder
do -- statusline
---@return string out formatted status line
function _G.Status()
--- get the percentage through the file
---@return string out the formatted percentage
local function percentage()
local percent, line, lines
-- get the current and total # of lines
line = vim.api.nvim_win_get_cursor(0)[1]
lines = vim.api.nvim_buf_line_count(0)
-- calculate the percentage through the file
percent = math.floor((line / lines) * 100)
if percent == 0 or line == 1 then
return "Top"
elseif percent == 100 or line == lines then
return "Bot"
end
return percent.."%%"
end
-- this is my statusline:
--
-- opts.lua [+] λ1 163,61-60 88%
--
return table.concat {
"%t", -- file name
" %h", -- help buffer tag
"%m", -- modify tag
"%r", -- readonly flag
"%=", -- seperate left and right side
-- print out the number of lsp clients attached with nice colors :)
"λ"..#vim.lsp.get_clients({ bufnr = 0 }), " ",
"%<", -- we can start truncating here (I want to keep the file name)
"%l,%c%V", -- line, column-virtual column
"%<", -- we can start truncating here
" "..percentage() -- percentage through the buffer
}
end
vim.o.stl = "%!v:lua.Status()"
vim.o.ls = 3
end