" Improved Vim settings set nocompatible set background=dark set nu set dir=$HOME/.vim_tmp/swap imap 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 colorscheme blackboard syntax enable let g:airline#extensions#tabline#enabled = 1 " NERDTree settings map :NERDTreeToggle 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 :Autoformat " 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 c I// autocmd FileType python nnoremap c I# " Indentation settings set ts=8 set expandtab set autoindent set nowrap " Mouse and paste settings set mouse=a set pastetoggle= " Commenting settings let g:comments_map_keys = 0 noremap :call CommentLine() vnoremap :call RangeCommentLine() noremap :call UnCommentLine() vnoremap :call RangeUnCommentLine() " 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 " 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": 4096, \ "temperature": 0.7, \ "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 command suggesting git commit message, takes no arguments function! GitCommitMessageFn() let l:diff = system('git --no-pager diff --staged') let l:prompt = "generate a short commit message from the diff below:\n" . l:diff let l:range = 0 let l:config = { \ "engine": "chat", \ "options": { \ "endpoint_url": "https://api.openai.com/v1/chat/completions", \ "model": "gpt-4-turbo-preview", \ "initial_prompt": ">>> system\nyou are a code assistant", \ "request_timeout": 30, \ "temperature": 0.7, \ }, \} call vim_ai#AIRun(l:range, l:config, l:prompt) endfunction command! GitCommitMessage call GitCommitMessageFn() " custom command that provides a code review for selected code block function! CodeReviewFn(range) range let l:prompt = "programming syntax is " . &filetype . ", review the code below" let l:config = { \ "options": { \ "initial_prompt": ">>> system\nyou are a clean code expert", \ }, \} '<,'>call vim_ai#AIChatRun(a:range, l:config, l:prompt) endfunction command! -range CodeReview ,call CodeReviewFn() " custom command adding filetype to the instruction function! AISyntaxFn(range, ...) range let l:instruction = "programming language is " . &filetype if a:0 let l:instruction = l:instruction . " - " . a:1 endif if a:range '<,'>call vim_ai#AIRun(a:range, {}, l:instruction) else call vim_ai#AIRun(a:range, {}, l:instruction) endif endfunction command! -range -nargs=? AISyntax ,call AISyntaxFn(, ) " AI Key mappings nnoremap a :AI xnoremap a :AI xnoremap s :AIEdit fix grammar and spelling nnoremap s :AIEdit fix grammar and spelling xnoremap c :AIChat nnoremap c :AIChat nnoremap r :AIRedo " Rust let g:rustfmt_autosave = 1 " Rust key mappings nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction