diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b76186b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.lua] +max_line_length = 80 diff --git a/config/lua/ivy/config/options.lua b/config/lua/ivy/config/options.lua index 87e924b..6f9549c 100644 --- a/config/lua/ivy/config/options.lua +++ b/config/lua/ivy/config/options.lua @@ -6,23 +6,77 @@ 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 = "%f · nvim" vim.o.errorbells = false + vim.o.mouse = "nv" -vim.o.exrc = true --- set space as leader +vim.o.rulerformat = "%Ll %l:%c %3p%%" +vim.o.colorcolumn = "+1" + +-- basics · keymaps ============================================================ + +-- set space as leader & space + m as localleader vim.g.mapleader = " " vim.g.maplocalleader = " m" -vim.o.jumpoptions = "stack,view,clean" +vim.o.timeout = false +-- decrease mapped sequence wait time - displays which-key popup sooner +vim.o.timeoutlen = 0 -vim.o.keywordprg = ":vertical botright help" -vim.o.rulerformat = "%Ll %l:%c %3p%%" -vim.o.colorcolumn = "+1" +-- 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 @@ -32,38 +86,161 @@ 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" + +-- 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" --- completion options +-- 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.opt.wildoptions = { "pum", "tagfile" } vim.opt.wildmode = { "list", "full" } + vim.o.complete = "" vim.opt.completeopt = { "menuone", "noinsert", "popup" } vim.opt.completeitemalign = { "kind", "abbr", "menu" } vim.o.autocomplete = true -vim.opt.shortmess:append("c") -- don't show autocomplete messages --- split directions -vim.o.splitbelow = true -vim.o.splitright = true -vim.o.splitkeep = "screen" +-- don't show autocomplete messages +vim.opt.shortmess:append("c") --- search settings -vim.o.incsearch = true -- show search results while typing -vim.o.hlsearch = true -vim.o.ignorecase = true -- ignore case when searching; use `\C` to reset -vim.o.infercase = true -- infer letter cases for a richer built-in keyword completion -vim.o.smartcase = true -- don't ignore case when searching if pattern has upper case --- substitution with preview window -vim.o.inccommand = "split" +-- 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 ============================================================== --- folding local function setfolds() if vim.bo.buftype ~= "" then vim.o.foldenable = false @@ -85,62 +262,7 @@ foldgroup("OptionSet", { pattern = "buftype" }, function(ev) vim.api.nvim_buf_call(ev.buf, setfolds) end) --- allow cursor to move paste the end of the line in visual block mode -vim.o.virtualedit = "block" - --- indentations settings -vim.o.shiftwidth = 2 -vim.o.tabstop = 2 -vim.o.softtabstop = 0 -- dont insert spaces on -vim.o.expandtab = true -vim.o.smartindent = true -vim.o.smarttab = true --- enable break indent -vim.o.breakindent = true -vim.o.wrap = false - -vim.opt.fillchars:append({ - fold = " ", - eob = "·", - diff = "─", - foldopen = "▼", - foldclose = "▶", -}) - --- always show 1 column of sign column (gitsigns, etc.) -vim.o.signcolumn = "yes:1" - --- hide search notices, intro -vim.opt.shortmess:append("sI") - -vim.o.formatoptions = "tcrqj" - --- hide extra text -vim.o.conceallevel = 2 -vim.o.concealcursor = "c" - --- nice font icons or something -vim.g.have_nerd_font = true - --- decrease update time -vim.o.updatetime = 250 - -vim.o.timeout = false --- decrease mapped sequence wait time - displays which-key popup sooner -vim.o.timeoutlen = 0 - --- Don't show the mode, since it's already in the status line -vim.o.showmode = false -vim.o.showcmd = false -vim.o.showtabline = 2 -vim.o.cmdheight = 0 --- global statusline -vim.o.laststatus = 3 - --- 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 · spell check ======================================================== -- let me have spelling checking for english vim.o.spelllang = "en_ca,en_gb,en_us" @@ -150,27 +272,7 @@ vim.o.spellsuggest = "double,4" vim.o.spellfile = "" vim.o.dictionary = "spell" -vim.o.list = true -vim.opt.listchars:append({ - eol = " ", - tab = "│ ", - trail = "-", - extends = "…", - precedes = "…", - nbsp = "␣", -}) - -vim.o.shell = os.getenv("SHELL") or "/bin/sh" - --- 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 · borders ============================================================ ---@type { [string]: { style: string, ['vert'|'vertleft'|'vertright'|'horiz'|'horizup'|'horizdown'|'verthoriz'|'topleft'|'topright'|'botleft'|'botright']: string, bottom?: string } } local borderchars = { @@ -283,10 +385,8 @@ vim.opt.fillchars:append({ vim.o.winborder = vim.g.border_style --- rust save -vim.g.rustfmt_autosave = 1 +-- editor · cursor ============================================================= --- cursor vim.g.guicursor_config = { normal = { type = "block", @@ -312,20 +412,3 @@ vim.g.guicursor_config = { type = "block", }, } - --- lsp -vim.diagnostic.config({ - virtual_text = { - hl_mode = "combine", - }, - -- virtual_lines = { - -- current_line = true, - -- }, - signs = true, - float = { - header = "", - prefix = function(_, i) - return string.format("%d. ", i), "LineNr" - end, - }, -}) diff --git a/stylua.toml b/stylua.toml index 5957975..32d4fb8 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,6 +1,6 @@ indent_type = "Spaces" indent_width = 2 -column_width = 120 +column_width = 80 quote_style = "AutoPreferDouble" call_parentheses = "Always" line_endings = "Unix"