Mercurial > dotfiles
annotate dot_config/nvim/init.lua @ 448:d847c4df584b
Remove custom icons from status line
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sat, 04 Sep 2021 11:40:32 +0200 |
parents | aa15d8b06f04 |
children | 10fc275a8914 |
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' } | |
423 | 59 use { |
60 'sjl/splice.vim', | |
61 opt = true, | |
62 cmd = { 'SpliceInit' }, | |
63 config = function() | |
64 vim.g.splice_initial_diff_grid = 1 | |
65 vim.g.splice_initial_diff_compare = 1 | |
66 vim.g.splice_initial_diff_path = 0 | |
67 vim.g.splice_initial_scrollbind_grid = 1 | |
68 vim.g.splice_initial_scrollbind_compare = 1 | |
69 vim.g.splice_initial_scrollbind_path = 1 | |
70 vim.g.splice_wrap = 'nowrap' | |
71 end, | |
72 } | |
427 | 73 use { 'tpope/vim-git', ft = { 'gitcommit', 'gitrebase' } } |
411 | 74 |
75 -- Comments | |
426 | 76 use { |
77 'b3nj5m1n/kommentary', | |
78 config = function() | |
79 require('kommentary.config').configure_language('default', { prefer_single_line_comments = true }) | |
80 end, | |
433
4a539353bd54
Load kommentary on visual selection mappings too
Zeger Van de Vannet <zegervdv@me.com>
parents:
432
diff
changeset
|
81 keys = { |
435
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
82 { 'n', 'gcc' }, |
433
4a539353bd54
Load kommentary on visual selection mappings too
Zeger Van de Vannet <zegervdv@me.com>
parents:
432
diff
changeset
|
83 { 'v', 'gc' }, |
4a539353bd54
Load kommentary on visual selection mappings too
Zeger Van de Vannet <zegervdv@me.com>
parents:
432
diff
changeset
|
84 }, |
426 | 85 } |
411 | 86 |
87 -- Undoing | |
88 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } | |
89 | |
90 -- Parentheses etc | |
91 use { 'tpope/vim-surround' } | |
423 | 92 use { |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
93 'windwp/nvim-autopairs', |
423 | 94 config = function() |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
95 local npairs = require 'nvim-autopairs' |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
96 local Rule = require 'nvim-autopairs.rule' |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
97 |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
98 require('nvim-autopairs.completion.cmp').setup { |
447
aa15d8b06f04
Configure autopairs for cmp
Zeger Van de Vannet <zegervdv@me.com>
parents:
446
diff
changeset
|
99 map_cr = true, -- map <CR> on insert mode |
aa15d8b06f04
Configure autopairs for cmp
Zeger Van de Vannet <zegervdv@me.com>
parents:
446
diff
changeset
|
100 map_complete = true, -- it will auto insert `(` after select function or method item |
aa15d8b06f04
Configure autopairs for cmp
Zeger Van de Vannet <zegervdv@me.com>
parents:
446
diff
changeset
|
101 auto_select = false, -- automatically select the first item |
aa15d8b06f04
Configure autopairs for cmp
Zeger Van de Vannet <zegervdv@me.com>
parents:
446
diff
changeset
|
102 } |
aa15d8b06f04
Configure autopairs for cmp
Zeger Van de Vannet <zegervdv@me.com>
parents:
446
diff
changeset
|
103 |
435
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
104 npairs.setup { |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
105 ignored_next_char = string.gsub([[ [%w%%%'%[%.] ]], '%s+', ''), |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
106 } |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
107 |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
108 npairs.add_rules { |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
109 Rule(' ', ' '):with_pair(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
110 local pair = opts.line:sub(opts.col - 1, opts.col) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
111 return vim.tbl_contains({ '()', '[]', '{}' }, pair) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
112 end), |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
113 Rule('( ', ' )') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
114 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
115 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
116 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
117 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
118 return opts.prev_char:match '.%)' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
119 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
120 :use_key ')', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
121 Rule('{ ', ' }') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
122 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
123 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
124 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
125 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
126 return opts.prev_char:match '.%}' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
127 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
128 :use_key '}', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
129 Rule('[ ', ' ]') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
130 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
131 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
132 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
133 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
134 return opts.prev_char:match '.%]' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
135 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
136 :use_key ']', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
137 } |
432
b6d669b13e1e
Disable ` pairing for systemverilog
Zeger Van de Vannet <zegervdv@me.com>
parents:
430
diff
changeset
|
138 |
435
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
139 npairs.get_rule('`'):with_pair(function() |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
140 return vim.bo.filetype ~= 'systemverilog' |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
141 end) |
438
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
142 |
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
143 npairs.get_rule("'"):with_pair(function() |
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
144 return vim.bo.filetype ~= 'systemverilog' |
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
145 end) |
423 | 146 end, |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
147 after = { 'nvim-cmp' }, |
423 | 148 } |
411 | 149 |
150 -- Moving around within lines | |
151 use { 'wellle/targets.vim', event = 'InsertEnter *' } | |
152 | |
153 -- Searching | |
154 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } | |
155 | |
156 -- Keymaps TODO: to be removed when #13823 is merged | |
157 use { | |
158 'tjdevries/astronauta.nvim', | |
159 config = function() | |
160 require 'astronauta.keymap' | |
161 end, | |
162 } | |
163 | |
164 -- Opening files | |
165 use { 'wsdjeg/vim-fetch' } | |
166 | |
167 -- Indent lines | |
168 use { | |
169 'lukas-reineke/indent-blankline.nvim', | |
170 config = function() | |
171 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
172 vim.g.indent_blankline_show_first_indent_level = false | |
422
24330d37c9e3
Use special char for indentline with no gaps
zegervdv <zegervdv@me.com>
parents:
417
diff
changeset
|
173 vim.g.indent_blankline_char = '│' |
411 | 174 end, |
175 } | |
176 | |
177 -- Increment/decrement | |
178 use { | |
179 'zegervdv/nrpattern.nvim', | |
180 requires = 'tpope/vim-repeat', | |
181 config = function() | |
182 local nrpattern = require 'nrpattern' | |
183 local defaults = require 'nrpattern.default' | |
184 | |
185 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
186 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
187 | |
188 nrpattern.setup(defaults) | |
189 end, | |
190 } | |
191 | |
192 -- Tmux | |
193 use { | |
194 'numtostr/navigator.nvim', | |
195 config = function() | |
196 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
197 | |
198 local nnoremap = vim.keymap.nnoremap | |
199 nnoremap { '<c-h>', require('Navigator').left, silent = true } | |
200 nnoremap { '<c-j>', require('Navigator').down, silent = true } | |
201 nnoremap { '<c-k>', require('Navigator').up, silent = true } | |
202 nnoremap { '<c-l>', require('Navigator').right, silent = true } | |
203 end, | |
204 requires = 'tjdevries/astronauta.nvim', | |
205 after = 'astronauta.nvim', | |
206 } | |
207 | |
208 -- Completion/snippets/LSP | |
209 use { 'neovim/nvim-lspconfig' } | |
210 use { | |
439 | 211 'hrsh7th/nvim-cmp', |
441 | 212 requires = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-path' }, |
411 | 213 config = function() |
439 | 214 local cmp = require 'cmp' |
215 cmp.setup { | |
444
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
216 snippet = { |
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
217 expand = function(args) |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
218 vim.fn['vsnip#anonymous'](args.body) |
444
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
219 end, |
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
220 }, |
439 | 221 mapping = { |
222 ['<C-p>'] = cmp.mapping.select_prev_item(), | |
223 ['<C-n>'] = cmp.mapping.select_next_item(), | |
224 ['<C-d>'] = cmp.mapping.scroll_docs(-4), | |
225 ['<C-f>'] = cmp.mapping.scroll_docs(4), | |
443
7e2e4f89c7bc
Fix mapping for forced completion
zegervdv <zegervdv@me.com>
parents:
442
diff
changeset
|
226 ['<C-y>'] = cmp.mapping.complete(), |
439 | 227 ['<C-e>'] = cmp.mapping.close(), |
228 ['<CR>'] = cmp.mapping.confirm { | |
229 behavior = cmp.ConfirmBehavior.Replace, | |
230 }, | |
231 }, | |
232 sources = { | |
233 { name = 'buffer' }, | |
234 { name = 'nvim_lsp' }, | |
441 | 235 { name = 'vsnip' }, |
236 { name = 'path' }, | |
411 | 237 }, |
238 } | |
239 end, | |
240 } | |
241 use { | |
242 { | |
243 'nvim-treesitter/nvim-treesitter', | |
244 config = function() | |
245 require 'nvim-treesitter.highlight' | |
246 | |
247 require('nvim-treesitter.configs').setup { | |
248 highlight = { enable = false }, | |
249 incremental_selection = { | |
250 enable = true, | |
251 keymaps = { | |
252 init_selection = 'gnn', | |
253 node_incremental = 'grn', | |
254 scope_incremental = 'grc', | |
255 node_decremental = 'grm', | |
256 }, | |
257 }, | |
258 refactor = { | |
259 highlight_definitions = { enable = true }, | |
260 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
261 navigation = { | |
262 enable = true, | |
263 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
264 }, | |
265 }, | |
266 textobjects = { | |
267 move = { | |
268 enable = true, | |
269 goto_next_start = { [']]'] = '@block.outer' }, | |
270 goto_previous_start = { ['[['] = '@block.outer' }, | |
271 goto_next_end = { [']['] = '@block.outer' }, | |
272 goto_previous_end = { ['[]'] = '@block.outer' }, | |
273 }, | |
274 }, | |
275 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
276 } | |
277 end, | |
278 }, | |
279 'nvim-treesitter/nvim-treesitter-refactor', | |
280 'nvim-treesitter/nvim-treesitter-textobjects', | |
281 { 'nvim-treesitter/playground', opt = true }, | |
282 } | |
283 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } | |
284 use { | |
285 'rmagatti/goto-preview', | |
286 config = function() | |
287 require('goto-preview').setup {} | |
288 end, | |
289 } | |
290 use { | |
291 'jose-elias-alvarez/null-ls.nvim', | |
292 requires = 'nvim-lua/plenary.nvim', | |
293 } | |
429
5c72a33ba7d7
Fix lazy loading issues with lua-dev
zegervdv <zegervdv@me.com>
parents:
428
diff
changeset
|
294 use { 'folke/lua-dev.nvim' } |
411 | 295 |
424 | 296 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } } |
297 | |
411 | 298 -- Vanity |
299 use { | |
300 'yamatsum/nvim-web-nonicons', | |
301 requires = 'kyazdani42/nvim-web-devicons', | |
302 config = function() | |
303 require 'nvim-nonicons' | |
304 end, | |
305 } | |
306 | |
307 use { | |
308 'glepnir/galaxyline.nvim', | |
309 branch = 'main', | |
310 -- your statusline | |
311 config = function() | |
312 local gl = require 'galaxyline' | |
313 local colors = require('galaxyline.theme').default | |
314 local condition = require 'galaxyline.condition' | |
315 local gls = gl.section | |
316 | |
317 colors.bg = '#2C323C' | |
318 | |
319 gls.left[1] = { | |
320 RainbowRed = { | |
321 provider = function() | |
322 return '▊ ' | |
323 end, | |
324 highlight = { colors.blue, colors.bg }, | |
325 }, | |
326 } | |
327 | |
328 gls.left[2] = { | |
329 FileName = { | |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
330 provider = function() |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
331 return require('galaxyline.provider_fileinfo').get_current_file_name '⊙' |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
332 end, |
411 | 333 condition = condition.buffer_not_empty, |
334 highlight = { colors.magenta, colors.bg, 'bold' }, | |
335 }, | |
336 } | |
337 | |
338 gls.right[1] = { | |
339 ShowLspClient = { | |
340 provider = 'GetLspClient', | |
341 condition = function() | |
342 local tbl = { ['dashboard'] = true, [''] = true } | |
343 if tbl[vim.bo.filetype] then | |
344 return false | |
345 end | |
346 return true | |
347 end, | |
348 highlight = { colors.green, colors.bg, 'bold' }, | |
349 }, | |
350 } | |
351 | |
352 gls.right[2] = { | |
353 LineInfo = { | |
354 provider = 'LineColumn', | |
355 separator = ' ', | |
356 separator_highlight = { 'NONE', colors.bg }, | |
357 highlight = { colors.fg, colors.bg }, | |
358 }, | |
359 } | |
360 | |
361 gls.right[3] = { | |
362 PerCent = { | |
363 provider = 'LinePercent', | |
364 separator = ' ', | |
365 separator_highlight = { 'NONE', colors.bg }, | |
366 highlight = { colors.fg, colors.bg, 'bold' }, | |
367 }, | |
368 } | |
369 gls.right[8] = { | |
370 RainbowBlue = { | |
371 provider = function() | |
372 return ' ▊' | |
373 end, | |
374 highlight = { colors.blue, colors.bg }, | |
375 }, | |
376 } | |
377 | |
378 gls.short_line_left[1] = { | |
379 BufferType = { | |
380 provider = 'FileTypeName', | |
381 separator = ' ', | |
382 separator_highlight = { 'NONE', colors.bg }, | |
383 highlight = { colors.blue, colors.bg, 'bold' }, | |
384 }, | |
385 } | |
386 | |
387 gls.short_line_left[2] = { | |
388 SFileName = { | |
389 provider = 'SFileName', | |
390 condition = condition.buffer_not_empty, | |
391 highlight = { colors.fg, colors.bg, 'bold' }, | |
392 }, | |
393 } | |
394 | |
395 gls.short_line_right[1] = { | |
396 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, | |
397 } | |
398 end, | |
399 } | |
400 | |
401 -- File navigation | |
402 use { 'justinmk/vim-dirvish' } | |
403 | |
404 -- Colorscheme | |
405 use { | |
406 'zegervdv/one-lush', | |
407 requires = 'rktjmp/lush.nvim', | |
408 config = function() | |
409 require 'lush_theme.one-lush' | |
410 vim.cmd [[ colorscheme one-lush ]] | |
411 end, | |
412 } | |
413 | |
414 -- Terminal | |
415 use { | |
416 'akinsho/nvim-toggleterm.lua', | |
417 config = function() | |
418 require('toggleterm').setup { | |
419 size = 15, | |
420 open_mapping = [[<F12>]], | |
421 shade_filetypes = { 'none' }, | |
422 shade_terminals = true, | |
423 persist_size = true, | |
424 direction = 'horizontal', | |
425 } | |
426 end, | |
427 | 427 keys = { [[<F12>]] }, |
411 | 428 } |
429 | |
430 -- Filetypes | |
416 | 431 use { 'lepture/vim-jinja' } |
411 | 432 end) |
433 end, 0) | |
434 | |
423 | 435 -- Configuration |
436 local opt = vim.opt | |
437 | |
438 opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything | |
439 | |
440 opt.autoread = true -- Read changed files | |
441 opt.hidden = true -- Allow to move away from modified files | |
442 opt.autowriteall = true -- Write changes when losing focus | |
443 | |
444 -- Visuals | |
445 opt.number = true | |
446 opt.relativenumber = true | |
447 opt.scrolloff = 4 | |
448 opt.showcmd = true -- Show incomplete commands while typing | |
449 | |
450 opt.termguicolors = true | |
451 opt.background = 'dark' | |
452 | |
453 opt.showmatch = true -- Highligh matching braces | |
454 | |
455 opt.wrap = true -- Wrap lines | |
456 opt.wrapmargin = 2 -- Stay 2 chars from side | |
457 opt.textwidth = 79 | |
458 opt.colorcolumn = '81' -- Show indication of 81 chars | |
459 opt.linebreak = true -- Smarter wrapping | |
460 opt.breakindent = true -- Indent wrapped lines to same level | |
461 | |
462 opt.fixendofline = true -- Add EOL when missing | |
463 | |
464 opt.expandtab = true -- Add spaces when pressing tab | |
465 opt.tabstop = 2 -- Tab is 2 spaces | |
466 opt.shiftwidth = 2 -- Shift per 2 spaces | |
467 opt.shiftround = true -- Round shifts to allign (1 space + tab = 2 spaces) | |
468 | |
469 -- Searching and substitute | |
470 opt.magic = true -- Enable regexes | |
471 opt.hlsearch = true -- Highlight all matches | |
472 opt.incsearch = true -- Show matches while typing | |
473 opt.ignorecase = true | |
474 opt.smartcase = true -- When search pattern contains cases, be case sensitive | |
475 opt.gdefault = true -- Use global flag for substitute: replace all matches on line | |
476 opt.inccommand = 'nosplit' -- Show live replacements directly in text | |
477 | |
478 opt.autoindent = true | |
479 opt.cindent = true -- C-syntax based indenting | |
480 | |
481 opt.updatetime = 300 -- Faster triggering of CursorHold events | |
482 | |
483 opt.errorbells = false -- Don't you beep to me | |
484 | |
485 opt.history = 1000 -- Remember last commands | |
486 | |
487 opt.wildmenu = true -- Command completion | |
430
5d6bfec9cb5a
Restore old behaviour of wildmenu
zegervdv <zegervdv@me.com>
parents:
429
diff
changeset
|
488 opt.wildmode = 'longest:full,full' |
423 | 489 opt.shortmess:append 'c' -- Hide ins-completion messages |
490 | |
491 opt.ttyfast = true -- fast terminal | |
492 opt.lazyredraw = true | |
493 opt.ttimeoutlen = -1 -- Minimum timeout | |
494 | |
495 opt.diffopt:append 'iwhite' -- Ignore whitespace in diffs | |
496 opt.diffopt:append 'internal' -- Internal diff engine | |
497 opt.diffopt:append 'algorithm:patience' -- Use patience algorithm | |
498 | |
499 opt.tags = { '.git/tags', 'tags' } | |
500 | |
501 opt.path:append '**' -- Recursively search current directory | |
502 | |
503 opt.formatoptions = { | |
504 c = true, -- Wrap comments | |
505 r = true, -- Continue comments | |
506 o = true, -- Insert comment with o/O | |
507 q = true, -- Format comments with gq | |
508 n = true, -- Indent numbered lists | |
509 [2] = true, -- Indent from 2nd line of paragraph | |
510 [1] = true, -- Don't break before one letter words | |
511 } | |
512 | |
513 opt.signcolumn = 'yes' -- Always show signcolumn | |
514 | |
515 opt.cursorline = true | |
516 | |
517 -- Show certain characters | |
518 opt.list = true | |
519 opt.listchars = { trail = '·', extends = '>', precedes = '<', nbsp = '+' } | |
520 | |
521 opt.sessionoptions:remove 'options' -- Remove options from saved sessions (reload from config) | |
522 | |
523 opt.completeopt = { 'menu', 'menuone', 'noselect' } | |
524 | |
525 opt.splitright = true -- Open new splits to right | |
526 opt.virtualedit = 'block' -- Enable block editting | |
527 | |
528 opt.conceallevel = 0 -- Disable conceal | |
529 | |
530 opt.pastetoggle = '<F2>' -- Enable paste mode | |
531 | |
532 opt.undofile = true -- Persistently remember undos | |
533 opt.undolevels = 1000 | |
534 opt.undodir = os.getenv 'HOME' .. '/.config/nvim/tmp/undo//' | |
535 opt.swapfile = false -- Disable swap files | |
536 opt.backup = true -- Keep backups | |
537 opt.backupdir = os.getenv 'HOME' .. '/.config/nvim/tmp/backup//' | |
538 | |
539 -- Files to ignore from completion | |
540 opt.wildignore:append { | |
541 '*/tmp/*', | |
542 '*.so', | |
543 '*.swp', | |
544 '*.zip', | |
545 '*.o', | |
546 '*.bin', | |
547 '*.elf', | |
548 '*.hex', | |
549 '*.eps', | |
550 '.git/*', | |
551 '*.dup', | |
552 '.hg/**', | |
553 '*.orig', | |
554 '*.*~', | |
555 } | |
556 | |
557 opt.mouse = { | |
558 n = true, -- Normal mode | |
559 i = true, -- Insert mode | |
560 c = true, -- Commandline mode | |
561 } | |
562 | |
411 | 563 -- LSP config |
564 local lsp = require 'lspconfig' | |
565 local null_ls = require 'null-ls' | |
566 | |
567 local on_attach = function(client) | |
568 local nnoremap = vim.keymap.nnoremap | |
569 local inoremap = vim.keymap.inoremap | |
570 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } | |
571 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true } | |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
572 nnoremap { |
446
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
573 'g<c-]>', |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
574 function() |
446
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
575 local params = vim.lsp.util.make_position_params() |
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
576 opts = {} |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
577 local results_lsp = vim.lsp.buf_request_sync(0, 'textDocument/definition', params, opts.timeout or 10000) |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
578 if not results_lsp or vim.tbl_isempty(results_lsp) then |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
579 print 'No results from textDocument/definition' |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
580 return |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
581 end |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
582 for _, lsp_data in pairs(results_lsp) do |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
583 if lsp_data ~= nil and lsp_data.result ~= nil and not vim.tbl_isempty(lsp_data.result) then |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
584 for _, value in pairs(lsp_data.result) do |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
585 local range = value.range or value.targetRange |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
586 if range ~= nil then |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
587 local file = value.uri or value.targetUri |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
588 if file ~= nil then |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
589 vim.api.nvim_command [[split]] |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
590 vim.lsp.util.jump_to_location(value) |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
591 return |
446
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
592 end |
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
593 end |
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
594 end |
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
595 end |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
596 end |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
597 -- try to call default lsp function |
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
598 vim.lsp.buf.definition() |
446
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
599 end, |
448
d847c4df584b
Remove custom icons from status line
zegervdv <zegervdv@me.com>
parents:
447
diff
changeset
|
600 silent = true, |
446
9c575d146453
Add mapping to open definition in split
Zeger Van de Vannet <zegervdv@me.com>
parents:
445
diff
changeset
|
601 } |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
602 nnoremap { 'K', vim.lsp.buf.hover, silent = true } |
411 | 603 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } |
604 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
605 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
606 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
607 nnoremap { | |
608 '<c-p>', | |
609 function() | |
610 vim.lsp.buf.formatting_sync({}, 5000) | |
611 end, | |
612 silent = true, | |
613 } | |
614 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } | |
615 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true } | |
616 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true } | |
617 | |
618 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } | |
619 | |
620 vim.fn.sign_define( | |
621 'LspDiagnosticsSignError', | |
622 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' } | |
623 ) | |
624 vim.fn.sign_define('LspDiagnosticsSignWarning', { | |
625 texthl = 'LspDiagnosticsSignWarning', | |
626 linehl = '', | |
627 numhl = '', | |
628 text = '▎', | |
629 }) | |
630 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
631 texthl = 'LspDiagnosticsSignInformation', | |
632 linehl = '', | |
633 numhl = '', | |
634 text = '▎', | |
635 }) | |
636 vim.fn.sign_define( | |
637 'LspDiagnosticsSignHint', | |
638 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' } | |
639 ) | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
640 |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
641 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
|
642 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
|
643 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
|
644 underline = true, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
645 update_in_insert = false, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
646 virtual_text = { severity_limit = 'Warning' }, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
647 }) |
411 | 648 end |
649 | |
650 local capabilities = vim.lsp.protocol.make_client_capabilities() | |
651 capabilities.textDocument.completion.completionItem.snippetSupport = true | |
652 capabilities.textDocument.completion.completionItem.resolveSupport = { | |
653 properties = { | |
654 'documentation', | |
655 'detail', | |
656 'additionalTextEdits', | |
657 }, | |
658 } | |
442
e830ae093010
Add capabilities from cmp_nvim_lsp
zegervdv <zegervdv@me.com>
parents:
441
diff
changeset
|
659 capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) |
411 | 660 |
661 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } | |
662 | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
663 null_ls.config { |
411 | 664 sources = { |
665 null_ls.builtins.formatting.black, | |
666 null_ls.builtins.formatting.stylua, | |
667 }, | |
668 } | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
669 lsp['null-ls'].setup { |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
670 on_attach = on_attach, |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
671 root_dir = require('lspconfig.util').root_pattern('.hg', '.git'), |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
672 } |
411 | 673 |
674 local luadev = require('lua-dev').setup { | |
675 lspconfig = { | |
676 cmd = { 'lua-language-server' }, | |
677 on_attach = on_attach, | |
678 capabilities = capabilities, | |
679 settings = { | |
680 Lua = { | |
681 diagnostics = { | |
682 globals = { 'use' }, | |
683 }, | |
684 }, | |
685 }, | |
686 }, | |
687 } | |
688 | |
689 lsp.sumneko_lua.setup(luadev) | |
690 | |
691 -- Try importing local config | |
692 local ok, localconfig = pcall(require, 'localconfig') | |
693 if ok then | |
694 localconfig.setup { on_attach = on_attach, capabilities = capabilities } | |
695 end |