"use alt-/ to search within a highlighted visual field vnoremap /\%V " "Go to last position in file (also loads folding) autocmd BufWinLeave * silent! mkview autocmd BufWinEnter * silent! loadview " current directory to match netrw browsing let g:netrw_keepdir= 0 "give syntax highlighting to sh files with zsh syntax highlighting au BufRead,BufNewFile *.sh setfiletype zsh set syn=sh call plug#begin() Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/nvim-treesitter-textobjects' " relative and absolute line numbers "Plug 'sitiom/nvim-numbertoggle' "format json files Plug 'XadillaX/json-formatter.vim' "must also run: "npm install -g jjson "usage: ":JSONFormatter" Plug 'github/copilot.vim' "must also run: ":Copilot setup "# Go to my Microsoft Edge bookmark named "Copilot Login" ":Copilot enable "format terraform file with a :TerraformFmt ex command "Also include TerraformSyntax highlighting Plug 'hashivim/vim-terraform' "bash script syntax highlighting "Plug 'godlygeek/tabular' "Plug 'arzg/vim-sh' " Telescope stuff Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.6' } Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } Plug 'ThePrimeagen/harpoon' "Start using vim with googgle docs :))) "Plug 'aadv1k/gdoc.vim', {'do': './install.py'} "LSP stuff "Plug 'neoclide/coc.nvim', {'branch': 'release'} "Plug 'neovim/nvim-lspconfig' " AUTOCOMPLETE STUFF? "Plug 'hrsh7th/nvim-cmp' "Plug 'williamboman/nvim-lsp-installer' "Plug 'tami5/lspsaga.nvim' "Plug 'simrat39/symbols-outline.nvim' "Plug 'hrsh7th/nvim-cmp' "Plug 'hrsh7th/cmp-nvim-lsp' "Plug 'saadparwaiz1/cmp_luasnip' "Plug 'L3MON4D3/LuaSnip' "Plug 'ms-jpq/coq_nvim', {'branch': 'coq'} "Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'} "Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'} "Plug 'heavenshell/vim-pydocstring', { 'do': 'make install' } " "Debugger "Plug 'puremourning/vimspector' " AESTHETICS Plug 'gruvbox-community/gruvbox' "highlighting plugins that may be useful when I'm a senior dev Plug 'junegunn/goyo.vim' Plug 'junegunn/limelight.vim' Plug 'junegunn/rainbow_parentheses.vim' " FILE FORMATTING AND VISUAL HELPS "smooth scrolling Plug 'psliwka/vim-smoothie' "search blink Plug 'ivyl/vim-bling' Plug 'antoinemadec/FixCursorHold.nvim' " "Super handy. Shows the current function or class when scrolling down Plug 'wellle/context.vim' "useful for aligning dictionaries or other declarations "Plug 'junegunn/vim-easy-align' "Plug 'lukas-reineke/indent-blankline.nvim' Plug 'lukas-reineke/indent-blankline.nvim', { 'tag': 'v3.3.10' } " Automatic numbering and bullet points for new lines "Plug 'dkarter/bullets.vim' " FUNCTIONALITIES Plug 'tpope/vim-repeat' " Plug 'ctrlpvim/ctrlp.vim' Plug 'preservim/nerdcommenter' Plug 'svermeulen/vim-easyclip' "Fixes the clipboard functionality "Useful vim surround Keys: "1. cs"' to change the outer characters of current sentence "2. ds" to delete outer characters entirely "3. ysiw" to "surround current" word with " "4. yssb or yss( to wrap entire line with parenthesis "5. S" in visual mode will surround with quotes Plug 'tpope/vim-surround' "shows an outline of imports, functions, and classes by scope Plug 'majutsushi/tagbar' " git assistant Plug 'tpope/vim-fugitive' "Plug 'ryanoasis/vim-devicons' "Plug 'kyazdani42/nvim-web-devicons' "Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' Plug 'kshenoy/vim-signature' call plug#end() let g:NERDSpaceDelims = 1 " Enable automatic formatting of Terraform files on save let g:terraform_fmt_on_save = 1 "system clipboard on wsl2 if system('uname -r') =~ "microsoft" augroup Yank autocmd! autocmd TextYankPost * :call system('/mnt/c/windows/system32/clip.exe ',@") augroup END endif " EasyClip settings nmap M MoveMotionEndOfLinePlug nnoremap gm m " treesitter syntax highlighting lua << EOF require'nvim-treesitter.configs'.setup { highlight = { enable = true, -- Enable Tree-sitter based highlighting }, ensure_installed = {"yaml"}, -- Ensure YAML syntax is supported for GitHub Actions } EOF "set relativenumber " SETS "set startdir=$NVIM_PWD "set number "set relativenumber "set statusline=%!MyStatusLine() "function! MyStatusLine() set statusline+=%F let g:netrw_keepdir= 0 " this should open help in a vertical split set splitright "FOLDING set viminfo+=n~/.vim/viminfo set foldenable set foldmethod=manual function! ToggleAllFolds() " Check if there are any closed folds if foldclosed('.') != -1 " If there are, open all folds normal zR else " Otherwise, close all folds normal zM endif endfunction nnoremap ZA :call ToggleAllFolds() " Fold remaps "nnoremap ZA zR nnoremap ZD zE nnoremap zG VGo:fold nnoremap zgg Vgg:fold "set foldmarker=BEGIN_FOLD,END_FOLD " Managing Manual Folds: "za: Toggle fold under the cursor. "zR: Open all folds. "zM: Close all folds. "zo: Open fold under the cursor. "zc: Close fold under the cursor. "zd: Delete the fold at the cursor. "zE: Erase all folds in the file. "zj: Move to the start of the next fold. "zk: Move to the end of the previous fold. set formatoptions-=cro set nopaste "set splitright "set tabline set conceallevel=0 set autochdir set ignorecase set smartcase set tabstop=4 softtabstop=4 shiftwidth=2 set mouse=a set indentexpr='' "set expandtab "set autoindent "set smarttab "set incsearch ignorecase smartcase hlsearch set nohlsearch "set hlsearch! set wildmode=longest,list,full wildmenu set ruler laststatus=2 showcmd showmode set list listchars=trail:»,tab:»- set fillchars+=vert:\ set wrap breakindent set encoding=utf-8 set textwidth=0 set nohidden set title set undodir=~/.vim/undodir "I need to set up this directory set undofile set incsearch set backspace set autoread set scrolloff=10 set colorcolumn=120 set clipboard=unnamed,unnamedplus """ Coloring set splitbelow set splitright set nocindent set showbreak=>> "set nosmartindent "set noautoindent "set indentexpr= "filetype indent off "filetype plugin indent off lua require ('init') let g:coq_settings = { 'auto_start': v:true } "return to previous place in buffer """ Main Configurations "filetype plugin indent on " Functions and autocmds to run whenever changing colorschemes function! TransparentBackground() highlight Normal guibg=NONE ctermbg=NONE highlight LineNr guibg=NONE ctermbg=NONE set fillchars+=vert:\│ highlight VertSplit gui=NONE guibg=NONE guifg=#444444 cterm=NONE ctermbg=NONE ctermfg=gray endfunction autocmd ColorScheme * call TransparentBackground() " uncomment if you are using a translucent terminal and you want nvim to use that set relativenumber "nnoremap th :lua requre('tmux_split_even_horizontal').tmux_split_even_horizontal() "nnoremap s :lua require('toggle_rel_abs_numbers').toggle_rel_abs_numbers() "function! ToggleLineNumbers() "if &relativenumber "set norelativenumber "set number "else "set relativenumber "endif "endfunction nnoremap n :lua require('toggle_rel_abs_numbers').toggle_line_numbers() " Main Coloring Configurations syntax on color gruvbox " Enable True Color Support (ensure you're using a 256-color enabled $TERM, e.g. xterm-256color) set termguicolors " "CURSOR SETTINGS "cursor settings MUST COME AFTER set TERMGUICOLORS "https://github.com/neovim/neovim/wiki/FAQ#nvim-shows-weird-symbols-2-q-when-changing-modes "highlight Cursor guifg=blue guibg=blue "set guicursor=i:block-Cursor-blinkon1 "set guicursor=i:hor highlight Cursor guifg=blue guibg=blue autocmd InsertEnter * set cul autocmd InsertLeave * set nocul " REMAPS nnoremap gf :Telescope git_files "Harpoon nnoremap pf :lua require("harpoon.mark").add_file() nnoremap pf :lua require("harpoon.ui").toggle_quick_menu() nnoremap pf :lua require("harpoon.ui").toggle_quick_menu() "set timeout timeoutlen=1000 ttimeoutlen=100 "inoremap :w " "save with ctrl s nnoremap :mkview:w inoremap inoremap "netrw to automatically change working directory au FileType netrw nmap % mt:!tmux split-window -h;tmux select-layout even-horizontal au FileType netrw nmap z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal "open current NETRW directory in a new tab nnoremap z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal "open current NETRW directory in a new tab nnoremap % mt:!tmux split-window -h;tmux select-layout even-horizontal "ends up going to the same directory but doesn't open a file "function! OpenInTmuxPane() "" Get the full path of the current file ""let l:filepath = netrw#LocalBrowseCheck("") ""echo l:filepath "let l:filepath = expand('%:p') "" Prepare the tmux command "let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'" "" Call the command "call system(l:tmux_command) "endfunction function! OpenInTmuxPane() " Get the current directory from the netrw buffer let l:current_dir = b:netrw_curdir " Get the name of the file under the cursor let l:filename = expand('') " Combine the directory and filename to get the full path let l:filepath = l:current_dir . '/' . l:filename " Prepare the tmux command let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'" " Call the command call system(l:tmux_command) endfunction nnoremap 4 :call OpenInTmuxPane() "netrw copy a file au FileType netrw nmap yp mt:!cp -r ./ "netrw delete under cursor au FileType netrw nmap x mt:!rm -rf "netrw mkdir command au FileType netrw nmap mkdir mt:!mkdir -p ":!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal "OVERCOMING ANNOYING LITTLE VIM THINGS "nnoremap "inoremap "nnoremap o o "highlight search settings "highlight link Searchlight Incsearch "hi Search guibg=white guifg=green "hi Search cterm=NONE ctermfg=grey ctermbg=blue """ PLUGIN CONFIGURATIONS "let ctrlp search for hidden files and directories let g:ctrlp_show_hidden = 1 " Neovim :Terminal tmap "tmap "tmap :q "delete "I don't know what this does... "autocmd BufWinEnter,WinEnter term://* startinsert "autocmd BufLeave term://* stopinsert " vim-pydocstring let g:pydocstring_doq_path = '~/.config/nvim/env/bin/doq' " delete " Supertab "let g:SuperTabDefaultCompletionType = "" " EasyAlign xmap ga (EasyAlign) nmap ga (EasyAlign) " indentLine let g:indentLine_char = '▏' let g:indentLine_defaultGroup = 'NonText' " Disable indentLine from concealing json and markdown syntax (e.g. ```) "let g:vim_json_syntax_conceal = 0 "let g:vim_markdown_conceal = 0 "let g:vim_markdown_conceal_code_blocks = 0 " TagBar let g:tagbar_width = 40 " Limelight let g:limelight_conceal_ctermfg = 'gray' let g:limelight_conceal_guifg = 'gray' nmap l :Limelight!! xmap l :Limelight!! autocmd! User GoyoEnter Limelight autocmd! User GoyoLeave Limelight! " Startify "let g:startify_fortune_use_unicode = 1 "" Startify + NERDTree on start when no file is specified "let &tags = expand("%:p") "COC VIM START " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable " delays and poor user experience. set updatetime=300 " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("nvim-0.5.0") || has("patch-8.1.1564") "" Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. "inoremap "\ pumvisible() ? "\" : "\ check_back_space() ? "\" : "\ coc#refresh() "inoremap pumvisible() ? "\" : "\" "function! s:check_back_space() abort "let col = col('.') - 1 "return !col || getline('.')[col - 1] =~# '\s' "endfunction " Use to trigger completion. "if has('nvim') ""inoremap coc#refresh() "else ""inoremap coc#refresh() "endif " Make auto-select the first completion item and notify coc.nvim to " format on enter, could be remapped by other vim plugin "inoremap pumvisible() ? coc#_select_confirm() ""\: "\u\\=coc#on_enter()\" " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " GoTo code navigation. nmap gd (coc-definition) nmap gt (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window. "nnoremap K :call show_documentation() "function! s:show_documentation() "if (index(['vim','help'], &filetype) >= 0) "execute 'h '.expand('') "elseif (coc#rpc#ready()) "call CocActionAsync('doHover') "else "execute '!' . &keywordprg . " " . expand('') "endif "endfunction " Highlight the symbol and its references when holding the cursor. "autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. "nnoremap 9 (coc-rename) "nmap rn (coc-rename) " Formatting selected code. "xmap = (coc-format-selected) "nmap = (coc-format-selected) "augroup mygroup "autocmd! """ Setup formatexpr specified filetype(s). "autocmd FileType typescript,json,python,yaml setl formatexpr=CocAction('formatSelected') """ Update signature help on jump placeholder. "autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') "augroup end "let g:python3_host_prog = "/usr/bin/python3.8" " coc.vim END " signify "let g:signify_sign_add = '│' "let g:signify_sign_delete = '│' "let g:signify_sign_change = '│' "hi DiffDelete guifg=#ff5555 guibg=none " FixCursorHold for better performance let g:cursorhold_updatetime = 100 " context.vim let g:context_nvim_no_redraw =1 """ Filetype-Specific Configurations " HTML, XML, Jinja autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2 autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2 autocmd FileType xml setlocal shiftwidth=2 tabstop=2 softtabstop=2 autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2 autocmd FileType htmldjango inoremap {{ {{ }} autocmd FileType htmldjango inoremap {% {% %} autocmd FileType htmldjango inoremap {# {# #} " Markdown and Journal autocmd FileType markdown setlocal shiftwidth=2 tabstop=2 softtabstop=2 autocmd FileType journal setlocal shiftwidth=2 tabstop=2 softtabstop=2 """ Custom Functions " Trim Whitespaces "function! TrimWhitespace() "let l:save = winsaveview() "%s/\\\@ sj:terminal:set nonumber nmap vl:terminal:set nonumber " NerdTree "nmap q :NERDTreeToggle "nnoremap e :NERDTreeFocus "nnoremap :NERDTreeFind """open NerdTree current directory""" "nmap \\ q " "CHADtree "let &tags = expand("%:p") "nnoremap e :CHADopen "nnoremap 3 :CHADopen --always-focus "nnoremap e :Vexplorer "nnoremap E :Ex "Tagbar "nmap w :TagbarToggle "nmap \| w "Source vim nmap R :so ~/.config/nvim/init.vim "nmap t :call TrimWhitespace() "nmap y vl:HackerNews bestJ "nmap p (pydocstring) "easy align xmap a gaip* nmap a gaip* "nmap s :Rg "scroll sync lock nnoremap sl :set scb! "quick grep search "all system files -- not useful "nmap d :Files "nnoremap h: :History: "nnoremap h/ :History/ ""latest files -- very useful! "nnoremap hh :History ""find file in line "nmap z :BLines "nmap H :RainbowParentheses!! "nnoremap """ :reg " "nmap g :Goyo "nmap j :set filetype=journal "nmap l :Limelight!! "xmap l :Limelight!! " "I actually don't like what this does. It makes the python indent all weird. "Figure out what plugin would cause indent to be like this, then delete it. "I still have an annoying indentation error when I'm typing as well. "autocmd FileType python nmap x :0,$!~/.config/nvim/env/bin/python -m yapf nmap no :set hlsearch! "nmap :tabn "nmap :tabp " view current buffers and type the number you want to go to. ":bd to delete a single buffer nnoremap :buffers:buffer "go back to file tree "nnoremap :Ex "splits nnoremap :vsplit "nnoremap "Navigate split buffers "Normal Mode nnoremap nnoremap nnoremap nnoremap "Terminal mode tnoremap tnoremap tnoremap tnoremap "add current cursor position to jumplist nnoremap m :autocmd CursorHold * normal! m' ""easymotion mappings "let g:EasyMotion_do_mapping = 0 " Disable default mappings "nnoremap f (easymotion-prefix)f "nnoremap s (easymotion-s2) "nnoremap f (easymotion-prefix)s "nnoremap (easymotion-sn) "nnoremap / (easymotion-sn) "nnoremap F (easymotion-prefix)F "nnoremap s (easymotion-prefix)s "map (easymotion-next) "map (easymotion-prev)" Terminal mode: "nmap f (easymotion-overwin-f) "nmap cf c(easymotion-overwin-f) "nmap s (easymotion-overwin-f2) " Turn on case-insensitive feature let g:EasyMotion_smartcase = 1 "fuzzy finder "I have to remap ctrlp's default in order to make my custom command to work let g:ctrlp_map = '' "open up all files including dotfiles nnoremap p :CtrlP /home/ldraney set wildignore+=*/.vim/* " "Rename tmux window tab after current file with path "autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window " . expand("%:t")) let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro' nnoremap c GVggc