-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
145 lines (122 loc) · 3.91 KB
/
.vimrc
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
138
139
140
141
142
143
144
145
" eood list of pluggins: https://vimawesome.com
" Use vim-plug to manage pluggins
" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" Install new plugins
" :source %
" :PlugInstall
call plug#begin('~/.vim/plugged')
" fetches https://github.com/sheerun/vim-polyglot
Plug 'sheerun/vim-polyglot'
Plug 'rizzatti/dash.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'w0rp/ale'
Plug 'tpope/vim-fugitive'
Plug 'roxma/vim-paste-easy'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Initialize plugin system
call plug#end()
" change the mapleader from \ to space
" everyone else does “¯\_(ツ)_/¯“
let mapleader="\<Space>"
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :vs $MYVIMRC<CR>
nmap <silent> <leader>rv :source $MYVIMRC<CR>
nmap <silent> <leader>ts :put =strftime('%Y.%m.%d')<CR>
nmap <silent> <leader>b :e#<CR>
nmap <silent> <leader>gf :e <cfile><cr>
nmap <C-N><C-N> :set invnumber<CR>
" save current file with sudo
cmap w!! w !sudo tee % >/dev/null
" always display status line
set laststatus=2
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" Make it obvious where 90 characters is
"set textwidth=90
"set colorcolumn=+1
set ruler
set pastetoggle=<F2>
filetype plugin indent on
"set runtimepath^=~/.vim/bundle/presen.vim,~/.vim/bundle/vim-livedown
" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>
" Use netrw instead of NERDTree
" https://shapeshed.com/vim-netrw/
" use :Vex to open and :bd to close
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
" Vmwiki setup
"let wiki = {}
"let wiki.path = '~/repos/mego22/notes-spreeldy/'
"let wiki.index = 'index'
"let wiki.syntax = 'markdown'
"let wiki.ext = '.md'
"let g:vimwiki_list = [wiki]
" Insert a newline after each specified string (or before if use '!').
" If no arguments, use previous search.
command! -bang -nargs=* -range LineBreakAt <line1>,<line2>call LineBreakAt('<bang>', <f-args>)
function! LineBreakAt(bang, ...) range
let save_search = @/
if empty(a:bang)
let before = ''
let after = '\ze.'
let repl = '&\r'
else
let before = '.\zs'
let after = ''
let repl = '\r&'
endif
let pat_list = map(deepcopy(a:000), "escape(v:val, '/\\.*$^~[')")
let find = empty(pat_list) ? @/ : join(pat_list, '\|')
let find = before . '\%(' . find . '\)' . after
" Example: 10,20s/\%(arg1\|arg2\|arg3\)\ze./&\r/ge
execute a:firstline . ',' . a:lastline . 's/'. find . '/' . repl . '/ge'
let @/ = save_search
endfunction
if has("autocmd")
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()