.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" search options
27set nohlsearch incsearch ignorecase smartcase showmatch
28
29" ruler
30set rulerformat=%35(%{strftime('%F\ %H:%M')}%=%l/%L%=%c%V%=%p%%\ %)
31
32" expand tabs to spaces
33set tabstop=4 softtabstop=4
34set shiftwidth=4
35set expandtab
36
37" use autoindents
38set smartindent
39
40" replace default behaviour with undotree plugin
41set noswapfile nobackup
42set undodir=~/.local/share/nvim/undodir
43set undofile
44
45" actually, i don't remember what is this...
46set hidden
47
48" fix update time
49set updatetime=50
50
51" remind yourself about 80 column rule
52set colorcolumn=81
53
54" enable insert mode when entering git commit message
55autocmd VimEnter */COMMIT_EDITMSG startinsert
56
57" this could be used to show unprintable characters
58set listchars=tab:>-,eol:$,space:•,trail:~
59
60" vim plug plugins
61call plug#begin('~/.local/share/nvim/plugged')
62Plug '~/.local/share/nvim/plugged/gruvbox', {'branch': 'la-ninpre/la-ninpre'}
63Plug 'junegunn/goyo.vim'
64Plug 'junegunn/limelight.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'
72Plug 'dense-analysis/ale'
73Plug 'cespare/vim-toml'
74Plug 'https://tildegit.org/sloum/gemini-vim-syntax'
75call plug#end()
76filetype plugin indent on
77
78" colorscheme tweaks
79let g:gruvbox_contrast_dark = 'hard'
80if exists('+termguicolors')
81 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
82 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
83endif
84let g:gruvbox_invert_selection='0'
85colorscheme gruvbox
86set background=dark
87
88"
89" mappings
90"
91
92" easier navigation in splits
93map <C-H> <C-W><C-H>
94map <C-L> <C-W><C-L>
95map <C-J> <C-W><C-J>
96map <C-K> <C-W><C-K>
97
98" replace all occurencies of the word under the cursor
99nnoremap <leader>su :%s/\<<C-r><C-w>\>/
100
101" show or hide undo tree
102nnoremap <leader>u :UndotreeToggle<CR>
103
104" open helptags
105nnoremap <leader>h :Helptags<CR>
106
107" open file with fzf
108nnoremap <leader>o :Files<CR>
109
110" easy source init.vim
111nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
112" easy open init.vim
113nnoremap <leader>vc :e ~/.config/nvim/init.vim<CR>
114
115" show or hide unprintable characters
116nnoremap <leader>sl :set list<CR>
117nnoremap <leader>sn :set nolist<CR>
118
119" goyo
120nnoremap <leader>go :Goyo<CR>
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"
131" autocommands
132"
133
134" limelight on when goyo
135autocmd! User GoyoEnter Limelight
136autocmd! User GoyoLeave Limelight!
137
138" fix wrong nvim size when starting in alacritty
139autocmd VimEnter * :silent exec "!kill -s SIGWINCH $PPID"
140
141" highlight yanked text (needs nvim 0.5.x)
142augroup highlight_yank
143 autocmd!
144 autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 40})
145augroup END