From 665c99effc33788d7dd4c29ce1c427d0c483ca81 Mon Sep 17 00:00:00 2001 From: azpsen Date: Wed, 31 Jan 2024 10:14:31 -0600 Subject: [PATCH] add init.lua --- .config/nvim/init.lua | 137 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .config/nvim/init.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..07cf912 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,137 @@ +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- enable line numbers +vim.opt.number = true + +-- enable system clipboard +vim.cmd("set clipboard+=unnamedplus") + +-- set autocomplete to only insert when told to +vim.opt.completeopt = noinsert,menuone,noselect + +-- enable line under/around cursor +vim.opt.cursorline = true + +-- don't require writing files when changin buffers +vim.opt.hidden = true + +-- show find/replace preview in split window +vim.opt.inccommand = split + +-- enable mouse support +vim.opt.mouse = a + +-- set title of window to filename +vim.opt.title = true + +-- replace tabs with spaces +vim.opt.expandtab = true + +-- set autotab width to 2 +vim.opt.shiftwidth = 2 + +-- replace key with 2 spaces +vim.opt.tabstop = 2 + +-- disable compatibility mode +vim.cmd("set nocompatible") + +-- initialize lazy plugin manager +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- download plugins +require("lazy").setup({ + -- theme + "sainnhe/everforest", + + -- syntax highlighting, code features, etc. + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, + + -- sidebar file tree + { + "nvim-tree/nvim-tree.lua", + version = "*", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup {} + end, + }, + + -- status line + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("lualine").setup() + end, + }, + + -- auto match bracket/parenthesis/quote pairs + "jiangmiao/auto-pairs", + + -- show colors inline + "ap/vim-css-color", + + -- display git add/remove/blame info next to line numbers + { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup() + end, + }, + + -- write/read file as sudo + "lambdalisue/suda.vim", + + -- preveiw markdown in browser (:MarkdownPreview to activate) + { + 'iamcco/markdown-preview.nvim', + config = function() + vim.fn["mkdp#util#install"]() + end, + }, + }) + +-- set theme +vim.opt.termguicolors = true +vim.cmd([[colorscheme everforest]]) +vim.opt.background = "dark" + +-- set leader key to and disable other bindings +vim.g.mapleader = " " +vim.keymap.set('n', '', '') + +-- open sidebar file tree with e +vim.keymap.set('n', 'e', 'NvimTreeToggle') + +-- clear highlighting with h +vim.keymap.set('n', 'h', 'noh') + +-- buffer next/prev/close keybinds +vim.keymap.set('n', 'bn', 'bnext') +vim.keymap.set('n', 'bb', 'bprevious') +vim.keymap.set('n', 'bc', 'bd') + +-- vim.api.nvim_create_user_command('w!!', 'SudaWrite', {}) +vim.cmd("ca w!! :SudaWrite") + +-- import treesitter config from ~/.config/nvim/lua/treesitter.lua +require("treesitter")