From 01729e261340a4462a57bf80f6e591c1371ae996 Mon Sep 17 00:00:00 2001 From: Squibid Date: Sun, 22 Oct 2023 18:17:21 -0400 Subject: kitchen sink: - add code action previews - change indent blankline style - more luasnip snippets - change default mason stuff - customize neorg more - change notify style - change startpage completely - add line info to statusline - change telescope style - change how todo comments look - make indentation work via treesitter --- lua/core/binds.lua | 88 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 28 deletions(-) (limited to 'lua/core/binds.lua') diff --git a/lua/core/binds.lua b/lua/core/binds.lua index f27c87d..02216ae 100644 --- a/lua/core/binds.lua +++ b/lua/core/binds.lua @@ -9,17 +9,6 @@ local function map(mode, bind, cmd, opts) end elseif type(bind) == 'string' then vim.keymap.set(mode, bind, cmd, opts) - else - vim.notify('-- Invalid bind for keymap:\nvim.keymap.set(\'' - .. mode .. '\', ' .. bind .. ', \'' .. cmd .. '\')', - vim.log.levels.WARN, { - title = 'Neovim Config', - on_open = function(win) - local buf = vim.api.nvim_win_get_buf(win) - vim.api.nvim_buf_set_option(buf, "filetype", "lua") - end - } - ) end end @@ -40,7 +29,7 @@ map('n', 'N', 'Nzzzv') map('n', '', 'zz') -- half page jumping map('n', '', 'zz') -map('n', 'x', '!chmod +x %') -- execute order 111 +map('n', 'x', '!chmod +x "%"') -- execute order 111 -- add some keybinds to the file view (netrw) a.nvim_create_autocmd('FileType', { @@ -51,17 +40,17 @@ a.nvim_create_autocmd('FileType', { end bind('h', '-^') -- Go up a directory bind('l', '') -- Go down a directory / open a file - bind('.', 'gh') -- Toggle dotfiles + bind('.', 'gh') -- Toggle hidden files bind('P', 'z') -- Close preview window bind('', 'q') -- Close netrw end }) -- tabs -map('n', 'n', 'tabnew') -map('n', 'w', 'tabclose') -map('n', 'h', 'tabprev') -map('n', 'l', 'tabnext') +map('n', '[]', 'tabnew') +map('n', '][', 'tabc') +map('n', '[[', 'tabp') +map('n', ']]', 'tabN') -- plugin binds --------------------------------------------------------------- @@ -78,22 +67,41 @@ end if pcall(require, "telescope") then local telebuilt = require('telescope.builtin') -- telescope + -- local telexten = require('telescope').extensions map('n', 'sf', telebuilt.find_files, { desc = 'Find files.' }) + map('n', 'so', telebuilt.oldfiles, { desc = 'Find old files.' }) map('n', 'sg', telebuilt.git_files, { desc = 'Find git files.' }) + -- search urls in buffer + map('n', 'su', 'UrlView', { desc = 'Find urls in buffer.' }) + -- search lsp symbols + map('n', 'ss', telebuilt.lsp_document_symbols, + { desc = 'Find LSP Symbols.' }) + -- search for keybinds + map('n', 'sk', telebuilt.keymaps, + { desc = 'Find nvim Highlights.' }) + -- search for highlights + map('n', 'sh', telebuilt.highlights, + { desc = 'Find nvim Highlights.' }) + -- search for autocommands + map('n', 'sa', telebuilt.autocommands, + { desc = 'Find nvim Autocommands.' }) + -- search for vim options + map('n', 'sv', telebuilt.vim_options, { desc = 'Find vim options.' }) + -- search for string in project map('n', 'sp', function() - telebuilt.grep_string({ search = vim.fn.input( - 'Find string in project > ' - ) }) + 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.' }) + -- Code Actions (requires telescope) + if pcall(require, "actions-preview") then + map({ "n", "v" }, "ca", require("actions-preview").code_actions, { + desc = 'preview code actions' + }) + end end 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.' }) if pcall(require, "dapui") then local dapui = require('dapui') -- dap ui @@ -122,14 +130,38 @@ if pcall(require, "true-zen") then }) end --- Git -map('n', 'gph', 'Gitsigns preview_hunk_inline') -map('n', 'gsh', 'Gitsigns stage_hunk') +-- git +map('n', 'gp', 'Gitsigns preview_hunk_inline') +map('n', 'gs', 'Gitsigns stage_hunk') map('n', 'gb', 'Gitsigns blame_line') +map('n', 'g]', 'Gitsigns next_hunk') +map('n', 'g[', 'Gitsigns prev_hunk') -- neogen if pcall(require, "neogen") then map('n', 'df', require("neogen").generate, { - desc = 'Generate anootations', + desc = 'Generate anotations', }) end + +-- venn +function _G.Toggle_venn() + local venn_enabled = vim.inspect(vim.b.venn_enabled) + if venn_enabled == "nil" then + vim.b.venn_enabled = true + vim.cmd([[setlocal ve=all]]) + -- draw a line on HJKL keystokes + vim.api.nvim_buf_set_keymap(0, "n", "J", "j:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "K", "k:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "L", "l:VBox", {noremap = true}) + vim.api.nvim_buf_set_keymap(0, "n", "H", "h:VBox", {noremap = true}) + -- draw a box by pressing "f" with visual selection + vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox", {noremap = true}) + else + vim.cmd[[setlocal ve=]] + vim.cmd[[mapclear ]] + vim.b.venn_enabled = nil + end +end +-- toggle keymappings for venn using v +vim.api.nvim_set_keymap('n', 'v', ":lua Toggle_venn()", { noremap = true}) -- cgit v1.2.1