Status line

This commit is contained in:
Saeed Afzal
2024-04-13 16:04:26 +01:00
parent 100ea186dd
commit 409b0f7728
3 changed files with 43 additions and 1 deletions

View File

@@ -2,3 +2,4 @@ require "core.settings"
require "core.commands" require "core.commands"
require "core.autocmds" require "core.autocmds"
require "core.keys" require "core.keys"
require "core.statusline"

View File

@@ -12,7 +12,7 @@ opt.relativenumber = true
opt.scrolloff = 8 opt.scrolloff = 8
opt.sidescrolloff = 8 opt.sidescrolloff = 8
opt.title = true opt.title = true
-- opt.titlestring = "filename [+=-] - NVIM" opt.titlestring = "%t - NVIM"
opt.wrap = false opt.wrap = false
opt.clipboard = "unnamedplus" opt.clipboard = "unnamedplus"
opt.splitbelow = true opt.splitbelow = true
@@ -20,7 +20,10 @@ opt.splitright = true
opt.showmode = false opt.showmode = false
opt.grepprg = "rg --vimgrep --smart-case" opt.grepprg = "rg --vimgrep --smart-case"
opt.path = ".,**" opt.path = ".,**"
vim.cmd "set path-=node_modules/**"
vim.cmd "set wildignore-=*/node_modules/*"
-- Netrw -- Netrw
g.netrw_banner = 0 g.netrw_banner = 0

38
lua/core/statusline.lua Normal file
View File

@@ -0,0 +1,38 @@
local fn, api = vim.fn, vim.api
local modes = {
["n"] = "NORMAL",
["v"] = "VISUAL",
["V"] = "VISUAL LINE",
[""] = "VISUAL BLOCK",
["i"] = "INSERT",
["R"] = "REPLACE",
["Rv"] = "VISUAL REPLACE",
["c"] = "COMMAND",
["nt"] = "TERMINAL"
}
local function mode()
local current_mode = api.nvim_get_mode().mode
return string.format(" %s ", modes[current_mode]):upper()
end
function StatusLine()
local filename = fn.expand("%:t")
local filetype = vim.bo.filetype
local lineinfo = fn.line(".") .. ":" .. vim.fn.col(".")
local percent = fn.line(".") / fn.line("$") * 100
return table.concat {
mode(),
" ",
filename,
"%=%#StatusLineExtra#",
filetype,
" ",
string.format("%3.0f", percent) .. "%% ",
lineinfo
}
end
vim.o.statusline = "%!luaeval('StatusLine()')"