all repos — dotfiles @ 8f809f3e24ca8eae68dd54468deeea692d27b02e

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'
 71Plug 'dense-analysis/ale'
 72Plug 'cespare/vim-toml'
 73call plug#end()
 74filetype plugin indent on
 75
 76" colorscheme tweaks
 77let g:gruvbox_contrast_dark = 'hard'
 78if exists('+termguicolors')
 79    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
 80    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
 81endif
 82let g:gruvbox_invert_selection='0'
 83colorscheme gruvbox
 84set background=dark
 85
 86"
 87" mappings
 88"
 89
 90" easier navigation in splits
 91map <C-H> <C-W><C-H>
 92map <C-L> <C-W><C-L>
 93map <C-J> <C-W><C-J>
 94map <C-K> <C-W><C-K>
 95
 96" replace all occurencies of the word under the cursor
 97nnoremap <leader>su :%s/\<<C-r><C-w>\>/
 98
 99" show or hide undo tree
100nnoremap <leader>u :UndotreeToggle<CR>
101
102" open helptags
103nnoremap <leader>h :Helptags<CR>
104
105" open file with fzf
106nnoremap <leader>o :Files<CR>
107
108" easy source init.vim
109nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
110" easy open init.vim
111nnoremap <leader>vc :e ~/.config/nvim/init.vim<CR>
112
113" show or hide unprintable characters
114nnoremap <leader>sl :set list<CR>
115nnoremap <leader>sn :set nolist<CR>
116
117" goyo and limelight
118nnoremap <leader>go :Goyo<CR>
119autocmd! User GoyoEnter Limelight
120autocmd! User GoyoLeave Limelight!
121
122" actually magick!
123" this moves higlighted block up or down
124vnoremap J :m '>+1<CR>gv=gv
125vnoremap K :m '<-2<CR>gv=gv
126
127" alias for capturing group in command mode (for use with regexps)
128cmap ;( \(\)<Left><Left>
129
130" fix wrong nvim size when starting in alacritty
131autocmd VimEnter * :silent exec "!kill -s SIGWINCH $PPID"
132
133" highlight yanked text
134" i consider this as transition from visually selecting stuff and yanking it
135" to just yank text object without selecting it
136augroup highlight_yank
137    autocmd!
138    autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
139augroup END
140
141augroup xmobar_syntax
142    autocmd!
143    autocmd BufRead,BufNewFile xmobarrc* set syntax=haskell
144augroup END