From d98cce7d6438cd8f37ab61569005c24921ffcba6 Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 23 Dec 2022 20:06:50 -0500 Subject: too much to explain just read the diff --- init.lua | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 21 deletions(-) diff --git a/init.lua b/init.lua index 332f6d5..4d14b2d 100644 --- a/init.lua +++ b/init.lua @@ -10,13 +10,13 @@ g.mapleader = " " o.number = true o.relativenumber = true o.numberwidth = 2 -o.cursorline = true +o.cursorline = true -- highlights the current line o.scrolloff = 5 -- # lines below/above cursor -o.showmode = false -o.cmdheight = 2 +o.showmode = false -- stop vim from showing mode +o.cmdheight = 2 -- vim command height o.mouse = "" -- no mouse -o.wrap = true +o.wrap = true -- wrap lines o.linebreak = true o.emoji = false o.clipboard = 'unnamedplus' -- use system clipboard @@ -107,6 +107,14 @@ a.nvim_create_autocmd('TermClose', { command = 'call nvim_input("")' }) +-- close terminal buffer in normal mode +a.nvim_create_autocmd('FileType', { + pattern = 'term://*', + callback = function() + vim.keymap.set('n', '', 'q!', {remap = true, buffer = true}) + end +}) + -- start git messages in insert mode a.nvim_create_autocmd('FileType', { group = 'bufcheck', @@ -114,6 +122,34 @@ a.nvim_create_autocmd('FileType', { command = 'startinsert | 1' }) +-- add some keybinds to the file view +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', '') -- Go down a directory / open a file + bind('.', 'gh') -- Toggle dotfiles + bind('P', 'z') -- Close preview window + end +}) + +-- return to last place +a.nvim_create_autocmd('BufRead', { + pattern = '*', + command = [[call setpos(".", getpos("'\""))]] +}) + +-- source and compile lua conf +local packer_group = a.nvim_create_augroup('Packer', { clear = true }) +vim.api.nvim_create_autocmd('BufWritePost', { + command = 'source | PackerCompile', + group = packer_group, + pattern = vim.fn.expand '$MYVIMRC', +}) + -------------- -- keybinds -- -------------- @@ -127,17 +163,29 @@ a.nvim_set_keymap("t", "", "", default_opts) a.nvim_set_keymap("n", "to", "vw:term", default_opts) -- open file viewer -a.nvim_set_keymap("n", "", ":Explore", default_opts) -a.nvim_set_keymap("n", "", ":Sexplore", default_opts) +a.nvim_set_keymap("n", "", ":Ex", default_opts) +a.nvim_set_keymap("n", "", ":Sex", default_opts) -- clear search a.nvim_set_keymap("n", "", ":nohlsearch:echo", default_opts) +-- move selected text +a.nvim_set_keymap("v", "", ":m '>+1gv=gv", default_opts) +a.nvim_set_keymap("v", "", ":m '<-2gv=gv", default_opts) + +-- keep cursor middle +a.nvim_set_keymap("n", "", "mzJ`z", default_opts) -- when combining lines +a.nvim_set_keymap("n", "n", "nzzzv", default_opts) -- searching +a.nvim_set_keymap("n", "N", "Nzzzv", default_opts) + +-- execute order 111 +a.nvim_set_keymap("n", "x", "!chmod +x %", default_opts) + -- Resizing panes -a.nvim_set_keymap("n", '', "SmartResizeLeft", default_opts) -a.nvim_set_keymap("n", '', "SmartResizeDown", default_opts) -a.nvim_set_keymap("n", '', "SmartResizeUp", default_opts) -a.nvim_set_keymap("n", '', "SmartResizeRight", default_opts) +a.nvim_set_keymap("n", '', "SmartResizeLeft", default_opts) +a.nvim_set_keymap("n", '', "SmartResizeDown", default_opts) +a.nvim_set_keymap("n", '', "SmartResizeUp", default_opts) +a.nvim_set_keymap("n", '', "SmartResizeRight", default_opts) -- moving between splits a.nvim_set_keymap("n", '', "SmartCursorMoveLeft", default_opts) @@ -163,15 +211,15 @@ a.nvim_set_hl(0, "IndentBlanklineIndent6", { fg = colors.purple } ) if tablines == 'colored' then require("indent_blankline").setup { - space_char_blankline = " ", - char_highlight_list = { - "IndentBlanklineIndent1", - "IndentBlanklineIndent2", - "IndentBlanklineIndent3", - "IndentBlanklineIndent4", - "IndentBlanklineIndent5", - "IndentBlanklineIndent6", - }, + space_char_blankline = " ", + char_highlight_list = { + "IndentBlanklineIndent1", + "IndentBlanklineIndent2", + "IndentBlanklineIndent3", + "IndentBlanklineIndent4", + "IndentBlanklineIndent5", + "IndentBlanklineIndent6", + }, } elseif tablines == 'wrap' then o.list = true @@ -423,6 +471,18 @@ cmp.setup { ------------- -- plugins -- ------------- + +-- install packer (stolen from nvim-lua/kickstart.nvim) +local install_path = vim.fn.stdpath 'data' .. + '/site/pack/packer/start/packer.nvim' +local bootstrap = false +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + bootstrap = true + vim.fn.system { 'git', 'clone', '--depth', '1', + 'https://github.com/wbthomason/packer.nvim', install_path } + vim.cmd [[packadd packer.nvim]] +end + return require('packer').startup(function(use) -- use packer to manage packer :) use 'wbthomason/packer.nvim' @@ -450,6 +510,7 @@ return require('packer').startup(function(use) use { 'nvim-treesitter/nvim-treesitter', config = function() require'nvim-treesitter.configs'.setup { + ensure_installed = { "help", "c", "lua", }, highlight = { enable = true, additional_vim_regex_highlighting = false, @@ -465,8 +526,6 @@ return require('packer').startup(function(use) patterns = { default = { 'function', - --[[ 'class', - 'method', ]] }, }, } @@ -492,6 +551,7 @@ return require('packer').startup(function(use) "term", "gitcommit", "packer", + "vim", }, }) codewindow.apply_default_keybinds() @@ -544,4 +604,8 @@ return require('packer').startup(function(use) use { 'windwp/nvim-autopairs', config = function() require("nvim-autopairs").setup {} end } + + if bootstrap then + require('packer').sync() + end end) -- cgit v1.2.1