comparison dot_config/nvim/config.lua @ 406:270a0f0f4c7f

Format with stylua
author zegervdv <zegervdv@me.com>
date Fri, 16 Jul 2021 18:36:50 +0200
parents 34862cc22221
children 4406fc85ba0a
comparison
equal deleted inserted replaced
405:34862cc22221 406:270a0f0f4c7f
4 -- 4 --
5 local execute = vim.api.nvim_command 5 local execute = vim.api.nvim_command
6 local fn = vim.fn 6 local fn = vim.fn
7 7
8 -- Bootstrap package manager 8 -- Bootstrap package manager
9 local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' 9 local install_path = fn.stdpath 'data' .. '/site/pack/packer/opt/packer.nvim'
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
73 73
74 -- Searching 74 -- Searching
75 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } 75 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } }
76 76
77 -- Keymaps TODO: to be removed when #13823 is merged 77 -- Keymaps TODO: to be removed when #13823 is merged
78 use { 'tjdevries/astronauta.nvim', config = function() require 'astronauta.keymap' end } 78 use {
79 'tjdevries/astronauta.nvim',
80 config = function()
81 require 'astronauta.keymap'
82 end,
83 }
79 84
80 -- Opening files 85 -- Opening files
81 use { 'wsdjeg/vim-fetch' } 86 use { 'wsdjeg/vim-fetch' }
82 87
83 -- Indent lines 88 -- Indent lines
95 requires = 'tpope/vim-repeat', 100 requires = 'tpope/vim-repeat',
96 config = function() 101 config = function()
97 local nrpattern = require 'nrpattern' 102 local nrpattern = require 'nrpattern'
98 local defaults = require 'nrpattern.default' 103 local defaults = require 'nrpattern.default'
99 104
100 defaults[{ 'input', 'output' }] = 105 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } }
101 { priority = 12, filetypes = { 'verilog', 'systemverilog' } } 106 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } }
102 defaults[{ '\'1', '\'0' }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } }
103 107
104 nrpattern.setup(defaults) 108 nrpattern.setup(defaults)
105 end, 109 end,
106 } 110 }
107 111
110 'numtostr/navigator.nvim', 114 'numtostr/navigator.nvim',
111 config = function() 115 config = function()
112 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } 116 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true }
113 117
114 local nnoremap = vim.keymap.nnoremap 118 local nnoremap = vim.keymap.nnoremap
115 nnoremap { '<c-h>', require'Navigator'.left, silent = true } 119 nnoremap { '<c-h>', require('Navigator').left, silent = true }
116 nnoremap { '<c-j>', require'Navigator'.down, silent = true } 120 nnoremap { '<c-j>', require('Navigator').down, silent = true }
117 nnoremap { '<c-k>', require'Navigator'.up, silent = true } 121 nnoremap { '<c-k>', require('Navigator').up, silent = true }
118 nnoremap { '<c-l>', require'Navigator'.right, silent = true } 122 nnoremap { '<c-l>', require('Navigator').right, silent = true }
119 end, 123 end,
120 requires = 'tjdevries/astronauta.nvim', 124 requires = 'tjdevries/astronauta.nvim',
121 after = 'astronauta.nvim', 125 after = 'astronauta.nvim',
122 } 126 }
123 127
124 -- Completion/snippets/LSP 128 -- Completion/snippets/LSP
125 use { 'neovim/nvim-lspconfig' } 129 use { 'neovim/nvim-lspconfig' }
126 use { 130 use {
127 'hrsh7th/nvim-compe', 131 'hrsh7th/nvim-compe',
128 config = function() 132 config = function()
129 require'compe'.setup { 133 require('compe').setup {
130 enabled = true, 134 enabled = true,
131 autocomplete = true, 135 autocomplete = true,
132 debug = false, 136 debug = false,
133 min_length = 1, 137 min_length = 1,
134 preselect = 'enable', 138 preselect = 'enable',
159 { 163 {
160 'nvim-treesitter/nvim-treesitter', 164 'nvim-treesitter/nvim-treesitter',
161 config = function() 165 config = function()
162 require 'nvim-treesitter.highlight' 166 require 'nvim-treesitter.highlight'
163 167
164 require'nvim-treesitter.configs'.setup { 168 require('nvim-treesitter.configs').setup {
165 highlight = { enable = false }, 169 highlight = { enable = false },
166 incremental_selection = { 170 incremental_selection = {
167 enable = true, 171 enable = true,
168 keymaps = { 172 keymaps = {
169 init_selection = 'gnn', 173 init_selection = 'gnn',
196 'nvim-treesitter/nvim-treesitter-refactor', 200 'nvim-treesitter/nvim-treesitter-refactor',
197 'nvim-treesitter/nvim-treesitter-textobjects', 201 'nvim-treesitter/nvim-treesitter-textobjects',
198 { 'nvim-treesitter/playground', opt = true }, 202 { 'nvim-treesitter/playground', opt = true },
199 } 203 }
200 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } 204 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' }
201 use { 'glepnir/lspsaga.nvim', config = function() require'lspsaga'.init_lsp_saga {} end } 205 use {
202 use { 'rmagatti/goto-preview', config = function() require'goto-preview'.setup {} end } 206 'glepnir/lspsaga.nvim',
207 config = function()
208 require('lspsaga').init_lsp_saga {}
209 end,
210 }
211 use {
212 'rmagatti/goto-preview',
213 config = function()
214 require('goto-preview').setup {}
215 end,
216 }
203 use { 217 use {
204 'jose-elias-alvarez/null-ls.nvim', 218 'jose-elias-alvarez/null-ls.nvim',
205 requires='nvim-lua/plenary.nvim', 219 requires = 'nvim-lua/plenary.nvim',
206 } 220 }
207 221
208 -- Vanity 222 -- Vanity
209 use { 223 use {
210 'yamatsum/nvim-web-nonicons', 224 'yamatsum/nvim-web-nonicons',
211 requires = 'kyazdani42/nvim-web-devicons', 225 requires = 'kyazdani42/nvim-web-devicons',
212 config = function() require 'nvim-nonicons' end, 226 config = function()
227 require 'nvim-nonicons'
228 end,
213 } 229 }
214 230
215 use { 231 use {
216 'glepnir/galaxyline.nvim', 232 'glepnir/galaxyline.nvim',
217 branch = 'main', 233 branch = 'main',
218 -- your statusline 234 -- your statusline
219 config = function() 235 config = function()
220 local gl = require 'galaxyline' 236 local gl = require 'galaxyline'
221 local colors = require('galaxyline.theme').default 237 local colors = require('galaxyline.theme').default
222 local condition = require('galaxyline.condition') 238 local condition = require 'galaxyline.condition'
223 local gls = gl.section 239 local gls = gl.section
224 240
225 colors.bg = '#2C323C' 241 colors.bg = '#2C323C'
226 242
227 gls.left[1] = { 243 gls.left[1] = {
228 RainbowRed = { 244 RainbowRed = {
229 provider = function() return '▊ ' end, 245 provider = function()
246 return '▊ '
247 end,
230 highlight = { colors.blue, colors.bg }, 248 highlight = { colors.blue, colors.bg },
231 }, 249 },
232 } 250 }
233 251
234 gls.left[2] = { 252 gls.left[2] = {
250 gls.right[1] = { 268 gls.right[1] = {
251 ShowLspClient = { 269 ShowLspClient = {
252 provider = 'GetLspClient', 270 provider = 'GetLspClient',
253 condition = function() 271 condition = function()
254 local tbl = { ['dashboard'] = true, [''] = true } 272 local tbl = { ['dashboard'] = true, [''] = true }
255 if tbl[vim.bo.filetype] then return false end 273 if tbl[vim.bo.filetype] then
274 return false
275 end
256 return true 276 return true
257 end, 277 end,
258 icon = require'nvim-nonicons'.get('server') .. ' LSP:', 278 icon = require('nvim-nonicons').get 'server' .. ' LSP:',
259 highlight = { colors.green, colors.bg, 'bold' }, 279 highlight = { colors.green, colors.bg, 'bold' },
260 }, 280 },
261 } 281 }
262 282
263 gls.right[2] = { 283 gls.right[2] = {
277 highlight = { colors.fg, colors.bg, 'bold' }, 297 highlight = { colors.fg, colors.bg, 'bold' },
278 }, 298 },
279 } 299 }
280 gls.right[8] = { 300 gls.right[8] = {
281 RainbowBlue = { 301 RainbowBlue = {
282 provider = function() return ' ▊' end, 302 provider = function()
303 return ' ▊'
304 end,
283 highlight = { colors.blue, colors.bg }, 305 highlight = { colors.blue, colors.bg },
284 }, 306 },
285 } 307 }
286 308
287 gls.short_line_left[1] = { 309 gls.short_line_left[1] = {
322 344
323 -- Terminal 345 -- Terminal
324 use { 346 use {
325 'akinsho/nvim-toggleterm.lua', 347 'akinsho/nvim-toggleterm.lua',
326 config = function() 348 config = function()
327 require'toggleterm'.setup { 349 require('toggleterm').setup {
328 size = 15, 350 size = 15,
329 open_mapping = [[<F12>]], 351 open_mapping = [[<F12>]],
330 shade_filetypes = { 'none' }, 352 shade_filetypes = { 'none' },
331 shade_terminals = true, 353 shade_terminals = true,
332 persist_size = true, 354 persist_size = true,
335 end, 357 end,
336 } 358 }
337 359
338 -- Filetypes 360 -- Filetypes
339 use { 'Glench/Vim-Jinja2-Syntax' } 361 use { 'Glench/Vim-Jinja2-Syntax' }
340
341 end) 362 end)
342 363
343 -- LSP config 364 -- LSP config
344 local lsp = require 'lspconfig' 365 local lsp = require 'lspconfig'
345 local lsputil = require 'lspconfig.util' 366 local lsputil = require 'lspconfig.util'
346 local null_ls = require'null-ls' 367 local null_ls = require 'null-ls'
347 368
348 local on_attach = function(client) 369 local on_attach = function(client)
349 local nnoremap = vim.keymap.nnoremap 370 local nnoremap = vim.keymap.nnoremap
350 local inoremap = vim.keymap.inoremap 371 local inoremap = vim.keymap.inoremap
351 -- nnoremap { '', require'lspsaga.diagnostic'.show_line_diagnostics, silent = true } 372 -- nnoremap { '', require'lspsaga.diagnostic'.show_line_diagnostics, silent = true }
352 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } 373 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true }
353 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true } 374 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true }
354 nnoremap { 'K', require'lspsaga.hover'.render_hover_doc, silent = true } 375 nnoremap { 'K', require('lspsaga.hover').render_hover_doc, silent = true }
355 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } 376 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true }
356 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } 377 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true }
357 nnoremap { 'gr', vim.lsp.buf.references, silent = true } 378 nnoremap { 'gr', vim.lsp.buf.references, silent = true }
358 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } 379 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true }
359 nnoremap { '<c-p>', function() vim.lsp.buf.formatting_sync({}, 5000) end, silent = true } 380 nnoremap {
381 '<c-p>',
382 function()
383 vim.lsp.buf.formatting_sync({}, 5000)
384 end,
385 silent = true,
386 }
360 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } 387 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true }
361 nnoremap { 'gp', require'goto-preview'.goto_preview_definition, silent = true } 388 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true }
362 nnoremap { 'gP', require'goto-preview'.close_all_win, silent = true } 389 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true }
363 390
364 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } 391 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true }
365 392
366 vim.fn.sign_define('LspDiagnosticsSignError', 393 vim.fn.sign_define(
367 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' }) 394 'LspDiagnosticsSignError',
395 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' }
396 )
368 vim.fn.sign_define('LspDiagnosticsSignWarning', { 397 vim.fn.sign_define('LspDiagnosticsSignWarning', {
369 texthl = 'LspDiagnosticsSignWarning', 398 texthl = 'LspDiagnosticsSignWarning',
370 linehl = '', 399 linehl = '',
371 numhl = '', 400 numhl = '',
372 text = '▎', 401 text = '▎',
375 texthl = 'LspDiagnosticsSignInformation', 404 texthl = 'LspDiagnosticsSignInformation',
376 linehl = '', 405 linehl = '',
377 numhl = '', 406 numhl = '',
378 text = '▎', 407 text = '▎',
379 }) 408 })
380 vim.fn.sign_define('LspDiagnosticsSignHint', 409 vim.fn.sign_define(
381 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' }) 410 'LspDiagnosticsSignHint',
411 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' }
412 )
382 end 413 end
383 414
384 vim.lsp.handlers['textDocument/formatting'] = function(err, _, result, _, bufnr) 415 vim.lsp.handlers['textDocument/formatting'] = function(err, _, result, _, bufnr)
385 if err ~= nil or result == nil then return end 416 if err ~= nil or result == nil then
417 return
418 end
386 if not vim.api.nvim_buf_get_option(bufnr, 'modified') then 419 if not vim.api.nvim_buf_get_option(bufnr, 'modified') then
387 local view = vim.fn.winsaveview() 420 local view = vim.fn.winsaveview()
388 vim.lsp.util.apply_text_edits(result, bufnr) 421 vim.lsp.util.apply_text_edits(result, bufnr)
389 -- Fix to reload Treesitter 422 -- Fix to reload Treesitter
390 -- vim.api.nvim_command("edit") 423 -- vim.api.nvim_command("edit")
391 vim.fn.winrestview(view) 424 vim.fn.winrestview(view)
392 end 425 end
393 end 426 end
394 427
395 vim.lsp.handlers['textDocument/publishDiagnostics'] = 428 vim.lsp.handlers['textDocument/publishDiagnostics'] = function(...)
396 function(...) 429 vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = true, update_in_insert = false })(...)
397 vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, 430 end
398 { underline = true, update_in_insert = false })(...)
399 end
400 431
401 local capabilities = vim.lsp.protocol.make_client_capabilities() 432 local capabilities = vim.lsp.protocol.make_client_capabilities()
402 capabilities.textDocument.completion.completionItem.snippetSupport = true 433 capabilities.textDocument.completion.completionItem.snippetSupport = true
403 capabilities.textDocument.completion.completionItem.resolveSupport = { 434 capabilities.textDocument.completion.completionItem.resolveSupport = {
404 properties = { 435 properties = {
405 'documentation', 436 'documentation',
406 'detail', 437 'detail',
407 'additionalTextEdits', 438 'additionalTextEdits',
408 } 439 },
409 } 440 }
410 441
411 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } 442 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities }
412 443
413 null_ls.setup { 444 null_ls.setup {
418 }, 449 },
419 } 450 }
420 451
421 -- Try importing local config 452 -- Try importing local config
422 local ok, localconfig = pcall(require, 'localconfig') 453 local ok, localconfig = pcall(require, 'localconfig')
423 if ok then localconfig.setup { on_attach = on_attach, capabilities = capabilities } end 454 if ok then
455 localconfig.setup { on_attach = on_attach, capabilities = capabilities }
456 end