.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'
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>
115
116" goyo and limelight
117nnoremap <leader>go :Goyo<CR>
118autocmd! User GoyoEnter Limelight
119autocmd! User GoyoLeave Limelight!
120
121" actually magick!
122" this moves higlighted block up or down
123vnoremap J :m '>+1<CR>gv=gv
124vnoremap K :m '<-2<CR>gv=gv
125
126" alias for capturing group in command mode (for use with regexps)
127cmap ;( \(\)<Left><Left>
128
129" fix wrong nvim size when starting in alacritty
130autocmd VimEnter * :silent exec "!kill -s SIGWINCH $PPID"
131
132" highlight yanked text
133" i consider this as transition from visually selecting stuff and yanking it
134" to just yank text object without selecting it
135augroup highlight_yank
136 autocmd!
137 autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
138augroup END
139
140augroup xmobar_syntax
141 autocmd!
142 autocmd BufRead,BufNewFile xmobarrc* set syntax=haskell
143augroup END