aboutsummaryrefslogtreecommitdiff
path: root/.vimrc
blob: 1e359b6059f3b4a104f2d4cd9063a2b74bdd1834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
" Vim configuration file
" Author: eug-vs


" enter the current millenium
set nocompatible
syntax enable
filetype plugin on

" general stuff
set number
set relativenumber
set cursorline
set hidden                              " Required to keep multiple buffers open multiple buffers
set nowrap                              " Display long lines as just one line
set ruler              			            " Show the cursor position all the time
set conceallevel=0                      " So that I can see `` in markdown files
set tabstop=2                           " Insert 2 spaces for a tab
set shiftwidth=2                        " Change the number of space characters inserted for indentation
set smarttab                            " Makes tabbing smarter will realize you have 2 vs 4
set expandtab                           " Converts tabs to spaces
set smartindent                         " Makes indenting smart
set autoindent                          " Good auto indent
set showtabline=2                       " Always show tabs
set noshowmode                          " We don't need to see things like -- INSERT -- anymore
set clipboard=unnamedplus               " Copy paste between vim and everything else

" enable gruvbox colorscheme:
autocmd vimenter * ++nested colorscheme gruvbox

" vimrc management
nnoremap <leader>ev :rightbelow vs ~/.vimrc<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>

" windows
set splitbelow
set splitright 
nnoremap <TAB> <C-w>w
nnoremap <S-TAB> <C-w>W
nnoremap <c-h> <C-w>h
nnoremap <c-j> <C-w>j
nnoremap <c-k> <C-w>k
nnoremap <c-l> <C-w>l

" Defx
nnoremap <silent> <F3> :Defx<CR>
autocmd FileType defx call s:defx_my_settings()
autocmd BufEnter * if(winnr("$") == 1 && &ft == 'defx') | q | endif

function! s:defx_my_settings() abort
  set nonumber
  set norelativenumber

  nnoremap <buffer><expr> l
  \ defx#is_directory() ?
  \ defx#do_action('open_tree') :
  \ defx#do_action('open', 'choose')
  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> 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:filename:mark',
\ 'winwidth': 30,
\ })

" Startify
let g:startify_custom_header = [
  \ '              ___  __  ______ _     _   _______',
  \ '             / _ \/ / / / __ `/____| | / / ___/',
  \ '            /  __/ /_/ / /_/ /_____/ |/ (__  ) ',
  \ '            \___/\__,_/\__, /      |___/____/  ',
  \ '                      /____/                   ',
\]

" startup screen
autocmd VimEnter *
  \   if !argc()
  \ |   Startify
  \ |   Defx
  \ |   wincmd w
  \ | endif

" built-in fuzzy-finder
set path=.,**
set wildmenu
set wildignore+=**/node_modules/**,**/build/**,**/dist/**,**/__pycache__/**

" tags
command! MakeTags !ctags -R -f .git/tags --tag-relative --exclude=node_modules --exclude=.git --exclude=build --exclude=dist --map-Typescript=+.tsx
set tags+=.git/tags

" enable typescipt highlighting
augroup SyntaxSettings
    autocmd!
    autocmd BufNewFile,BufRead *.tsx set filetype=typescript
augroup END

" easier indentation
vnoremap < <gv
vnoremap > >gv

" Vimwiki
let g:vimwiki_list = [{'path': '~/Documents/wiki/', 'syntax': 'markdown', 'ext': '.md'}]
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

" TODO: command to toggle comments https://www.chrisatmachine.com/Neovim/09-vim-commentary/
" TODO: sessions https://www.chrisatmachine.com/Neovim/11-startify/