From e48c506796f8d6c7ce98cfa0a29b66ee4b08e6f7 Mon Sep 17 00:00:00 2001 From: tomit4 Date: Sat, 23 Apr 2022 09:44:23 -0700 Subject: [PATCH] almost done converting init.vim to init.lua, just need to install nvim-completion --- nvim/lua/config.lua | 63 ++++++++++++++++++++++++++++++++++++---- nvim/lua/keybindings.lua | 16 ++++++++++ nvim/lua/packages.lua | 17 ++++++----- 3 files changed, 83 insertions(+), 13 deletions(-) diff --git a/nvim/lua/config.lua b/nvim/lua/config.lua index 4d0c6d2d..77e87297 100644 --- a/nvim/lua/config.lua +++ b/nvim/lua/config.lua @@ -1,9 +1,9 @@ --- main init.lua configurations - keymap = vim.api.nvim_set_keymap --- Nvim_Tree configuration: --- -- setup with all defaults +-- Enable ColorScheme +vim.cmd[[colorscheme nord]] + +-- Nvim_Tree configuration: -- setup with all defaults -- each of these are documented in `:help nvim-tree.OPTION_NAME` require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS auto_reload_on_write = true, @@ -118,6 +118,11 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS }, } -- END_DEFAULT_OPTS for Nvim_Tree +-- Lua Line color configuration +require('lualine').setup({ +options = { theme = 'nord' } +}) + -- Automatically closes Nvim tree if last window open vim.cmd[[autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif]] @@ -148,6 +153,52 @@ vim.g.NERDSpaceDelims= 1 vim.g.termguicolors = true vim.g.nosplitright = true --- do not close the markdown preview tab when switching to other buffers -vim.g.mkdp_auto_close = 0 +-- set relative number +vim.opt.number = true +vim.opt.cursorcolumn = true +-- vim.opt.cursor = true +vim.opt.mouse = 'a' +vim.opt.autoindent = true +vim.opt.smarttab = true +vim.opt.ignorecase = true +vim.opt.cindent = true +vim.opt.tabstop = 8 +vim.opt.softtabstop = 0 +vim.opt.shiftwidth = 4 +-- always uses spaces instead of tab characters +vim.opt.expandtab = true + +-- if hidden is not set, TextEdit might fail. +vim.opt.hidden = true +-- Set the height of the status line down at the bottom +vim.opt.cmdheight = 1 +-- Set the amount of characters you get back from status/error messages +vim.opt.updatetime = 300 +-- always show signcolumns +vim.opt.signcolumn = 'yes' + +-- Fix Splitting +vim.opt.splitbelow = true +vim.opt.splitright = true + +-- Vertically center document when entering Insert mode +vim.cmd[[autocmd InsertEnter * norm zz]] + +-- Removes trailing spaces +vim.cmd[[function TrimWhiteSpace() + %s/\s*$// + '' +endfunction]] + +--Removes trailing spaces on save +vim.cmd[[autocmd FileWritePre * call TrimWhiteSpace()]] +vim.cmd[[autocmd FileAppendPre * call TrimWhiteSpace()]] +vim.cmd[[autocmd FilterWritePre * call TrimWhiteSpace()]] +vim.cmd[[autocmd BufWritePre * call TrimWhiteSpace()]] + +-- Enable Comments with Italics (below selected colorscheme) +vim.cmd[[highlight Comment cterm=italic gui=italic]] + +-- do not close the markdown preview tab when switching to other buffers +-- vim.g.mkdp_auto_close = 0 diff --git a/nvim/lua/keybindings.lua b/nvim/lua/keybindings.lua index 457da397..3739f2e8 100644 --- a/nvim/lua/keybindings.lua +++ b/nvim/lua/keybindings.lua @@ -1,3 +1,6 @@ +-- remap leader key +vim.g.mapleader = "," + -- remap Nvim_Tree toggle to CTRL+B keymap('n', '', ':NvimTreeToggle', {}) @@ -24,3 +27,16 @@ keymap('n', '', ':nohl', {silent = true}) -- Toggle Multi-Cursor with j or k vim.cmd[[nmap ]] vim.cmd[[nmap ]] + +-- Escape Insert Mode with ii +keymap('i', 'ii', '', {}) + +-- Insert a console.log() +vim.cmd[[ inoremap cll console.log()i]] + +-- Alias replace all to shift + S +vim.cmd[[nnoremap S :%s///gI]] + +-- j/k will move virtual lines (lines that wrap) +vim.cmd[[noremap j (v:count == 0 ? 'gj' : 'j')]] +vim.cmd[[noremap k (v:count == 0 ? 'gk' : 'k')]] diff --git a/nvim/lua/packages.lua b/nvim/lua/packages.lua index 4ebd5eec..a4cf9860 100644 --- a/nvim/lua/packages.lua +++ b/nvim/lua/packages.lua @@ -1,23 +1,26 @@ -- Packages installed using 'packer', install using :PackerSync +-- call Plug for MarkDownPreview +-- vim.cmd[[call plug#begin('~/.vim/plugged') Plug 'iamcco/markdown-preview.nvim', {'do': { -> mkdp#util#install() }}]] + require('packer').startup(function() use 'wbthomason/packer.nvim' use 'kyazdani42/nvim-web-devicons' -- for file icons use 'kyazdani42/nvim-tree.lua' + use {'nvim-lualine/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true }} + use 'shaunsingh/nord.nvim' use 'psliwka/vim-smoothie' -- use 'mattn/emmet-vim' -- use 'ap/vim-css-color' -- use 'airblade/vim-gitgutter' - -- use 'ctrlpvim/ctrlp.vim' -- fuzzy find files - -- use 'junegunn/fzf'--{ 'do': { -> fzf#install() } } + use 'ctrlpvim/ctrlp.vim' -- fuzzy find files + -- use {'junegunn/fzf', run = ':call fzf#installo()'}--{ 'do': { -> fzf#install() } } use 'preservim/nerdcommenter' - -- use 'Yggdroot/indentLine' - -- use 'sheerun/vim-polyglot' + use 'Yggdroot/indentLine' use 'mg979/vim-visual-multi'-- {'branch': 'master'} use {'iamcco/markdown-preview.nvim', run = ':call mkdp#util#install'} -- {'do': { -> mkdp#util#install() }} use 'luochen1990/rainbow' - -- use 'simeji/winresizer' + use 'simeji/winresizer' use '907th/vim-auto-save' - -- use 'itchyny/lightline.vim' - -- use 'jremmen/vim-ripgrep' + use 'jremmen/vim-ripgrep' end)