-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlua_init.lua
More file actions
349 lines (282 loc) · 10.6 KB
/
Copy pathlua_init.lua
File metadata and controls
349 lines (282 loc) · 10.6 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
-- Basic config
vim.opt.number = true -- Show line number
vim.opt.cul = true -- Show cursor line
vim.opt.lazyredraw = true -- Wait to redraw screen
vim.cmd [[colorscheme cool]] -- Set theme to custom
vim.opt.list = true -- Show tab and EOL
vim.opt.listchars:append "space:·" -- Space char
vim.opt.listchars:append "eol:↴" -- Eol char
vim.opt.smartindent = true -- Use smart indentation
vim.opt.expandtab = true -- Spaces instead of tabs
vim.opt.tabstop = 4 -- Number of tab spaces
vim.opt.shiftwidth = 4 -- Number of expanded tab spaces
vim.opt.ignorecase = true -- Non case-sensitive searches
vim.opt.smartcase = true -- Pattern is case sensitive if uppercase
vim.opt.hlsearch = true -- Automatically highlight
vim.opt.showcmd = true -- Show last command on status
vim.opt.showmode = true -- Show current mode on status
vim.opt.dir = "/home/" .. os.getenv("USER") .. "/.cache/nvim" -- Set swapfile directory
vim.opt.bdir = "/home/".. os.getenv("USER") .."/.cache/nvim" -- Set backup file directory
vim.opt.history = 500 -- Remember 500 last commands
vim.opt.scrolloff = 10 -- Lines to pad cursor
vim.opt.undofile = true -- Save undo history to file
vim.opt.undodir = "/home/".. os.getenv("USER") .."/.cache/nvim" -- Set undo file directory
vim.opt.formatoptions = "c"
vim.opt.formatoptions = "r"
vim.opt.formatoptions = "o"
vim.opt.equalalways = false -- Preserve buffer sizes after resize
-- Keybinds
vim.keymap.set("c", "<cr>", function()
if vim.fn.pumvisible() == 1 then return '<c-y>' end
return '<cr>'
end, { expr = true })
-- Matchparen
vim.g['matchparen_timeout'] = 10
vim.g['matchparen_insert_timeout'] = 10
-- Vim airline
vim.g['airline_powerline_fonts'] = 1 -- Use powerline fonts
vim.g['airline_theme'] = "codedark" -- Use VSCode dark theme
-- Bootstrap lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Config and use lazy
require("lazy").setup({
-- LSP
"VonHeikemen/lsp-zero.nvim",
"neovim/nvim-lspconfig",
"williamboman/mason-lspconfig.nvim",
"williamboman/mason.nvim",
-- Autocomplete
"f3fora/cmp-spell", -- Spell suggestion autocomplete source
"hrsh7th/cmp-buffer", -- Buffer autocomplete source
"hrsh7th/cmp-calc", -- Calculator autocomplete source
"hrsh7th/cmp-nvim-lsp", -- LSP autocomplete source
"hrsh7th/cmp-path", -- Filepath autocomplete source
"hrsh7th/nvim-cmp",
"onsails/lspkind.nvim",
"saadparwaiz1/cmp_luasnip", -- LuaSnip autocomplete source
-- Snippets
"L3MON4D3/LuaSnip", -- Snippet plugin
"rafamadriz/friendly-snippets", -- Snippets for common languages
-- Git
"lewis6991/gitsigns.nvim", -- Git decorations
"tpope/vim-fugitive", -- Git integration
-- Misc
"brenoprata10/nvim-highlight-colors", -- Color previews
"folke/which-key.nvim", -- Pop-up for custom keybinds
"junegunn/fzf.vim", -- Fuzzy finding
"lukas-reineke/indent-blankline.nvim", -- Indentation lines
"nvim-tree/nvim-web-devicons", -- Icon pack
"petertriho/nvim-scrollbar", -- Status scrollbar
"stevearc/oil.nvim", -- File browser in buffer
"tomasiser/vim-code-dark", -- VS Code theme
"tpope/vim-commentary", -- Selection commenting
"tpope/vim-surround", -- Change parentheses/quotes/etc
"vim-airline/vim-airline", -- Improved status bar
"windwp/nvim-autopairs", -- Pair parentheses and brackets
-- Sessionizer
{
"xolox/vim-session",
dependencies = {
"xolox/vim-misc",
}
},
})
-- Config vim-session
vim.g['session_directory'] = '~/.local/share/nvim/sessions' -- Session directory
vim.g['session_autosave'] = 'no' -- Don't autosave sessions
vim.g['session_default_to_last'] = 1
vim.g['session_command_aliases'] = 1
-- Set up gitsigns
require('gitsigns').setup {
signs = {
add = { text = '┃' },
change = { text = '┃' },
delete = { text = '▁' },
topdelete = { text = '▔' },
changedelete = { text = '~' },
untracked = { text = '┆' },
},
signs_staged = {
add = { text = '┃' },
change = { text = '┃' },
delete = { text = '▁' },
topdelete = { text = '▔' },
changedelete = { text = '~' },
untracked = { text = '┆' },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 1,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
}
-- Set up which-key
require("which-key").setup();
-- Set up nvim highlight colors
require("nvim-highlight-colors").setup {
---Render style
render = 'virtual',
virtual_symbol = '⯀',
---Set virtual symbol position()
virtual_symbol_position = 'inline',
enable_hex = true,
enable_short_hex = true,
enable_rgb = true,
enable_hsl = true,
enable_var_usage = true,
enable_named_colors = true,
enable_tailwind = false,
---Set custom colors
custom_colors = {
{ label = '%-%-theme%-primary%-color', color = '#0f1219' },
{ label = '%-%-theme%-secondary%-color', color = '#5a5d64' },
},
exclude_filetypes = {},
exclude_buftypes = {}
}
-- Set up nvim-autopairs
require("nvim-autopairs").setup {}
-- Setup nvim oil
require("oil").setup()
-- Indent lines
require("ibl").setup({
scope = {
enabled = false
}
})
-- Disable new line comments
vim.cmd('autocmd BufEnter * set formatoptions-=cro')
vim.cmd('autocmd BufEnter * setlocal formatoptions-=cro')
-- Setup LSP zero
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr})
end)
-- Error icons
lsp_zero.set_sign_icons({
error = 'X',
warn = '!',
hint = '⚑',
info = 'i',
})
-- Setup LSP mason package manager
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {},
handlers = {
function(server_name)
require('lspconfig')[server_name].setup({})
end,
},
})
local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
require('luasnip.loaders.from_vscode').lazy_load()
cmp.setup({
-- LSP sources
sources = {
{name = 'nvim_lsp'},
{name = 'path'},
{name = 'calc'},
{name = 'luasnip', keyword_length = 2},
{name = 'buffer', keyword_length = 3},
{
name = "spell",
option = {
keep_all_entries = false,
enable_in_context = function()
return true
end,
preselect_correct_word = true,
},
},
},
-- Autocomplete keybinds
mapping = cmp.mapping.preset.insert({
-- Tab autocomplete
['<Tab>'] = cmp_action.tab_complete(),
['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
['<Enter>'] = cmp.mapping.confirm({select = false}),
}),
-- Snippets support
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
-- Completion menu formatting
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- lsp-kind formatting
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 32 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
})
-- Autosuggest menu colors
vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { bg='NONE', strikethrough=true, fg='#808080' })
vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { bg='NONE', fg='#569CD6' })
vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { link='CmpIntemAbbrMatch' })
vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { bg='NONE', fg='#9CDCFE' })
vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { link='CmpItemKindVariable' })
vim.api.nvim_set_hl(0, 'CmpItemKindText', { link='CmpItemKindVariable' })
vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { bg='NONE', fg='#C586C0' })
vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { link='CmpItemKindFunction' })
vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { bg='NONE', fg='#D4D4D4' })
vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { link='CmpItemKindKeyword' })
vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { link='CmpItemKindKeyword' })
-- Set up scrollbar
require("scrollbar").setup({
handlers = {
cursor = true,
diagnostic = true,
gitsigns = true, -- Requires gitsigns
handle = true,
search = false, -- Requires hlslens
ale = false, -- Requires ALE
},
})