Mercurial > dotfiles
annotate dot_config/nvim/init.lua @ 415:85832377f39e
Disable compe's built-in lua completion
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 20 Jul 2021 14:27:20 +0200 |
parents | 32f1aecb9d01 |
children | 13bb07f84b83 |
rev | line source |
---|---|
411 | 1 -- |
2 -- Neovim dotfiles | |
3 -- | |
4 -- | |
5 local execute = vim.api.nvim_command | |
6 local fn = vim.fn | |
7 | |
8 -- Bootstrap package manager | |
9 local install_path = fn.stdpath 'data' .. '/site/pack/packer/opt/packer.nvim' | |
10 | |
11 if fn.empty(fn.glob(install_path)) > 0 then | |
12 execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) | |
13 end | |
14 | |
15 vim.defer_fn(function() | |
16 -- Packer configuration is compiled and only needs to be loaded on changes | |
17 vim.cmd 'packadd packer.nvim' | |
18 | |
19 require('packer').startup(function() | |
20 use { 'wbthomason/packer.nvim', opt = true } | |
21 | |
22 -- General plugins | |
23 use { 'tpope/vim-sensible' } | |
24 use { 'tpope/vim-repeat' } | |
25 use { 'tpope/vim-rsi' } | |
26 use { 'sgur/vim-editorconfig' } | |
27 use { 'ShikChen/osc52.vim' } | |
28 use { 'einfachtoll/didyoumean' } | |
29 | |
30 use { 'tpope/vim-obsession' } | |
31 use { | |
32 'tpope/vim-eunuch', | |
33 cmd = { | |
34 'Delete', | |
35 'Unlink', | |
36 'Move', | |
37 'Rename', | |
38 'Mkdir', | |
39 'Chmod', | |
40 'Cfind', | |
41 'Clocate', | |
42 'Lfind', | |
43 'Llocate', | |
44 'SudoEdit', | |
45 'SudoWrite', | |
46 'Wall', | |
47 }, | |
48 } | |
49 | |
50 use { 'psliwka/vim-smoothie' } | |
51 | |
52 use { 'nvim-lua/plenary.nvim' } | |
53 | |
54 -- Spelling/autocorrection | |
55 use { 'tpope/vim-abolish' } | |
56 | |
57 -- Git/VCS | |
58 use { 'vim-scripts/gitignore' } | |
59 use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } } | |
60 use { 'tpope/vim-git' } | |
61 | |
62 -- Comments | |
63 use { 'b3nj5m1n/kommentary' } | |
64 | |
65 -- Undoing | |
66 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } | |
67 | |
68 -- Parentheses etc | |
69 use { 'tpope/vim-surround' } | |
70 use { 'raimondi/delimitMate' } | |
71 | |
72 -- Moving around within lines | |
73 use { 'wellle/targets.vim', event = 'InsertEnter *' } | |
74 | |
75 -- Searching | |
76 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } | |
77 | |
78 -- Keymaps TODO: to be removed when #13823 is merged | |
79 use { | |
80 'tjdevries/astronauta.nvim', | |
81 config = function() | |
82 require 'astronauta.keymap' | |
83 end, | |
84 } | |
85 | |
86 -- Opening files | |
87 use { 'wsdjeg/vim-fetch' } | |
88 | |
89 -- Indent lines | |
90 use { | |
91 'lukas-reineke/indent-blankline.nvim', | |
92 config = function() | |
93 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
94 vim.g.indent_blankline_show_first_indent_level = false | |
95 end, | |
96 } | |
97 | |
98 -- Increment/decrement | |
99 use { | |
100 'zegervdv/nrpattern.nvim', | |
101 requires = 'tpope/vim-repeat', | |
102 config = function() | |
103 local nrpattern = require 'nrpattern' | |
104 local defaults = require 'nrpattern.default' | |
105 | |
106 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
107 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
108 | |
109 nrpattern.setup(defaults) | |
110 end, | |
111 } | |
112 | |
113 -- Tmux | |
114 use { | |
115 'numtostr/navigator.nvim', | |
116 config = function() | |
117 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
118 | |
119 local nnoremap = vim.keymap.nnoremap | |
120 nnoremap { '<c-h>', require('Navigator').left, silent = true } | |
121 nnoremap { '<c-j>', require('Navigator').down, silent = true } | |
122 nnoremap { '<c-k>', require('Navigator').up, silent = true } | |
123 nnoremap { '<c-l>', require('Navigator').right, silent = true } | |
124 end, | |
125 requires = 'tjdevries/astronauta.nvim', | |
126 after = 'astronauta.nvim', | |
127 } | |
128 | |
129 -- Completion/snippets/LSP | |
130 use { 'neovim/nvim-lspconfig' } | |
131 use { | |
132 'hrsh7th/nvim-compe', | |
133 config = function() | |
134 require('compe').setup { | |
135 enabled = true, | |
136 autocomplete = true, | |
137 debug = false, | |
138 min_length = 1, | |
139 preselect = 'enable', | |
140 throttle_time = 80, | |
141 source_timeout = 1000, | |
142 incomplete_delay = 400, | |
143 max_abbr_width = 100, | |
144 max_kind_width = 100, | |
145 max_menu_width = 100, | |
146 documentation = true, | |
147 | |
148 source = { | |
149 path = true, | |
150 buffer = true, | |
151 nvim_lsp = true, | |
415
85832377f39e
Disable compe's built-in lua completion
zegervdv <zegervdv@me.com>
parents:
413
diff
changeset
|
152 nvim_lua = false, |
411 | 153 spell = false, |
154 vsnip = true, | |
155 }, | |
156 } | |
157 | |
158 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] | |
159 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]] | |
160 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] | |
161 end, | |
162 } | |
163 use { | |
164 { | |
165 'nvim-treesitter/nvim-treesitter', | |
166 config = function() | |
167 require 'nvim-treesitter.highlight' | |
168 | |
169 require('nvim-treesitter.configs').setup { | |
170 highlight = { enable = false }, | |
171 incremental_selection = { | |
172 enable = true, | |
173 keymaps = { | |
174 init_selection = 'gnn', | |
175 node_incremental = 'grn', | |
176 scope_incremental = 'grc', | |
177 node_decremental = 'grm', | |
178 }, | |
179 }, | |
180 refactor = { | |
181 highlight_definitions = { enable = true }, | |
182 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
183 navigation = { | |
184 enable = true, | |
185 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
186 }, | |
187 }, | |
188 textobjects = { | |
189 move = { | |
190 enable = true, | |
191 goto_next_start = { [']]'] = '@block.outer' }, | |
192 goto_previous_start = { ['[['] = '@block.outer' }, | |
193 goto_next_end = { [']['] = '@block.outer' }, | |
194 goto_previous_end = { ['[]'] = '@block.outer' }, | |
195 }, | |
196 }, | |
197 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
198 } | |
199 end, | |
200 }, | |
201 'nvim-treesitter/nvim-treesitter-refactor', | |
202 'nvim-treesitter/nvim-treesitter-textobjects', | |
203 { 'nvim-treesitter/playground', opt = true }, | |
204 } | |
205 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } | |
206 use { | |
207 'rmagatti/goto-preview', | |
208 config = function() | |
209 require('goto-preview').setup {} | |
210 end, | |
211 } | |
212 use { | |
213 'jose-elias-alvarez/null-ls.nvim', | |
214 requires = 'nvim-lua/plenary.nvim', | |
215 } | |
216 use { | |
217 'folke/lua-dev.nvim', | |
218 } | |
219 | |
220 -- Vanity | |
221 use { | |
222 'yamatsum/nvim-web-nonicons', | |
223 requires = 'kyazdani42/nvim-web-devicons', | |
224 config = function() | |
225 require 'nvim-nonicons' | |
226 end, | |
227 } | |
228 | |
229 use { | |
230 'glepnir/galaxyline.nvim', | |
231 branch = 'main', | |
232 -- your statusline | |
233 config = function() | |
234 local gl = require 'galaxyline' | |
235 local colors = require('galaxyline.theme').default | |
236 local condition = require 'galaxyline.condition' | |
237 local gls = gl.section | |
238 | |
239 colors.bg = '#2C323C' | |
240 | |
241 gls.left[1] = { | |
242 RainbowRed = { | |
243 provider = function() | |
244 return '▊ ' | |
245 end, | |
246 highlight = { colors.blue, colors.bg }, | |
247 }, | |
248 } | |
249 | |
250 gls.left[2] = { | |
251 FileIcon = { | |
252 provider = 'FileIcon', | |
253 condition = condition.buffer_not_empty, | |
254 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, | |
255 }, | |
256 } | |
257 | |
258 gls.left[3] = { | |
259 FileName = { | |
260 provider = 'FileName', | |
261 condition = condition.buffer_not_empty, | |
262 highlight = { colors.magenta, colors.bg, 'bold' }, | |
263 }, | |
264 } | |
265 | |
266 gls.right[1] = { | |
267 ShowLspClient = { | |
268 provider = 'GetLspClient', | |
269 condition = function() | |
270 local tbl = { ['dashboard'] = true, [''] = true } | |
271 if tbl[vim.bo.filetype] then | |
272 return false | |
273 end | |
274 return true | |
275 end, | |
276 icon = require('nvim-nonicons').get 'server' .. ' LSP:', | |
277 highlight = { colors.green, colors.bg, 'bold' }, | |
278 }, | |
279 } | |
280 | |
281 gls.right[2] = { | |
282 LineInfo = { | |
283 provider = 'LineColumn', | |
284 separator = ' ', | |
285 separator_highlight = { 'NONE', colors.bg }, | |
286 highlight = { colors.fg, colors.bg }, | |
287 }, | |
288 } | |
289 | |
290 gls.right[3] = { | |
291 PerCent = { | |
292 provider = 'LinePercent', | |
293 separator = ' ', | |
294 separator_highlight = { 'NONE', colors.bg }, | |
295 highlight = { colors.fg, colors.bg, 'bold' }, | |
296 }, | |
297 } | |
298 gls.right[8] = { | |
299 RainbowBlue = { | |
300 provider = function() | |
301 return ' ▊' | |
302 end, | |
303 highlight = { colors.blue, colors.bg }, | |
304 }, | |
305 } | |
306 | |
307 gls.short_line_left[1] = { | |
308 BufferType = { | |
309 provider = 'FileTypeName', | |
310 separator = ' ', | |
311 separator_highlight = { 'NONE', colors.bg }, | |
312 highlight = { colors.blue, colors.bg, 'bold' }, | |
313 }, | |
314 } | |
315 | |
316 gls.short_line_left[2] = { | |
317 SFileName = { | |
318 provider = 'SFileName', | |
319 condition = condition.buffer_not_empty, | |
320 highlight = { colors.fg, colors.bg, 'bold' }, | |
321 }, | |
322 } | |
323 | |
324 gls.short_line_right[1] = { | |
325 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, | |
326 } | |
327 end, | |
328 } | |
329 | |
330 -- File navigation | |
331 use { 'justinmk/vim-dirvish' } | |
332 | |
333 -- Colorscheme | |
334 use { | |
335 'zegervdv/one-lush', | |
336 requires = 'rktjmp/lush.nvim', | |
337 config = function() | |
338 require 'lush_theme.one-lush' | |
339 vim.cmd [[ colorscheme one-lush ]] | |
340 end, | |
341 } | |
342 | |
343 -- Terminal | |
344 use { | |
345 'akinsho/nvim-toggleterm.lua', | |
346 config = function() | |
347 require('toggleterm').setup { | |
348 size = 15, | |
349 open_mapping = [[<F12>]], | |
350 shade_filetypes = { 'none' }, | |
351 shade_terminals = true, | |
352 persist_size = true, | |
353 direction = 'horizontal', | |
354 } | |
355 end, | |
356 } | |
357 | |
358 -- Filetypes | |
359 use { 'Glench/Vim-Jinja2-Syntax' } | |
360 end) | |
361 end, 0) | |
362 | |
363 -- LSP config | |
364 local lsp = require 'lspconfig' | |
365 local null_ls = require 'null-ls' | |
366 | |
367 local on_attach = function(client) | |
368 local nnoremap = vim.keymap.nnoremap | |
369 local inoremap = vim.keymap.inoremap | |
370 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } | |
371 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true } | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
372 nnoremap { 'K', vim.lsp.buf.hover, silent = true } |
411 | 373 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } |
374 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
375 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
376 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
377 nnoremap { | |
378 '<c-p>', | |
379 function() | |
380 vim.lsp.buf.formatting_sync({}, 5000) | |
381 end, | |
382 silent = true, | |
383 } | |
384 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } | |
385 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true } | |
386 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true } | |
387 | |
388 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } | |
389 | |
390 vim.fn.sign_define( | |
391 'LspDiagnosticsSignError', | |
392 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' } | |
393 ) | |
394 vim.fn.sign_define('LspDiagnosticsSignWarning', { | |
395 texthl = 'LspDiagnosticsSignWarning', | |
396 linehl = '', | |
397 numhl = '', | |
398 text = '▎', | |
399 }) | |
400 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
401 texthl = 'LspDiagnosticsSignInformation', | |
402 linehl = '', | |
403 numhl = '', | |
404 text = '▎', | |
405 }) | |
406 vim.fn.sign_define( | |
407 'LspDiagnosticsSignHint', | |
408 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' } | |
409 ) | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
410 |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
411 vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
412 vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) |
413
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
413 vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
414 underline = true, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
415 update_in_insert = false, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
416 virtual_text = { severity_limit = 'Warning' }, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
417 }) |
411 | 418 end |
419 | |
420 local capabilities = vim.lsp.protocol.make_client_capabilities() | |
421 capabilities.textDocument.completion.completionItem.snippetSupport = true | |
422 capabilities.textDocument.completion.completionItem.resolveSupport = { | |
423 properties = { | |
424 'documentation', | |
425 'detail', | |
426 'additionalTextEdits', | |
427 }, | |
428 } | |
429 | |
430 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } | |
431 | |
432 null_ls.setup { | |
433 on_attach = on_attach, | |
434 sources = { | |
435 null_ls.builtins.formatting.black, | |
436 null_ls.builtins.formatting.stylua, | |
437 }, | |
438 } | |
439 | |
440 local luadev = require('lua-dev').setup { | |
441 lspconfig = { | |
442 cmd = { 'lua-language-server' }, | |
443 on_attach = on_attach, | |
444 capabilities = capabilities, | |
445 settings = { | |
446 Lua = { | |
447 diagnostics = { | |
448 globals = { 'use' }, | |
449 }, | |
450 }, | |
451 }, | |
452 }, | |
453 } | |
454 | |
455 lsp.sumneko_lua.setup(luadev) | |
456 | |
457 -- Try importing local config | |
458 local ok, localconfig = pcall(require, 'localconfig') | |
459 if ok then | |
460 localconfig.setup { on_attach = on_attach, capabilities = capabilities } | |
461 end |