vim.on("User", nil, { pattern = "PackDone" }, function() local colorscheme = vim.env.COLORSCHEME or "evergarden" vim.cmd.colorscheme(colorscheme) end) vim.on("ColorScheme", nil, function(ev) vim.env.COLORSCHEME = ev.match end) -- basics ====================================================================== vim.o.encoding = "utf-8" -- basics · behavior =========================================================== vim.o.shell = os.getenv("SHELL") or "/bin/sh" -- enable .nvim.lua vim.o.exrc = true -- simplify jumps vim.o.jumpoptions = "stack,view,clean" -- open helpfiles on the right vim.o.keywordprg = ":vertical botright help" vim.o.formatoptions = "tcrqj" -- decrease update time vim.o.updatetime = 250 -- basics · tui ================================================================ vim.o.title = true vim.o.titlestring = '%{expand("%:p:~:.")} · nvim' vim.o.errorbells = false vim.o.mouse = "nv" vim.o.rulerformat = "%Ll %l:%c %3p%%" vim.o.colorcolumn = "+1" -- basics · keymaps ============================================================ -- set ; as leader & ; + m as localleader vim.g.mapleader = ";" vim.g.maplocalleader = ";m" vim.o.timeout = false -- decrease mapped sequence wait time - displays which-key popup sooner vim.o.timeoutlen = 0 -- basics · externals ========================================================== -- use rg for grepping vim.o.grepprg = vim.fn.executable("rg") == 1 and "rg --vimgrep -. --" or "grep -rniI --" vim.o.grepformat = "%f:%l:%c:%m" vim.g.findprg = vim.fn.executable("fd") == 1 and "fd -H -p -t f --color=never --" or "find . -type f -iregex '.*$*.*'" -- editor · appearance ========================================================= -- always show statusline at the bottom vim.o.laststatus = 3 vim.o.cmdheight = 0 -- don't show the mode, since it's already in the status line vim.o.showmode = false vim.o.showcmd = false -- always show tabline vim.o.showtabline = 2 -- always show 1 column of sign column (gitsigns, etc.) vim.o.signcolumn = "yes:1" -- hide search notices, intro vim.opt.shortmess:append("sI") -- line numbers vim.o.number = true vim.o.relativenumber = false vim.o.numberwidth = 3 vim.o.cursorline = true vim.o.cursorlineopt = "both" -- use Cursor hl for editor cursor vim.opt.guicursor:append("a:Cursor/lCursor") -- hide extra text vim.o.conceallevel = 2 vim.o.concealcursor = "c" vim.o.previewpopup = "height:12" -- editor · behavior =========================================================== -- split directions vim.o.splitbelow = true vim.o.splitright = true vim.o.splitkeep = "screen" -- allow cursor to move paste the end of the line in visual block mode vim.o.virtualedit = "block" -- scroll offsets vim.o.scrolloff = 5 vim.o.sidescrolloff = 15 -- smooth mousescroll vim.o.mousescroll = "ver:1,hor:1" -- substitution with preview window vim.o.inccommand = "split" -- editor · search ============================================================= vim.o.hlsearch = true -- show search results while typing vim.o.incsearch = true -- ignore case when searching; use `\C` to reset vim.o.ignorecase = true -- infer letter cases for a richer built-in keyword completion vim.o.infercase = true -- don't ignore case when searching if pattern has upper case vim.o.smartcase = true -- editor · indents ============================================================ -- indentations settings vim.o.shiftwidth = 2 vim.o.tabstop = 2 vim.o.expandtab = true vim.o.smarttab = true -- enable break indent vim.o.breakindent = true vim.o.wrap = true -- dont insert spaces on vim.o.softtabstop = 0 vim.o.smartindent = true -- editor · session state ====================================================== -- disable swap & backup, and configure undo files vim.o.swapfile = false vim.o.backup = false vim.o.writebackup = false vim.o.undodir = vim.fn.stdpath("state") .. "/undodir" vim.o.undofile = true -- dont unload abandoned buffers vim.o.hidden = true vim.o.sessionoptions = "help,tabpages,winsize" -- editor · completion ========================================================= vim.o.pumheight = 8 vim.o.pummaxwidth = 42 vim.o.wildoptions = "pum" vim.o.wildmode = "noselect:full" vim.o.complete = "" vim.opt.completeopt = { "menuone", "preinsert", "noselect", "popup" } vim.opt.completeitemalign = { "kind", "abbr", "menu" } vim.o.autocomplete = true -- don't show autocomplete messages vim.opt.shortmess:append("c") -- editor · diagnostics ======================================================== local signs = { [vim.diagnostic.severity.ERROR] = "E", [vim.diagnostic.severity.WARN] = "W", [vim.diagnostic.severity.INFO] = "I", [vim.diagnostic.severity.HINT] = "H", } local hl_map = { [vim.diagnostic.severity.ERROR] = "DiagnosticError", [vim.diagnostic.severity.WARN] = "DiagnosticWarn", [vim.diagnostic.severity.INFO] = "DiagnosticInfo", [vim.diagnostic.severity.HINT] = "DiagnosticHint", } vim.diagnostic.config({ float = { header = "", prefix = function(_, i) return string.format("%d. ", i), "LineNr" end, }, jump = { wrap = false, }, signs = true, status = { format = function(d) local items = {} for level in ipairs(vim.diagnostic.severity) do local count = d[level] if count then table.insert( items, ("%%#%s#%s %s"):format(hl_map[level], signs[level], count) ) end end return table.concat(items, " ") end, }, virtual_text = { hl_mode = "combine", }, }) -- editor · listchars ========================================================== vim.o.list = true vim.opt.listchars:append({ eol = " ", tab = "│ ", trail = "-", extends = "…", precedes = "…", nbsp = "␣", }) -- editor · fillchars ========================================================== vim.opt.fillchars:append({ fold = " ", eob = "·", diff = "─", foldopen = "▼", foldclose = "▶", }) -- editor · folds ============================================================== local function setfolds() if vim.bo.buftype ~= "" then vim.o.foldenable = false return end vim.o.foldenable = true vim.o.foldlevel = 99 vim.o.foldlevelstart = 99 vim.o.foldcolumn = "0" vim.o.foldnestmax = 1 vim.o.foldmethod = "indent" end local foldgroup = vim.augroup("@ivy.folds.init", true) foldgroup({ "BufWinEnter", "VimEnter" }, function(ev) vim.api.nvim_buf_call(ev.buf or 0, setfolds) end) foldgroup("OptionSet", { pattern = "buftype" }, function(ev) vim.api.nvim_buf_call(ev.buf, setfolds) end) -- editor · spell check ======================================================== -- let me have spelling checking for english vim.o.spelllang = "en_ca,en_gb,en_us" vim.opt.spelloptions:append("noplainbuffer") vim.o.spellsuggest = "double,4" -- use `data/site/spell/{lang}.add` vim.o.spellfile = "" vim.o.dictionary = "spell" -- editor · borders ============================================================ ---@type { [string]: { style: string, ['vert'|'vertleft'|'vertright'|'horiz'|'horizup'|'horizdown'|'verthoriz'|'topleft'|'topright'|'botleft'|'botright']: string, bottom?: string } } local borderchars = { solid = { style = "solid", vert = "█", vertleft = "█", vertright = "█", horiz = "▄", horizup = "▀", horizdown = "▄", verthoriz = "█", topleft = "▄", topright = "▄", botleft = "▀", botright = "▀", bottom = "▀", }, single = { style = "single", vert = "│", vertleft = "┤", vertright = "├", horiz = "─", horizup = "┴", horizdown = "┬", verthoriz = "┼", topleft = "┌", topright = "┐", botleft = "└", botright = "┘", }, double = { style = "double", vert = "║", vertleft = "╣", vertright = "╠", horiz = "═", horizup = "╩", horizdown = "╦", verthoriz = "╬", topleft = "╔", topright = "╗", botleft = "╚", botright = "╝", }, rounded = { style = "rounded", vert = "│", vertleft = "┤", vertright = "├", horiz = "─", horizup = "┴", horizdown = "┬", verthoriz = "┼", topleft = "╭", topright = "╮", botleft = "╰", botright = "╯", }, none = { vert = "", vertleft = "", vertright = "", horiz = "", horizup = "", horizdown = "", verthoriz = "", topleft = "", topright = "", botleft = "", botright = "", }, bold = { vert = "┃", vertleft = "┫", vertright = "┣", horiz = "━", horizup = "┻", horizdown = "┳", topleft = "┏", topright = "┓", botright = "┛", botleft = "┗", }, } vim.g.border_style = "single" -- my custom borderchars vim.g.bc = borderchars[vim.g.border_style] vim.g.bc_all = { vim.g.bc.topleft, vim.g.bc.top or vim.g.bc.horiz, vim.g.bc.topright, vim.g.bc.vert, vim.g.bc.botright, vim.g.bc.bottom or vim.g.bc.horiz, vim.g.bc.botleft, vim.g.bc.vert, } vim.opt.fillchars:append({ horiz = vim.g.bc.horiz, horizup = vim.g.bc.horizup, horizdown = vim.g.bc.horizdown, vert = vim.g.bc.vert, vertright = vim.g.bc.vertright, vertleft = vim.g.bc.vertleft, verthoriz = vim.g.bc.verthoriz, }) vim.o.winborder = vim.g.border_style -- editor · cursor ============================================================= vim.g.guicursor_config = { normal = { type = "block", }, insert = { type = "vertical", size = 20, animate = { wait = 50, on = 250, off = 250, }, }, replace = { type = "horizontal", size = 20, }, operator = { type = "horizontal", size = 50, }, showmatch = { type = "block", }, }