Files
.dotfiles/neovim/.config/nvim/init.vim
T

133 lines
4.7 KiB
VimL

let $MYPLUGDIRECTORY = "~/.config/nvim/plugged/"
"plugins
call plug#begin($MYPLUGDIRECTORY)
Plug 'scrooloose/nerdtree' " file tree
Plug 'luochen1990/rainbow' " rainbow colored parenthesis and brakets
Plug 'itchyny/lightline.vim' " statusline
Plug 'preservim/nerdcommenter' " easier comment management
Plug 'neoclide/coc.nvim', {'branch': 'release'} " code completion
Plug 'jiangmiao/auto-pairs' " automatic pairs
Plug 'machakann/vim-sandwich' " manipulate elements surrounding other elements
Plug 'airblade/vim-gitgutter' " show git changes
Plug 'vim-scripts/colorizer' " colorize color codes
Plug 'honza/vim-snippets' " snippets
Plug 'lervag/vimtex' " vimtex
call plug#end()
" coc plugins
let g:coc_global_extensions = ['coc-snippets', 'coc-git', 'coc-vimtex']
"neovim-remote for vimtex
let g:vimtex_compiler_progname = 'nvr'
"vimtex
let g:vimtex_view_method = 'zathura'
" lightline
set laststatus=2
"NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
set nocompatible " disable compatibility to old-time vi
set showmatch " show matching brackets.
set mouse=v " middle-click paste with mouse
set hlsearch " highlight search results
set tabstop=4 " number of columns occupied by a tab character
set softtabstop=4 " see multiple spaces as tabstops so <BS> does the right thing
set expandtab " converts tabs to white space
set shiftwidth=4 " width for autoindents
set autoindent " indent a new line the same amount as the line just typed
set wildmode=longest,list " get bash-like tab completions
filetype plugin indent on " allows auto-indenting depending on file type
syntax on " syntax highlighting
let mapleader=" " " set mapleader to space
let maplocalleader=" " " set localleader to space
set timeoutlen=1000 " set timeout length
"colors
colorscheme default
"extra specified colors
highlight ColorColumn ctermbg=8
highlight clear SignColumn
highlight GitGutterAdd ctermfg=2
highlight GitGutterChange ctermfg=3
highlight GitGutterDelete ctermfg=1
highlight LineNr ctermfg=7
highlight CursorLineNr ctermfg=7
set cc=80 " set an 80 column border for good coding style
"toggle cc when reasonable
augroup cctoggle
autocmd!
autocmd BufEnter,FocusGained * set cc=80
autocmd BufLeave,FocusLost * set cc=0
augroup END
"toggle relativenumber when reasonable
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
"gitgutter update speed
set updatetime=100
"gitgutter signs
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '~'
let g:gitgutter_sign_removed = '-'
let g:gitgutter_sign_removed_first_line = '^'
"--------------------
"mappings
"--------------------
"custom window ommands
nnoremap <leader>wv <C-W>v
nnoremap <leader>ws <C-W>s
nnoremap <leader>wc <C-W>c
nnoremap <leader>wo <C-W>o
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap öw :w<CR>
nnoremap öq :q<CR>
"custom tab commands
nnoremap <leader>tn :tabnew<space>
"show buffers
nnoremap <Leader>b :buffers<CR>:buffer<Space>
"reload settings
nnoremap <leader>rl :source ~/.config/nvim/init.vim<CR>
"NERDTree commands
nnoremap <leader>nt :NERDTreeToggle<CR>
nnoremap <leader>f :NERDTreeFind<CR>
"symbol renaming
nnoremap <leader>rn <Plug>(coc-reame)
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.')- 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" Make <tab> used for trigger completion, completion confirm, snippet expand and jump like VSCode.
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'