Dot_Files/.config/nvim/lua/plugins/mappings.lua

161 lines
5.5 KiB
Lua
Raw Normal View History

local utils = require('utils.funcs')
local loaded, async = pcall(require, 'plenary.async')
2022-01-10 09:55:15 -06:00
local map = utils.map
if not loaded then
return
end
2022-01-10 09:55:15 -06:00
-- Telescope mappings
2022-05-08 21:41:54 -05:00
map('n', '<Leader>tw', ':Telescope live_grep<CR>')
2022-06-02 11:48:15 -05:00
map('n', '<Leader>tgs', ':Telescope git_status<CR>')
map('n', '<Leader>tgc', ':Telescope git_commits<CR>')
map('n', '<Leader>tgb', ':Telescope git_branches<CR>')
2022-05-08 21:41:54 -05:00
map('n', '<Leader>tf', ':Telescope find_files<CR>')
map('n', '<Leader>td', ':Telescope find_directories<CR>')
map('n', '<Leader>tb', ':Telescope buffers<CR>')
map('n', '<Leader>th', ':Telescope help_tags<CR>')
map('n', '<Leader>to', ':Telescope oldfiles<CR>')
map('n', '<leader>tc', ':Telescope neoclip default<CR>')
map('n', '<leader>tr', ':Telescope registers<CR>')
map('n', '<leader>tt', ':Telescope file_browser<CR>')
map('n', '<leader>ts', ':Telescope spell_suggest<CR>')
map('n', '<leader>tl', ':Telescope resume<CR>')
2022-05-08 21:41:54 -05:00
map('n', '<leader>tT', ':TodoTelescope<CR>')
2022-01-10 09:55:15 -06:00
-- Lsp Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>lD', ':lua vim.lsp.buf.declaration()<CR>')
map('n', '<leader>ld', ':lua vim.lsp.buf.definition()<CR>')
map('n', '<leader>k', ':lua vim.lsp.buf.hover()<CR>')
map('n', '<leader>K', ':lua vim.lsp.buf.signature_help()<CR>')
map('n', '<leader>li', ':lua vim.lsp.buf.implementation()<CR>')
map('n', '<leader>la', ':lua vim.lsp.buf.add_workspace_folder()<CR>')
map('n', '<leader>lx', ':lua vim.lsp.buf.remove_workspace_folder()<CR>')
map('n', '<leader>ll', ':lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>')
2022-07-08 17:31:41 -05:00
map('n', '<leader>ln', ':IncRename ')
2022-05-08 21:41:54 -05:00
map('n', '<leader>lc', ':CodeActionMenu<CR>')
map('n', '<leader>lr', ':lua vim.lsp.buf.references()<CR>')
map('n', '<leader>lR', ':LspRestart<CR>')
map('n', '<leader>ls', ":lua vim.diagnostic.open_float(nil, {focus=false, scope='cursor'})<CR>")
map('n', '<leader>lf', ':lua vim.lsp.buf.format({ async = true })<CR>')
map('n', '[l', ':lua vim.diagnostic.goto_prev()<CR>')
map('n', ']l', ':lua vim.diagnostic.goto_next()<CR>')
map('n', '<leader>lq', ':Telescope diagnostics bufnr=0<CR>')
local virtual_lines_enabled = true
map('n', '<leader>lt', '', {
callback = function()
virtual_lines_enabled = not virtual_lines_enabled
vim.diagnostic.config({ virtual_lines = virtual_lines_enabled, virtual_text = not virtual_lines_enabled })
end,
})
-- Trouble mappings
map('n', '<leader>lT', ':TroubleToggle<CR>')
2022-01-10 09:55:15 -06:00
-- Formatter
2022-05-08 21:41:54 -05:00
map('n', '<leader>nf', ':Neoformat<CR>')
2022-01-10 09:55:15 -06:00
-- DAP Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>dR', ':lua require("dap").continue()<CR>')
map('n', '<leader>de', ':lua require("dap").terminate()<CR>')
map('n', '<leader>db', ':lua require("dap").toggle_breakpoint()<CR>')
map('n', '<leader>dr', ':lua require("dap").set_breakpoint(vim.fn.input(\'Breakpoint condition: \'))<CR>')
map('n', '<leader>dp', ':lua require("dap").set_breakpoint(nil, nil, vim.fn.input(\'Log point message: \'))<CR>')
map('n', '<F5>', ':lua require("dap").step_over()<CR>')
map('n', '<F6>', ':lua require("dap").step_into()<CR>')
map('n', '<F7>', ':lua require("dap").step_out()<CR>')
map('n', '<leader>dB', ':lua require("dap").step_back()<CR>')
map('n', '<leader>dc', ':lua require("dap").run_to_cursor()<CR>')
map('n', '<leader>do', ':lua require("dap").repl.open()<CR>')
map('n', '<leader>dt', ':lua require("dapui").toggle()<CR>')
map('n', '<leader>dl', ':lua require("dap").run_last()<CR>')
2022-01-10 09:55:15 -06:00
-- Comments
2022-05-08 21:41:54 -05:00
map('n', '<leader>/', ':CommentToggle<CR>')
map('v', '<leader>/', ":'<,'>CommentToggle<CR>")
2022-01-10 09:55:15 -06:00
-- Code Outline
2022-05-08 21:41:54 -05:00
map('n', '<leader>co', ':SymbolsOutline<CR>')
2022-01-10 09:55:15 -06:00
-- Bufferline mappings
2022-05-08 21:41:54 -05:00
map('n', '<A-a>', ':BufferLineCyclePrev<CR>')
map('n', '<A-s>', ':BufferLineCycleNext<CR>')
map('n', '<A-x>', ":lua require('utils.funcs').close_buffer()<CR>")
2022-01-15 19:15:09 -06:00
-- Vim Notify Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>nv', ":lua require('telescope').extensions.notify.notify()<CR>")
map('n', '<leader>nd', ":lua require('notify').dismiss()<CR>")
2022-02-15 13:23:03 -06:00
-- Whichkey Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>ww', ':WhichKey<CR>')
map('n', '<leader>wk', ':Telescope keymaps<CR>')
map('n', '<leader>wc', ':Telescope commands<CR>')
2022-02-28 08:05:25 -06:00
-- Neogen Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>ng', ':Neogen<CR>')
2022-03-14 03:14:13 -05:00
-- Nvim Tree Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>nt', ':Neotree show toggle focus<cr>')
2022-05-06 20:44:49 -05:00
-- Plenary Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>pt', '<Plug>PlenaryTestFile', {})
2022-05-07 18:41:23 -05:00
-- Zenmode Mappings
2022-05-08 21:41:54 -05:00
map('n', '<leader>zm', ':ZenMode<CR>')
2022-06-02 11:36:16 -05:00
-- Neogit Mappings
2022-06-02 11:51:01 -05:00
map('n', '<leader>gg', ':Neogit<CR>')
-- Gitsigns Mappings
map('n', ']g', '<cmd>Gitsigns next_hunk<CR>')
map('n', '[g', '<cmd>Gitsigns prev_hunk<CR>')
map('n', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>')
map('n', '<leader>gr', '<cmd>Gitsigns reset_hunk<CR>')
map('n', '<leader>gu', '<cmd>Gitsigns undo_stage_hunk<CR>')
2022-06-02 11:36:16 -05:00
2022-05-08 21:41:54 -05:00
-- SnipRun Mappings
local run_snip = function()
2022-05-11 21:00:57 -05:00
async.run(function()
2022-05-08 21:41:54 -05:00
vim.notify.async('Running snippet, saving current buffer.', 'info', {
2022-05-11 21:00:57 -05:00
title = 'SnipRun',
2022-05-08 21:41:54 -05:00
})
end)
vim.cmd('w')
vim.cmd('SnipRun')
end
map('n', '<leader>sr', '', {
2022-05-11 21:00:57 -05:00
callback = run_snip,
2022-05-08 21:41:54 -05:00
})
map('v', '<leader>sr', '', {
2022-05-11 21:00:57 -05:00
callback = run_snip,
2022-05-08 21:41:54 -05:00
})
2022-05-09 17:37:21 -05:00
-- Packer Mappings
2022-05-11 21:00:57 -05:00
local packer = require('packer')
local packer_sync = function()
vim.notify('Syncing packer.', 'info', {
title = 'Packer',
})
local snap_shot_time = tostring(os.date('!%Y-%m-%dT%TZ'))
packer.snapshot(snap_shot_time)
packer.sync()
2022-05-09 17:37:21 -05:00
end
2022-05-11 21:00:57 -05:00
local packer_compile = function()
vim.notify('Compiling packer.', 'info', {
title = 'Packer',
})
packer.compile()
2022-05-09 21:24:45 -05:00
end
2022-05-09 17:37:21 -05:00
map('n', '<leader>ps', '', {
2022-05-11 21:00:57 -05:00
callback = packer_sync,
2022-05-09 17:37:21 -05:00
})
2022-05-09 21:24:45 -05:00
map('n', '<leader>pc', '', {
2022-05-11 21:00:57 -05:00
callback = packer_compile,
2022-05-09 21:24:45 -05:00
})
-- Undotree mappings
map('n', '<leader>ut', ':UndotreeToggle<CR>')