From 01729e261340a4462a57bf80f6e591c1371ae996 Mon Sep 17 00:00:00 2001
From: Squibid <me@zacharyscheiman.com>
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/auto.lua    | 39 +----------------------
 lua/core/binds.lua   | 88 +++++++++++++++++++++++++++++++++++-----------------
 lua/core/cmds.lua    |  4 ++-
 lua/core/opts.lua    | 13 +++-----
 lua/core/plugins.lua | 80 +++++++++++++++++++++++++++--------------------
 5 files changed, 116 insertions(+), 108 deletions(-)

(limited to 'lua/core')

diff --git a/lua/core/auto.lua b/lua/core/auto.lua
index 5a6c3a3..4c50357 100644
--- a/lua/core/auto.lua
+++ b/lua/core/auto.lua
@@ -2,7 +2,7 @@ local function auto(event, opts)
   a.nvim_create_autocmd(event, opts)
 end
 
-a.nvim_create_augroup('bufcheck', {clear = true})
+a.nvim_create_augroup('bufcheck', { clear = true })
 
 auto('TextYankPost', { -- highlight yanks
   group = 'bufcheck',
@@ -26,43 +26,6 @@ auto('BufRead', { -- return to last place
   desc = 'Return to the last place the buffer was closed in.',
 })
 
-auto('TermOpen', { -- start terminal in insert mode
-  group    = 'bufcheck',
-  pattern  = '*',
-  desc     = 'Start terminal in insert mode.',
-  callback = function()
-    vim.cmd('startinsert | set winfixheight')
-    o.winfixheight = true
-    o.cmdheight = 0
-  end
-})
-
-auto('TermClose', { -- close terminal buffers after shell dies
-  group    = 'bufcheck',
-  pattern  = 'term://*',
-  desc     = 'Close terminal after shell dies.',
-  callback = function()
-    vim.cmd('call nvim_input("<CR>")')
-    o.cmdheight = 1
-  end
-})
-
-auto('InsertEnter', { -- toggle things when entering insert mode
-  group = 'bufcheck',
-  desc  = 'Turn things on insert mode.',
-  callback = function()
-    o.colorcolumn = { 80 }
-  end
-})
-
-auto('InsertLeave', { -- toggle things when exiting insert mode
-  group = 'bufcheck',
-  desc  = 'Turn things off insert mode.',
-  callback = function()
-    o.colorcolumn = { 0 }
-  end
-})
-
 auto('BufWritePre', { -- make dirs when they don't exist
   pattern = '*',
   group = vim.api.nvim_create_augroup('auto_create_dir', { clear = true }),
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', '<C-d>', '<C-d>zz') -- half page jumping
 map('n', '<C-u>', '<C-u>zz')
 
-map('n', '<leader>x', '<cmd>!chmod +x %<CR>') -- execute order 111
+map('n', '<leader>x', '<cmd>!chmod +x "%"<CR>') -- 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', '<CR>') -- Go down a directory / open a file
-    bind('.', 'gh') -- Toggle dotfiles
+    bind('.', 'gh') -- Toggle hidden files
     bind('P', '<C-w>z') -- Close preview window
     bind('<esc>', '<cmd>q<CR>') -- Close netrw
   end
 })
 
 -- tabs
-map('n', '<C-q>n', '<cmd>tabnew<CR>')
-map('n', '<C-q>w', '<cmd>tabclose<CR>')
-map('n', '<C-q>h', '<cmd>tabprev<CR>')
-map('n', '<C-q>l', '<cmd>tabnext<CR>')
+map('n', '[]', '<cmd>tabnew<CR>')
+map('n', '][', '<cmd>tabc<CR>')
+map('n', '[[', '<cmd>tabp<CR>')
+map('n', ']]', '<cmd>tabN<CR>')
 
 -- 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', '<leader>sf', telebuilt.find_files, { desc = 'Find files.' })
+  map('n', '<leader>so', telebuilt.oldfiles, { desc = 'Find old files.' })
   map('n', '<leader>sg', telebuilt.git_files, { desc = 'Find git files.' })
+  -- search urls in buffer
+  map('n', '<leader>su', '<Cmd>UrlView<CR>', { desc = 'Find urls in buffer.' })
+  -- search lsp symbols
+  map('n', '<leader>ss', telebuilt.lsp_document_symbols,
+      { desc = 'Find LSP Symbols.' })
+  -- search for keybinds
+  map('n', '<leader>sk', telebuilt.keymaps,
+      { desc = 'Find nvim Highlights.' })
+  -- search for highlights
+  map('n', '<leader>sh', telebuilt.highlights,
+      { desc = 'Find nvim Highlights.' })
+  -- search for autocommands
+  map('n', '<leader>sa', telebuilt.autocommands,
+      { desc = 'Find nvim Autocommands.' })
+  -- search for vim options
+  map('n', '<leader>sv', telebuilt.vim_options, { desc = 'Find vim options.' })
+  -- search for string in project
   map('n', '<leader>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', '<leader>so', telebuilt.oldfiles, { desc = 'Find old files.' })
+  -- Code Actions (requires telescope)
+  if pcall(require, "actions-preview") then
+    map({ "n", "v" }, "<leader>ca", require("actions-preview").code_actions, {
+      desc = 'preview code actions'
+    })
+  end
 end
 
 map('n', '<leader>u', '<cmd>UndotreeToggle<CR>', { desc = 'Open undo tree.' })
 map('n', '<leader>f', '<cmd>SFMToggle<CR>', { desc = 'Open file tree view.' })
 map('n', '<leader>b', '<cmd>JABSOpen<CR>', { desc = 'Switch between buffers.' })
-map('n', '<leader>tt', '<cmd>TroubleToggle<CR>', { desc = 'Diagnostic list.' })
-map('n', '<leader>tc', '<cmd>TodoTrouble<CR>', { desc = 'Comment list.' })
-map('n', '<C-e>', '<cmd>IconPickerYank<CR>', { 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', '<leader>gph', '<cmd>Gitsigns preview_hunk_inline<CR>')
-map('n', '<leader>gsh', '<cmd>Gitsigns stage_hunk<CR>')
+-- git
+map('n', '<leader>gp', '<cmd>Gitsigns preview_hunk_inline<CR>')
+map('n', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>')
 map('n', '<leader>gb', '<cmd>Gitsigns blame_line<CR>')
+map('n', '<leader>g]', '<cmd>Gitsigns next_hunk<CR>')
+map('n', '<leader>g[', '<cmd>Gitsigns prev_hunk<CR>')
 
 -- neogen
 if pcall(require, "neogen") then
   map('n', '<leader>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", "<C-v>j:VBox<CR>", {noremap = true})
+    vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true})
+    vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true})
+    vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true})
+    -- draw a box by pressing "f" with visual selection
+    vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true})
+  else
+    vim.cmd[[setlocal ve=]]
+    vim.cmd[[mapclear <buffer>]]
+    vim.b.venn_enabled = nil
+  end
+end
+-- toggle keymappings for venn using <leader>v
+vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true})
diff --git a/lua/core/cmds.lua b/lua/core/cmds.lua
index 03ff87f..3cc78e1 100644
--- a/lua/core/cmds.lua
+++ b/lua/core/cmds.lua
@@ -3,4 +3,6 @@ local function cmd(name, exec, opts)
   vim.api.nvim_create_user_command(name, exec, opts)
 end
 
-cmd('Colorscheme', 'Telescope colorscheme')
+cmd('Colorscheme', function()
+  require('telescope.builtin').colorscheme()
+end)
diff --git a/lua/core/opts.lua b/lua/core/opts.lua
index 62386dc..82d88bd 100644
--- a/lua/core/opts.lua
+++ b/lua/core/opts.lua
@@ -1,6 +1,6 @@
 -- better ui ------------------------------------------------------------------
 if pcall(require, "notify") then vim.notify = require("notify") end
--- o.colorcolumn = { 80 }
+o.colorcolumn = { 80 }
 
 -- buffer
 o.scrolloff = 5
@@ -11,16 +11,13 @@ o.cursorline = true
 -- statusbar
 o.laststatus = 3
 o.cmdheight = 1
-if o.cmdheight == 0 then
-  o.showcmdloc = 'statusline'
-end
 o.showmode = false -- stop vim from showing mode (we have a statusbar)
 
+-- tabline
+o.showtabline = 2
+
 -- status column
 o.signcolumn = 'yes:1' -- show gutter
-o.relativenumber = true
-o.number = true
-o.numberwidth = 2
 
 -- indents + tabs
 local tabwidth = 2
@@ -38,7 +35,7 @@ vim.cmd('colorscheme mellow') -- mellow
 vim.cmd('colorscheme mellow+') -- some changes
 
 -- better editing -------------------------------------------------------------
-o.clipboard = 'unnamedplus' -- system clipboard (on unix like)
+o.clipboard = 'unnamedplus' -- system clipboard
 
 -- file saving ----------------------------------------------------------------
 o.swapfile = false
diff --git a/lua/core/plugins.lua b/lua/core/plugins.lua
index a22bed4..106e73d 100644
--- a/lua/core/plugins.lua
+++ b/lua/core/plugins.lua
@@ -16,8 +16,9 @@ require 'dep' {
   -- { 'andweeb/presence.nvim' },
 
   -- colorschemes -------------------------------------------------------------
-  { 'kvrohit/mellow.nvim' },
-  { 'rockerBOO/boo-colorscheme-nvim' },
+  { 'kvrohit/mellow.nvim',
+    requires = 'nvim-treesitter/nvim-treesitter'
+  },
 
   -- ui -----------------------------------------------------------------------
   { 'lukas-reineke/indent-blankline.nvim' }, -- indentation indicators
@@ -28,35 +29,41 @@ require 'dep' {
   },
   { 'goolord/alpha-nvim' }, -- start page
   { 'dinhhuy258/sfm.nvim', -- tree view
-    requires = 'dinhhuy258/sfm-git.nvim',
+    deps = 'dinhhuy258/sfm-git.nvim',
   },
-  { 'mrjones2014/smart-splits.nvim'}, -- buffer resizing
-  { 'axieax/urlview.nvim' }, -- view urls in current buffer
   { 'matbme/JABS.nvim' }, -- buffer switcher
-  { 'ziontee113/icon-picker.nvim' }, -- icons
-  { 'petertriho/nvim-scrollbar' }, -- scrollbar
-  -- { 'lewis6991/satellite.nvim' }, -- new scrollbar for nvim 0.10
-  { 'pocco81/true-zen.nvim' }, -- focus on the current thing
   { 'tomiis4/Hypersonic.nvim' }, -- regex helper/displayer
 
-  { 'lewis6991/cleanfold.nvim' }, -- nice fold line
-  { 'yaocccc/nvim-foldsign' }, -- fold sign in gutter
-
   -- functional plugins -------------------------------------------------------
-  { 'lewis6991/gitsigns.nvim' },
-  { 'chentoast/marks.nvim' },
-  { 'pta2002/intellitab.nvim' },
+  { 'lewis6991/gitsigns.nvim' }, -- very helpful git things
+  { 'squibid/git-yodel', -- git cache diff preview when in commit buffer
+    url = 'https://git.squi.bid/git-yodel'
+  },
+  { 'chentoast/marks.nvim' }, -- marks in gutter
+  { 'pta2002/intellitab.nvim' }, -- better tabbing into indents
   { 'mbbill/undotree' }, -- careful this one is written in vimscript
+  { 'dhruvasagar/vim-table-mode' }, -- same with this one
   { 'windwp/nvim-autopairs' },
   { 'numToStr/Comment.nvim' },
-  { 'numtostr/BufOnly.nvim' }, -- kill the other buffers with :BufOnly
   { 'ahmedkhalf/project.nvim' }, -- cd into root of project
-  { 'akinsho/toggleterm.nvim' },
-  { 'chomosuke/term-edit.nvim' }, -- full vim keybinds in terminals
+  { 'akinsho/toggleterm.nvim' }, -- TODO: switch to tmux based popup terminal
+  { 'mrjones2014/smart-splits.nvim'}, -- buffer resizing
 
   -- note taking --------------------------------------------------------------
-  { 'nvim-neorg/neorg' },
-  { 'nvim-neorg/neorg-telescope' },
+  { 'nvim-neorg/neorg',
+    config = function()
+      if package.loaded['nvim-treesitter'] then
+        vim.cmd(':Neorg sync-parsers<CR>')
+      end
+    end,
+    requires = {
+      'nvim-lua/plenary.nvim',
+      'nvim-treesitter/nvim-treesitter'
+    },
+    deps = 'nvim-neorg/neorg-telescope'
+  },
+
+  { 'jbyuki/venn.nvim' },
 
   -- fzf ----------------------------------------------------------------------
   { 'nvim-telescope/telescope.nvim',
@@ -64,19 +71,23 @@ require 'dep' {
     deps = {
       'nvim-telescope/telescope-file-browser.nvim',
       'nvim-telescope/telescope-ui-select.nvim',
-      'AckslD/nvim-neoclip.lua',
+      'nvim-telescope/telescope-symbols.nvim',
+      'axieax/urlview.nvim',
     }
   },
 
   -- treesitter + colorizing --------------------------------------------------
   { 'nvim-treesitter/nvim-treesitter',
     deps = {
-      { 'm-demare/hlargs.nvim' },
-      { 'Wansmer/treesj' },
-      { 'nvim-treesitter/nvim-treesitter-context' },
+      'm-demare/hlargs.nvim',
+      'Wansmer/treesj',
+      'nvim-treesitter/nvim-treesitter-context',
     }
   },
   { 'NvChad/nvim-colorizer.lua' },
+  { 'folke/todo-comments.nvim',
+    requires = 'nvim-lua/plenary.nvim',
+  },
 
   -- cmp ----------------------------------------------------------------------
   { 'hrsh7th/nvim-cmp',
@@ -103,15 +114,16 @@ require 'dep' {
   { 'j-hui/fidget.nvim', -- shows lsp progress
     branch = 'legacy',
   },
-  { 'folke/neodev.nvim' }, -- configure lua lsp for neovim
 
   { 'ray-x/lsp_signature.nvim' }, -- see information about the current function
   { 'dnlhc/glance.nvim' }, -- diagnostic info at a glance
+  { 'aznhe21/actions-preview.nvim', -- codeactions
+    requires = 'nvim-telescope/telescope.nvim'
+  },
 
-  { 'folke/trouble.nvim' },
-  { 'folke/todo-comments.nvim' },
-
-  { 'danymat/neogen' }, -- generate lsp annotations
+  { 'danymat/neogen', -- generate lsp annotations
+    requires = 'nvim-treesitter/nvim-treesitter'
+  },
 
   { 'whynothugo/lsp_lines.nvim',
     url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim',
@@ -120,9 +132,11 @@ require 'dep' {
   -- dap + lsp + linter + formatter installer ---------------------------------
   { 'williamboman/mason.nvim',
     deps = {
-      { 'WhoIsSethDaniel/mason-tool-installer.nvim' },
-      { 'williamboman/mason-lspconfig.nvim' },
-      { 'jay-babu/mason-nvim-dap.nvim' },
-    },
+      'WhoIsSethDaniel/mason-tool-installer.nvim',
+      'williamboman/mason-lspconfig.nvim',
+    }
+  },
+  { 'mfussenegger/nvim-dap',
+    deps = 'rcarriga/nvim-dap-ui'
   },
 }
-- 
cgit v1.2.1