Summary Files Commits Branches @commit @diff @stats
path: root / nvim / .nvim / lua / ux.lua
blob: 8ff01fcae26cf148870c8d444026357a1760b9c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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"