Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 760:b64652ec91cb
feat: migrate to lazy.nvim plugin manager
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 12 Mar 2023 17:32:18 +0100 |
parents | b9d3378f6c9e |
children | ec5b57266af2 |
comparison
equal
deleted
inserted
replaced
759:5ee8e6af3494 | 760:b64652ec91cb |
---|---|
1 -- | 1 -- |
2 -- Neovim dotfiles | 2 -- Neovim dotfiles |
3 -- | 3 -- |
4 -- | 4 -- |
5 local execute = vim.api.nvim_command | |
6 local fn = vim.fn | |
7 | |
8 local home = os.getenv 'HOME' | 5 local home = os.getenv 'HOME' |
9 if home == nil then home = os.getenv 'USERPROFILE' end | 6 if home == nil then home = os.getenv 'USERPROFILE' end |
10 | 7 |
11 -- Bootstrap package manager | 8 -- Bootstrap lazy |
12 local install_path = fn.stdpath 'data' .. '/site/pack/packer/opt/packer.nvim' | 9 local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' |
13 | 10 if not vim.loop.fs_stat(lazypath) then |
14 if fn.empty(fn.glob(install_path)) > 0 then | 11 vim.fn.system { |
15 execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) | 12 'git', |
13 'clone', | |
14 '--filter=blob:none', | |
15 'https://github.com/folke/lazy.nvim.git', | |
16 '--branch=stable', -- latest stable release | |
17 lazypath, | |
18 } | |
16 end | 19 end |
17 | 20 vim.opt.rtp:prepend(lazypath) |
18 -- Packer configuration is compiled and only needs to be loaded on changes | 21 |
19 vim.cmd.packadd 'packer.nvim' | 22 -- Set leader to space |
20 | 23 vim.g.mapleader = ' ' |
21 local local_plugin = function(name) | 24 |
22 local path = home .. '/Projects/' .. name | 25 require('lazy').setup { |
23 if vim.fn.isdirectory(path) > 0 then | 26 -- General plugins |
24 return path | 27 { 'tpope/vim-sensible' }, |
25 else | 28 { 'tpope/vim-repeat' }, |
26 return 'zegervdv/' .. name | 29 { 'tpope/vim-rsi' }, |
27 end | 30 { 'sgur/vim-editorconfig' }, |
28 end | 31 { |
29 | 32 'ojroques/nvim-osc52', |
30 require('packer').startup { | 33 config = function() |
31 function(use) | 34 require('osc52').setup { trim = true } |
32 use { 'wbthomason/packer.nvim', opt = true } | 35 local copy = function(lines, _) require('osc52').copy(table.concat(lines, '\n')) end |
33 | 36 local paste = function() return { vim.fn.split(vim.fn.getreg '', '\n'), vim.fn.getregtype '' } end |
34 -- General plugins | 37 vim.g.clipboard = { |
35 use { 'tpope/vim-sensible' } | 38 name = 'osc52', |
36 use { 'tpope/vim-repeat' } | 39 copy = { ['+'] = copy, ['*'] = copy }, |
37 use { 'tpope/vim-rsi' } | 40 paste = { ['+'] = paste, ['*'] = paste }, |
38 use { 'sgur/vim-editorconfig' } | 41 } |
39 use { | 42 end, |
40 'ojroques/nvim-osc52', | 43 }, |
44 | |
45 { | |
46 'tpope/vim-eunuch', | |
47 cmd = { | |
48 'Delete', | |
49 'Unlink', | |
50 'Move', | |
51 'Rename', | |
52 'Mkdir', | |
53 'Chmod', | |
54 'Cfind', | |
55 'Clocate', | |
56 'Lfind', | |
57 'Llocate', | |
58 'SudoEdit', | |
59 'SudoWrite', | |
60 'Wall', | |
61 }, | |
62 }, | |
63 | |
64 -- Smooth scrolling | |
65 { | |
66 'karb94/neoscroll.nvim', | |
67 config = function() require('neoscroll').setup {} end, | |
68 }, | |
69 | |
70 -- Faster lua package loading (until 15436 is merged) | |
71 -- { | |
72 -- 'lewis6991/impatient.nvim', | |
73 -- module = { 'impatient' }, | |
74 -- setup = function() require 'impatient' end, | |
75 -- }, | |
76 | |
77 -- Library with lua functions | |
78 { 'nvim-lua/plenary.nvim' }, | |
79 | |
80 -- Spelling/autocorrection | |
81 { 'tpope/vim-abolish' }, | |
82 | |
83 -- Git/VCS | |
84 { 'vim-scripts/gitignore' }, | |
85 | |
86 { 'tpope/vim-git', ft = { 'gitcommit', 'gitrebase' } }, | |
87 { | |
88 'sindrets/diffview.nvim', | |
89 config = function() | |
90 require('diffview').setup { | |
91 use_icons = false, | |
92 icons = { | |
93 folder_closed = '+', | |
94 folder_open = '-', | |
95 }, | |
96 signs = { | |
97 fold_closed = '+', | |
98 fold_open = '-', | |
99 done = '✓', | |
100 }, | |
101 hg_cmd = { 'chg' }, | |
102 view = { | |
103 merge_tool = { | |
104 layout = 'diff4_mixed', | |
105 }, | |
106 }, | |
107 } | |
108 local wk = require 'which-key' | |
109 wk.register { ['<leader>d'] = { name = 'Diffview' } } | |
110 vim.keymap.set('n', '<leader>do', '<cmd>DiffviewOpen<CR>', { desc = 'Open Diffview' }) | |
111 vim.keymap.set('n', '<leader>df', '<cmd>DiffviewFileHistory %<CR>', { desc = 'Show history for current file' }) | |
112 vim.keymap.set('n', '<leader>dh', ':DiffviewFileHistory ', { desc = 'Show history' }) | |
113 vim.keymap.set('n', '<leader>dc', '<cmd>DiffviewClose<CR>', { desc = 'Close Diffview window' }) | |
114 end, | |
115 }, | |
116 | |
117 -- Comments | |
118 { | |
119 'numToStr/Comment.nvim', | |
120 config = function() | |
121 local ft = require 'Comment.ft' | |
122 ft.systemverilog = { '//%s', '/*%s*/' } | |
123 ft.verilog = { '//%s', '/*%s*/' } | |
124 | |
125 require('Comment').setup { | |
126 padding = true, | |
127 sticky = true, | |
128 ignore = '^(%s*)$', | |
129 mappings = { | |
130 basic = true, | |
131 extra = true, | |
132 }, | |
133 } | |
134 end, | |
135 keys = { | |
136 { 'n', 'gc', 'Comment toggle' }, | |
137 { 'n', 'gb', 'Comment Block toggle' }, | |
138 { 'v', 'gc', 'Comment toggle' }, | |
139 { 'v', 'gb', 'Comment block toggle' }, | |
140 }, | |
141 }, | |
142 | |
143 -- Parentheses etc | |
144 { | |
145 'kylechui/nvim-surround', | |
146 config = function() require('nvim-surround').setup() end, | |
147 }, | |
148 { | |
149 'windwp/nvim-autopairs', | |
150 config = function() | |
151 local npairs = require 'nvim-autopairs' | |
152 local Rule = require 'nvim-autopairs.rule' | |
153 | |
154 local cmp = require 'nvim-autopairs.completion.cmp' | |
155 | |
156 require('cmp').event:on('confirm_done', cmp.on_confirm_done()) | |
157 | |
158 npairs.setup { | |
159 ignored_next_char = string.gsub([[ [%w%%%'%[%.] ]], '%s+', ''), | |
160 enable_afterquote = false, | |
161 } | |
162 | |
163 npairs.add_rules { | |
164 Rule(' ', ' '):with_pair(function(opts) | |
165 local pair = opts.line:sub(opts.col - 1, opts.col) | |
166 return vim.tbl_contains({ '()', '[]', '{}' }, pair) | |
167 end), | |
168 Rule('( ', ' )') | |
169 :with_pair(function() return false end) | |
170 :with_move(function(opts) return opts.prev_char:match '.%)' ~= nil end) | |
171 :use_key ')', | |
172 Rule('{ ', ' }') | |
173 :with_pair(function() return false end) | |
174 :with_move(function(opts) return opts.prev_char:match '.%}' ~= nil end) | |
175 :use_key '}', | |
176 Rule('[ ', ' ]') | |
177 :with_pair(function() return false end) | |
178 :with_move(function(opts) return opts.prev_char:match '.%]' ~= nil end) | |
179 :use_key ']', | |
180 } | |
181 | |
182 npairs.get_rule('`'):with_pair(function() return vim.bo.filetype ~= 'systemverilog' end) | |
183 | |
184 npairs.get_rule("'")[1]:with_pair(function() return vim.bo.filetype ~= 'systemverilog' end) | |
185 end, | |
186 }, | |
187 | |
188 -- Moving around within lines | |
189 { 'wellle/targets.vim', event = 'InsertEnter *' }, | |
190 | |
191 -- Search | |
192 -- Opening files | |
193 { 'wsdjeg/vim-fetch' }, | |
194 | |
195 -- session management | |
196 { | |
197 'folke/persistence.nvim', | |
198 event = 'BufReadPre', | |
199 module = 'persistence', | |
200 config = function() require('persistence').setup() end, | |
201 }, | |
202 | |
203 -- Indent lines | |
204 { | |
205 'lukas-reineke/indent-blankline.nvim', | |
206 config = function() | |
207 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
208 vim.g.indent_blankline_show_first_indent_level = false | |
209 vim.g.indent_blankline_char = '│' | |
210 end, | |
211 }, | |
212 | |
213 -- Increment/decrement | |
214 { | |
215 'zegervdv/nrpattern.nvim', | |
216 branch = 'lua', | |
217 dependencies = 'tpope/vim-repeat', | |
218 config = function() | |
219 local nrpattern = require 'nrpattern' | |
220 local defaults = require 'nrpattern.default' | |
221 | |
222 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
223 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
224 | |
225 nrpattern.setup(defaults) | |
226 end, | |
227 }, | |
228 | |
229 -- Tmux | |
230 { | |
231 'numtostr/navigator.nvim', | |
232 config = function() | |
233 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
234 | |
235 local nmap = function(lhs, rhs, opts) return vim.keymap.set('n', lhs, rhs, opts) end | |
236 nmap('<c-h>', require('Navigator').left, { silent = true }) | |
237 nmap('<c-j>', require('Navigator').down, { silent = true }) | |
238 nmap('<c-k>', require('Navigator').up, { silent = true }) | |
239 nmap('<c-l>', require('Navigator').right, { silent = true }) | |
240 end, | |
241 }, | |
242 | |
243 -- Keymap help | |
244 { | |
245 'folke/which-key.nvim', | |
246 config = function() | |
247 require('which-key').setup { | |
248 plugins = { | |
249 spelling = { | |
250 enabled = true, | |
251 suggestions = 20, | |
252 }, | |
253 }, | |
254 triggers = { '<leader>', 'g', '<c-w>', '"', '`', 'z' }, | |
255 } | |
256 end, | |
257 }, | |
258 | |
259 -- Completion/snippets/LSP | |
260 { 'neovim/nvim-lspconfig' }, | |
261 { | |
262 'hrsh7th/nvim-cmp', | |
263 dependencies = { | |
264 'hrsh7th/cmp-buffer', | |
265 'hrsh7th/cmp-nvim-lsp', | |
266 'saadparwaiz1/cmp_luasnip', | |
267 'hrsh7th/cmp-path', | |
268 'hrsh7th/cmp-cmdline', | |
269 'hrsh7th/cmp-nvim-lsp-signature-help', | |
270 }, | |
271 config = function() | |
272 local cmp = require 'cmp' | |
273 local luasnip = require 'luasnip' | |
274 | |
275 local has_words_before = function() | |
276 local line, col = unpack(vim.api.nvim_win_get_cursor(0)) | |
277 return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil | |
278 end | |
279 | |
280 cmp.setup { | |
281 snippet = { | |
282 expand = function(args) luasnip.lsp_expand(args.body) end, | |
283 }, | |
284 mapping = { | |
285 ['<C-p>'] = { i = cmp.mapping.select_prev_item() }, | |
286 ['<C-n>'] = { i = cmp.mapping.select_next_item() }, | |
287 ['<C-d>'] = { i = cmp.mapping.scroll_docs(-4) }, | |
288 ['<C-y>'] = { i = cmp.mapping.complete() }, | |
289 ['<C-e>'] = { i = cmp.mapping.close() }, | |
290 ['<CR>'] = { i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace } }, | |
291 ['<C-k>'] = { i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace } }, | |
292 }, | |
293 sources = { | |
294 { name = 'nvim_lsp' }, | |
295 { name = 'nvim_lsp_signature_help' }, | |
296 { name = 'buffer', keyword_length = 5 }, | |
297 { name = 'luasnip' }, | |
298 { name = 'path' }, | |
299 }, | |
300 experimental = { | |
301 native_menu = false, | |
302 ghost_text = true, | |
303 }, | |
304 } | |
305 | |
306 cmp.setup.cmdline(':', { | |
307 mapping = cmp.mapping.preset.cmdline { | |
308 ['<C-p>'] = { c = cmp.mapping.select_prev_item() }, | |
309 ['<C-n>'] = { c = cmp.mapping.select_next_item() }, | |
310 ['<C-y>'] = { c = cmp.mapping.complete() }, | |
311 }, | |
312 sources = cmp.config.sources({ | |
313 { name = 'path' }, | |
314 }, { | |
315 { name = 'cmdline', keyword_length = 4 }, | |
316 }), | |
317 }) | |
318 end, | |
319 }, | |
320 { | |
321 { | |
322 'nvim-treesitter/nvim-treesitter', | |
41 config = function() | 323 config = function() |
42 require('osc52').setup { trim = true } | 324 require 'nvim-treesitter.highlight' |
43 local copy = function(lines, _) require('osc52').copy(table.concat(lines, '\n')) end | 325 |
44 local paste = function() return { vim.fn.split(vim.fn.getreg '', '\n'), vim.fn.getregtype '' } end | 326 require('nvim-treesitter.configs').setup { |
45 vim.g.clipboard = { | 327 ensure_installed = { |
46 name = 'osc52', | 328 'python', |
47 copy = { ['+'] = copy, ['*'] = copy }, | 329 'lua', |
48 paste = { ['+'] = paste, ['*'] = paste }, | 330 'verilog', |
331 'json', | |
332 'yaml', | |
333 'bash', | |
334 'dockerfile', | |
335 'c', | |
336 'cpp', | |
337 'regex', | |
338 'markdown', | |
339 'rst', | |
340 'beancount', | |
341 }, | |
342 indent = { | |
343 enable = false, | |
344 }, | |
345 highlight = { | |
346 enable = true, | |
347 disable = { 'systemverilog', 'verilog' }, | |
348 }, | |
349 incremental_selection = { | |
350 enable = true, | |
351 keymaps = { | |
352 init_selection = 'gnn', | |
353 node_incremental = 'grn', | |
354 scope_incremental = 'grc', | |
355 node_decremental = 'grm', | |
356 }, | |
357 }, | |
358 refactor = { | |
359 highlight_definitions = { enable = true }, | |
360 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
361 navigation = { | |
362 enable = true, | |
363 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
364 }, | |
365 }, | |
366 textobjects = { | |
367 move = { | |
368 enable = true, | |
369 goto_next_start = { [']]'] = '@block.outer' }, | |
370 goto_previous_start = { ['[['] = '@block.outer' }, | |
371 goto_next_end = { [']['] = '@block.outer' }, | |
372 goto_previous_end = { ['[]'] = '@block.outer' }, | |
373 }, | |
374 select = { | |
375 enable = true, | |
376 lookahead = true, | |
377 keymaps = { | |
378 ['af'] = '@function.outer', | |
379 ['if'] = '@function.inner', | |
380 ['ab'] = '@block.outer', | |
381 ['ib'] = '@block.inner', | |
382 }, | |
383 }, | |
384 }, | |
385 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
49 } | 386 } |
50 end, | 387 end, |
51 } | 388 }, |
52 | 389 'nvim-treesitter/nvim-treesitter-refactor', |
53 use { | 390 'nvim-treesitter/nvim-treesitter-textobjects', |
54 'tpope/vim-eunuch', | 391 { 'nvim-treesitter/playground' }, |
55 cmd = { | 392 }, |
56 'Delete', | 393 { 'L3MON4D3/luasnip' }, |
57 'Unlink', | 394 { |
58 'Move', | 395 'rmagatti/goto-preview', |
59 'Rename', | 396 config = function() require('goto-preview').setup {} end, |
60 'Mkdir', | 397 }, |
61 'Chmod', | 398 { |
62 'Cfind', | 399 'jose-elias-alvarez/null-ls.nvim', |
63 'Clocate', | 400 dependencies = 'nvim-lua/plenary.nvim', |
64 'Lfind', | 401 }, |
65 'Llocate', | 402 { 'folke/neodev.nvim', version = '2.5.x' }, |
66 'SudoEdit', | 403 { |
67 'SudoWrite', | 404 'smjonas/inc-rename.nvim', |
68 'Wall', | 405 config = function() |
69 }, | 406 require('inc_rename').setup { |
70 } | 407 post_hook = function(result) |
71 | 408 local changed = {} |
72 -- Smooth scrolling | 409 for uri, changes in pairs(result.changes or result.documentChanges) do |
73 use { | 410 local bufnr = vim.uri_to_bufnr(uri) |
74 'karb94/neoscroll.nvim', | 411 for _, edits in ipairs(changes) do |
75 config = function() require('neoscroll').setup {} end, | 412 table.insert(changed, { |
76 } | 413 bufnr = bufnr, |
77 | 414 lnum = edits.range.start.line + 1, |
78 -- Faster lua package loading (until 15436 is merged) | 415 col = edits.range.start.character + 1, |
79 use { | 416 text = vim.api.nvim_buf_get_lines(bufnr, edits.range.start.line, edits.range.start.line + 1, false)[1], |
80 'lewis6991/impatient.nvim', | 417 }) |
81 module = { 'impatient' }, | 418 end |
82 setup = function() require 'impatient' end, | 419 end |
83 } | 420 vim.fn.setqflist(changed, 'r') |
84 | |
85 -- Library with lua functions | |
86 use { 'nvim-lua/plenary.nvim' } | |
87 | |
88 -- Spelling/autocorrection | |
89 use { 'tpope/vim-abolish' } | |
90 | |
91 -- Git/VCS | |
92 use { 'vim-scripts/gitignore' } | |
93 use { | |
94 'zegervdv/settle.nvim', | |
95 opt = true, | |
96 cmd = { 'SettleInit' }, | |
97 config = function() | |
98 require('settle').setup { | |
99 wrap = true, | |
100 symbol = '▊', | |
101 pre_hook = function() | |
102 -- disable dirvish | |
103 vim.api.nvim_del_keymap('n', '-') | |
104 end, | |
105 } | |
106 end, | |
107 } | |
108 use { 'tpope/vim-git', ft = { 'gitcommit', 'gitrebase' } } | |
109 use { | |
110 local_plugin 'diffview.nvim', | |
111 config = function() | |
112 require('diffview').setup { | |
113 use_icons = false, | |
114 icons = { | |
115 folder_closed = '+', | |
116 folder_open = '-', | |
117 }, | |
118 signs = { | |
119 fold_closed = '+', | |
120 fold_open = '-', | |
121 done = '✓', | |
122 }, | |
123 hg_cmd = { 'chg' }, | |
124 view = { | |
125 merge_tool = { | |
126 layout = 'diff4_mixed', | |
127 }, | |
128 }, | |
129 } | |
130 local wk = require 'which-key' | |
131 wk.register { ['<leader>d'] = { name = 'Diffview' } } | |
132 vim.keymap.set('n', '<leader>do', '<cmd>DiffviewOpen<CR>', { desc = 'Open Diffview' }) | |
133 vim.keymap.set('n', '<leader>df', '<cmd>DiffviewFileHistory %<CR>', { desc = 'Show history for current file' }) | |
134 vim.keymap.set('n', '<leader>dh', ':DiffviewFileHistory ', { desc = 'Show history' }) | |
135 vim.keymap.set('n', '<leader>dc', '<cmd>DiffviewClose<CR>', { desc = 'Close Diffview window' }) | |
136 end, | |
137 } | |
138 | |
139 -- Comments | |
140 use { | |
141 'numToStr/Comment.nvim', | |
142 config = function() | |
143 local ft = require 'Comment.ft' | |
144 ft.systemverilog = { '//%s', '/*%s*/' } | |
145 ft.verilog = { '//%s', '/*%s*/' } | |
146 | |
147 require('Comment').setup { | |
148 padding = true, | |
149 sticky = true, | |
150 ignore = '^(%s*)$', | |
151 mappings = { | |
152 basic = true, | |
153 extra = true, | |
154 }, | |
155 } | |
156 end, | |
157 keys = { | |
158 { 'n', 'gc', 'Comment toggle' }, | |
159 { 'n', 'gb', 'Comment Block toggle' }, | |
160 { 'v', 'gc', 'Comment toggle' }, | |
161 { 'v', 'gb', 'Comment block toggle' }, | |
162 }, | |
163 } | |
164 | |
165 -- Parentheses etc | |
166 use { 'kylechui/nvim-surround', config = function() require('nvim-surround').setup() end } | |
167 use { | |
168 'windwp/nvim-autopairs', | |
169 config = function() | |
170 local npairs = require 'nvim-autopairs' | |
171 local Rule = require 'nvim-autopairs.rule' | |
172 | |
173 local cmp = require 'nvim-autopairs.completion.cmp' | |
174 | |
175 require('cmp').event:on('confirm_done', cmp.on_confirm_done()) | |
176 | |
177 npairs.setup { | |
178 ignored_next_char = string.gsub([[ [%w%%%'%[%.] ]], '%s+', ''), | |
179 enable_afterquote = false, | |
180 } | |
181 | |
182 npairs.add_rules { | |
183 Rule(' ', ' '):with_pair(function(opts) | |
184 local pair = opts.line:sub(opts.col - 1, opts.col) | |
185 return vim.tbl_contains({ '()', '[]', '{}' }, pair) | |
186 end), | |
187 Rule('( ', ' )') | |
188 :with_pair(function() return false end) | |
189 :with_move(function(opts) return opts.prev_char:match '.%)' ~= nil end) | |
190 :use_key ')', | |
191 Rule('{ ', ' }') | |
192 :with_pair(function() return false end) | |
193 :with_move(function(opts) return opts.prev_char:match '.%}' ~= nil end) | |
194 :use_key '}', | |
195 Rule('[ ', ' ]') | |
196 :with_pair(function() return false end) | |
197 :with_move(function(opts) return opts.prev_char:match '.%]' ~= nil end) | |
198 :use_key ']', | |
199 } | |
200 | |
201 npairs.get_rule('`'):with_pair(function() return vim.bo.filetype ~= 'systemverilog' end) | |
202 | |
203 npairs.get_rule("'")[1]:with_pair(function() return vim.bo.filetype ~= 'systemverilog' end) | |
204 end, | |
205 after = { 'nvim-cmp' }, | |
206 } | |
207 | |
208 -- Moving around within lines | |
209 use { 'wellle/targets.vim', event = 'InsertEnter *' } | |
210 | |
211 -- Search | |
212 -- Opening files | |
213 use { 'wsdjeg/vim-fetch' } | |
214 | |
215 -- session management | |
216 use { | |
217 'folke/persistence.nvim', | |
218 event = 'BufReadPre', | |
219 module = 'persistence', | |
220 config = function() require('persistence').setup() end, | |
221 } | |
222 | |
223 -- Indent lines | |
224 use { | |
225 'lukas-reineke/indent-blankline.nvim', | |
226 config = function() | |
227 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
228 vim.g.indent_blankline_show_first_indent_level = false | |
229 vim.g.indent_blankline_char = '│' | |
230 end, | |
231 } | |
232 | |
233 -- Increment/decrement | |
234 use { | |
235 'zegervdv/nrpattern.nvim', | |
236 branch = 'lua', | |
237 requires = 'tpope/vim-repeat', | |
238 config = function() | |
239 local nrpattern = require 'nrpattern' | |
240 local defaults = require 'nrpattern.default' | |
241 | |
242 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
243 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
244 | |
245 nrpattern.setup(defaults) | |
246 end, | |
247 } | |
248 | |
249 -- Tmux | |
250 use { | |
251 'numtostr/navigator.nvim', | |
252 config = function() | |
253 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
254 | |
255 local nmap = function(lhs, rhs, opts) return vim.keymap.set('n', lhs, rhs, opts) end | |
256 nmap('<c-h>', require('Navigator').left, { silent = true }) | |
257 nmap('<c-j>', require('Navigator').down, { silent = true }) | |
258 nmap('<c-k>', require('Navigator').up, { silent = true }) | |
259 nmap('<c-l>', require('Navigator').right, { silent = true }) | |
260 end, | |
261 } | |
262 | |
263 -- Keymap help | |
264 use { | |
265 'folke/which-key.nvim', | |
266 config = function() | |
267 require('which-key').setup { | |
268 plugins = { | |
269 spelling = { | |
270 enabled = true, | |
271 suggestions = 20, | |
272 }, | |
273 }, | |
274 triggers = { '<leader>', 'g', '<c-w>', '"', '`', 'z' }, | |
275 } | |
276 end, | |
277 } | |
278 | |
279 -- Completion/snippets/LSP | |
280 use { 'neovim/nvim-lspconfig' } | |
281 use { | |
282 'hrsh7th/nvim-cmp', | |
283 requires = { | |
284 'hrsh7th/cmp-buffer', | |
285 'hrsh7th/cmp-nvim-lsp', | |
286 'saadparwaiz1/cmp_luasnip', | |
287 'hrsh7th/cmp-path', | |
288 'hrsh7th/cmp-cmdline', | |
289 'hrsh7th/cmp-nvim-lsp-signature-help', | |
290 }, | |
291 config = function() | |
292 local cmp = require 'cmp' | |
293 local luasnip = require 'luasnip' | |
294 | |
295 local has_words_before = function() | |
296 local line, col = unpack(vim.api.nvim_win_get_cursor(0)) | |
297 return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil | |
298 end | |
299 | |
300 cmp.setup { | |
301 snippet = { | |
302 expand = function(args) luasnip.lsp_expand(args.body) end, | |
303 }, | |
304 mapping = { | |
305 ['<C-p>'] = { i = cmp.mapping.select_prev_item() }, | |
306 ['<C-n>'] = { i = cmp.mapping.select_next_item() }, | |
307 ['<C-d>'] = { i = cmp.mapping.scroll_docs(-4) }, | |
308 ['<C-y>'] = { i = cmp.mapping.complete() }, | |
309 ['<C-e>'] = { i = cmp.mapping.close() }, | |
310 ['<CR>'] = { i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace } }, | |
311 ['<C-k>'] = { i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace } }, | |
312 }, | |
313 sources = { | |
314 { name = 'nvim_lsp' }, | |
315 { name = 'nvim_lsp_signature_help' }, | |
316 { name = 'buffer', keyword_length = 5 }, | |
317 { name = 'luasnip' }, | |
318 { name = 'path' }, | |
319 }, | |
320 experimental = { | |
321 native_menu = false, | |
322 ghost_text = true, | |
323 }, | |
324 } | |
325 | |
326 cmp.setup.cmdline(':', { | |
327 mapping = cmp.mapping.preset.cmdline { | |
328 ['<C-p>'] = { c = cmp.mapping.select_prev_item() }, | |
329 ['<C-n>'] = { c = cmp.mapping.select_next_item() }, | |
330 ['<C-y>'] = { c = cmp.mapping.complete() }, | |
331 }, | |
332 sources = cmp.config.sources({ | |
333 { name = 'path' }, | |
334 }, { | |
335 { name = 'cmdline', keyword_length = 4 }, | |
336 }), | |
337 }) | |
338 end, | |
339 after = 'luasnip', | |
340 } | |
341 use { | |
342 { | |
343 'nvim-treesitter/nvim-treesitter', | |
344 run = ':TSUpdate', | |
345 config = function() | |
346 require 'nvim-treesitter.highlight' | |
347 | |
348 require('nvim-treesitter.configs').setup { | |
349 ensure_installed = { | |
350 'python', | |
351 'lua', | |
352 'verilog', | |
353 'json', | |
354 'yaml', | |
355 'bash', | |
356 'dockerfile', | |
357 'c', | |
358 'cpp', | |
359 'regex', | |
360 'markdown', | |
361 'rst', | |
362 'beancount', | |
363 }, | |
364 indent = { | |
365 enable = false, | |
366 }, | |
367 highlight = { | |
368 enable = true, | |
369 disable = { 'systemverilog', 'verilog' }, | |
370 }, | |
371 incremental_selection = { | |
372 enable = true, | |
373 keymaps = { | |
374 init_selection = 'gnn', | |
375 node_incremental = 'grn', | |
376 scope_incremental = 'grc', | |
377 node_decremental = 'grm', | |
378 }, | |
379 }, | |
380 refactor = { | |
381 highlight_definitions = { enable = true }, | |
382 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
383 navigation = { | |
384 enable = true, | |
385 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
386 }, | |
387 }, | |
388 textobjects = { | |
389 move = { | |
390 enable = true, | |
391 goto_next_start = { [']]'] = '@block.outer' }, | |
392 goto_previous_start = { ['[['] = '@block.outer' }, | |
393 goto_next_end = { [']['] = '@block.outer' }, | |
394 goto_previous_end = { ['[]'] = '@block.outer' }, | |
395 }, | |
396 select = { | |
397 enable = true, | |
398 lookahead = true, | |
399 keymaps = { | |
400 ['af'] = '@function.outer', | |
401 ['if'] = '@function.inner', | |
402 ['ab'] = '@block.outer', | |
403 ['ib'] = '@block.inner', | |
404 }, | |
405 }, | |
406 }, | |
407 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
408 } | |
409 end, | 421 end, |
410 }, | 422 } |
411 'nvim-treesitter/nvim-treesitter-refactor', | 423 end, |
412 'nvim-treesitter/nvim-treesitter-textobjects', | 424 }, |
413 { 'nvim-treesitter/playground', opt = true }, | 425 { |
414 } | 426 'joechrisellis/lsp-format-modifications.nvim', |
415 use { 'L3MON4D3/luasnip' } | 427 dependencies = { 'nvim-lua/plenary.nvim' }, |
416 use { | 428 }, |
417 'rmagatti/goto-preview', | 429 { |
418 config = function() require('goto-preview').setup {} end, | 430 'vigoux/notifier.nvim', |
419 } | 431 config = function() require('notifier').setup { status_width = 70 } end, |
420 use { | 432 }, |
421 'jose-elias-alvarez/null-ls.nvim', | 433 |
422 requires = 'nvim-lua/plenary.nvim', | 434 { |
423 } | 435 'ThePrimeagen/refactoring.nvim', |
424 use { 'folke/neodev.nvim' } | 436 dependencies = { |
425 use { | 437 'nvim-lua/plenary.nvim', |
426 'smjonas/inc-rename.nvim', | 438 'nvim-treesitter/nvim-treesitter', |
427 config = function() | 439 }, |
428 require('inc_rename').setup { | 440 config = function() |
429 post_hook = function(result) | 441 local refactoring = require 'refactoring' |
430 local changed = {} | 442 local wk = require 'which-key' |
431 for uri, changes in pairs(result.changes or result.documentChanges) do | 443 |
432 local bufnr = vim.uri_to_bufnr(uri) | 444 refactoring.setup {} |
433 for _, edits in ipairs(changes) do | 445 |
434 table.insert(changed, { | 446 wk.register { ['<leader>r'] = { name = 'Refactoring' } } |
435 bufnr = bufnr, | 447 |
436 lnum = edits.range.start.line + 1, | 448 local maps = { |
437 col = edits.range.start.character + 1, | 449 { mode = 'v', key = 'e', name = 'Extract Function' }, |
438 text = vim.api.nvim_buf_get_lines(bufnr, edits.range.start.line, edits.range.start.line + 1, false)[1], | 450 { mode = 'v', key = 'f', name = 'Extract Function To File' }, |
439 }) | 451 { mode = 'v', key = 'v', name = 'Extract Variable' }, |
440 end | 452 { mode = 'v', key = 'i', name = 'Inline Variable' }, |
441 end | 453 { mode = 'n', key = 'b', name = 'Extract Block' }, |
442 vim.fn.setqflist(changed, 'r') | 454 { mode = 'n', key = 'bf', name = 'Extract Block To File' }, |
443 end, | 455 { mode = 'n', key = 'i', name = 'Inline Variable' }, |
444 } | 456 } |
445 end, | 457 for _, map in ipairs(maps) do |
446 } | |
447 use { | |
448 'joechrisellis/lsp-format-modifications.nvim', | |
449 requires = { 'nvim-lua/plenary.nvim' }, | |
450 } | |
451 use { | |
452 'vigoux/notifier.nvim', | |
453 config = function() require('notifier').setup { status_width = 70 } end, | |
454 } | |
455 use { | |
456 'https://git.sr.ht/~whynothugo/lsp_lines.nvim', | |
457 disable = true, | |
458 config = function() | |
459 require('lsp_lines').setup() | |
460 vim.diagnostic.config { virtual_lines = false, virtual_text = false } | |
461 vim.keymap.set( | 458 vim.keymap.set( |
462 'n', | 459 map.mode, |
463 'g?', | 460 '<leader>r' .. map.key, |
464 function() require('lsp_lines').toggle() end, | 461 function() refactoring.refactor(map.name) end, |
465 { desc = 'Toggle LSP diagnostic lines' } | 462 { desc = map.name, silent = true, expr = false } |
466 ) | 463 ) |
467 end, | 464 end |
468 } | 465 vim.keymap.set( |
469 | 466 'n', |
470 use { | 467 '<leader>rpp', |
471 'ThePrimeagen/refactoring.nvim', | 468 function() refactoring.debug.printf { below = false } end, |
472 after = 'which-key.nvim', | 469 { desc = 'Add debug print statement', silent = true } |
473 requires = { | 470 ) |
474 'nvim-lua/plenary.nvim', | 471 vim.keymap.set( |
475 'nvim-treesitter/nvim-treesitter', | 472 'n', |
476 }, | 473 '<leader>rpv', |
477 config = function() | 474 function() refactoring.debug.print_var { normal = true } end, |
478 local refactoring = require 'refactoring' | 475 { desc = 'Print variable', silent = true } |
479 local wk = require 'which-key' | 476 ) |
480 | 477 vim.keymap.set( |
481 refactoring.setup {} | 478 'v', |
482 | 479 '<leader>rpv', |
483 wk.register { ['<leader>r'] = { name = 'Refactoring' } } | 480 function() refactoring.debug.print_var() end, |
484 | 481 { desc = 'Print variable', silent = true } |
485 local maps = { | 482 ) |
486 { mode = 'v', key = 'e', name = 'Extract Function' }, | 483 vim.keymap.set( |
487 { mode = 'v', key = 'f', name = 'Extract Function To File' }, | 484 'n', |
488 { mode = 'v', key = 'v', name = 'Extract Variable' }, | 485 '<leader>rpc', |
489 { mode = 'v', key = 'i', name = 'Inline Variable' }, | 486 function() refactoring.debug.cleanup {} end, |
490 { mode = 'n', key = 'b', name = 'Extract Block' }, | 487 { desc = 'Clean up debug prints', silent = true } |
491 { mode = 'n', key = 'bf', name = 'Extract Block To File' }, | 488 ) |
492 { mode = 'n', key = 'i', name = 'Inline Variable' }, | 489 end, |
493 } | 490 }, |
494 for _, map in ipairs(maps) do | 491 |
495 vim.keymap.set( | 492 { |
496 map.mode, | 493 'ibhagwan/fzf-lua', |
497 '<leader>r' .. map.key, | 494 config = function() |
498 function() refactoring.refactor(map.name) end, | 495 local fzf = require 'fzf-lua' |
499 { desc = map.name, silent = true, expr = false } | 496 fzf.setup { |
500 ) | 497 winopts = { |
501 end | 498 border = 'single', |
502 vim.keymap.set( | 499 }, |
503 'n', | 500 } |
504 '<leader>rpp', | 501 fzf.register_ui_select() |
505 function() refactoring.debug.printf { below = false } end, | 502 |
506 { desc = 'Add debug print statement', silent = true } | 503 local grep_opts = function(pattern) |
507 ) | 504 local utils = require 'fzf-lua.utils' |
508 vim.keymap.set( | 505 local config = require 'fzf-lua.config' |
509 'n', | 506 |
510 '<leader>rpv', | 507 local args = utils.input 'rg opts> ' |
511 function() refactoring.debug.print_var { normal = true } end, | 508 local rg_opts = config.globals.grep.rg_opts .. ' ' .. args |
512 { desc = 'Print variable', silent = true } | 509 local opts = config.normalize_opts({ rg_opts = rg_opts }, config.globals.grep) |
513 ) | 510 |
514 vim.keymap.set( | 511 opts.search = pattern |
515 'v', | 512 fzf.live_grep(opts) |
516 '<leader>rpv', | 513 end |
517 function() refactoring.debug.print_var() end, | 514 local get_selected_word = function() |
518 { desc = 'Print variable', silent = true } | 515 local start_pos = vim.fn.getpos "'[" |
519 ) | 516 local end_pos = vim.fn.getpos "']" |
520 vim.keymap.set( | 517 local start_line = math.min(start_pos[2], end_pos[2]) - 1 |
521 'n', | 518 local end_line = math.max(start_pos[2], end_pos[2]) |
522 '<leader>rpc', | 519 local start_col = math.min(start_pos[3], end_pos[3]) |
523 function() refactoring.debug.cleanup {} end, | 520 local end_col = math.max(start_pos[3], end_pos[3]) |
524 { desc = 'Clean up debug prints', silent = true } | 521 |
525 ) | 522 local line = vim.api.nvim_buf_get_lines(0, start_line, end_line, true) |
526 end, | 523 return line[1]:sub(start_col, end_col) |
527 } | 524 end |
528 | 525 |
529 use { | 526 vim.keymap.set({ 'n' }, '<leader>fg', function() grep_opts() end, { desc = 'Live grep prompting for options' }) |
530 'ibhagwan/fzf-lua', | 527 vim.keymap.set({ 'n' }, '<leader>ff', function() fzf.files() end, { desc = 'Search for files' }) |
531 config = function() | 528 |
532 local fzf = require 'fzf-lua' | 529 function _G.__live_grep(motion) |
533 fzf.setup { | 530 local word = get_selected_word() |
534 winopts = { | 531 fzf.live_grep { search = word } |
535 border = 'single', | 532 end |
536 }, | 533 |
537 } | 534 vim.keymap.set({ 'x', 'n' }, 'gs', function() |
538 fzf.register_ui_select() | 535 vim.o.operatorfunc = 'v:lua.__live_grep' |
539 | 536 return 'g@' |
540 local grep_opts = function(pattern) | 537 end, { expr = true, desc = 'Live grep for word' }) |
541 local utils = require 'fzf-lua.utils' | 538 |
542 local config = require 'fzf-lua.config' | 539 function _G.__live_grep_opts(motion) |
543 | 540 local word = get_selected_word() |
544 local args = utils.input 'rg opts> ' | 541 grep_opts(word) |
545 local rg_opts = config.globals.grep.rg_opts .. ' ' .. args | 542 end |
546 local opts = config.normalize_opts({ rg_opts = rg_opts }, config.globals.grep) | 543 |
547 | 544 vim.keymap.set({ 'x', 'n' }, 'gt', function() |
548 opts.search = pattern | 545 vim.o.operatorfunc = 'v:lua.__live_grep_opts' |
549 fzf.live_grep(opts) | 546 return 'g@' |
550 end | 547 end, { expr = true, desc = 'Live grep for word with options' }) |
551 local get_selected_word = function() | 548 end, |
552 local start_pos = vim.fn.getpos "'[" | 549 }, |
553 local end_pos = vim.fn.getpos "']" | 550 |
554 local start_line = math.min(start_pos[2], end_pos[2]) - 1 | 551 { 'vimjas/vim-python-pep8-indent', ft = { 'python' } }, |
555 local end_line = math.max(start_pos[2], end_pos[2]) | 552 |
556 local start_col = math.min(start_pos[3], end_pos[3]) | 553 { |
557 local end_col = math.max(start_pos[3], end_pos[3]) | 554 'rebelot/heirline.nvim', |
558 | 555 config = function() |
559 local line = vim.api.nvim_buf_get_lines(0, start_line, end_line, true) | 556 local utils = require 'heirline.utils' |
560 return line[1]:sub(start_col, end_col) | 557 local conditions = require 'heirline.conditions' |
561 end | 558 |
562 | 559 local colors |
563 vim.keymap.set({ 'n' }, '<leader>fg', function() grep_opts() end, { desc = 'Live grep prompting for options' }) | 560 if os.getenv 'DARKMODE' then |
564 vim.keymap.set({ 'n' }, '<leader>ff', function() fzf.files() end, { desc = 'Search for files' }) | 561 colors = require('catppuccin.palettes').get_palette 'macchiato' |
565 | 562 else |
566 function _G.__live_grep(motion) | 563 colors = require('tutti-colori.colors').setup() |
567 local word = get_selected_word() | 564 end |
568 fzf.live_grep { search = word } | 565 |
569 end | 566 colors.diag_warn = utils.get_highlight('DiagnosticSignWarn').fg |
570 | 567 colors.diag_error = utils.get_highlight('DiagnosticSignError').fg |
571 vim.keymap.set({ 'x', 'n' }, 'gs', function() | 568 |
572 vim.o.operatorfunc = 'v:lua.__live_grep' | 569 require('heirline').load_colors(colors) |
573 return 'g@' | 570 |
574 end, { expr = true, desc = 'Live grep for word' }) | 571 local align = { provider = '%=' } |
575 | 572 local space = { provider = ' ' } |
576 function _G.__live_grep_opts(motion) | 573 local lbound = { provider = '▊ ', hl = { fg = 'blue', bg = 'bg' } } |
577 local word = get_selected_word() | 574 local rbound = { provider = ' ▊', hl = { fg = 'blue', bg = 'bg' } } |
578 grep_opts(word) | 575 |
579 end | 576 local FileNameBlock = { |
580 | 577 init = function(self) self.filename = vim.api.nvim_buf_get_name(0) end, |
581 vim.keymap.set({ 'x', 'n' }, 'gt', function() | 578 } |
582 vim.o.operatorfunc = 'v:lua.__live_grep_opts' | 579 |
583 return 'g@' | 580 local FileName = { |
584 end, { expr = true, desc = 'Live grep for word with options' }) | 581 provider = function(self) |
585 end, | 582 local filename = vim.fn.fnamemodify(self.filename, ':.') |
586 } | 583 if filename == '' then return '[No Name]' end |
587 | 584 |
588 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } } | 585 if not conditions.width_percent_below(#filename, 0.25) then filename = vim.fn.pathshorten(filename) end |
589 | 586 |
590 use { | 587 return filename |
591 'rebelot/heirline.nvim', | 588 end, |
592 after = { 'espresso-tutti-colori.nvim', 'catppuccin' }, | 589 hl = { fg = 'blue' }, |
593 config = function() | 590 } |
594 local utils = require 'heirline.utils' | 591 |
595 local conditions = require 'heirline.conditions' | 592 local FileFlags = { |
596 | 593 { |
597 local colors | |
598 if os.getenv 'DARKMODE' then | |
599 colors = require('catppuccin.palettes').get_palette 'mocha' | |
600 else | |
601 colors = require('tutti-colori.colors').setup() | |
602 end | |
603 colors.diag_warn = utils.get_highlight('DiagnosticSignWarn').fg | |
604 colors.diag_error = utils.get_highlight('DiagnosticSignError').fg | |
605 | |
606 require('heirline').load_colors(colors) | |
607 | |
608 local align = { provider = '%=' } | |
609 local space = { provider = ' ' } | |
610 local lbound = { provider = '▊ ', hl = { fg = 'blue', bg = 'bg' } } | |
611 local rbound = { provider = ' ▊', hl = { fg = 'blue', bg = 'bg' } } | |
612 | |
613 local FileNameBlock = { | |
614 init = function(self) self.filename = vim.api.nvim_buf_get_name(0) end, | |
615 } | |
616 | |
617 local FileName = { | |
618 provider = function(self) | |
619 local filename = vim.fn.fnamemodify(self.filename, ':.') | |
620 if filename == '' then return '[No Name]' end | |
621 | |
622 if not conditions.width_percent_below(#filename, 0.25) then filename = vim.fn.pathshorten(filename) end | |
623 | |
624 return filename | |
625 end, | |
626 hl = { fg = 'blue' }, | |
627 } | |
628 | |
629 local FileFlags = { | |
630 { | |
631 provider = function() | |
632 if vim.bo.modified then return ' [+]' end | |
633 end, | |
634 hl = { fg = 'green' }, | |
635 }, | |
636 { | |
637 provider = function() | |
638 if not vim.bo.modifiable or vim.bo.readonly then return ' RO' end | |
639 end, | |
640 hl = { fg = 'orange' }, | |
641 }, | |
642 } | |
643 | |
644 FileNameBlock = utils.insert(FileNameBlock, FileName, unpack(FileFlags), { provider = '%<' }) | |
645 | |
646 local Ruler = { provider = '%l : %c %P' } | |
647 | |
648 local Lsp = { | |
649 condition = conditions.lsp_attached, | |
650 update = { 'LspAttach', 'LspDetach' }, | |
651 provider = function() | 594 provider = function() |
652 local names = {} | 595 if vim.bo.modified then return ' [+]' end |
653 for _, server in pairs(vim.lsp.get_active_clients { bufnr = 0 }) do | |
654 table.insert(names, server.name) | |
655 end | |
656 return table.concat(names, ', ') | |
657 end, | 596 end, |
658 hl = { fg = 'green' }, | 597 hl = { fg = 'green' }, |
659 } | 598 }, |
660 | 599 { |
661 local Diagnostics = { | 600 provider = function() |
662 condition = conditions.has_diagnostics, | 601 if not vim.bo.modifiable or vim.bo.readonly then return ' RO' end |
663 init = function(self) | |
664 self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) | |
665 self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) | |
666 end, | 602 end, |
667 update = { 'DiagnosticChanged', 'BufEnter' }, | 603 hl = { fg = 'orange' }, |
668 { | 604 }, |
669 provider = function(self) return self.errors > 0 and self.errors .. ' ' end, | 605 } |
670 hl = { fg = 'diag_error' }, | 606 |
607 FileNameBlock = utils.insert(FileNameBlock, FileName, unpack(FileFlags), { provider = '%<' }) | |
608 | |
609 local Ruler = { provider = '%l : %c %P' } | |
610 | |
611 local Lsp = { | |
612 condition = conditions.lsp_attached, | |
613 update = { 'LspAttach', 'LspDetach' }, | |
614 provider = function() | |
615 local names = {} | |
616 for _, server in pairs(vim.lsp.get_active_clients { bufnr = 0 }) do | |
617 table.insert(names, server.name) | |
618 end | |
619 return table.concat(names, ', ') | |
620 end, | |
621 hl = { fg = 'green' }, | |
622 } | |
623 | |
624 local Diagnostics = { | |
625 condition = conditions.has_diagnostics, | |
626 init = function(self) | |
627 self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) | |
628 self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) | |
629 end, | |
630 update = { 'DiagnosticChanged', 'BufEnter' }, | |
631 { | |
632 provider = function(self) return self.errors > 0 and self.errors .. ' ' end, | |
633 hl = { fg = 'diag_error' }, | |
634 }, | |
635 { | |
636 provider = function(self) return self.warnings > 0 and self.warnings .. ' ' end, | |
637 }, | |
638 hl = { fg = 'diag_warn' }, | |
639 on_click = { | |
640 callback = function() | |
641 local diagnostics = vim.diagnostic.get(0, { severity = { min = vim.diagnostic.severity.WARN } }) | |
642 vim.fn.setqflist(vim.diagnostic.toqflist(diagnostics)) | |
643 vim.cmd.copen { mods = { split = 'botright' } } | |
644 end, | |
645 name = 'heirline_diagnostics', | |
646 }, | |
647 } | |
648 | |
649 local Window = { | |
650 provider = function() return '- ' .. vim.api.nvim_win_get_number(0) .. ' -' end, | |
651 hl = { fg = 'blue' }, | |
652 } | |
653 | |
654 local statusline_default = { lbound, FileNameBlock, align, Diagnostics, Lsp, space, Ruler, rbound } | |
655 local statusline_inactive = { | |
656 condition = function() return not conditions.is_active() end, | |
657 lbound, | |
658 FileNameBlock, | |
659 align, | |
660 Window, | |
661 rbound, | |
662 } | |
663 local statusline = { | |
664 fallthrough = false, | |
665 hl = { bg = 'bg' }, | |
666 statusline_inactive, | |
667 statusline_default, | |
668 } | |
669 | |
670 require('heirline').setup { statusline = statusline } | |
671 end, | |
672 }, | |
673 | |
674 -- File navigation | |
675 { | |
676 'elihunter173/dirbuf.nvim', | |
677 config = function() | |
678 require('dirbuf').setup { | |
679 hash_padding = 2, | |
680 show_hidden = true, | |
681 } | |
682 end, | |
683 }, | |
684 | |
685 -- Colorscheme | |
686 { | |
687 'zegervdv/espresso-tutti-colori.nvim', | |
688 name = 'tutti-colori', | |
689 cond = not os.getenv 'DARKMODE', | |
690 config = function() | |
691 require('tutti-colori').setup() | |
692 require('tutti-colori').load() | |
693 end, | |
694 priority = 1000, | |
695 lazy = false, | |
696 }, | |
697 { | |
698 'catppuccin/nvim', | |
699 name = 'catppuccin', | |
700 cond = not not os.getenv 'DARKMODE', | |
701 config = function() | |
702 require('catppuccin').setup { | |
703 flavour = 'macchiato', | |
704 } | |
705 vim.cmd.colorscheme 'catppuccin-macchiato' | |
706 end, | |
707 priority = 1000, | |
708 lazy = false, | |
709 }, | |
710 | |
711 -- Integration with external tools | |
712 { | |
713 'glacambre/firenvim', | |
714 build = function() vim.fn['firenvim#install'](0) end, | |
715 config = function() | |
716 vim.g.firenvim_config = { | |
717 localSettings = { | |
718 ['.*'] = { | |
719 takeover = 'never', | |
671 }, | 720 }, |
672 { | 721 }, |
673 provider = function(self) return self.warnings > 0 and self.warnings .. ' ' end, | 722 } |
674 }, | 723 end, |
675 hl = { fg = 'diag_warn' }, | 724 }, |
676 on_click = { | |
677 callback = function() | |
678 local diagnostics = vim.diagnostic.get(0, { severity = { min = vim.diagnostic.severity.WARN } }) | |
679 vim.fn.setqflist(vim.diagnostic.toqflist(diagnostics)) | |
680 vim.cmd.copen { mods = { split = 'botright' } } | |
681 end, | |
682 name = 'heirline_diagnostics', | |
683 }, | |
684 } | |
685 | |
686 local Window = { | |
687 provider = function() return '- ' .. vim.api.nvim_win_get_number(0) .. ' -' end, | |
688 hl = { fg = 'blue' }, | |
689 } | |
690 | |
691 local statusline_default = { lbound, FileNameBlock, align, Diagnostics, Lsp, space, Ruler, rbound } | |
692 local statusline_inactive = { | |
693 condition = function() return not conditions.is_active() end, | |
694 lbound, | |
695 FileNameBlock, | |
696 align, | |
697 Window, | |
698 rbound, | |
699 } | |
700 local statusline = { | |
701 fallthrough = false, | |
702 hl = { bg = 'bg' }, | |
703 statusline_inactive, | |
704 statusline_default, | |
705 } | |
706 | |
707 require('heirline').setup { statusline = statusline } | |
708 end, | |
709 } | |
710 | |
711 -- File navigation | |
712 use { | |
713 'elihunter173/dirbuf.nvim', | |
714 opt = true, | |
715 config = function() | |
716 require('dirbuf').setup { | |
717 hash_padding = 2, | |
718 show_hidden = true, | |
719 } | |
720 end, | |
721 } | |
722 | |
723 -- Colorscheme | |
724 use { | |
725 local_plugin 'espresso-tutti-colori.nvim', | |
726 disable = os.getenv 'DARKMODE', | |
727 config = function() | |
728 require('tutti-colori').setup() | |
729 require('tutti-colori').load() | |
730 end, | |
731 } | |
732 use { | |
733 'catppuccin/nvim', | |
734 as = 'catppuccin', | |
735 config = function() | |
736 require('catppuccin').setup { | |
737 flavour = 'mocha', | |
738 } | |
739 end, | |
740 } | |
741 | |
742 -- Terminal | |
743 use { | |
744 'akinsho/nvim-toggleterm.lua', | |
745 config = function() | |
746 require('toggleterm').setup { | |
747 size = 15, | |
748 open_mapping = [[<F12>]], | |
749 shade_filetypes = { 'none' }, | |
750 shade_terminals = true, | |
751 persist_size = true, | |
752 direction = 'horizontal', | |
753 } | |
754 end, | |
755 keys = { [[<F12>]] }, | |
756 } | |
757 | |
758 -- Integration with external tools | |
759 use { | |
760 'glacambre/firenvim', | |
761 run = function() vim.fn['firenvim#install'](0) end, | |
762 config = function() | |
763 vim.g.firenvim_config = { | |
764 localSettings = { | |
765 ['.*'] = { | |
766 takeover = 'never', | |
767 }, | |
768 }, | |
769 } | |
770 end, | |
771 } | |
772 end, | |
773 config = { snapshot_path = vim.fn.stdpath 'config' }, | |
774 } | 725 } |
775 | |
776 vim.cmd.packadd 'dirbuf.nvim' | |
777 | |
778 if os.getenv 'DARKMODE' then | |
779 vim.cmd.colorscheme 'catppuccin' | |
780 else | |
781 require('tutti-colori').setup() | |
782 vim.cmd.colorscheme 'espresso-tutti-colori' | |
783 end | |
784 | 726 |
785 -- Configuration | 727 -- Configuration |
786 vim.opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything | 728 vim.opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything |
787 | 729 |
788 vim.opt.autoread = true -- Read changed files | 730 vim.opt.autoread = true -- Read changed files |
981 local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end | 923 local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end |
982 | 924 |
983 -- General keymaps | 925 -- General keymaps |
984 local map = vim.keymap.set | 926 local map = vim.keymap.set |
985 | 927 |
986 -- Set leader to space | |
987 vim.g.mapleader = ' ' | |
988 | |
989 -- Move while in insert mode | 928 -- Move while in insert mode |
990 map('i', '<C-f>', '<right>') | 929 map('i', '<C-f>', '<right>') |
991 | 930 |
992 -- Keep search matches centered | 931 -- Keep search matches centered |
993 map('n', 'n', 'nzzzv') | 932 map('n', 'n', 'nzzzv') |