diff options
author | Squibid <me@zacharyscheiman.com> | 2023-08-11 20:43:58 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2023-08-11 20:43:58 -0400 |
commit | 590f0309995a569954fc94b1d5df6b6391ead9fa (patch) | |
tree | cfca10f62e189018c0bb7944d446423e6397f375 /lua/core | |
parent | b8d70ed288b3b542b7bb24609384aa540339b2da (diff) | |
download | nvim-590f0309995a569954fc94b1d5df6b6391ead9fa.tar.gz nvim-590f0309995a569954fc94b1d5df6b6391ead9fa.tar.bz2 nvim-590f0309995a569954fc94b1d5df6b6391ead9fa.zip |
kitchen sink cause I'm too lazy to sort through this junk
Diffstat (limited to 'lua/core')
-rw-r--r-- | lua/core/auto.lua | 61 | ||||
-rw-r--r-- | lua/core/binds.lua | 94 | ||||
-rw-r--r-- | lua/core/handler.lua | 1 | ||||
-rw-r--r-- | lua/core/highlight.lua | 3 | ||||
-rw-r--r-- | lua/core/opts.lua | 4 | ||||
-rw-r--r-- | lua/core/plugins.lua | 19 |
6 files changed, 87 insertions, 95 deletions
diff --git a/lua/core/auto.lua b/lua/core/auto.lua index d833aa2..5a6c3a3 100644 --- a/lua/core/auto.lua +++ b/lua/core/auto.lua @@ -7,6 +7,7 @@ a.nvim_create_augroup('bufcheck', {clear = true}) auto('TextYankPost', { -- highlight yanks group = 'bufcheck', pattern = '*', + desc = 'Highlight on yank.', callback = function() vim.highlight.on_yank{ timeout = 250 } end @@ -15,68 +16,20 @@ auto('TextYankPost', { -- highlight yanks auto('FileType', { -- start git messages in insert mode group = 'bufcheck', pattern = { 'gitcommit', 'gitrebase', }, + desc = 'Start git messages in insert mode.', command = 'startinsert | 1' }) -auto('FileType', { -- show git cached diff - group = 'bufcheck', - pattern = { 'gitcommit', 'gitrebase', }, - callback = function() - local function lower(a, b) - if a > b then - return b - else - return a - end - end - - local function tablelength(T) - local count = 0 - for _ in pairs(T) do count = count + 1 end - return count - end - - local diff = io.popen('git diff --cached', "r") - local diffl = {} - for i in diff:lines() do - table.insert(diffl, i) - end - diff:close() - - if next(diffl) == nil then - vim.notify('No diff to show :(', vim.log.levels.INFO, { - title = 'Neovim Config' }) - return - end - - local buf = a.nvim_create_buf(true, false) - a.nvim_buf_set_lines(buf, 0, -1, false, diffl) - a.nvim_buf_set_name(buf, 'Git Commit Diff') - a.nvim_buf_set_option(buf, 'ft', 'diff') - a.nvim_buf_set_option(buf, 'readonly', true) - a.nvim_buf_set_option(buf, 'modifiable', false) - a.nvim_buf_set_option(buf, 'modified', false) - local win = a.nvim_open_win(buf, false, { - row = 1, - col = 80, - relative = 'win', - width = 80, - height = lower(vim.o.lines - vim.o.cmdheight - 4, tablelength(diffl)), - border = 'shadow', - style = 'minimal', - }) - end, -}) - - auto('BufRead', { -- return to last place pattern = '*', - command = [[call setpos(".", getpos("'\""))]] + command = [[call setpos(".", getpos("'\""))]], + 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 @@ -87,6 +40,7 @@ auto('TermOpen', { -- start terminal in insert mode 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 @@ -95,6 +49,7 @@ auto('TermClose', { -- close terminal buffers after shell dies auto('InsertEnter', { -- toggle things when entering insert mode group = 'bufcheck', + desc = 'Turn things on insert mode.', callback = function() o.colorcolumn = { 80 } end @@ -102,6 +57,7 @@ auto('InsertEnter', { -- toggle things when entering insert mode auto('InsertLeave', { -- toggle things when exiting insert mode group = 'bufcheck', + desc = 'Turn things off insert mode.', callback = function() o.colorcolumn = { 0 } end @@ -110,6 +66,7 @@ auto('InsertLeave', { -- toggle things when exiting insert mode auto('BufWritePre', { -- make dirs when they don't exist pattern = '*', group = vim.api.nvim_create_augroup('auto_create_dir', { clear = true }), + desc = 'Basically mkdir -p.', callback = function(ctx) local dir = vim.fn.fnamemodify(ctx.file, ':p:h') vim.fn.mkdir(dir, 'p') 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', '<leader>p', [["_dP]]) -- greatest remap ever -map('n', '<ESC>', ':nohlsearch<Bar>:echo<CR>') -- clear search -map('t', '<ESC>', '<C-\\><C-n>') -- make <ESC> work in terminals +map('x', '<leader>p', [["_dP]], { desc = 'Greatest remap of all time.' }) +map('n', '<esc>', ':nohlsearch<Bar>:echo<CR>', { desc = 'Clear search.' }) +map('t', '<esc>', '<C-\\><C-n>', { desc = 'make <esc> work in terminals.' }) -- move selected text up/down -map('v', '<S-k>', ":m '<-2<CR>gv=gv") -map('v', '<S-j>', ":m '>+1<CR>gv=gv") +map('v', '<S-k>', ":m '<-2<CR>gv=gv", { desc = 'Move selected text up.' }) +map('v', '<S-j>', ":m '>+1<CR>gv=gv", { desc = 'Move selected text down.' }) -- the cursor STAYS IN THE MIDDLE map('n', '<S-j>', 'mzJ`z<cmd>delm z<CR>') -- when combining lines @@ -50,10 +53,16 @@ a.nvim_create_autocmd('FileType', { bind('l', '<CR>') -- Go down a directory / open a file bind('.', 'gh') -- Toggle dotfiles bind('P', '<C-w>z') -- Close preview window - bind('<ESC>', '<cmd>q<CR>') -- Close netrw + 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>') + -- plugin binds --------------------------------------------------------------- -- pretty lsp view @@ -62,41 +71,56 @@ map('n', 'gr', '<CMD>Glance references<CR>') map('n', 'gy', '<CMD>Glance type_definitions<CR>') map('n', 'gi', '<CMD>Glance implementations<CR>') -local treesj = require('treesj') -- treesj -map('n', '<leader>j', treesj.toggle) - -local telebuilt = require('telescope.builtin') -- telescope -map('n', '<leader>sf', telebuilt.find_files) -map('n', '<leader>sg', telebuilt.git_files) -map('n', '<leader>sp', function() - telebuilt.grep_string({ search = vim.fn.input('Find string in project > ') }) -end) -map('n', '<leader>so', telebuilt.oldfiles) +if pcall(require, "treesj") then + local treesj = require('treesj') -- treesj + map('n', '<leader>j', treesj.toggle) +end -local intellitab = require('intellitab') -- intellitab -map('n', '<Tab>', intellitab.indent) +if pcall(require, "telescope") then + local telebuilt = require('telescope.builtin') -- telescope + map('n', '<leader>sf', telebuilt.find_files, { desc = 'Find files.' }) + map('n', '<leader>sg', telebuilt.git_files, { desc = 'Find git files.' }) + map('n', '<leader>sp', function() + 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.' }) +end -map('n', '<leader>u', '<cmd>UndotreeToggle<CR>') -- undo tree -map('n', '<leader>f', '<cmd>SFMToggle<CR>') -- sfm -map('n', '<leader>b', '<cmd>JABSOpen<CR>') -- switch between previous buffers -map('n', '<leader>tt', '<cmd>TroubleToggle<CR>') -- trouble (lsp error view) -map('n', '<leader>tc', '<cmd>TodoTrouble<CR>') -- todo trouble -map('n', '<C-e>', '<cmd>IconPickerYank<CR>') -- icon picker +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.' }) -local dapui = require('dapui') -- dap ui -map('n', '<leader>d', dapui.toggle) +if pcall(require, "dapui") then + local dapui = require('dapui') -- dap ui + map('n', '<leader>d', dapui.toggle, { desc = 'Debuging ui.' }) +end -local smartsplits = require('smart-splits') -- resizing buffers (toggleable) -map('n', '<leader>r', smartsplits.start_resize_mode) +if pcall(require, "smart-splits") then + local smartsplits = require('smart-splits') -- resizing buffers (toggleable) + map('n', '<leader>r', smartsplits.start_resize_mode) +end -- toggle term (don't use leader key in these binds) map({'n', 't'}, '<C-\\>', '<cmd>ToggleTerm direction=float<CR>') map({'n', 't'}, '<C-g>', '<cmd>lua _glow()<CR>') -- true zen -map('n', '<leader>zf', '<cmd>lua require("true-zen.focus").toggle()<CR>') -map('n', '<leader>zm', '<cmd>lua require("true-zen.minimalist").toggle()<CR>') -map('n', '<leader>za', '<cmd>lua require("true-zen.ataraxis").toggle()<CR>') +if pcall(require, "true-zen") then + map('n', '<leader>zf', require("true-zen.focus").toggle, { + desc = 'fullscreen', + }) + map('n', '<leader>zm', require("true-zen.minimalist").toggle, { + desc = 'minimal', + }) + map('n', '<leader>za', require("true-zen.ataraxis").toggle, { + desc = 'zen', + }) +end -- Git map('n', '<leader>gph', '<cmd>Gitsigns preview_hunk_inline<CR>') @@ -104,4 +128,8 @@ map('n', '<leader>gsh', '<cmd>Gitsigns stage_hunk<CR>') map('n', '<leader>gb', '<cmd>Gitsigns blame_line<CR>') -- neogen -map('n', '<leader>df', '<cmd>lua require("neogen").generate()<CR>') +if pcall(require, "neogen") then + map('n', '<leader>df', require("neogen").generate, { + desc = 'Generate anootations', + }) +end diff --git a/lua/core/handler.lua b/lua/core/handler.lua index 2808f2f..e1d62c8 100644 --- a/lua/core/handler.lua +++ b/lua/core/handler.lua @@ -1,5 +1,4 @@ require('core.plugins') -- load plugins first to allow colorscheme to be set in opts -require'impatient'.enable_profile() require('core.opts') require('core.highlight') require('core.binds') diff --git a/lua/core/highlight.lua b/lua/core/highlight.lua index c90fd3f..716c5ed 100644 --- a/lua/core/highlight.lua +++ b/lua/core/highlight.lua @@ -1,4 +1,5 @@ local highlight = function(group, opts, space) + if not pcall(require, "mellow") then return end space = space or 0 if type(group) == 'table' then @@ -10,7 +11,7 @@ local highlight = function(group, opts, space) end end -local c = require('mellow.colors').dark +if pcall(require, "mellow") then c = require('mellow.colors').dark end -- vim highlights ------------------------------------------------------------- highlight('CursorLineNr', { bg = c.bg_dark, fg = c.fg, bold = true }) diff --git a/lua/core/opts.lua b/lua/core/opts.lua index 07a3293..826f2b2 100644 --- a/lua/core/opts.lua +++ b/lua/core/opts.lua @@ -1,5 +1,5 @@ -- better ui ------------------------------------------------------------------ -vim.notify = require("notify") +if pcall(require, "notify") then vim.notify = require("notify") end -- o.colorcolumn = { 80 } -- buffer @@ -34,7 +34,7 @@ o.softtabstop = tabwidth -- colorscheme o.termguicolors = true -vim.cmd('colorscheme mellow') +if pcall(require, "mellow") then vim.cmd('colorscheme mellow') end -- better editing ------------------------------------------------------------- o.clipboard = 'unnamedplus' -- system clipboard (on unix like) diff --git a/lua/core/plugins.lua b/lua/core/plugins.lua index d5f6379..8401aad 100644 --- a/lua/core/plugins.lua +++ b/lua/core/plugins.lua @@ -15,15 +15,17 @@ require 'dep' { -- flexing on all the discord users ----------------------------------------- -- { 'andweeb/presence.nvim' }, + -- colorschemes ------------------------------------------------------------- + { 'kvrohit/mellow.nvim' }, + { 'rockerBOO/boo-colorscheme-nvim' }, + -- ui ----------------------------------------------------------------------- - { 'kvrohit/mellow.nvim' }, -- colorscheme { 'lukas-reineke/indent-blankline.nvim' }, -- indentation indicators { 'folke/which-key.nvim' }, -- key map help { 'rcarriga/nvim-notify' }, -- notifications { 'tjdevries/express_line.nvim', -- status bar requires = 'nvim-lua/plenary.nvim', }, - { 'alvarosevilla95/luatab.nvim' }, -- tabline { 'goolord/alpha-nvim' }, -- start page { 'dinhhuy258/sfm.nvim', -- tree view requires = 'dinhhuy258/sfm-git.nvim', @@ -32,10 +34,14 @@ require 'dep' { { 'axieax/urlview.nvim' }, -- view urls in current buffer { 'matbme/JABS.nvim' }, -- buffer switcher { 'ziontee113/icon-picker.nvim' }, -- icons - { 'petertriho/nvim-scrollbar' }, - { 'pocco81/true-zen.nvim' }, + { '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' }, @@ -50,6 +56,7 @@ require 'dep' { -- note taking -------------------------------------------------------------- { 'nvim-neorg/neorg' }, + { 'nvim-neorg/neorg-telescope' }, -- fzf ---------------------------------------------------------------------- { 'nvim-telescope/telescope.nvim', @@ -96,10 +103,10 @@ 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 - { 'kosayoda/nvim-lightbulb' }, -- "light bulb" - Gru - { 'weilbith/nvim-code-action-menu' }, -- code actions { 'folke/trouble.nvim' }, { 'folke/todo-comments.nvim' }, |