dotfiles/nvim/init.vim

176 lines
4.6 KiB
VimL
Raw 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'
2020-11-22 12:38:26 +00:00
"Plug 'franbach/miramare'
Plug 'cocopon/iceberg.vim'
Plug 'patstockwell/vim-monokai-tasty'
2020-11-05 08:26:43 +00:00
Plug 'antoinemadec/FixCursorHold.nvim'
Plug 'lambdalisue/fern.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
2020-08-22 16:04:56 +00:00
call plug#end()
2020-11-22 12:38:26 +00:00
colorscheme iceberg
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
2020-12-08 11:58:40 +00:00
" COC
2020-12-31 08:56:25 +00:00
"" Use tab for trigger completion with characters ahead and navigate.
"inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
"
"function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
"endfunction
"
"" Use <c-space> to trigger completion.
"if has('nvim')
" inoremap <silent><expr> <c-space> coc#refresh()
"else
" inoremap <silent><expr> <c-@> coc#refresh()
"endif
"
"" Make <CR> auto-select the first completion item and notify coc.nvim to
"" format on enter, <cr> could be remapped by other vim plugin
"inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
" \: (((add a double quote here after uncommenting this)\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"