all repos — dotfiles @ 7e044d5c92091a626d81635e6fbe2e8ad4068221

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 '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" replace all occurencies of the word under the cursor
 94nnoremap <leader>su :%s/\<<C-r><C-w>\>/
 95
 96" show or hide undo tree
 97nnoremap <leader>u :UndotreeToggle<CR>
 98
 99" open helptags
100nnoremap <leader>h :Helptags<CR>
101
102" open file with fzf
103nnoremap <leader>o :Files<CR>
104
105" easy source init.vim
106nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
107" easy open init.vim
108nnoremap <leader>vc :e ~/.config/nvim/init.vim<CR>
109
110" show or hide unprintable characters
111nnoremap <leader>sl :set list<CR>
112nnoremap <leader>sn :set nolist<CR>
113nnoremap <leader>go :Goyo<CR>
114
115" actually magick!
116" this moves higlighted block up or down
117vnoremap J :m '>+1<CR>gv=gv
118vnoremap K :m '<-2<CR>gv=gv
119
120" alias for capturing group in command mode (for use with regexps)
121cmap ;( \(\)<Left><Left>
122
123" highlight yanked text
124" i consider this as transition from visually selecting stuff and yanking it
125" to just yank text object without selecting it
126augroup highlight_yank
127    autocmd!
128    autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
129augroup END