all repos — dotfiles @ cfbc8cb11d1c206b2379a2231573ba7b43e4aa3d

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
 29" expand tabs to spaces
 30set tabstop=4 softtabstop=4
 31set shiftwidth=4
 32set expandtab
 33
 34" use autoindents
 35set smartindent
 36
 37" replace default behaviour with undotree plugin
 38set noswapfile nobackup
 39set undodir=~/.local/share/nvim/undodir
 40set undofile
 41
 42" actually, i don't remember what is this...
 43set hidden
 44
 45" fix update time
 46set updatetime=50
 47
 48" remind yourself about 80 column rule
 49set colorcolumn=81
 50
 51" disable coloured column when editing plain text files and git commit msgs
 52autocmd BufRead,BufNewFile *.md,*.txt,*/.git/COMMIT_EDITMSG set cc=
 53" enable insert mode when entering git commit message
 54autocmd VimEnter */.git/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 'morhetz/gruvbox'
 62Plug 'junegunn/goyo.vim'
 63Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
 64Plug 'junegunn/fzf.vim'
 65Plug 'mattn/emmet-vim'
 66Plug 'ap/vim-css-color'
 67Plug 'preservim/nerdcommenter'
 68Plug 'tpope/vim-surround'
 69Plug 'mbbill/undotree'
 70call plug#end()
 71filetype plugin indent on
 72
 73" colorscheme tweaks
 74let g:gruvbox_contrast_dark = 'hard'
 75if exists('+termguicolors')
 76    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
 77    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
 78endif
 79let g:gruvbox_invert_selection='0'
 80colorscheme gruvbox
 81set background=dark
 82
 83"
 84" mappings
 85"
 86
 87" easier navigation in splits
 88map <C-H> <C-W><C-H>
 89map <C-L> <C-W><C-L>
 90map <C-J> <C-W><C-J>
 91map <C-K> <C-W><C-K>
 92
 93" show or hide undo tree
 94nnoremap <leader>u :UndotreeToggle<CR>
 95
 96" open helptags
 97nnoremap <leader>h :Helptags<CR>
 98
 99" open file with fzf
100nnoremap <leader>o :Files<CR>
101
102" easy source init.vim
103nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
104" easy open init.vim
105nnoremap <leader>vc :e ~/.config/nvim/init.vim<CR>
106
107" show or hide unprintable characters
108nnoremap <leader>sl :set list<CR>
109nnoremap <leader>sn :set nolist<CR>
110nnoremap <leader>go :Goyo<CR>
111
112" actually magick!
113" this moves higlighted block up or down
114vnoremap J :m '>+1<CR>gv=gv
115vnoremap K :m '<-2<CR>gv=gv
116
117" alias for capturing group in command mode (for use with regexps)
118cmap ;( \(\)<Left><Left>
119
120" highlight yanked text
121" i consider this as transition from visually selecting stuff and yanking it
122" to just yank text object without selecting it
123augroup highlight_yank
124    autocmd!
125    autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
126augroup END