diff options
author | eug-vs <eugene@eug-vs.xyz> | 2021-08-20 10:25:43 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2021-08-20 10:25:43 +0300 |
commit | 1a9194b6bc7708f631353ea733e14ccd189b4b57 (patch) | |
tree | a0671d4c8cba9f69a2212e886dda621c97de3356 /nvim/.config | |
parent | e6853abfd3733e55b1b8338d40c156dd998cea74 (diff) | |
download | dotfiles-1a9194b6bc7708f631353ea733e14ccd189b4b57.tar.gz |
refactor(nvim): make config modular
Diffstat (limited to 'nvim/.config')
-rw-r--r-- | nvim/.config/nvim/coc.vim | 15 | ||||
-rw-r--r-- | nvim/.config/nvim/defx.vim | 37 | ||||
-rw-r--r-- | nvim/.config/nvim/fzf.vim | 4 | ||||
-rw-r--r-- | nvim/.config/nvim/init.vim | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/startify.vim | 25 | ||||
-rw-r--r-- | nvim/.config/nvim/vimwiki.vim | 29 |
6 files changed, 174 insertions, 1 deletions
diff --git a/nvim/.config/nvim/coc.vim b/nvim/.config/nvim/coc.vim new file mode 100644 index 0000000..7adde13 --- /dev/null +++ b/nvim/.config/nvim/coc.vim @@ -0,0 +1,15 @@ +" Coc.nvim configuration +nmap <silent> gd <Plug>(coc-definition) +nnoremap <silent> <Leader>t :call <SID>show_documentation()<CR> + +inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" + +autocmd BufNewFile,BufRead *.tsx set filetype=typescriptreact + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('<cword>') + else + call CocAction('doHover') + endif +endfunction diff --git a/nvim/.config/nvim/defx.vim b/nvim/.config/nvim/defx.vim new file mode 100644 index 0000000..8b44dfc --- /dev/null +++ b/nvim/.config/nvim/defx.vim @@ -0,0 +1,37 @@ +" Defx configuration +nnoremap <silent> <F3> :Defx<CR> +autocmd FileType defx call s:defx_my_settings() +autocmd BufEnter * if(winnr("$") == 1 && &ft == 'defx') | q | endif +autocmd BufWritePost * call defx#redraw() + +function! SmartTabEdit(context) abort + tabnew + execute "e " . a:context.targets[0] + tabp +endfunction + +function! s:defx_my_settings() abort + set nonumber norelativenumber + + nnoremap <buffer><expr> l + \ defx#is_directory() ? + \ defx#do_action('open_tree') : + \ defx#do_action('open', 'choose') + nnoremap <silent><buffer><expr> t defx#do_action('call', 'SmartTabEdit') + nnoremap <silent><buffer><expr> h defx#do_action('close_tree') + nnoremap <silent><buffer><expr> dd defx#do_action('remove') + nnoremap <silent><buffer><expr> cw defx#do_action('rename') + nnoremap <silent><buffer><expr> o defx#do_action('new_file') + nnoremap <silent><buffer><expr> q defx#do_action('quit') +endfunction + +call defx#custom#option('_', { +\ 'toggle': 1, +\ 'resume': 1, +\ 'show_ignored_files': 1, +\ 'buffer_name': 'explorer', +\ 'split': 'vertical', +\ 'direction': 'topleft', +\ 'columns': 'space:indent:git:icons:space:filename:mark', +\ 'winwidth': 30, +\ }) diff --git a/nvim/.config/nvim/fzf.vim b/nvim/.config/nvim/fzf.vim new file mode 100644 index 0000000..2d64a69 --- /dev/null +++ b/nvim/.config/nvim/fzf.vim @@ -0,0 +1,4 @@ +" fzf.vim configuration +nnoremap <leader>r :Rg<CR> +nnoremap <leader>f :FZF<CR> +nnoremap <leader>g :GFiles<CR> diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index b16b89f..55fb6d2 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -1,5 +1,68 @@ +" Neovim configuration file +" Author: eug-vs +" Email: eugene@eug-vs.xyz + +" Load plugins set runtimepath^=~/.vim runtimepath+=~/.vim/after let &packpath = &runtimepath source ~/.config/nvim/vim-plug/plugins.vim -source ~/.vimrc + +" Enter the current millenium +set nocompatible +syntax enable +filetype plugin on + +" General stuff +set number relativenumber +set ignorecase smartcase +set splitbelow splitright +set termguicolors +set cursorline +set hidden +set nowrap +set ruler +set mouse=a +set clipboard=unnamedplus +set scrolloff=3 +set conceallevel=0 + +" Indentation +set smarttab expandtab +set smartindent autoindent +set tabstop=2 +set shiftwidth=2 +set showtabline=2 + +" Colorscheme +autocmd vimenter * ++nested colorscheme gruvbox + +" Built-in fuzzy-finder +set path=.,** +set wildmenu +set wildignore+=**/node_modules/**,**/build/**,**/dist/**,**/__pycache__/** +set wildmode=longest,list,full + +" Easier window navigation +nnoremap <c-h> <C-w>h +nnoremap <c-j> <C-w>j +nnoremap <c-k> <C-w>k +nnoremap <c-l> <C-w>l + +" Easier indentation +vnoremap < <gv +vnoremap > >gv + +" Remove trailing whitespace on save +autocmd BufWritePre * %s/\s\+$//e + +" Vimrc management +nnoremap <leader>ev :vs ~/.vimrc<CR> +nnoremap <leader>sv :source $MYVIMRC<CR> + +" Plugin-specific configuration +source ~/.config/nvim/startify.vim +source ~/.config/nvim/defx.vim +source ~/.config/nvim/vimwiki.vim +source ~/.config/nvim/coc.vim +source ~/.config/nvim/fzf.vim diff --git a/nvim/.config/nvim/startify.vim b/nvim/.config/nvim/startify.vim new file mode 100644 index 0000000..9c129c4 --- /dev/null +++ b/nvim/.config/nvim/startify.vim @@ -0,0 +1,25 @@ +" Startify configuration +let g:startify_session_delete_buffers = 1 +let g:startify_session_persistence = 1 +let g:startify_change_to_vcs_root = 1 +let g:startify_padding_left = 4 + +let g:startify_custom_header = startify#pad(startify#fortune#cowsay('', '═','║','╔','╗','╝','╚')) + +let g:startify_bookmarks = [ + \ { 'r': '~/.vimrc' }, + \ { 'z': '~/.zshrc' }, +\ ] + +let g:startify_lists = [ + \ { 'type': 'bookmarks', 'header': [' Bookmarks:'] }, + \ { 'type': 'dir', 'header': [' Recently edited files:'] }, + \ { 'type': 'sessions', 'header': [' Sessions:'] }, +\] + +autocmd VimEnter * + \ if !argc() + \ | Startify + \ | Defx + \ | wincmd w + \ | endif diff --git a/nvim/.config/nvim/vimwiki.vim b/nvim/.config/nvim/vimwiki.vim new file mode 100644 index 0000000..4a35dc6 --- /dev/null +++ b/nvim/.config/nvim/vimwiki.vim @@ -0,0 +1,29 @@ +" Vimwiki configuration +let g:vimwiki_list = [ + \ {'path': '~/Sync/', 'syntax': 'markdown', 'ext': '.md', 'auto_generate_links': 1}, + \ {'path': '~/Documents/Projects/eug-vs-xyz', 'syntax': 'markdown', 'ext': '.md', 'auto_generate_links': 1, 'diary_rel_path': 'blog/', 'diary_index': 'index', 'diary_header': "Blog"}, + \ {'path': '~/Documents/wiki/', 'syntax': 'markdown', 'ext': '.md'}, +\] + +let g:vimwiki_markdown_link_ext = 1 + +autocmd FileType vimwiki setlocal spell wrap linebreak + +nnoremap <Leader>c :let &cole=(&cole == 2) ? 0 : 2 <bar> echo 'conceallevel ' . &cole <CR> + +function! VimwikiLinkHandler(link) + let link = a:link + if link =~# '^vfile:' + let link = link[1:] + else + return 0 + endif + let link_infos = vimwiki#base#resolve_link(link) + if link_infos.filename == '' + echomsg 'Vimwiki Error: Unable to resolve link!' + return 0 + else + exe 'e ' . fnameescape(link_infos.filename) + return 1 + endif +endfunction |