-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
203 lines (178 loc) · 5.08 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
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
""
"" Basic Setup
""
set nocompatible " Use vim, no vi defaults
set number
set ruler
set termguicolors
syntax enable
set encoding=utf-8
set autowrite
let mapleader = ","
" noremap <leader>w :w<cr>
map <Leader>m :!clear;make<Enter>
map <Leader>t :!clear;make test<Enter>
map <Leader>n :NERDTree<Enter>
if has('win32')
map <Leader>m :!make<Enter>
map <Leader>t :!make test<Enter>
endif
map <Leader>s :w<Enter>:so $MYVIMRC<Enter>
set relativenumber
set nohlsearch
set scrolloff=8
set colorcolumn=80
set wildignorecase
set clipboard=unnamed
set shortmess=Ot
""
"" Whitespace
""
set nowrap
set tabstop=2
set shiftwidth=2
set expandtab
set list
set backspace=indent,eol,start
set listchars=tab:→\ ,trail:.,extends:>,precedes:<
""
"" Searching
""
set incsearch
set hlsearch
set ignorecase
set smartcase
""
"" Others settings
""
" Pluging management with https://github.com/junegunn/vim-plug
call plug#begin()
Plug 'ntpeters/vim-better-whitespace'
Plug 'bling/vim-airline'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'editorconfig/editorconfig-vim'
Plug 'scrooloose/nerdtree'
Plug 'chr4/nginx.vim'
Plug 'fatih/vim-go'
Plug 'mustache/vim-mustache-handlebars'
Plug 'chase/vim-ansible-yaml'
Plug 'martindelille/vim-martin'
Plug 'peterhoeg/vim-qml'
Plug 'martindelille/vim-qmake'
Plug 'djoshea/vim-autoread'
Plug 'cespare/vim-toml'
Plug 'nelsyeung/twig.vim'
Plug 'lilyinstarlight/vim-sonic-pi'
Plug 'cdelledonne/vim-cmake'
Plug 'tpope/vim-liquid'
Plug 'sainnhe/edge'
Plug 'ap/vim-css-color'
Plug 'github/copilot.vim'
Plug 'rhysd/conflict-marker.vim'
Plug 'matze/vim-move'
Plug 'madox2/vim-ai'
Plug 'darfink/vim-plist'
Plug 'mattn/emmet-vim'
Plug 'AndrewRadev/tagalong.vim'
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
let b:ale_fixers = ['prettier']
call plug#end()
filetype plugin on
filetype plugin indent on
" Airline setup
let g:airline_powerline_fonts = 1
set laststatus=2
set noshowmode
" Theme setup
let g:edge_style = 'aura'
let g:edge_better_performance = 1
colorscheme edge
autocmd BufNewFile,BufRead conanfile.txt set syntax=toml
autocmd BufNewFile,BufRead *.recordr set syntax=yaml
autocmd BufNewFile,BufRead *.ttal set syntax=json
autocmd BufNewFile,BufRead *.vcv set syntax=json
autocmd BufNewFile,BufRead *.qss set syntax=css
autocmd BufRead,BufNewFile *.txt setlocal wrap linebreak
" Git setup
command Gc Git commit -v
command Gapa Git add -p
" Copilot
let g:copilot_filetypes = {
\ 'gitcommit': v:true,
\ 'markdown': v:true,
\ 'yaml': v:true
\ }
" vim-ai
map <Leader>a :AI<CR>
map <Leader>c :AIChat<CR>
let initial_prompt =<< trim END
>>> system
You are going to play a role of a coding assistant:
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
" wrap lines in chat window
let g:vim_ai_chat = {
\ "options": {
\ "model": "gpt-4",
\ "endpoint_url": "https://api.openai.com/v1/chat/completions",
\ "enable_auth": 1,
\ "initial_prompt": initial_prompt,
\ },
\ "ui": {
\ "open_chat_command": "setlocal wrap | call vim_ai#MakeScratchWindow()",
\ },
\}
function! AIUseGPT3Fn()
let g:vim_ai_chat['options']['model'] = 'gpt-3.5-turbo'
let g:vim_ai_chat['options']['endpoint_url'] = 'https://api.openai.com/v1/chat/completions'
let g:vim_ai_chat['options']['enable_auth'] = 1
let g:vim_ai_chat['options']['initial_prompt'] = initial_prompt
endfunction
command! AIUseGPT3 call AIUseGPT3Fn()
function! AIUseGPT4Fn()
let g:vim_ai_chat['options']['model'] = 'gpt-4'
let g:vim_ai_chat['options']['endpoint_url'] = 'https://api.openai.com/v1/chat/completions'
let g:vim_ai_chat['options']['enable_auth'] = 1
let g:vim_ai_chat['options']['initial_prompt'] = initial_prompt
endfunction
command! AIUseGPT4 call AIUseGPT4Fn()
" 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": {
\ "model": "gpt-3.5-turbo",
\ "initial_prompt": ">>> system\nyou are a code assistant",
\ "temperature": 1,
\ },
\}
call vim_ai#AIRun(l:range, l:config, l:prompt)
" echo "Hello, world ooo!"
endfunction
command! Gcai call GitCommitMessageFn()
map <Leader>g :Gcai<CR>
" 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 <line1>,<line2>call AISyntaxFn(<range>, <f-args>)
function! CopyRange() range
call setreg('*', a:firstline .. ',' .. a:lastline)
endfunction
command! -range CopyRange call CopyRange()