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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
-- vim.opt.list = true
-- vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
-- vim.opt.listchars:append("space:⋅")
-- Set highlight on search
-- vim.opt.hlsearch = false
-- require("vim._core.ui2").enable()
vim.cmd.packadd("nvim.undotree")
-- vim.cmd.packadd("nvim.difftool")
vim.o.showmode = false
vim.o.showcmd = false
vim.o.winborder = "single"
vim.opt.hlsearch = true
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
-- Preview substitutions live, as you type!
vim.opt.inccommand = "split"
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 3
-- Make line numbers default
vim.wo.number = true
vim.o.cursorline = true
-- Disable mouse mode
vim.o.mouse = ""
-- Indent
vim.o.smarttab = true
-- vim.o.smartindent = true
-- vim.o.indentexpr = true
vim.o.autoindent = true
vim.opt.cpoptions:append("I")
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
vim.o.expandtab = true
-- stops line wrapping from being confusing
vim.o.wrap = true
vim.o.linebreak = true
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = false
vim.o.title = true
vim.o.swapfile = false
-- Case-insensitive searching UNLESS \C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.wo.signcolumn = "yes"
vim.wo.relativenumber = true
vim.opt.lazyredraw = true
-- Decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300
-- Set completeopt to have a better completion experience
vim.o.completeopt = "menu,preview,noselect"
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true
-- remove empty buffer text
vim.opt.shortmess:append("I")
vim.g.netrw_liststyle = 0
vim.g.netrw_banner = 0
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.hl.on_yank()
end,
group = highlight_group,
pattern = "*",
})
local augroup = vim.api.nvim_create_augroup("UserConfig", {})
-- [[ Disable auto comment on enter ]]
-- See :help formatoptions
vim.api.nvim_create_autocmd("FileType", {
desc = "remove formatoptions",
group = augroup,
callback = function()
vim.opt.formatoptions:remove({ "c", "r", "o" })
end,
})
vim.api.nvim_create_autocmd("FileType", {
group = augroup,
pattern = "help",
callback = function()
vim.bo.bufhidden = "unload"
vim.cmd.wincmd("L")
end,
})
-- -- Create directories when saving files
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- group = augroup,
-- callback = function()
-- local dir = vim.fn.expand('<afile>:p:h')
-- if vim.fn.isdirectory(dir) == 0 then
-- vim.fn.mkdir(dir, 'p')
-- end
-- end,
-- })
|