all repos — dotfiles @ 265f13c89fa12e81aed02e81e4ad4830b7b2c656

personal dotfiles

.config/nvim/init.vim (view raw)

  1" la-ninpre init.vim "
  2
  3" use space as leader key
  4let mapleader=" "
  5
  6" enter new era :D
  7set nocompatible
  8set encoding=utf-8
  9
 10" enable 24-bit colors
 11set termguicolors
 12
 13" enable hybrid numbers
 14set nu rnu
 15
 16" mouse is bad, but sometimes is useful
 17set mouse=a
 18
 19" this is for better file searching
 20set path=.,**
 21set wildmenu
 22
 23" more intuitive splits
 24set splitbelow splitright
 25
 26" don't highlight everything when search and move cursor to the searched word
 27set nohlsearch incsearch
 28
 29set rulerformat=%35(%{strftime('%F\ %H:%M')}%=%l/%L%=%c%V%=%p%%\ %)
 30
 31" expand tabs to spaces
 32set tabstop=4 softtabstop=4
 33set shiftwidth=4
 34set expandtab
 35
 36" use autoindents
 37set smartindent
 38
 39" replace default behaviour with undotree plugin
 40set noswapfile nobackup
 41set undodir=~/.local/share/nvim/undodir
 42set undofile
 43
 44" actually, i don't remember what is this...
 45set hidden
 46
 47" fix update time
 48set updatetime=50
 49
 50" remind yourself about 80 column rule
 51set colorcolumn=81
 52
 53" enable insert mode when entering git commit message
 54autocmd VimEnter */COMMIT_EDITMSG startinsert
 55
 56" this could be used to show unprintable characters
 57set listchars=tab:>-,eol:$,space:•,trail:~
 58
 59" vim plug plugins
 60call plug#begin('~/.local/share/nvim/plugged')
 61Plug '~/.local/share/nvim/plugged/gruvbox', {'branch': 'la-ninpre/la-ninpre'}
 62Plug 'junegunn/goyo.vim'
 63Plug 'junegunn/limelight.vim'
 64Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
 65Plug 'junegunn/fzf.vim'
 66Plug 'mattn/emmet-vim'
 67Plug 'ap/vim-css-color'
 68Plug 'preservim/nerdcommenter'
 69Plug 'tpope/vim-surround'
 70Plug 'mbbill/undotree'
 71call plug#end()
 72filetype plugin indent on
 73
 74" colorscheme tweaks
 75let g:gruvbox_contrast_dark = 'hard'
 76if exists('+termguicolors')
 77    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
 78    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
 79endif
 80let g:gruvbox_invert_selection='0'
 81colorscheme gruvbox
 82set background=dark
 83
 84"
 85" mappings
 86"
 87
 88" easier navigation in splits
 89map <C-H> <C-W><C-H>
 90map <C-L> <C-W><C-L>
 91map <C-J> <C-W><C-J>
 92map <C-K> <C-W><C-K>
 93
 94" replace all occurencies of the word under the cursor
 95nnoremap <leader>su :%s/\<<C-r><C-w>\>/
 96
 97" show or hide undo tree
 98nnoremap <leader>u :UndotreeToggle<CR>
 99
100" open helptags
101nnoremap <leader>h :Helptags<CR>
102
103" open file with fzf
104nnoremap <leader>o :Files<CR>
105
106" easy source init.vim
107nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
108" easy open init.vim
109nnoremap <leader>vc :e ~/.config/nvim/init.vim<CR>
110
111" show or hide unprintable characters
112nnoremap <leader>sl :set list<CR>
113nnoremap <leader>sn :set nolist<CR>
114
115" goyo and limelight
116nnoremap <leader>go :Goyo<CR>
117autocmd! User GoyoEnter Limelight
118autocmd! User GoyoLeave Limelight!
119
120" actually magick!
121" this moves higlighted block up or down
122vnoremap J :m '>+1<CR>gv=gv
123vnoremap K :m '<-2<CR>gv=gv
124
125" alias for capturing group in command mode (for use with regexps)
126cmap ;( \(\)<Left><Left>
127
128" highlight yanked text
129" i consider this as transition from visually selecting stuff and yanking it
130" to just yank text object without selecting it
131augroup highlight_yank
132    autocmd!
133    autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
134augroup END