-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
343 lines (268 loc) · 8.8 KB
/
init.lua
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
-- Install packer
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
local is_bootstrap = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
is_bootstrap = true
vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }
vim.cmd [[packadd packer.nvim]]
end
require('packer').startup(function(use)
-- Package manager
use 'wbthomason/packer.nvim'
use 'sbdchd/neoformat'
use 'ddrscott/vim-side-search'
use 'github/copilot.vim'
use 'ThePrimeagen/harpoon'
use 'rose-pine/neovim'
use ({ 'projekt0n/github-nvim-theme' })
use 'tjdevries/colorbuddy.nvim'
use 'backdround/global-note.nvim'
use {
'antosha417/nvim-lsp-file-operations',
requires = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-tree.lua",
}
}
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup()
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
use 'jiangmiao/auto-pairs'
use 'tpope/vim-surround'
use { 'andymass/vim-matchup' }
use 'sunjon/Shade.nvim'
use {
"SmiteshP/nvim-navbuddy",
requires = {
"neovim/nvim-lspconfig",
"SmiteshP/nvim-navic",
"MunifTanjim/nui.nvim"
}
}
use {
"SmiteshP/nvim-navic",
requires = "neovim/nvim-lspconfig"
}
use { -- LSP Configuration & Plugins
'neovim/nvim-lspconfig',
requires = {
-- Automatically install LSPs to stdpath for neovim
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
"mfussenegger/nvim-dap",
"jayp0521/mason-nvim-dap.nvim",
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
-- Useful status updates for LSP
{'j-hui/fidget.nvim', tag = "legacy"},
-- Additional lua configuration, makes nvim stuff amazing
'folke/neodev.nvim',
},
}
use 'nvim-telescope/telescope-dap.nvim'
use 'debugloop/telescope-undo.nvim'
use { -- Autocompletion
'hrsh7th/nvim-cmp',
requires = {
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-nvim-lsp',
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip'
},
}
use { -- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
run = function()
pcall(require('nvim-treesitter.install').update { with_sync = true })
end,
}
use 'nvim-treesitter/nvim-treesitter-context'
use 'RRethy/vim-illuminate'
use { -- Additional text objects via treesitter
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter',
}
-- Git related plugins
use 'tpope/vim-fugitive'
use 'tpope/vim-rhubarb'
use 'lewis6991/gitsigns.nvim'
use 'f-person/git-blame.nvim'
use 'tommcdo/vim-fubitive'
use {'akinsho/git-conflict.nvim', tag = "*", config = function()
require('git-conflict').setup()
end}
use 'navarasu/onedark.nvim' -- Theme inspired by Atom
use { "catppuccin/nvim", as = "catppuccin" }
use "rebelot/kanagawa.nvim"
use 'nvim-lualine/lualine.nvim' -- Fancier statusline
use 'lukas-reineke/indent-blankline.nvim' -- Add indentation guides even on blank lines
use 'numToStr/Comment.nvim' -- "gc" to comment visual regions/lines
use 'tpope/vim-sleuth' -- Detect tabstop and shiftwidth automatically
-- use 'https://gitlab.com/HiPhish/rainbow-delimiters.nvim' -- Highlight matching parenthesis
-- Fuzzy Finder (files, lsp, etc)
use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } }
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable 'make' == 1 }
use { "nvim-telescope/telescope-file-browser.nvim" }
-- File browser
use 'stevearc/oil.nvim'
use {'nvim-telescope/telescope-ui-select.nvim' }
-- Add custom plugins to packer from ~/.config/nvim/lua/custom/plugins.lua
local has_plugins, plugins = pcall(require, 'custom.plugins')
if has_plugins then
plugins(use)
end
if is_bootstrap then
require('packer').sync()
end
end)
-- When we are bootstrapping a configuration, it doesn't
-- make sense to execute the rest of the init.lua.
--
-- You'll need to restart nvim, and then it will work.
if is_bootstrap then
print '=================================='
print ' Plugins are being installed'
print ' Wait until Packer completes,'
print ' then restart nvim'
print '=================================='
return
end
-- Automatically source and re-compile packer whenever you save this init.lua
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
vim.api.nvim_create_autocmd('BufWritePost', {
command = 'source <afile> | silent! LspStop | silent! LspStart | PackerCompile',
group = packer_group,
pattern = vim.fn.expand '$MYVIMRC',
})
-- nischal
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt_local.shiftwidth = 4
vim.opt_local.tabstop = 4
vim.opt.scrolloff = 4
vim.opt.termguicolors = true -- set termguicolors to enable highlight groups
vim.api.nvim_create_autocmd("FileType", {
pattern = "javascript",
callback = function()
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "typescript",
callback = function()
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "go",
callback = function()
vim.opt.expandtab = false
end
})
-- /nischal
-- [[ Setting options ]]
-- Set highlight on search
vim.o.hlsearch = false
-- Make line numbers default
vim.wo.number = true
vim.wo.relativenumber = true
-- Enable mouse mode
vim.o.mouse = 'a'
-- Enable break indent
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Decrease update time
vim.o.updatetime = 250
vim.wo.signcolumn = 'yes'
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- [[ Basic Keymaps ]]
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
-- Don't do anything when you hit space in normal mode and visual mode
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- -- Remap for dealing with word wrap
-- vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- [[ 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.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})
-- Enable Comment.nvim
require('Comment').setup()
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
-- support italics
vim.cmd [[
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
]]
-- Automatically source .zshrc on save
vim.cmd([[
autocmd BufWritePost ~/.zshrc !source ~/.zshrc > /dev/null
]])
vim.opt.colorcolumn = "81,121"
-- require("chatgpt").setup({
-- api_key = "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"
-- })
vim.g.copilot_no_tab_map = true
vim.api.nvim_set_keymap("i", "<C-L>", 'copilot#Accept("<CR>")', { silent = true, expr = true })
vim.cmd([[
augroup QuickfixSettings
autocmd!
autocmd FileType qf setlocal nowrap
augroup END
]])
require("lsp-file-operations").setup()
-- local global_note = require("global-note")
-- global_note.setup()
-- FORMATTERS
-- Create group to assign commands
-- "clear = true" must be set to prevent loading an
-- auto-command repeatedly every time a file is resourced
local autocmd_group = vim.api.nvim_create_augroup("Custom auto-commands", { clear = true })
-- formatter stuff
vim.cmd[[
let g:neoformat_try_node_exe = 1
]]
-- vim.api.nvim_create_autocmd({ "BufWritePre" }, {
-- pattern = { "*.js", "*.ts", "*.d.ts", "*.jsx", "*.tsx" },
-- desc = "Auto-format javascript and typescript files after saving",
-- callback = function()
-- local fileName = vim.api.nvim_buf_get_name(0)
-- -- vim.cmd(":silent !npx prettier --write " .. fileName)
-- -- vim.cmd(":e")
-- vim.cmd(":Neoformat prettier")
-- end,
-- group = autocmd_group,
-- })