dot

vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks

123 lines3571 bytesLua
1vim.opt.tabstop = 2
2vim.opt.shiftwidth = 2
3vim.opt.expandtab = true
4
5vim.opt.number = true
6vim.opt.relativenumber = true
7
8vim.opt.scrolloff = 5
9
10vim.opt.cursorline = true
11vim.opt.textwidth = 100
12vim.opt.colorcolumn = '+1'
13vim.opt.formatoptions = 'cqj'
14
15vim.opt.undofile = true
16vim.opt.undodir = vim.fn.stdpath('data') .. '/undodir'
17
18vim.opt.path = vim.o.path .. '**'
19vim.opt.wildmenu = true
20vim.opt.wildignore = {
21 "**/.direnv/**",
22 "**/node_modules/**",
23 "**/vendor/**",
24};
25
26vim.api.nvim_set_hl(0, 'Normal', { bg='none' })
27vim.api.nvim_set_hl(0, 'StatusLine', { bg='none' })
28vim.api.nvim_set_hl(0, 'StatusLineNC', { bg='none', fg='gray' })
29vim.api.nvim_set_hl(0, 'WinBar', { bg='none' })
30vim.api.nvim_set_hl(0, 'WinBarNC', { bg='none', fg='gray' })
31vim.api.nvim_set_hl(0, 'NormalFloat', { bg='none' })
32vim.api.nvim_set_hl(0, 'FloatBorder', { bg='none' })
33vim.api.nvim_set_hl(0, 'Pmenu', { bg='none' })
34vim.api.nvim_set_hl(0, 'PmenuBorder', { bg='none' })
35
36vim.opt.winborder = "rounded";
37vim.opt.pumborder = "rounded";
38
39vim.opt.cmdheight = 1
40vim.opt.showcmd = true
41
42vim.api.nvim_create_autocmd('BufReadPost', {
43 group = vim.api.nvim_create_augroup('ReturnToLastLine', { clear = true }),
44 callback = function()
45 local last = vim.fn.line([['"]])
46 if last > 1 and last < vim.fn.line("$") then
47 vim.cmd([[normal! g'"]])
48 end
49 end
50})
51
52vim.opt.list = true
53vim.opt.listchars = {
54 trail = '~',
55 tab = '| ',
56 leadmultispace = ':' .. string.rep(' ', vim.opt.shiftwidth:get() - 1),
57}
58
59local function update()
60 local listchars = vim.opt_local.listchars:get()
61 listchars.leadmultispace = ':' .. string.rep(' ', vim.opt_local.shiftwidth:get() - 1)
62 vim.opt_local.listchars = listchars
63end
64
65local group = vim.api.nvim_create_augroup('ListcharsLeadmultispaceWidth', { clear = true }),
66
67vim.api.nvim_create_autocmd('OptionSet', {
68 group = group,
69 pattern = 'shiftwidth',
70 callback = update,
71})
72
73vim.api.nvim_create_autocmd({ 'FileType', 'BufWinEnter' }, {
74 group = group,
75 callback = update,
76})
77
78vim.api.nvim_create_autocmd(
79 {'BufEnter', 'BufAdd', 'BufDelete', 'BufLeave', 'BufModifiedSet', 'BufWrite'},
80 {
81 group = vim.api.nvim_create_augroup("WinBarBuffers", { clear = true }),
82 pattern = "*",
83 callback = function()
84 local buffers = {}
85 local current = vim.api.nvim_win_get_buf(0)
86
87 for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
88 if vim.bo[bufnr].buflisted then
89 local name = vim.fn.fnamemodify(vim.fn.bufname(bufnr), ":t")
90 if name == "" then name = "[No name]" end
91
92 local highlight = bufnr == current and "WinBar" or "WinBarNC"
93 local modified = vim.bo[bufnr].modified and "*" or ""
94
95 table.insert(buffers, string.format(
96 "%%#%s# %d:%s%s %%*",
97 highlight, bufnr, name, modified
98 ))
99 end
100 end
101
102 if #buffers > 1 and vim.bo[current].buflisted then
103 vim.opt_local.winbar = table.concat(buffers)
104 vim.keymap.set({'n','v'}, '<C-n>', ':bn<cr>', { buffer = current })
105 vim.keymap.set({'n','v'}, '<C-p>', ':bp<cr>', { buffer = current })
106
107 else
108 vim.opt_local.winbar = ""
109 pcall(function()
110 vim.keymap.del({'n','v'}, '<C-n>', { buffer = current })
111 vim.keymap.del({'n','v'}, '<C-p>', { buffer = current })
112 end)
113 end
114 end
115 }
116)
117
118vim.keymap.set({'n','v'}, '<C-c>', '"+y')
119vim.keymap.set({'n','v'}, '<C-v>', '"+p')
120vim.keymap.set({'n','v'}, '<C-x>', '"+d')
121
122-- Use C-q for block visual mode
123vim.keymap.set({'n','v'}, '<C-q>', '<C-v>', { noremap = true})