all repos — dotfiles @ 11be2f548312f98661d22dbbaf13b2dc2aafbee0

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" disable coloured column when editing plain text files and git commit msgs
 54autocmd BufRead,BufNewFile *.md,*.txt,*/.git/COMMIT_EDITMSG set cc=
 55" enable insert mode when entering git commit message
 56autocmd VimEnter */COMMIT_EDITMSG startinsert
 57
 58" this could be used to show unprintable characters
 59set listchars=tab:>-,eol:$,space:•,trail:~
 60
 61" vim plug plugins
 62call plug#begin('~/.local/share/nvim/plugged')
 63Plug 'morhetz/gruvbox'
 64Plug 'junegunn/goyo.vim'
 65Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
 66Plug 'junegunn/fzf.vim'
 67Plug 'mattn/emmet-vim'
 68Plug 'ap/vim-css-color'
 69Plug 'preservim/nerdcommenter'
 70Plug 'tpope/vim-surround'
 71Plug 'mbbill/undotree'
 72call plug#end()
 73filetype plugin indent on
 74
 75" colorscheme tweaks
 76let g:gruvbox_contrast_dark = 'hard'
 77if exists('+termguicolors')
 78    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
 79    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
 80endif
 81let g:gruvbox_invert_selection='0'
 82colorscheme gruvbox
 83set background=dark
 84
 85"
 86" mappings
 87"
 88
 89" easier navigation in splits
 90map <C-H> <C-W><C-H>
 91map <C-L> <C-W><C-L>
 92map <C-J> <C-W><C-J>
 93map <C-K> <C-W><C-K>
 94
 95" replace all occurencies of the word under the cursor
 96nnoremap <leader>su :%s/\<<C-r><C-w>\>/
 97
 98" show or hide undo tree
 99nnoremap <leader>u :UndotreeToggle<CR>
100
101" open helptags
102nnoremap <leader>h :Helptags<CR>
103
104" open file with fzf
105nnoremap <leader>o :Files<CR>
106
107" easy source init.vim
108nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
109" easy open init.vim
110nnoremap <leader>vc :e ~/.config/nvim/init.vim<CR>
111
112" show or hide unprintable characters
113nnoremap <leader>sl :set list<CR>
114nnoremap <leader>sn :set nolist<CR>
115nnoremap <leader>go :Goyo<CR>
116
117" actually magick!
118" this moves higlighted block up or down
119vnoremap J :m '>+1<CR>gv=gv
120vnoremap K :m '<-2<CR>gv=gv
121
122" alias for capturing group in command mode (for use with regexps)
123cmap ;( \(\)<Left><Left>
124
125" highlight yanked text
126" i consider this as transition from visually selecting stuff and yanking it
127" to just yank text object without selecting it
128augroup highlight_yank
129    autocmd!
130    autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
131augroup END