diff options
1 files changed, 69 insertions, 0 deletions
| -rw-r--r-- | nvim/.nvim/lua/ux.lua | 69 |
diff --git a/nvim/.nvim/lua/ux.lua b/nvim/.nvim/lua/ux.lua new file mode 100644 index 0000000..8ff01fc --- /dev/null +++ b/nvim/.nvim/lua/ux.lua @@ -0,0 +1,69 @@ +--[=[ Search ]=]-- + +vim.o.hlsearch = false -- No highlighting when searching + +vim.api.nvim_create_autocmd({ "Filetype" }, { + pattern = "qf", + command = "wincmd J" +}) + +--[=[ Cursor and mouse ]=]-- + +vim.o.scrolloff = 5 -- Lines above and below cursor +vim.o.showmatch = true -- Jump to opening brace when having typed closing one + +vim.o.cursorline = true +vim.api.nvim_create_autocmd({ "InsertLeave", "BufEnter" }, { + command = "set cul" +}) +vim.api.nvim_create_autocmd({ "InsertEnter", "BufLeave" }, { + command = "set nocul" +}) + +vim.o.mouse = "a" + +--[=[ Windows ]=]-- + +vim.o.splitbelow = true +vim.o.splitright = true + +vim.o.number = true +vim.o.signcolumn = "number" + +vim.o.showmode = false +vim.o.timeoutlen = 350 + +--[=[ History ]=]-- + +vim.o.undofile = true +vim.o.undodir = vim.fn.expand("~/nvim/undo") + +--[=[ Quickfix ]=]-- + +vim.cmd [[ + function QuickFixFormat(info) + let qfl = [] + + let maxfnlen = 0 + let maxlilen = 0 + for d in getqflist() + let maxfnlen = max([maxfnlen, strdisplaywidth(fnamemodify(bufname(d.bufnr), ":t"))]) + let maxlilen = max([maxlilen, strdisplaywidth(string(d.lnum))]) + endfor + let strfmt = "%-" . maxfnlen . "s |%". maxlilen ."d|%s" + + let lastfile = "" + for d in getqflist() + let fn = fnamemodify(bufname(d.bufnr), ":t") + if d.lnum != 0 + call add(qfl, printf(strfmt, fn == lastfile ? '' : fn, d.lnum, d.text)) + let lastfile = fn + else + call add(qfl, ' ') + endif + endfor + return qfl + endfunction +]] + +vim.o.quickfixtextfunc = "QuickFixFormat" |
