mappings.lua (922B)
1 local map = function(keys, func, desc, mode) 2 mode = mode or 'n' 3 vim.keymap.set(mode, keys, func, { desc = desc }) 4 end 5 local diag = vim.diagnostic 6 -- Diagnostic keymaps 7 map('[d', function() diag.jump({ count = -1, float = true }) end, 'Previous diagnostic') 8 map(']d', function() diag.jump({ count = 1, float = true }) end, 'Next diagnostic') 9 10 map('[e', function() 11 diag.jump({ count = -1, float = true, severity = diag.severity.ERROR }) 12 end, 'Previous error') 13 map(']e', function() 14 diag.jump({ count = 1, float = true, severity = diag.severity.ERROR }) 15 end, 'Next error') 16 17 map('<leader>e', diag.open_float, 'Show errors') 18 map('<leader>q', function() diag.setloclist({ severity = diag.severity.ERROR }) end, 'Errors to quickfix') 19 20 -- 'i' that indents correctly on empty lines 21 vim.keymap.set('n', 'i', function() 22 if #vim.fn.getline(".") == 0 then 23 return [["_cc]] 24 else 25 return "i" 26 end 27 end, { expr = true })