comparison dot_config/nvim/config.lua @ 409:f0300cd1584c

Defer loading of packer config
author zegervdv <zegervdv@me.com>
date Sat, 17 Jul 2021 11:32:01 +0200
parents 4406fc85ba0a
children
comparison
equal deleted inserted replaced
408:4406fc85ba0a 409:f0300cd1584c
10 10
11 if fn.empty(fn.glob(install_path)) > 0 then 11 if fn.empty(fn.glob(install_path)) > 0 then
12 execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) 12 execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
13 end 13 end
14 14
15 -- Packer configuration is compiled and only needs to be loaded on changes 15 vim.defer_fn(function()
16 vim.cmd 'packadd packer.nvim' 16 -- Packer configuration is compiled and only needs to be loaded on changes
17 17 vim.cmd 'packadd packer.nvim'
18 require('packer').startup(function() 18
19 use { 'wbthomason/packer.nvim', opt = true } 19 require('packer').startup(function()
20 20 use { 'wbthomason/packer.nvim', opt = true }
21 -- General plugins 21
22 use { 'tpope/vim-sensible' } 22 -- General plugins
23 use { 'tpope/vim-repeat' } 23 use { 'tpope/vim-sensible' }
24 use { 'tpope/vim-rsi' } 24 use { 'tpope/vim-repeat' }
25 use { 'sgur/vim-editorconfig' } 25 use { 'tpope/vim-rsi' }
26 use { 'ShikChen/osc52.vim' } 26 use { 'sgur/vim-editorconfig' }
27 use { 'einfachtoll/didyoumean' } 27 use { 'ShikChen/osc52.vim' }
28 28 use { 'einfachtoll/didyoumean' }
29 use { 'tpope/vim-obsession' } 29
30 use { 30 use { 'tpope/vim-obsession' }
31 'tpope/vim-eunuch', 31 use {
32 cmd = { 32 'tpope/vim-eunuch',
33 'Delete', 33 cmd = {
34 'Unlink', 34 'Delete',
35 'Move', 35 'Unlink',
36 'Rename', 36 'Move',
37 'Mkdir', 37 'Rename',
38 'Chmod', 38 'Mkdir',
39 'Cfind', 39 'Chmod',
40 'Clocate', 40 'Cfind',
41 'Lfind', 41 'Clocate',
42 'Llocate', 42 'Lfind',
43 'SudoEdit', 43 'Llocate',
44 'SudoWrite', 44 'SudoEdit',
45 'Wall', 45 'SudoWrite',
46 }, 46 'Wall',
47 } 47 },
48 48 }
49 use { 'psliwka/vim-smoothie' } 49
50 50 use { 'psliwka/vim-smoothie' }
51 use { 'nvim-lua/plenary.nvim' } 51
52 52 use { 'nvim-lua/plenary.nvim' }
53 -- Spelling/autocorrection 53
54 use { 'tpope/vim-abolish' } 54 -- Spelling/autocorrection
55 55 use { 'tpope/vim-abolish' }
56 -- Git/VCS 56
57 use { 'vim-scripts/gitignore' } 57 -- Git/VCS
58 use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } } 58 use { 'vim-scripts/gitignore' }
59 use { 'tpope/vim-git' } 59 use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } }
60 60 use { 'tpope/vim-git' }
61 -- Comments 61
62 use { 'b3nj5m1n/kommentary' } 62 -- Comments
63 63 use { 'b3nj5m1n/kommentary' }
64 -- Undoing 64
65 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } 65 -- Undoing
66 66 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } }
67 -- Parentheses etc 67
68 use { 'tpope/vim-surround' } 68 -- Parentheses etc
69 use { 'raimondi/delimitMate' } 69 use { 'tpope/vim-surround' }
70 70 use { 'raimondi/delimitMate' }
71 -- Moving around within lines 71
72 use { 'wellle/targets.vim', event = 'InsertEnter *' } 72 -- Moving around within lines
73 73 use { 'wellle/targets.vim', event = 'InsertEnter *' }
74 -- Searching 74
75 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } 75 -- Searching
76 76 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } }
77 -- Keymaps TODO: to be removed when #13823 is merged 77
78 use { 78 -- Keymaps TODO: to be removed when #13823 is merged
79 'tjdevries/astronauta.nvim', 79 use {
80 config = function() 80 'tjdevries/astronauta.nvim',
81 require 'astronauta.keymap' 81 config = function()
82 end, 82 require 'astronauta.keymap'
83 } 83 end,
84 84 }
85 -- Opening files 85
86 use { 'wsdjeg/vim-fetch' } 86 -- Opening files
87 87 use { 'wsdjeg/vim-fetch' }
88 -- Indent lines 88
89 use { 89 -- Indent lines
90 'lukas-reineke/indent-blankline.nvim', 90 use {
91 config = function() 91 'lukas-reineke/indent-blankline.nvim',
92 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } 92 config = function()
93 vim.g.indent_blankline_show_first_indent_level = false 93 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' }
94 end, 94 vim.g.indent_blankline_show_first_indent_level = false
95 } 95 end,
96 96 }
97 -- Increment/decrement 97
98 use { 98 -- Increment/decrement
99 'zegervdv/nrpattern.nvim', 99 use {
100 requires = 'tpope/vim-repeat', 100 'zegervdv/nrpattern.nvim',
101 config = function() 101 requires = 'tpope/vim-repeat',
102 local nrpattern = require 'nrpattern' 102 config = function()
103 local defaults = require 'nrpattern.default' 103 local nrpattern = require 'nrpattern'
104 104 local defaults = require 'nrpattern.default'
105 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } 105
106 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } 106 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } }
107 107 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } }
108 nrpattern.setup(defaults) 108
109 end, 109 nrpattern.setup(defaults)
110 } 110 end,
111 111 }
112 -- Tmux 112
113 use { 113 -- Tmux
114 'numtostr/navigator.nvim', 114 use {
115 config = function() 115 'numtostr/navigator.nvim',
116 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } 116 config = function()
117 117 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true }
118 local nnoremap = vim.keymap.nnoremap 118
119 nnoremap { '<c-h>', require('Navigator').left, silent = true } 119 local nnoremap = vim.keymap.nnoremap
120 nnoremap { '<c-j>', require('Navigator').down, silent = true } 120 nnoremap { '<c-h>', require('Navigator').left, silent = true }
121 nnoremap { '<c-k>', require('Navigator').up, silent = true } 121 nnoremap { '<c-j>', require('Navigator').down, silent = true }
122 nnoremap { '<c-l>', require('Navigator').right, silent = true } 122 nnoremap { '<c-k>', require('Navigator').up, silent = true }
123 end, 123 nnoremap { '<c-l>', require('Navigator').right, silent = true }
124 requires = 'tjdevries/astronauta.nvim', 124 end,
125 after = 'astronauta.nvim', 125 requires = 'tjdevries/astronauta.nvim',
126 } 126 after = 'astronauta.nvim',
127 127 }
128 -- Completion/snippets/LSP 128
129 use { 'neovim/nvim-lspconfig' } 129 -- Completion/snippets/LSP
130 use { 130 use { 'neovim/nvim-lspconfig' }
131 'hrsh7th/nvim-compe', 131 use {
132 config = function() 132 'hrsh7th/nvim-compe',
133 require('compe').setup { 133 config = function()
134 enabled = true, 134 require('compe').setup {
135 autocomplete = true, 135 enabled = true,
136 debug = false, 136 autocomplete = true,
137 min_length = 1, 137 debug = false,
138 preselect = 'enable', 138 min_length = 1,
139 throttle_time = 80, 139 preselect = 'enable',
140 source_timeout = 1000, 140 throttle_time = 80,
141 incomplete_delay = 400, 141 source_timeout = 1000,
142 max_abbr_width = 100, 142 incomplete_delay = 400,
143 max_kind_width = 100, 143 max_abbr_width = 100,
144 max_menu_width = 100, 144 max_kind_width = 100,
145 documentation = true, 145 max_menu_width = 100,
146 146 documentation = true,
147 source = { 147
148 path = true, 148 source = {
149 buffer = true, 149 path = true,
150 nvim_lsp = true, 150 buffer = true,
151 nvim_lua = true, 151 nvim_lsp = true,
152 spell = false, 152 nvim_lua = true,
153 vsnip = true, 153 spell = false,
154 }, 154 vsnip = true,
155 } 155 },
156 156 }
157 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] 157
158 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]] 158 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]]
159 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] 159 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]]
160 end, 160 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]]
161 } 161 end,
162 use { 162 }
163 { 163 use {
164 'nvim-treesitter/nvim-treesitter', 164 {
165 config = function() 165 'nvim-treesitter/nvim-treesitter',
166 require 'nvim-treesitter.highlight' 166 config = function()
167 167 require 'nvim-treesitter.highlight'
168 require('nvim-treesitter.configs').setup { 168
169 highlight = { enable = false }, 169 require('nvim-treesitter.configs').setup {
170 incremental_selection = { 170 highlight = { enable = false },
171 enable = true, 171 incremental_selection = {
172 keymaps = { 172 enable = true,
173 init_selection = 'gnn', 173 keymaps = {
174 node_incremental = 'grn', 174 init_selection = 'gnn',
175 scope_incremental = 'grc', 175 node_incremental = 'grn',
176 node_decremental = 'grm', 176 scope_incremental = 'grc',
177 node_decremental = 'grm',
178 },
177 }, 179 },
178 }, 180 refactor = {
179 refactor = { 181 highlight_definitions = { enable = true },
180 highlight_definitions = { enable = true }, 182 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } },
181 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, 183 navigation = {
182 navigation = { 184 enable = true,
183 enable = true, 185 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' },
184 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, 186 },
185 }, 187 },
186 }, 188 textobjects = {
187 textobjects = { 189 move = {
188 move = { 190 enable = true,
189 enable = true, 191 goto_next_start = { [']]'] = '@block.outer' },
190 goto_next_start = { [']]'] = '@block.outer' }, 192 goto_previous_start = { ['[['] = '@block.outer' },
191 goto_previous_start = { ['[['] = '@block.outer' }, 193 goto_next_end = { [']['] = '@block.outer' },
192 goto_next_end = { [']['] = '@block.outer' }, 194 goto_previous_end = { ['[]'] = '@block.outer' },
193 goto_previous_end = { ['[]'] = '@block.outer' }, 195 },
194 }, 196 },
195 }, 197 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false },
196 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, 198 }
197 } 199 end,
198 end, 200 },
199 }, 201 'nvim-treesitter/nvim-treesitter-refactor',
200 'nvim-treesitter/nvim-treesitter-refactor', 202 'nvim-treesitter/nvim-treesitter-textobjects',
201 'nvim-treesitter/nvim-treesitter-textobjects', 203 { 'nvim-treesitter/playground', opt = true },
202 { 'nvim-treesitter/playground', opt = true }, 204 }
203 } 205 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' }
204 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } 206 use {
205 use { 207 'glepnir/lspsaga.nvim',
206 'glepnir/lspsaga.nvim', 208 config = function()
207 config = function() 209 require('lspsaga').init_lsp_saga {}
208 require('lspsaga').init_lsp_saga {} 210 end,
209 end, 211 }
210 } 212 use {
211 use { 213 'rmagatti/goto-preview',
212 'rmagatti/goto-preview', 214 config = function()
213 config = function() 215 require('goto-preview').setup {}
214 require('goto-preview').setup {} 216 end,
215 end, 217 }
216 } 218 use {
217 use { 219 'jose-elias-alvarez/null-ls.nvim',
218 'jose-elias-alvarez/null-ls.nvim', 220 requires = 'nvim-lua/plenary.nvim',
219 requires = 'nvim-lua/plenary.nvim', 221 }
220 } 222 use {
221 use { 223 'folke/lua-dev.nvim',
222 'folke/lua-dev.nvim', 224 }
223 } 225
224 226 -- Vanity
225 -- Vanity 227 use {
226 use { 228 'yamatsum/nvim-web-nonicons',
227 'yamatsum/nvim-web-nonicons', 229 requires = 'kyazdani42/nvim-web-devicons',
228 requires = 'kyazdani42/nvim-web-devicons', 230 config = function()
229 config = function() 231 require 'nvim-nonicons'
230 require 'nvim-nonicons' 232 end,
231 end, 233 }
232 } 234
233 235 use {
234 use { 236 'glepnir/galaxyline.nvim',
235 'glepnir/galaxyline.nvim', 237 branch = 'main',
236 branch = 'main', 238 -- your statusline
237 -- your statusline 239 config = function()
238 config = function() 240 local gl = require 'galaxyline'
239 local gl = require 'galaxyline' 241 local colors = require('galaxyline.theme').default
240 local colors = require('galaxyline.theme').default 242 local condition = require 'galaxyline.condition'
241 local condition = require 'galaxyline.condition' 243 local gls = gl.section
242 local gls = gl.section 244
243 245 colors.bg = '#2C323C'
244 colors.bg = '#2C323C' 246
245 247 gls.left[1] = {
246 gls.left[1] = { 248 RainbowRed = {
247 RainbowRed = { 249 provider = function()
248 provider = function() 250 return '▊ '
249 return '▊ ' 251 end,
250 end, 252 highlight = { colors.blue, colors.bg },
251 highlight = { colors.blue, colors.bg }, 253 },
252 }, 254 }
253 } 255
254 256 gls.left[2] = {
255 gls.left[2] = { 257 FileIcon = {
256 FileIcon = { 258 provider = 'FileIcon',
257 provider = 'FileIcon', 259 condition = condition.buffer_not_empty,
258 condition = condition.buffer_not_empty, 260 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg },
259 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, 261 },
260 }, 262 }
261 } 263
262 264 gls.left[3] = {
263 gls.left[3] = { 265 FileName = {
264 FileName = { 266 provider = 'FileName',
265 provider = 'FileName', 267 condition = condition.buffer_not_empty,
266 condition = condition.buffer_not_empty, 268 highlight = { colors.magenta, colors.bg, 'bold' },
267 highlight = { colors.magenta, colors.bg, 'bold' }, 269 },
268 }, 270 }
269 } 271
270 272 gls.right[1] = {
271 gls.right[1] = { 273 ShowLspClient = {
272 ShowLspClient = { 274 provider = 'GetLspClient',
273 provider = 'GetLspClient', 275 condition = function()
274 condition = function() 276 local tbl = { ['dashboard'] = true, [''] = true }
275 local tbl = { ['dashboard'] = true, [''] = true } 277 if tbl[vim.bo.filetype] then
276 if tbl[vim.bo.filetype] then 278 return false
277 return false 279 end
278 end 280 return true
279 return true 281 end,
280 end, 282 icon = require('nvim-nonicons').get 'server' .. ' LSP:',
281 icon = require('nvim-nonicons').get 'server' .. ' LSP:', 283 highlight = { colors.green, colors.bg, 'bold' },
282 highlight = { colors.green, colors.bg, 'bold' }, 284 },
283 }, 285 }
284 } 286
285 287 gls.right[2] = {
286 gls.right[2] = { 288 LineInfo = {
287 LineInfo = { 289 provider = 'LineColumn',
288 provider = 'LineColumn', 290 separator = ' ',
289 separator = ' ', 291 separator_highlight = { 'NONE', colors.bg },
290 separator_highlight = { 'NONE', colors.bg }, 292 highlight = { colors.fg, colors.bg },
291 highlight = { colors.fg, colors.bg }, 293 },
292 }, 294 }
293 } 295
294 296 gls.right[3] = {
295 gls.right[3] = { 297 PerCent = {
296 PerCent = { 298 provider = 'LinePercent',
297 provider = 'LinePercent', 299 separator = ' ',
298 separator = ' ', 300 separator_highlight = { 'NONE', colors.bg },
299 separator_highlight = { 'NONE', colors.bg }, 301 highlight = { colors.fg, colors.bg, 'bold' },
300 highlight = { colors.fg, colors.bg, 'bold' }, 302 },
301 }, 303 }
302 } 304 gls.right[8] = {
303 gls.right[8] = { 305 RainbowBlue = {
304 RainbowBlue = { 306 provider = function()
305 provider = function() 307 return ' ▊'
306 return ' ▊' 308 end,
307 end, 309 highlight = { colors.blue, colors.bg },
308 highlight = { colors.blue, colors.bg }, 310 },
309 }, 311 }
310 } 312
311 313 gls.short_line_left[1] = {
312 gls.short_line_left[1] = { 314 BufferType = {
313 BufferType = { 315 provider = 'FileTypeName',
314 provider = 'FileTypeName', 316 separator = ' ',
315 separator = ' ', 317 separator_highlight = { 'NONE', colors.bg },
316 separator_highlight = { 'NONE', colors.bg }, 318 highlight = { colors.blue, colors.bg, 'bold' },
317 highlight = { colors.blue, colors.bg, 'bold' }, 319 },
318 }, 320 }
319 } 321
320 322 gls.short_line_left[2] = {
321 gls.short_line_left[2] = { 323 SFileName = {
322 SFileName = { 324 provider = 'SFileName',
323 provider = 'SFileName', 325 condition = condition.buffer_not_empty,
324 condition = condition.buffer_not_empty, 326 highlight = { colors.fg, colors.bg, 'bold' },
325 highlight = { colors.fg, colors.bg, 'bold' }, 327 },
326 }, 328 }
327 } 329
328 330 gls.short_line_right[1] = {
329 gls.short_line_right[1] = { 331 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } },
330 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, 332 }
331 } 333 end,
332 end, 334 }
333 } 335
334 336 -- File navigation
335 -- File navigation 337 use { 'justinmk/vim-dirvish' }
336 use { 'justinmk/vim-dirvish' } 338
337 339 -- Colorscheme
338 -- Colorscheme 340 use {
339 use { 341 'zegervdv/one-lush',
340 'zegervdv/one-lush', 342 requires = 'rktjmp/lush.nvim',
341 requires = 'rktjmp/lush.nvim', 343 config = function()
342 config = function() 344 require 'lush_theme.one-lush'
343 require 'lush_theme.one-lush' 345 vim.cmd [[ colorscheme one-lush ]]
344 vim.cmd [[ colorscheme one-lush ]] 346 end,
345 end, 347 }
346 } 348
347 349 -- Terminal
348 -- Terminal 350 use {
349 use { 351 'akinsho/nvim-toggleterm.lua',
350 'akinsho/nvim-toggleterm.lua', 352 config = function()
351 config = function() 353 require('toggleterm').setup {
352 require('toggleterm').setup { 354 size = 15,
353 size = 15, 355 open_mapping = [[<F12>]],
354 open_mapping = [[<F12>]], 356 shade_filetypes = { 'none' },
355 shade_filetypes = { 'none' }, 357 shade_terminals = true,
356 shade_terminals = true, 358 persist_size = true,
357 persist_size = true, 359 direction = 'horizontal',
358 direction = 'horizontal', 360 }
359 } 361 end,
360 end, 362 }
361 } 363
362 364 -- Filetypes
363 -- Filetypes 365 use { 'Glench/Vim-Jinja2-Syntax' }
364 use { 'Glench/Vim-Jinja2-Syntax' } 366 end)
365 end) 367 end, 0)
366 368
367 -- LSP config 369 -- LSP config
368 local lsp = require 'lspconfig' 370 local lsp = require 'lspconfig'
369 local null_ls = require 'null-ls' 371 local null_ls = require 'null-ls'
370 372