-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
173 lines (134 loc) · 4.15 KB
/
init.vim
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
" Key bindings can be changed, see below
" call wilder#setup({'modes': [':', '/', '?']})
"call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_border_theme({
"\ 'highlights': {
"\ 'border': 'Normal',
"\ },
"\ 'border': 'rounded',
"\ })))
" Theme
set termguicolors
set nonu
cabbrev t tabnew
cabbrev tn tabnext
cabbrev tp tabprevious
map <c-u> :tabprevious<CR>
imap <c-u> <ESC>:tabprevious<CR>
map <c-i> :tabnext<CR>
nmap <c-i> <ESC>:tabnext<CR>
map <c-j> <c-f>
map <c-k> <c-b>
let g:tokyonight_style = 'night' " available: night, storm
let g:tokyonight_enable_italic = 1
"colorscheme tokyonight
colorscheme sidonia
" Delete word backward
nnoremap dw bdw
" Old status line theme
" Color groups for status lines for Neovide
hi User1 guibg=#5F5FAF guifg=Black
hi User2 guibg=#5F5FAF guifg=White
" hi User1 guifg=#5F5FAF
"hi User2 guibg=#5F5FAF guifg=White
" Status text
fun! GetPaddingSpaces(s)
let w = winwidth('%')
let width = &modified ? w - 1: w
let padding = (width - len(a:s)) / 2
return repeat('\ ', padding)
endfun
fun! GetStatus()
let sign = &modified ? '*' : ''
let lineNumber= repeat('1', len(printf('%i', getline('.'))))
let columnNumber = repeat('1', len(printf('%i', virtcol('.'))))
let fullPath = fnameescape(pathshorten(expand('%:p:h')))
let filename = fnameescape(expand('%:t'))
let path = fullPath.'/'.filename.':'.lineNumber.':'.columnNumber
let spaces = GetPaddingSpaces(path)
" Show file encoding on status line
"let s = 'set statusline=%2*'.sign.spaces.'%1*'.fullPath.'/%2*'.filename.'%1*:%l'."%=%2*%{''.(&fenc!=''?&fenc:&enc).''}"
let s = 'set statusline=%2*'.sign.spaces.'%1*'.fullPath.'/%2*'.filename.'%1*:%l:%2*%c'
exec s
endfun
autocmd CursorMoved * call GetStatus()
autocmd BufWritePost * call GetStatus()
autocmd BufRead,BufNewFile * call GetStatus()
autocmd! BufRead,BufNewFile * call GetStatus()
autocmd! BufEnter * call GetStatus()
autocmd VimEnter * call GetStatus()
" Change to current directory which contains new file
fun! CWD()
let fullPath = expand('%:p:h')
let s = "cd ".fullPath
exec s
endfun
autocmd BufRead,BufNewFile * call CWD()
autocmd! BufRead,BufNewFile * call CWD()
autocmd! BufEnter * call CWD()
" In visual mode, use Y to copy to system clipboard
vnoremap Y "*y
" In normal mode, do the same with the current line
nnoremap Y "*yy
" vv = V
nnoremap vv V
" yank also copy to system pasteboad
set clipboard=unnamed
" yank also copy to system clipboard for Ubuntu
set clipboard=unnamedplus
" Easy way for ^, $
nnoremap <silent> e ^
vnoremap <silent> e ^
nnoremap <silent> r $
vnoremap <silent> r $
nnoremap <silent> t 0
vnoremap <silent> t 0
nnoremap <silent> s e
" gg, GG shortcuts
noremap <silent> <nowait> G GG
" New line
nmap <CR> o<Esc>i
" Hide coloration of found words
map <C-C> :nohlsearch<CR>
call plug#begin()
Plug 'ryanoasis/vim-devicons'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'tweekmonster/deoplete-clang2'
call plug#end()
let g:deoplete#enable_at_startup = 1
set completeopt=menu,menuone,noselect
" Source configurations
source ~/.config/nvim/vim/colorizer.vim
source ~/.config/nvim/vim/nvim-cmp.vim
source ~/.config/nvim/vim/cscope.vim
" Disable mouse
set mouse=
" Tabline colors
hi TabLineSel guifg=white guibg=#5F5FAF
" Wrap text to textwidth: set textwidth=80, and use this command
nmap <C-L> gqG
" Set tabs for cosmopolitan
au BufRead,BufNewFile,BufEnter /home/rkt/projects/cosmopolitan/* setlocal ts=2 sts=2 sw=2
" Set tab line
set tabline=%!GetTabLine()
function! GetTabLine()
let line = ''
let s:current_tab = tabpagenr()
for i in range(tabpagenr('$'))
let bufnr = tabpagebuflist(i+1)[0]
let bufname = bufname(bufnr)
let tab_label = fnamemodify(bufname, ':t')
if i+1 == s:current_tab
let line .= '%' . (i+1) . 'T%#TabLineSel#' . tab_label . ' %#TabLine#'
else
let line .= '%' . (i+1) . 'T%#TabLine#' . tab_label . ' '
endif
endfor
return line
endfunction
" Comment out erlang block codes
vnoremap <silent> <C-k> :s/^/%<cr>:noh<cr>
vnoremap <silent> <C-l> :s/^%/<cr>:noh<cr>