summaryrefslogtreecommitdiffstats
path: root/lua/conf
diff options
context:
space:
mode:
Diffstat (limited to 'lua/conf')
-rw-r--r--lua/conf/auto.lua85
-rw-r--r--lua/conf/binds.lua174
-rw-r--r--lua/conf/init.lua4
-rw-r--r--lua/conf/opts.lua65
-rw-r--r--lua/conf/plugins.lua141
5 files changed, 469 insertions, 0 deletions
diff --git a/lua/conf/auto.lua b/lua/conf/auto.lua
new file mode 100644
index 0000000..8c990d6
--- /dev/null
+++ b/lua/conf/auto.lua
@@ -0,0 +1,85 @@
+local function auto(event, opts)
+ a.nvim_create_autocmd(event, opts)
+end
+
+local function augroup(name, opts)
+ opts = opts or {}
+ opts['clear'] = true
+ a.nvim_create_augroup(name, opts)
+end
+
+local winchange = augroup('winchange')
+local bufcheck = augroup('bufcheck')
+local toggles = augroup('toggles')
+
+auto({ "FocusGained", "TermClose", "TermLeave" }, {
+ group = bufcheck,
+ desc = 'Update contents of file.',
+ command = "checktime",
+})
+
+auto("VimResized", {
+ group = winchange,
+ desc = 'Resize splits when window is resized.',
+ callback = function()
+ local current_tab = vim.fn.tabpagenr()
+ vim.cmd("tabdo wincmd =")
+ vim.cmd("tabnext " .. current_tab)
+ end,
+})
+
+auto('TextYankPost', {
+ group = bufcheck,
+ pattern = '*',
+ desc = 'Highlight on yank.',
+ callback = function()
+ vim.highlight.on_yank{ timeout = 250 }
+ end
+})
+
+auto('BufRead', {
+ pattern = '*',
+ group = bufcheck,
+ desc = 'Return to the last place the buffer was closed in.',
+ callback = function() vim.cmd([[call setpos(".", getpos("'\""))]]) end
+})
+
+auto('FileType', {
+ pattern = { 'gitcommit', 'markdown' },
+ desc = 'Spell checking and wrapping in commit buffers and markdown files.',
+ callback = function()
+ vim.opt_local.wrap = true
+ vim.opt_local.spell = true
+ end
+})
+
+auto('BufWritePre', {
+ pattern = '*',
+ group = bufcheck,
+ desc = 'Basically mkdir -p.',
+ callback = function(ctx)
+ if ctx.match:match("^%w%w+://") then return end
+ local dir = vim.fn.fnamemodify(ctx.file, ':p:h')
+ vim.fn.mkdir(dir, 'p')
+ end
+})
+
+auto('WinLeave', {
+ pattern = '!Alpha',
+ desc = 'Unset cursorline',
+ group = toggles,
+ callback = function() vim.opt.cursorline = false end
+})
+
+auto('WinEnter', {
+ pattern = '!Alpha',
+ desc = 'Set cursorline',
+ group = toggles,
+ callback = function() vim.opt.cursorline = true end
+})
+
+auto('ColorScheme', {
+ desc = 'Update statusline on colorscheme change',
+ group = winchange,
+ callback = function() require('el').reset_windows() end
+})
diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua
new file mode 100644
index 0000000..5fc8055
--- /dev/null
+++ b/lua/conf/binds.lua
@@ -0,0 +1,174 @@
+local conf = require('core.conf')
+
+local function map(mode, bind, cmd, opts)
+ 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)
+ end
+ elseif type(bind) == 'string' then
+ vim.keymap.set(mode, bind, cmd, opts)
+ end
+end
+
+-- vim binds ------------------------------------------------------------------
+g.mapleader = ' ' -- set leader key
+
+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", { 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
+map('n', 'n', 'nzzzv') -- when searching
+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
+
+-- add some keybinds to the file view (netrw)
+a.nvim_create_autocmd('FileType', {
+ pattern = 'netrw',
+ callback = function()
+ local bind = function(lhs, rhs)
+ vim.keymap.set('n', lhs, rhs, { remap = true, buffer = true })
+ end
+ bind('h', '-^') -- Go up a directory
+ bind('l', '<CR>') -- Go down a directory / open a file
+ bind('.', 'gh') -- Toggle hidden files
+ bind('P', '<C-w>z') -- Close preview window
+ bind('<esc>', '<cmd>q<CR>') -- Close netrw
+ end
+})
+
+-- tabs
+map('n', '[]', '<cmd>tabnew<CR>')
+map('n', '][', '<cmd>tabc<CR>')
+map('n', '[[', '<cmd>tabp<CR>')
+map('n', ']]', '<cmd>tabN<CR>')
+
+-- config binds ---------------------------------------------------------------
+map('n', '<leader>m', conf.configmenu, { desc = 'Neovim config manager menu', })
+
+-- plugin binds ---------------------------------------------------------------
+
+-- pretty lsp view
+map('n', 'gd', '<CMD>Glance definitions<CR>')
+map('n', 'gr', '<CMD>Glance references<CR>')
+map('n', 'gy', '<CMD>Glance type_definitions<CR>')
+map('n', 'gi', '<CMD>Glance implementations<CR>')
+
+if pcall(require, "treesj") then
+ local treesj = require('treesj') -- treesj
+ map('n', '<leader>j', treesj.toggle)
+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 Keymaps.' })
+ -- 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()
+ vim.ui.input({ prompt = 'Find string in project' }, function(input)
+ if not input or input == '' then
+ vim.notify('No query!', vim.log.levels.WARN, { title = misc.appid })
+ return nil
+ end
+ telebuilt.grep_string({ search = input })
+ end)
+ end, { desc = 'Find string in project.' })
+ -- 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.' })
+
+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
+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>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 anotations',
+ })
+end
+
+-- venn
+function _G.Toggle_venn()
+ local mapb = vim.api.nvim_buf_set_keymap
+ 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
+ mapb(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
+ mapb(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
+ mapb(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
+ mapb(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
+ -- draw a box by pressing "f" with visual selection
+ mapb(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
+map('n', '<leader>v', ":lua Toggle_venn()<CR>")
diff --git a/lua/conf/init.lua b/lua/conf/init.lua
new file mode 100644
index 0000000..2029141
--- /dev/null
+++ b/lua/conf/init.lua
@@ -0,0 +1,4 @@
+misc.include('conf.plugins') -- load plugins first to allow colorscheme to be set in opts
+misc.include('conf.opts')
+misc.include('conf.binds')
+misc.include('conf.auto')
diff --git a/lua/conf/opts.lua b/lua/conf/opts.lua
new file mode 100644
index 0000000..3997b5f
--- /dev/null
+++ b/lua/conf/opts.lua
@@ -0,0 +1,65 @@
+-- better ui ------------------------------------------------------------------
+if pcall(require, "notify") then vim.notify = require("notify") end
+o.colorcolumn = { 80 }
+
+-- buffer
+o.scrolloff = 5
+o.wrap = true -- wraping lines
+o.linebreak = true -- fix where line is wraped
+o.cursorline = true
+
+-- statusbar
+o.laststatus = 3
+o.cmdheight = 1
+o.showmode = false -- stop vim from showing mode (we have a statusbar)
+
+-- tabline
+o.showtabline = 2
+
+-- status column
+o.signcolumn = 'yes:1' -- show gutter
+
+-- indents + tabs
+local tabwidth = 2
+o.expandtab = true
+o.smarttab = true
+o.cindent = true
+o.autoindent = true
+o.tabstop = tabwidth
+o.shiftwidth = tabwidth
+o.softtabstop = tabwidth
+
+-- colorscheme
+o.termguicolors = true
+misc.colorscheme('mellow')
+
+-- better editing -------------------------------------------------------------
+o.clipboard = 'unnamedplus' -- system clipboard
+o.splitkeep = "screen" -- keep same text on screen when spliting
+
+-- file saving ----------------------------------------------------------------
+o.swapfile = false
+o.undofile = true
+o.confirm = true
+
+-- searching ------------------------------------------------------------------
+o.ignorecase = true
+o.smartcase = true
+o.wrapscan = true
+o.showmatch = true
+o.incsearch = true
+
+-- wild menus -----------------------------------------------------------------
+o.wildoptions = 'pum'
+o.pumblend = 3
+o.pumheight = 20
+
+o.wildignorecase = true
+o.wildignore = '*.o'
+
+-- netrw ----------------------------------------------------------------------
+g.netrw_banner = 1
+g.netrw_localcopydircmd = 'cp -r'
+g.netrw_winsize = 30
+g.netrw_liststyle = 1
+g.netrw_preview = 1
diff --git a/lua/conf/plugins.lua b/lua/conf/plugins.lua
new file mode 100644
index 0000000..23be6c6
--- /dev/null
+++ b/lua/conf/plugins.lua
@@ -0,0 +1,141 @@
+require('dep') {
+ -- dep manages dep ----------------------------------------------------------
+ { 'squibid/dep',
+ url = 'https://git.squi.bid/dep',
+ pin = true,
+ -- branch = 'dev'
+ },
+
+ -- colorschemes -------------------------------------------------------------
+ { 'kvrohit/mellow.nvim',
+ requires = 'nvim-treesitter/nvim-treesitter'
+ },
+
+ -- ui -----------------------------------------------------------------------
+ { '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'
+ },
+ { 'goolord/alpha-nvim' }, -- start page
+ { 'dinhhuy258/sfm.nvim', -- tree view
+ deps = 'dinhhuy258/sfm-git.nvim'
+ },
+ { 'matbme/JABS.nvim' }, -- buffer switcher
+ { 'stevearc/dressing.nvim', -- nice ui selectors
+ requires = 'nvim-telescope/telescope.nvim'
+ },
+ { 'lukas-reineke/headlines.nvim',
+ requires = 'nvim-neorg/neorg'
+ },
+
+ -- functional plugins -------------------------------------------------------
+ { '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
+ { 'vidocqh/auto-indent.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' },
+ { 'ahmedkhalf/project.nvim' }, -- cd into root of project
+ { 'akinsho/toggleterm.nvim' }, -- TODO: switch to tmux based popup terminal
+ { 'mrjones2014/smart-splits.nvim'}, -- buffer resizing
+
+ -- note taking --------------------------------------------------------------
+ { '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',
+ requires = 'nvim-lua/plenary.nvim',
+ deps = {
+ 'nvim-telescope/telescope-file-browser.nvim',
+ 'nvim-telescope/telescope-symbols.nvim',
+ 'axieax/urlview.nvim'
+ }
+ },
+ { 'nvim-telescope/telescope-fzf-native.nvim',
+ config = function()
+ vim.cmd('make')
+ end,
+ requires = 'nvim-telescope/telescope.nvim'
+ },
+
+ -- treesitter + colorizing --------------------------------------------------
+ { 'nvim-treesitter/nvim-treesitter',
+ deps = {
+ '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',
+ deps = {
+ 'lukas-reineke/cmp-under-comparator', -- better results
+ 'hrsh7th/cmp-buffer', -- buffers
+ 'FelipeLema/cmp-async-path', -- path
+ 'hrsh7th/cmp-calc', -- calculator
+ 'hrsh7th/cmp-nvim-lsp', -- lsp
+ 'uga-rosa/cmp-dictionary', -- dictionary
+ 'hrsh7th/cmp-nvim-lua', -- nvim lua api
+ { 'doxnit/cmp-luasnip-choice', -- luasnip
+ requires = 'L3MON4D3/LuaSnip'
+ }
+ },
+ },
+
+ -- snippets -----------------------------------------------------------------
+ { 'L3MON4D3/LuaSnip',
+ deps = 'rafamadriz/friendly-snippets'
+ },
+
+ -- lsp ----------------------------------------------------------------------
+ { 'neovim/nvim-lspconfig' }, -- setup lsp
+ { 'j-hui/fidget.nvim', -- shows lsp progress
+ branch = 'legacy'
+ },
+
+ { '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'
+ },
+
+ { 'danymat/neogen', -- generate lsp annotations
+ requires = 'nvim-treesitter/nvim-treesitter'
+ },
+
+ { 'whynothugo/lsp_lines.nvim',
+ url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim'
+ },
+
+ -- mason --------------------------------------------------------------------
+ { 'williamboman/mason.nvim',
+ deps = {
+ 'WhoIsSethDaniel/mason-tool-installer.nvim',
+ 'williamboman/mason-lspconfig.nvim'
+ }
+ }
+}