From 590f0309995a569954fc94b1d5df6b6391ead9fa Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 11 Aug 2023 20:43:58 -0400 Subject: kitchen sink cause I'm too lazy to sort through this junk --- lua/core/binds.lua | 94 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 33 deletions(-) (limited to 'lua/core/binds.lua') diff --git a/lua/core/binds.lua b/lua/core/binds.lua index 4afc57c..f27c87d 100644 --- a/lua/core/binds.lua +++ b/lua/core/binds.lua @@ -1,5 +1,8 @@ local function map(mode, bind, cmd, opts) - opts = opts or {noremap = true, silent = true} + opts = opts or {} + opts['noremap'] = true + opts['silent'] = true + if type(bind) == 'table' then for i in pairs(bind) do vim.keymap.set(mode, bind[i], cmd, opts) @@ -23,12 +26,12 @@ end -- vim binds ------------------------------------------------------------------ g.mapleader = ' ' -- set leader key -map('x', 'p', [["_dP]]) -- greatest remap ever -map('n', '', ':nohlsearch:echo') -- clear search -map('t', '', '') -- make work in terminals +map('x', 'p', [["_dP]], { desc = 'Greatest remap of all time.' }) +map('n', '', ':nohlsearch:echo', { desc = 'Clear search.' }) +map('t', '', '', { desc = 'make work in terminals.' }) -- move selected text up/down -map('v', '', ":m '<-2gv=gv") -map('v', '', ":m '>+1gv=gv") +map('v', '', ":m '<-2gv=gv", { desc = 'Move selected text up.' }) +map('v', '', ":m '>+1gv=gv", { desc = 'Move selected text down.' }) -- the cursor STAYS IN THE MIDDLE map('n', '', 'mzJ`zdelm z') -- when combining lines @@ -50,10 +53,16 @@ a.nvim_create_autocmd('FileType', { bind('l', '') -- Go down a directory / open a file bind('.', 'gh') -- Toggle dotfiles bind('P', 'z') -- Close preview window - bind('', 'q') -- Close netrw + bind('', 'q') -- Close netrw end }) +-- tabs +map('n', 'n', 'tabnew') +map('n', 'w', 'tabclose') +map('n', 'h', 'tabprev') +map('n', 'l', 'tabnext') + -- plugin binds --------------------------------------------------------------- -- pretty lsp view @@ -62,41 +71,56 @@ map('n', 'gr', 'Glance references') map('n', 'gy', 'Glance type_definitions') map('n', 'gi', 'Glance implementations') -local treesj = require('treesj') -- treesj -map('n', 'j', treesj.toggle) - -local telebuilt = require('telescope.builtin') -- telescope -map('n', 'sf', telebuilt.find_files) -map('n', 'sg', telebuilt.git_files) -map('n', 'sp', function() - telebuilt.grep_string({ search = vim.fn.input('Find string in project > ') }) -end) -map('n', 'so', telebuilt.oldfiles) +if pcall(require, "treesj") then + local treesj = require('treesj') -- treesj + map('n', 'j', treesj.toggle) +end -local intellitab = require('intellitab') -- intellitab -map('n', '', intellitab.indent) +if pcall(require, "telescope") then + local telebuilt = require('telescope.builtin') -- telescope + map('n', 'sf', telebuilt.find_files, { desc = 'Find files.' }) + map('n', 'sg', telebuilt.git_files, { desc = 'Find git files.' }) + map('n', 'sp', function() + telebuilt.grep_string({ search = vim.fn.input( + 'Find string in project > ' + ) }) + end, { desc = 'Find string in project.' }) + map('n', 'so', telebuilt.oldfiles, { desc = 'Find old files.' }) +end -map('n', 'u', 'UndotreeToggle') -- undo tree -map('n', 'f', 'SFMToggle') -- sfm -map('n', 'b', 'JABSOpen') -- switch between previous buffers -map('n', 'tt', 'TroubleToggle') -- trouble (lsp error view) -map('n', 'tc', 'TodoTrouble') -- todo trouble -map('n', '', 'IconPickerYank') -- icon picker +map('n', 'u', 'UndotreeToggle', { desc = 'Open undo tree.' }) +map('n', 'f', 'SFMToggle', { desc = 'Open file tree view.' }) +map('n', 'b', 'JABSOpen', { desc = 'Switch between buffers.' }) +map('n', 'tt', 'TroubleToggle', { desc = 'Diagnostic list.' }) +map('n', 'tc', 'TodoTrouble', { desc = 'Comment list.' }) +map('n', '', 'IconPickerYank', { desc = 'Icon picker list.' }) -local dapui = require('dapui') -- dap ui -map('n', 'd', dapui.toggle) +if pcall(require, "dapui") then + local dapui = require('dapui') -- dap ui + map('n', 'd', dapui.toggle, { desc = 'Debuging ui.' }) +end -local smartsplits = require('smart-splits') -- resizing buffers (toggleable) -map('n', 'r', smartsplits.start_resize_mode) +if pcall(require, "smart-splits") then + local smartsplits = require('smart-splits') -- resizing buffers (toggleable) + map('n', 'r', smartsplits.start_resize_mode) +end -- toggle term (don't use leader key in these binds) map({'n', 't'}, '', 'ToggleTerm direction=float') map({'n', 't'}, '', 'lua _glow()') -- true zen -map('n', 'zf', 'lua require("true-zen.focus").toggle()') -map('n', 'zm', 'lua require("true-zen.minimalist").toggle()') -map('n', 'za', 'lua require("true-zen.ataraxis").toggle()') +if pcall(require, "true-zen") then + map('n', 'zf', require("true-zen.focus").toggle, { + desc = 'fullscreen', + }) + map('n', 'zm', require("true-zen.minimalist").toggle, { + desc = 'minimal', + }) + map('n', 'za', require("true-zen.ataraxis").toggle, { + desc = 'zen', + }) +end -- Git map('n', 'gph', 'Gitsigns preview_hunk_inline') @@ -104,4 +128,8 @@ map('n', 'gsh', 'Gitsigns stage_hunk') map('n', 'gb', 'Gitsigns blame_line') -- neogen -map('n', 'df', 'lua require("neogen").generate()') +if pcall(require, "neogen") then + map('n', 'df', require("neogen").generate, { + desc = 'Generate anootations', + }) +end -- cgit v1.2.1