summaryrefslogtreecommitdiff
path: root/vimrc
blob: fed86badc7a97129e5f5168216f6bf89a1d565dd (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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
" Improved Vim settings
set nocompatible
set background=dark
set nu
set dir=$HOME/.vim_tmp/swap
imap <C-c> <Esc>
if !isdirectory(&dir) | call mkdir(&dir, 'p', 0700) | endif

" Runtime path configuration
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" Vundle plugin management
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'fatih/vim-go'
Plugin 'scrooloose/nerdtree'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'kien/ctrlp.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'posva/vim-vue'
Plugin 'scrooloose/syntastic'
Plugin 'Chiel92/vim-autoformat'
Plugin 'eugen0329/vim-esearch'
Plugin 'majutsushi/tagbar'
Plugin 'dgryski/vim-godef'
Plugin 'tpope/vim-surround'
Bundle 'sudar/comments.vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'nsf/gocode', {'rtp': 'vim/'}
Plugin 'leafgarland/typescript-vim'
Plugin 'peitalin/vim-jsx-typescript'
Plugin 'rust-lang/rust.vim'
Plugin 'madox2/vim-ai'
Plugin 'neoclide/coc.nvim', {'branch': 'master', 'do': 'npm ci'}

call vundle#end()
filetype plugin indent on
syntax enable
let g:airline#extensions#tabline#enabled = 1

" NERDTree settings
map <C-n> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
let NERDTreeMinimalUI=1
let NERDTreeShowHidden=1

" CtrlP settings
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*/tmp/*,*/node_modules/*,*.so,*.swp,*.zip,*.gz,*.tar
let g:ctrlp_custom_ignore = {'dir':  '\v[\/]\.(git|hg|svn)$', 'file': '\v\.(exe|so|dll)$'}

" General settings
set encoding=utf-8
set t_Co=256
set term=xterm-256color
set termencoding=utf-8

" Syntastic settings
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_always_populate_loc_list = 1
let g:formatters_javascript = ['eslint']
let g:formatters_vue = ['eslint']
noremap <F3> :Autoformat<CR>

" Go settings
let g:go_fmt_command = "goimports"
let g:tagbar_type_go = {
  \ 'ctagstype' : 'go',
  \ 'kinds'     : [
    \ 'p:package',
    \ 'i:imports:1',
    \ 'c:constants',
    \ 'v:variables',
    \ 't:types',
    \ 'n:interfaces',
    \ 'w:fields',
    \ 'e:embedded',
    \ 'm:methods',
    \ 'r:constructor',
    \ 'f:functions'
  \ ],
  \ 'sro' : '.',
  \ 'kind2scope' : {
    \ 't' : 'ctype',
    \ 'n' : 'ntype'
  \ },
  \ 'scope2kind' : {
    \ 'ctype' : 't',
    \ 'ntype' : 'n'
  \ },
  \ 'ctagsbin'  : 'gotags',
  \ 'ctagsargs' : '-sort -silent'
\ }
let g:godef_split=2
let g:syntastic_go_checkers = ['govet', 'errcheck', 'go']

" Filetype settings
autocmd BufNewFile,BufRead *.vue set ft=vue
autocmd Filetype yaml setlocal tabstop=8
autocmd Filetype go setlocal tabstop=8
autocmd FileType vue :call ESlintVueFormatter()
autocmd FileType javascript :call ESlintJSFormatter()
autocmd FileType javascript nnoremap <buffer> <localleader>c I//<esc>
autocmd FileType python     nnoremap <buffer> <localleader>c I#<esc>

" Indentation settings
set ts=8
set expandtab
set autoindent
set nowrap

" Mouse and paste settings
set mouse=a
set pastetoggle=<F2>

" Commenting settings
let g:comments_map_keys = 0
noremap  <silent> <C-k> :call CommentLine()<CR>
vnoremap <silent> <C-k> :call RangeCommentLine()<CR>
noremap  <silent> <C-l> :call UnCommentLine()<CR>
vnoremap <silent> <C-l> :call RangeUnCommentLine()<CR>

" Color scheme
color blackboard

" TypeScript settings
let g:typescript_compiler_binary = 'tsc'
let g:typescript_compiler_options = ''
let g:go_gopls_enabled = 0
autocmd BufNewFile,BufRead *.ts set filetype=typescript
autocmd FileType typescript :set makeprg=tsc
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx

" Rust settings
let g:rustfmt_autosave = 1

" AI integration
let g:vim_ai_complete = {
\  "options": {
\    "model": "gpt-4-turbo-preview",
\    "endpoint_url": "https://api.openai.com/v1/chat/completions",
\    "temperature": 0.1,
\    "request_timeout": 20,
\  },
\}

let g:vim_ai_edit = {
\  "options": {
\    "model": "gpt-4-turbo-preview",
\    "endpoint_url": "https://api.openai.com/v1/chat/completions",
\    "temperature": 0.1,
\    "request_timeout": 20,
\  },
\}

let initial_prompt =<< trim END
You are going to play a role of a completion engine with following parameters:
Task: Provide compact code/text completion, generation, transformation or explanation
Topic: general programming and text editing
Style: Plain result without any commentary, unless commentary is necessary
Audience: Users of text editor and programmers that need to transform/generate text
END

let chat_engine_config = {
\  "engine": "chat",
\  "options": {
\    "endpoint_url": "https://api.openai.com/v1/chat/completions",
\    "model": "gpt-4-turbo-preview",
\    "max_tokens": 128000,
\    "temperature": 0.1,
\    "request_timeout": 30,
\    "selection_boundary": "",
\    "initial_prompt": initial_prompt,
\  },
\}

let g:vim_ai_complete = chat_engine_config
let g:vim_ai_edit = chat_engine_config
let g:vim_ai_debug = 1

" Custom commands
command! GitCommitMessage call GitCommitMessageFn()
command! -range CodeReview <line1>,<line2>call CodeReviewFn(<range>)

" Key mappings
nnoremap <leader>a :AI<CR>
xnoremap <leader>a :AI<CR>
xnoremap <leader>s :AIEdit fix grammar and spelling<CR>
nnoremap <leader>s :AIEdit fix grammar and spelling<CR>
xnoremap <leader>c :AIChat<CR>
nnoremap <leader>c :AIChat<CR>
nnoremap <leader>r :AIRedo<CR>

" Rust key mappings
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nnoremap <silent> K :call <SID>show_documentation()<CR>