dotfiles/nvim/init.vim

151 lines
3.8 KiB
VimL
Raw Permalink Normal View History

2020-08-22 16:04:56 +00:00
let mapleader=" "
" Basic stuff
set mouse=a
set nocompatible
set nohlsearch
filetype plugin on
syntax on
set encoding=utf-8
set number
set termguicolors
2020-09-08 13:01:22 +00:00
set splitbelow splitright
2020-11-22 12:38:26 +00:00
set scrolloff=5
2020-12-08 11:58:40 +00:00
" coc specific
set updatetime=300
2020-09-08 13:01:22 +00:00
2020-09-24 16:46:14 +00:00
set cursorline
2020-11-05 08:26:43 +00:00
" Netrw settings
let g:netrw_liststyle = 0
let g:netrw_banner = 0
2020-09-08 13:01:22 +00:00
" restore cursor to the last position after reopening a file
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
2020-08-22 16:04:56 +00:00
" Enable spell checking, s for spell check
map <leader>se :setlocal spell! spelllang=en<CR>
map <leader>sr :setlocal spell! spelllang=ro<CR>
" ###
" # Plugins
" ###
call plug#begin('~/.local/share/nvim/plugged')
2020-11-05 08:26:43 +00:00
" REMINDER - some plugins have the following external dependencies
" hexokinase(color preview): go
" coc(code completion): nodejs, yarn
2020-12-08 12:01:43 +00:00
""" TODO write here what to do to install the C syntax server and watnot
2020-11-22 12:38:26 +00:00
" vimdiscord: nvim installed from pip (python extension thingy)
2020-12-08 11:58:40 +00:00
"Plug 'vbe0201/vimdiscord'
2020-08-22 16:04:56 +00:00
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' }
2020-09-15 15:39:41 +00:00
Plug 'vimwiki/vimwiki'
2021-04-07 07:01:52 +00:00
Plug 'franbach/miramare'
2020-11-22 12:38:26 +00:00
Plug 'cocopon/iceberg.vim'
2021-04-10 15:26:18 +00:00
Plug 'sainnhe/sonokai'
Plug 'sainnhe/everforest'
2020-11-22 12:38:26 +00:00
Plug 'patstockwell/vim-monokai-tasty'
2020-11-05 08:26:43 +00:00
Plug 'antoinemadec/FixCursorHold.nvim'
Plug 'lambdalisue/fern.vim'
2020-08-22 16:04:56 +00:00
call plug#end()
2021-04-10 15:26:18 +00:00
colorscheme sonokai
2020-09-24 16:46:14 +00:00
2020-08-22 16:04:56 +00:00
" hexokinase
let g:Hexokinase_refreshEvents = ['InsertLeave']
let g:Hexokinase_highlighters = ['backgroundfull']
autocmd VimEnter * HexokinaseTurnOn
2020-11-05 08:26:43 +00:00
" ###
" # Fern -- sidebar file manager
" ###
let g:fern#drawer_width = 30
let g:fern#default_hidden = 1
let g:fern#disable_drawer_auto_quit = 1
""" KEYBIND TO TOGGLE FERN
noremap <leader>f :Fern . -drawer -toggle <CR>
function! s:init_fern() abort
nmap <buffer> H <Plug>(fern-action-open:split)
nmap <buffer> V <Plug>(fern-action-open:vsplit)
nmap <buffer> R <Plug>(fern-action-rename)
nmap <buffer> M <Plug>(fern-action-move)
nmap <buffer> C <Plug>(fern-action-copy)
"nmap <buffer> N <Plug>(fern-action-new-path)
nmap <buffer> T <Plug>(fern-action-new-file)
nmap <buffer> D <Plug>(fern-action-new-dir)
nmap <buffer> S <Plug>(fern-action-hidden-toggle)
nmap <buffer> dd <Plug>(fern-action-trash)
nmap <buffer> m <Plug>(fern-action-mark)
endfunction
augroup fern-custom
autocmd! *
autocmd FileType fern call s:init_fern()
augroup END
""" C Compiler!
function! TermWrapper(command) abort
exec '20sp '
exec 'term ' . a:command
exec 'startinsert'
endfunction
command! -nargs=0 CompileAndRun call TermWrapper(printf('gcc -lm %s && ./a.out', expand('%'), <args>))
2020-08-22 16:04:56 +00:00
" ###
" # Key Remapping
" ###
2020-09-15 15:39:41 +00:00
" Reload this config file
2020-08-22 16:04:56 +00:00
map <C-s> :source ~/.config/nvim/init.vim<CR>
2020-09-08 13:01:22 +00:00
nnoremap <leader>e :Ex<CR>
" Easier Write and Quit aliases
2020-11-05 08:26:43 +00:00
"nnoremap <silent> <leader>q :CocCommand cord.disconnect<CR>:q<CR>
nnoremap <silent> <leader>q :q<CR>
2020-09-08 13:01:22 +00:00
nnoremap <leader>Q :wq<CR>
nnoremap <leader>w :w<CR>
" Split navigation with leader key
nnoremap <leader>h <C-w>h
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>l <C-w>l
" Make adjusing split sizes a bit more friendly
2020-11-05 08:26:43 +00:00
noremap <silent> <C-h> :vertical resize +3<CR>
noremap <silent> <C-l> :vertical resize -3<CR>
noremap <silent> <C-k> :resize +3<CR>
noremap <silent> <C-j> :resize -3<CR>
2020-09-08 13:01:22 +00:00
" New splits
nnoremap <leader>sv :Vex<CR>
nnoremap <leader>sh :Sex<CR>
nnoremap <leader>t :24sp<CR>:term<CR>:startinsert<CR>
2020-11-05 08:26:43 +00:00
nnoremap <leader>cc :CompileAndRun<CR>
2020-09-08 13:01:22 +00:00
" exit insert mode in terminal easier
tnoremap <C-\> <C-\><C-N>
2020-09-24 16:46:14 +00:00
2020-11-05 08:26:43 +00:00
tnoremap <A-h> <C-\><C-N><C-w>h
tnoremap <A-j> <C-\><C-N><C-w>j
tnoremap <A-k> <C-\><C-N><C-w>k
tnoremap <A-l> <C-\><C-N><C-w>l
inoremap <A-h> <C-\><C-N><C-w>h
inoremap <A-j> <C-\><C-N><C-w>j
inoremap <A-k> <C-\><C-N><C-w>k
inoremap <A-l> <C-\><C-N><C-w>l
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l