-- Author: Jianqun (https://jianqun.me) -- Updated: 2026-05-15 vim.cmd("colorscheme habamax") vim.cmd("filetype indent off") -- Options vim.opt.cdhome = true vim.opt.clipboard = "" vim.opt.confirm = true vim.opt.cursorline = true vim.opt.expandtab = true vim.opt.fileformats = { "unix", "dos" } vim.opt.foldcolumn = "auto" vim.opt.guicursor = { "n-v-c-sm-t:block-Cursor", "i-ci-ve:ver10-Cursor", "r-cr-o:hor5-Cursor", "a:blinkon0" } vim.opt.ignorecase = true vim.opt.list = true vim.opt.listchars = { tab = "··‣", lead = "·", trail = "·" } vim.opt.matchpairs = { "(:)", "[:]", "{:}", "<:>" } vim.opt.modeline = false vim.opt.mouse = "" vim.opt.mousemodel = "extend" vim.opt.number = true vim.opt.relativenumber = true vim.opt.shadafile = "NONE" vim.opt.shiftwidth = 0 vim.opt.showmatch = true vim.opt.showtabline = 2 vim.opt.smartcase = true vim.opt.splitbelow = true vim.opt.splitright = true vim.opt.statuscolumn = "%(%C%s%=%l│ %)" vim.opt.statusline = "%!v:lua.MyStatusLine()" vim.opt.switchbuf = "usetab" vim.opt.tabline = "%!v:lua.MyTabLine()" vim.opt.tabstop = 4 vim.opt.termguicolors = true vim.opt.timeoutlen = 200 vim.opt.title = true vim.opt.titlestring = table.concat({ "%{bufname('%')==''?'Untitled':fnamemodify(bufname('%'),':t')}", "%( [%H%W%{&modified?',+':''}%R]%) - Nvim" }, "") if vim.env.TERM == "linux" then vim.opt.cursorline = false vim.opt.guicursor = "" vim.opt.list = false vim.opt.termguicolors = false vim.opt.title = false end -- MyStatusLine function MyStatusLine() local mode_map = { ["n"] = "[NORMAL] ", ["niI"] = "[(insert)] ", ["niR"] = "[(replace)] ", ["niV"] = "[(vreplace)] ", ["nt"] = "[(terminal)] ", ["ntT"] = "[(terminal)] ", ["v"] = "[VISUAL] ", ["vs"] = "[VISUAL] ", ["V"] = "[VISUAL LINE] ", ["Vs"] = "[VISUAL LINE] ", ["\22"] = "[VISUAL BLOCK] ", ["\22s"] = "[VISUAL BLOCK] ", ["s"] = "[SELECT] ", ["S"] = "[SELECT LINE] ", ["\19"] = "[SELECT BLOCK] ", ["i"] = "[INSERT] ", ["ic"] = "[INSERT] ", ["R"] = "[REPLACE] ", ["Rc"] = "[REPLACE] ", ["Rv"] = "[VREPLACE] ", ["Rvc"] = "[VREPLACE] ", ["c"] = "[CMDLINE] ", ["ct"] = "[CMDLINE] ", ["cr"] = "[CMDLINE] ", ["t"] = "[TERMINAL] " } return (mode_map[vim.fn.mode(1)] or "") .. table.concat({ "%<", "%{bufname('%')==''?'Untitled':bufname('%')}", "%( [%H%W%{&modified?',+':''}%R]%)", "%= %l,%c%V %p%%", "%( [%{toupper(&fenc!=''?&fenc:&enc)},%{toupper(&ff)}%(,%Y%)]%)" }, "") end -- MyTabLine function MyTabLine() local tab_count = vim.fn.tabpagenr("$") local active_tabnr = vim.fn.tabpagenr() local screen_width = vim.o.columns local total_width = 0 local tabs = {} for tabnr = 1, tab_count do local buflist = vim.fn.tabpagebuflist(tabnr) local bufname = vim.fn.bufname(buflist[vim.fn.tabpagewinnr(tabnr)]) bufname = (bufname ~= "") and vim.fn.fnamemodify(bufname, ":t") or "Untitled" local is_modified = false for _, bufnr in ipairs(buflist) do if vim.fn.getbufvar(bufnr, "&modified") == 1 then is_modified = true break end end local winnr = vim.fn.tabpagewinnr(tabnr, "$") local label = "" if winnr > 1 then label = label .. winnr end if is_modified then label = label .. "+" end if label ~= "" then label = label .. " " end local text = " " .. label .. bufname .. " " local width = vim.fn.strdisplaywidth(text) tabs[tabnr] = { text = text, width = width } total_width = total_width + width end local start_tabnr = active_tabnr local end_tabnr = active_tabnr if total_width > screen_width then local max_width = screen_width - 4 local active_width = tabs[active_tabnr].width local can_expand = true while can_expand do can_expand = false if start_tabnr > 1 then local candidate_width = tabs[start_tabnr - 1].width if active_width + candidate_width <= max_width then start_tabnr = start_tabnr - 1 active_width = active_width + candidate_width can_expand = true end end if end_tabnr < tab_count then local candidate_width = tabs[end_tabnr + 1].width if active_width + candidate_width <= max_width then end_tabnr = end_tabnr + 1 active_width = active_width + candidate_width can_expand = true end end end else start_tabnr = 1 end_tabnr = tab_count end local tabline = "" if start_tabnr > 1 then tabline = tabline .. "%#TabLineFill#" .. "< " end for tabnr = start_tabnr, end_tabnr do tabline = tabline .. (tabnr == active_tabnr and "%#TabLineSel#" or "%#TabLine#") tabline = tabline .. "%" .. tabnr .. "T" tabline = tabline .. tabs[tabnr].text end if end_tabnr < tab_count then tabline = tabline .. "%#TabLineFill#" .. "%= >" end tabline = tabline .. "%#TabLineFill#%T" return tabline end -- AutocmdGroup vim.api.nvim_create_augroup("init.lua", { clear = true }) -- SyntaxComplete vim.api.nvim_create_autocmd("Filetype", { group = "init.lua", callback = function() if vim.bo.omnifunc == "" then vim.bo.omnifunc = "syntaxcomplete#Complete" end end }) -- Clipboard vim.g.clipboard = { name = "disabled", copy = { ["+"] = function() end, ["*"] = function() end }, paste = { ["+"] = function() return { {}, "" } end, ["*"] = function() return { {}, "" } end } } vim.api.nvim_create_autocmd("TextYankPost", { group = "init.lua", callback = function() if vim.v.event.operator == "y" then vim.highlight.on_yank() require("vim.ui.clipboard.osc52").copy("+")(vim.v.event.regcontents) end end }) -- Mappings vim.keymap.set({ "n", "v" }, "", "") vim.keymap.set({ "n", "v" }, "", "") vim.keymap.set({ "i", "c" }, "", "") vim.keymap.set({ "i", "c" }, "", "") vim.keymap.set({ "i", "c" }, "", "") vim.keymap.set({ "i", "c" }, "", "") vim.keymap.set("v", "", ":m '>+1gv", { silent = true }) vim.keymap.set("v", "", ":m '<-2gv", { silent = true }) local scrollwheelkeys = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" } for _, scrollwheel in ipairs(scrollwheelkeys) do vim.keymap.set({ "", "!" }, scrollwheel, "") end