-
-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathinit.lua
More file actions
242 lines (228 loc) · 5.75 KB
/
init.lua
File metadata and controls
242 lines (228 loc) · 5.75 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
231
232
233
234
235
236
237
238
239
240
241
242
-- https://github.com/blazkowolf/gruber-darker.nvim
local g = vim.g
vim.loader.enable()
g.mapleader = vim.keycode('<space>')
g.loaded_gzip = 1
g.loaded_tar = 1
g.loaded_tarPlugin = 1
g.loaded_zip = 1
g.loaded_zipPlugin = 1
g.loaded_getscript = 1
g.loaded_getscriptPlugin = 1
g.loaded_vimball = 1
g.loaded_vimballPlugin = 1
g.loaded_matchit = 1
g.loaded_2html_plugin = 1
g.loaded_rrhelper = 1
g.loaded_netrwPlugin = 1
g.loaded_matchparen = 1
local o = vim.o
o.hidden = true
o.magic = true
o.virtualedit = 'block'
o.clipboard = 'unnamedplus'
o.wildignorecase = true
o.swapfile = false
o.timeout = true
o.ttimeout = true
o.timeoutlen = 500
o.ttimeoutlen = 10
o.updatetime = 500
o.ignorecase = true
o.smartcase = true
o.cursorline = true
o.showmode = false
o.shortmess = 'aoOTIcF'
o.scrolloff = 2
o.sidescrolloff = 5
o.ruler = false
o.showtabline = 0
o.showcmd = false
o.pumheight = 15
o.pummaxwidth = 30
o.pumborder = 'rounded'
o.list = true
--eol:¬
o.listchars = 'tab:» ,nbsp:+,trail:·,extends:→,precedes:←,'
o.fillchars = 'trunc:…'
o.foldtext = ''
o.foldlevelstart = 99
o.undofile = true
o.linebreak = true
o.smoothscroll = true
o.smarttab = true
o.expandtab = true
o.autoindent = true
o.tabstop = 2
o.sw = 2
o.wrap = false
o.number = true
o.signcolumn = 'yes'
o.textwidth = 80
o.colorcolumn = '+0'
o.winborder = 'rounded'
o.splitright = true
-- reset to 2 in dashboard.lua lnum 273
o.laststatus = 0
o.cot = 'menu,menuone,noinsert,fuzzy,popup' -- nosort or not???
o.cia = 'kind,abbr,menu'
vim.opt.guicursor:remove({ 't:block-blinkon500-blinkoff500-TermCursor' })
vim.cmd.colorscheme('solarized')
g.health = { style = 'float' }
g.editorconfig = false
g._lang = {
'c',
'cpp',
'rust',
'zig',
'lua',
'python',
'proto',
'typescript',
'javascript',
'tsx',
'css',
'scss',
'diff',
'dockerfile',
'graphql',
'html',
'sql',
'markdown',
'markdown_inline',
'vimdoc',
'vim',
'cmake',
}
vim.api.nvim_create_autocmd('PackChanged', {
callback = function(ev)
local name, active = ev.data.spec.name, ev.data.active
if name == 'nvim-treesitter' then
if not active then
vim.cmd.packadd('nvim-treesitter')
end
local nts = require('nvim-treesitter')
nts.install(g.lang, { summary = true })
nts.update(nil, { summary = true })
end
end,
})
vim.api.nvim_create_user_command('PackDelete', function(args)
vim.pack.del(args.fargs, { force = true })
end, {
nargs = '+',
complete = function()
return vim
.iter(vim.pack.get())
:map(function(p)
return p.spec.name
end)
:totable()
end,
})
g.phoenix = {
snippet = vim.fn.stdpath('config') .. '/snippets',
}
local P = {}
local function normalize_url(s)
return s:match('^https?://') and s or 'https://github.com/' .. s
end
local function normalize_spec(spec)
if type(spec) == 'string' then
return normalize_url(spec)
end
if spec.src then
return vim.tbl_extend('force', spec, { src = normalize_url(spec.src) })
end
return spec
end
local function ensure_list(specs)
return (type(specs) == 'string' or (type(specs) == 'table' and specs.src)) and { specs } or specs
end
local function on_cmd(cmd, pkg_name, setup_fn)
return function()
vim.api.nvim_create_user_command(cmd, function(data)
vim.api.nvim_del_user_command(cmd)
vim.cmd.packadd(pkg_name)
if setup_fn then
setup_fn()
end
vim.cmd(('%s %s'):format(cmd, data.args))
end, { nargs = '?' })
end
end
local function on_event(events, pkg_name, setup_fn)
return function()
vim.api.nvim_create_autocmd(events, {
once = true,
callback = function()
for _, p in ipairs(ensure_list(pkg_name)) do
vim.cmd.packadd(p)
end
if setup_fn then
setup_fn()
end
end,
})
end
end
function P:add(specs, opts)
specs = vim.tbl_map(normalize_spec, ensure_list(specs))
vim.pack.add(specs, vim.tbl_extend('keep', opts or {}, { confirm = false }))
return self
end
P:add({
'nvimdev/modeline.nvim',
'lewis6991/gitsigns.nvim',
'nvimdev/phoenix.nvim',
{ src = 'nvim-treesitter/nvim-treesitter', version = 'main' },
{ src = 'nvim-treesitter/nvim-treesitter-textobjects', version = 'main' },
}, { load = false })
:add('nvimdev/dired.nvim', {
load = on_cmd('Dired', 'dired.nvim'),
})
:add('ibhagwan/fzf-lua', {
load = on_cmd('FzfLua', 'fzf-lua', function()
require('fzf-lua').setup({
lsp = { symbols = { symbol_style = 3 } },
grep = {
rg_opts = "--column --line-number --no-heading --color=always --smart-case --colors 'path:fg:blue'",
},
live_grep = {
rg_opts = "--column --line-number --no-heading --color=always --smart-case --colors 'path:fg:blue'",
},
winopts = {
preview = {
default = true,
builtin = {
treesitter = { enabled = false },
},
},
},
files = { file_icons = false },
})
end),
})
:add({ 'nvimdev/guard.nvim', 'nvimdev/guard-collection' }, {
load = on_event('BufReadPost', { 'guard.nvim', 'guard-collection' }, function()
local ft = require('guard.filetype')
ft('c,cpp'):fmt({
cmd = 'clang-format',
args = function(bufnr)
local f = vim.bo[bufnr].filetype == 'cpp' and '.cc-format' or '.c-format'
return { ('--style=file:%s/%s'):format(vim.env.HOME, f) }
end,
stdin = true,
ignore_patterns = { 'neovim', 'vim' },
})
ft('lua'):fmt({
cmd = 'stylua',
args = { '-' },
stdin = true,
ignore_patterns = 'function.*_spec%.lua',
find = '.stylua.toml',
})
ft('rust'):fmt('rustfmt')
ft('typescript', 'javascript', 'typescriptreact', 'javascriptreact'):fmt('prettier')
end),
})