-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
230 lines (196 loc) · 5.76 KB
/
init.lua
File metadata and controls
230 lines (196 loc) · 5.76 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
-- Map leader keys
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
vim.g.have_nerd_font = true
vim.opt.linebreak = true
vim.opt.list = true
-- Line numbers
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.mouse = "a"
vim.opt.showmode = false
vim.opt.switchbuf = "usetab"
vim.opt.shada = "'100,<50,s10,:100,/100,@100,h,ra:,rb:,r/tmp"
vim.opt.swapfile = false
vim.opt.undofile = true
vim.opt.confirm = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.signcolumn = "yes"
vim.opt.colorcolumn = "81"
vim.opt.updatetime = 300
vim.opt.timeoutlen = 1000
vim.opt.splitkeep = "screen"
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.list = true
vim.opt.listchars = {
tab = "» ",
trail = "·",
nbsp = "␣",
extends = "…",
precedes = "…",
}
vim.opt.inccommand = "split"
vim.opt.incsearch = true
vim.opt.fileformats = "unix,dos"
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.cindent = true
vim.opt.breakindent = true
vim.opt.breakindentopt = "list:-1"
-- Default fold
-- vim.opt.foldenable = false
vim.opt.foldlevel = 10
vim.opt.foldmethod = "indent"
vim.opt.foldnestmax = 10
vim.opt.foldtext = ""
vim.opt.scrolloff = 10
vim.opt.hlsearch = true
vim.opt.termguicolors = true
vim.opt.cursorline = true
vim.opt.cursorlineopt = "screenline,number"
vim.opt.guicursor = "a:Cursor/lCursor,\z
n-v-c:block,\z
i-ci-ve:ver25-blinkwait0-blinkoff500-blinkon500,\z
r-cr-o:hor20,\z
sm:blinkwait0-blinkoff500-blinkon500,\z
t:TermCursor"
vim.opt.pumheight = 10
vim.opt.winborder = "rounded"
-- Experimental
-- vim.opt.cmdheight = 0
-- vim.api.nvim_create_autocmd("CmdlineEnter", {
-- desc = "Restore cmdline when entered",
-- group = vim.api.nvim_create_augroup(
-- "nvim-restore-cmdline",
-- { clear = true }
-- ),
-- callback = function()
-- vim.opt.cmdheight = 1
-- end,
-- })
-- vim.api.nvim_create_autocmd("CmdlineLeave", {
-- desc = "Hide cmdline when left",
-- group = vim.api.nvim_create_augroup("nvim-hide-cmdline", { clear = true }),
-- callback = function()
-- vim.opt.cmdheight = 0
-- end,
-- })
-- Per directory overrides
vim.opt.exrc = true
-- Add empty blank line
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- desc = "Add blank line at the end of file",
-- group = vim.api.nvim_create_augroup(
-- "nvim-blank-line-eof",
-- { clear = true }
-- ),
-- callback = function()
-- local last_line = vim.api.nvim_buf_get_lines(0, -2, -1, true)[1]
-- if vim.fn.empty(last_line) == 0 then
-- vim.api.nvim_buf_set_lines(0, -1, -1, true, { "" })
-- end
-- end,
-- })
-- Highlight when copying
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup(
"nvim-highlight-yank",
{ clear = true }
),
callback = function()
vim.hl.on_yank()
end,
})
-- Set terminal to pwsh on Windows
if vim.fn.index(vim.fn.keys(vim.fn.environ()), "shell", 0, true) == -1 then
vim.opt.shell = vim.fn.executable "pwsh" == 1 and "pwsh" or "powershell"
vim.opt.shellcmdflag =
"-NoLogo -NonInteractive -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues['Out-File:Encoding']='utf8';$PSStyle.OutputRendering='plaintext';Remove-Alias -Force -ErrorAction SilentlyContinue tee;"
vim.opt.shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode'
vim.opt.shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode'
vim.opt.shellquote = ""
vim.opt.shellxquote = ""
end
-- Using explorer.exe to open URL
local original_open = vim.ui.open
---@param path string
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.open = function(path, opt)
if vim.fn.executable "explorer.exe" == 1 and opt == nil then
return original_open(path, { cmd = { "explorer.exe" } })
end
return original_open(path, opt)
end
-- Disable line number in terminal
vim.api.nvim_create_autocmd("TermOpen", {
desc = "Disable line number in terminal mode",
group = vim.api.nvim_create_augroup("nvim-term-custom", { clear = true }),
callback = function()
vim.wo.number = false
vim.wo.relativenumber = false
end,
})
-- Lazy.nvim
require "config.lazy"
-- Treesitter
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"lua",
"luadoc",
"vim",
"vimdoc",
"markdown",
"zig",
"c",
"cpp",
"cmake",
"rust",
"json",
"html",
"css",
"javascript",
"jsdoc",
"typescript",
"typescriptreact",
"typescript.tsx", -- really?
"tsx", -- What should I use?
"astro",
"python",
"toml",
"yaml",
"ssh_config",
"git_config",
"gitcommit",
"git_rebase",
"gitignore",
"gitattributes",
"editorconfig",
"bash",
"zsh",
"powershell",
"hyprlang",
"latex",
"kotlin",
},
callback = function()
-- syntax highlighting, provided by Neovim
vim.treesitter.start()
-- folds, provided by Neovim
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.wo.foldmethod = "expr"
vim.wo.fillchars = "fold:-"
-- indentation, provided by nvim-treesitter
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
-- Default color scheme
if not vim.g.vscode then
vim.cmd.colorscheme "rose-pine"
end
-- Key mappings
require "config.keymaps"