-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
278 lines (215 loc) · 9.26 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
lua require 'init'
call plug#begin('~/.vim/plugged')
"Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-vinegar'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'pangloss/vim-javascript'
Plug 'dense-analysis/ale'
"Plug 'altercation/vim-colors-solarized'
Plug 'dart-lang/dart-vim-plugin'
"Plug 'neovim/nvim-lspconfig'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'unblevable/quick-scope'
Plug 'wellle/targets.vim'
Plug 'ncm2/float-preview.nvim'
"New Color scheme
"Plug 'wuelnerdotexe/vim-enfocado'
Plug 'rust-lang/rust.vim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " We recommend updating the parsers on update
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
Plug 'gruvbox-community/gruvbox'
call plug#end()
set number relativenumber
syntax on
set noexpandtab
set copyindent
set preserveindent
set lazyredraw
set ignorecase smartcase
let $RTP = $XDG_CONFIG_HOME."/nvim"
set tabstop=2
set shiftwidth=2
set expandtab
set colorcolumn=120
set hidden
set scrolloff=8
"set cursor to blink
"set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175
set cursorline
" Use ALE for Omnifunc
set omnifunc=ale#completion#OmniFunc
set background=dark
" colorscheme solarized
"colorscheme desert
colorscheme gruvbox
"autocmd VimEnter * ++nested colorscheme enfocado if filereadable(".last.sess") | :source .last.sess | endif
"save state on quit
"autocmd VimLeave * :mksession! .last.sess
" Set foldmethod
set foldmethod=expr " if we set foldmethod to 'syntax' we would have to enable vim syntax on top of treesitter which can affect performance
set foldexpr=nvim_treesitter#foldexpr()
"set foldmethod=syntax
set foldlevel=1
set foldnestmax=3 " tree sitter only seems to fold at the method level
" Dictionary
set dictionary+=/usr/share/dict/words
set complete+=k
" Set blinking cursor
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175
filetype plugin on
filetype plugin indent on
augroup FileTypeGroup
au BufRead,BufNewFile *.cls,*.trigger,*.apex setlocal filetype=apex
"au BufRead,BufNewFile *.cls,*.trigger,*.apex set filetype=apex | set syntax=java | UltiSnipsAddFiletypes cls.java
au BufRead,BufNewFile *.soql set filetype=apex | set syntax=sql | UltiSnipsAddFiletypes sql
au BufRead,BufNewFile *-meta.xml UltiSnipsAddFiletypes meta.xml
au BufRead,BufNewFile project-scratch-def.json set filetype=scratch | set syntax=json
au BufRead,BufNewFile *.vue,*.svelte,*.jsw,*.cmp,*.page set filetype=html
au BufRead,BufNewFile *.tsx,*.jsw set filetype=javascript
au BufRead,BufNewFile *.jsx set filetype=javascript.jsx
au BufRead,BufNewFile **/lwc/*.js UltiSnipsAddFiletypes lwc.js
augroup END
" Set current directory to the parent dir of the current file
" autocmd BufEnter * silent! lcd %:p:h
command! WipeReg for i in range(34,122) silent! call setreg(nr2char(i), []) endfor
"Keymaps
" Press Space to turn off highlighting and clear any message already displayed.
let hlstate=0
:nnoremap <silent> <Space> :if (hlstate%2 == 0) \| nohlsearch \| else \| set hlsearch \| endif \| let hlstate=hlstate+1<Bar>:echo<CR>
:nnoremap <C-j>t :bo 15sp +te<CR>A
:nnoremap <C-w>m <C-w>_<C-w>\|
:nnoremap <C-w><Left> :vertical resize -5<CR>
:nnoremap <C-w><Right> :vertical resize +5<CR>
:nnoremap <C-w><Down> :resize +5<CR>
:nnoremap <C-w><Up> :resize +5<CR>
:nnoremap <C-s> :ls<CR>:b<Space>
":nnoremap <C-y> [{zf%
:nnoremap zm zMza
:nnoremap zr zR
:noremap <C-e> :tabnew ~/.vimrc<CR>
:noremap <leader>e :tabnew ~/.local/share/nvim/swap/<CR>
:nnoremap ++ :!git add "%"<CR>
:nnoremap ]t <C-w>s<C-w>j10<C-w>-:term sfdx force:apex:test:run -y -r human -c -w 5 -n "%:t:r" --verbose<CR>
:nnoremap <silent> ]tt ?\c@IsTest<CR>j0f(hyiw<C-w>s<C-w>j10<C-w>-:term sfdx force:apex:test:run -y -r human -c -w 5 --verbose -t "%:t:r".<C-r>"<CR>
:nnoremap ]a <C-w>s<C-w>j10<C-w>-:term sfdx force:source:beta:push<CR>
:nnoremap ]af <C-w>s<C-w>j10<C-w>-:term sfdx force:source:beta:push -f<CR>
:nnoremap ]u <C-w>s<C-w>j10<C-w>-:term sfdx force:source:beta:pull<CR>
:nnoremap ]uf <C-w>s<C-w>j10<C-w>-:term sfdx force:source:beta:pull -f<CR>
:nnoremap ]d <C-w>s<C-w>j10<C-w>-:term sfdx force:source:deploy -p "%" -l NoTestRun -w 5 -u
:nnoremap ]dd <C-w>s<C-w>j10<C-w>-:term sfdx force:source:deploy -p "%" -l NoTestRun -w 5<CR>
:nnoremap ]e :tabnew \| read !sfdx force:apex:execute -f "#" -u
:nnoremap ]ee :tabnew \| read !sfdx force:apex:execute -f "#"<CR>
"apex logs
:nnoremap ]l :tabnew /tmp/apexlogs.log<CR><C-w>s<C-w>j:term sfdx force:apex:log:tail --color -u <bar> tee /tmp/apexlogs.log<C-left><C-left><C-left>
:nnoremap ]ll :tabnew /tmp/apexlogs.log<CR><C-w>s<C-w>j:term sfdx force:apex:log:tail --color <bar> tee /tmp/apexlogs.log<CR>
"remap 'U' to revert to previous save
nnoremap U :ea 1f<CR>
"fzf key bindings
:nnoremap <C-p> :Files!<CR>
:nnoremap <silent> <C-f>b :Buffers!<CR>
:nnoremap <silent> <C-f>s :Snippets!<CR>
:nnoremap <silent> <C-f>g :Commits!<CR>
:nnoremap <silent> <C-f>f <Esc><Esc>:BLines!<CR>
":nnoremap <silent> <C-f>l <Esc><Esc>:Helptags!<CR>
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
inoremap <expr> <C-x>c fzf#vim#complete('cat ~/.sldsclasses.txt')
inoremap <expr> <Leader>s fzf#vim#complete({
\ 'source': 'cat schema.txt',
\ 'reducer': { lines -> split(lines[0],' ')[0]}})
"ale key bindings
:nnoremap <silent> <C-w>i :ALEToggleBuffer<CR>
" use 'za' to toggle folds
" Prevent wq accidents
:command! W w
:command! Wq wq
:command! Wqa wqa
:command! Q q
:command! Qa qa
" Prevent gq accidents
:nnoremap gQ gq
"Remap arrow keys
:nnoremap <Up> ddkP
:nnoremap <Down> ddp
"sudo save
cmap w!! w !sudo tee > /dev/null %
"remove all tabs and spaces from lines with just tabs and spaces to make them
"truly blank lines
:command! BL %s/^\(\s\|\t\)*$//g
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_root_markers = ['.git','pom.xml','.ssh','node_modules']
" let g:netrw_banner = 0
" let g:netrw_browse_split = 3
let g:netrw_winsize = 25
let g:netrw_bufsettings = 'noma nomod nu nowrap ro nobl'
" au BufRead /tmp/psql.edit.* set syntax=sql
"
" Ultisnips Trigger configuration
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsListSnippets="<s-tab>"
let g:UltiSnipsUsePythonVersion = 3
let g:UltiSnipsSnippetDirectories=["UltiSnips",$HOME."/.vim/mysnips"]
" Ctrl p exclude directories
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|src'
" Only run linters named in ale_linters settings.
let g:ale_linters_explicit = 1
"Dock floating preview window
let g:float_preview#docked=1
let g:ale_linters = {'javascript': ['eslint'],'css':['eslint'],'html':['eslint'],'apex':['apexlsp','pmd'],'jsw':['eslint'],'markdown':['markdownlint'],'rust':['analyzer'],'sh':['shellcheck']}
let g:ale_fixers = {'javascript': ['prettier'],'css':['prettier'],'apex':['prettier'],'html':['prettier'],'jsw':['prettier'],'json':['jq'],'python':['black'],'java':['google_java_format'],'markdown':['prettier'],'rust': ['rustfmt', 'trim_whitespace', 'remove_trailing_lines'],'sh':['prettier']}
let g:ale_fix_on_save= 1
let g:ale_sign_error='>>'
"let g:ale_sign_warning='⚠️'
let g:ale_sign_warning='--'
let g:ale_floating_preview=1
let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_use_global = 1
let g:ale_completion_tsserver_autoimport = 1
let g:ale_java_google_java_format_executable = "~/.scripts/jformat.sh"
let g:ale_apex_apexlsp_executable = "/usr/bin/java"
if $PATH !~ "\.scripts"
let $PATH="~/.scripts/:".$PATH
endif
if (has("termguicolors"))
set termguicolors
endif
"search recursively in subfolders using 'find'
set path+=**
"Ignore folders from vim grep
set wildignore+=**/node_modules/**
syntax sync minlines=10000
function! StatuslineSfdx(...) abort
if !exists('./sfdx/sfdx-config.json')
return ''
endif
return system("if [ -f './.sfdx/sfdx-config.json' ];then cat ./.sfdx/sfdx-config.json 2>/dev/null | jq -r '.defaultusername' 2>/dev/null; fi")
endfunction
" status line changes
set laststatus=2
"let g:airline_section_a=airline#section#create(['%{StatuslineSfdx()}',' ','branch'])
"set statusline='%{StatuslineSfdx()}'
lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = {"java","json","javascript","bash","lua","vim","comment"}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ignore_install = {}, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
disable = {}, -- list of language that will be disabled
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false
}
}
local ft_to_parser = require"nvim-treesitter.parsers".filetype_to_parsername
ft_to_parser.apex = "java"
EOF