Skip to content

Commit

Permalink
Show neovim position in file as a percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
notahat committed Jul 14, 2024
1 parent 1c24753 commit e980918
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion config/nvim/lua/plugin-specs/ui/lualine-opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ end
local function position()
local current = vim.fn.line(".")
local total = vim.fn.line("$")
return string.format("%d/%d", current, total)
local progress = math.floor((current / total) * 100)
-- Both string.format and lualine interpret '%' as special, so to get a
-- single literal '%' in the output, we need four of them here.
return string.format("%d%%%%/%d", progress, total)
end

return {
Expand Down

0 comments on commit e980918

Please sign in to comment.