Last active
March 31, 2023 12:05
-
-
Save arren-ru/97fadbbbe71248940981e1a55f668f6e to your computer and use it in GitHub Desktop.
dotfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" VIM 8 defaults | |
unlet! skip_defaults_vim | |
silent! source $VIMRUNTIME/defaults.vim | |
set viminfo=%,<1000,'10,/50,:100,h,f0,n~/.vim/.viminfo | |
" │ │ │ │ │ │ │ ╰─ viminfo file path | |
" │ │ │ │ │ │ ╰──── file marks 0-9,A-Z 0=NOT stored | |
" │ │ │ │ │ ╰────── disable 'hlsearch' loading viminfo | |
" │ │ │ │ ╰─────────── command-line history saved | |
" │ │ │ ╰─────────────── search history saved | |
" │ │ ╰─────────────────── files marks saved | |
" │ ╰───────────────────────── lines saved each register (old name for <, vi6.2) | |
" ╰─────────────────────────── save/restore buffer list | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -sfLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
au VimEnter * ++once PlugInstall --sync | so $MYVIMRC | |
endif | |
silent! if plug#begin('~/.vim/plugged') | |
Plug 'mhinz/vim-startify' | |
let g:startify_custom_header = '' | |
let g:startify_bookmarks = [ | |
\ #{ v: '~/.vimrc' }, | |
\ #{ z: '~/.zshrc' }, | |
\ #{ s: '~/.ssh/config' } ] | |
let g:startify_commands = [ | |
\ #{ u: 'PlugUpdate | CocUpdate' } ] | |
nnoremap <silent> <F12> :Startify<CR> | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'jacoborus/tender.vim' | |
Plug 'sickill/vim-monokai' | |
Plug 'tomasr/molokai' | |
Plug 'mhinz/vim-janah' | |
Plug 'cespare/vim-toml' | |
Plug 'vim-airline/vim-airline' | |
let g:airline_powerline_fonts = 1 | |
if !exists('g:airline_symbols') | let g:airline_symbols = {} | endif | |
let g:airline_symbols.modified = '⁺' | |
let g:airline_symbols.dirty = '⁺' | |
let g:airline_symbols.notexists = '⁻' | |
let g:airline_symbols.branch = 'שׂ' | |
let g:airline_symbols.readonly = ' ' | |
let g:airline_symbols.crypt = ' ' | |
let g:airline_symbols.whitespace = ' ' | |
let g:airline_section_z = '%v•%l/%L' | |
let g:airline#extensions#default#layout = [['a', 'c'], ['x', 'b', 'error', 'warning']] | |
let g:airline#extensions#searchcount#enabled = 0 | |
let g:airline#extensions#hunks#enabled = 0 | |
let g:airline#extensions#ale#show_line_numbers = 0 | |
let g:airline#extensions#ale#error_symbol = ' ' | |
let g:airline#extensions#ale#warning_symbol = ' ' | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#fnamemod = ':t' | |
let g:airline#extensions#tabline#show_close_button = 0 | |
let g:airline#extensions#tabline#show_tab_count = 0 | |
let g:airline#extensions#tabline#tabs_label = '' | |
let g:airline#extensions#tabline#tab_nr_type = 1 | |
let g:airline#extensions#tabline#show_buffers = 0 | |
let g:airline#extensions#tabline#show_splits = 0 | |
let g:airline#extensions#whitespace#trailing_format = ' %s' | |
let g:airline#extensions#whitespace#mixed_indent_format = ' %s' | |
let g:airline#extensions#whitespace#mixed_indent_file_format = ' %s' | |
let g:airline#extensions#whitespace#long_format = 'ﲒ %s' | |
let g:airline#extensions#whitespace#conflicts_format = '裂%s' | |
Plug 'jeffkreeftmeijer/vim-numbertoggle' | |
Plug 'yggdroot/indentline' | |
let g:indentLine_setConceal = 0 | |
let g:indentLine_concealcursor = 'inc' | |
let g:indentLine_conceallevel = 2 | |
let g:indentLine_char = '▏' | |
let g:indentLine_color_term = 237 | |
let g:indentLine_color_gui = '#353535' | |
Plug 'tpope/vim-commentary' | |
nmap // <Plug>CommentaryLine | |
vmap / <Plug>Commentary | |
Plug 'tpope/vim-fugitive' | |
Plug 'junegunn/gv.vim', #{ on: ['GV'] } | |
Plug 'airblade/vim-gitgutter' | |
let g:gitgutter_map_keys = 0 | |
let g:gitgutter_set_sign_backgrounds = 1 | |
let g:gitgutter_preview_win_floating = 1 | |
let g:gitgutter_grep = 'rg' | |
let g:gitgutter_sign_added = '░▏' | |
let g:gitgutter_sign_modified = '░▏' | |
let g:gitgutter_sign_modified_removed = '░▏' | |
let g:gitgutter_sign_removed = '░▏' | |
let g:gitgutter_sign_removed_first_line = '░▏' | |
nmap <silent> ]g <Plug>(GitGutterNextHunk)<Plug>(GitGutterPreviewHunk) | |
nmap <silent> [g <Plug>(GitGutterPrevHunk)<Plug>(GitGutterPreviewHunk) | |
nmap <silent> <Leader>gg <Plug>(GitGutterPreviewHunk) | |
nmap <silent> <Leader>gs <Plug>(GitGutterStageHunk) | |
nmap <silent> <Leader>gu <Plug>(GitGutterUndoHunk) | |
Plug 'junegunn/vim-peekaboo' | |
Plug 'junegunn/vim-easy-align' | |
let g:easy_align_delimiters = { | |
\ '>': #{ pattern: '>>\|=>\|>' }, | |
\ '\': #{ pattern: '\\' }, | |
\ '/': #{ pattern: '//\+\|/\*\|\*/', delimiter_align: 'l', ignore_groups: ['!Comment'] }, | |
\ 'f': #{ pattern: ' \(\S\+(\)\@=', left_margin: 0, right_margin: 0 }, | |
\ 'd': #{ pattern: ' \ze\S\+\s*[;=]', left_margin: 0, right_margin: 0 }} | |
xmap g= <Plug>(EasyAlign) | |
nmap g= <Plug>(EasyAlign) | |
Plug 'junegunn/fzf' | |
Plug 'junegunn/fzf.vim' | |
let g:fzf_action = #{ ctrl-t: 'tab sp', ctrl-s: 'sp', ctrl-v: 'vs' } | |
let g:fzf_layout = #{ window: #{ width: 0.9, height: 0.8 } } | |
let g:fzf_preview_window = 'up' | |
let g:fzf_buffers_jump = 1 | |
nnoremap <silent> g/ :call fzf#vim#lines()<CR> | |
nnoremap <silent> g? :call fzf#vim#lines(expand('<cWORD>'))<CR> | |
nnoremap <silent> <Bar> :Buffers<CR> | |
nnoremap <silent> <Leader>m :Marks<CR> | |
nnoremap <silent> <Leader>w :Windows<CR> | |
aug vimrc_fzf_esc | |
au! | |
au FileType fzf tnoremap <buffer> <Esc> <Esc> | |
aug end | |
Plug 'easymotion/vim-easymotion' | |
let g:EasyMotion_do_mapping = 0 | |
let g:EasyMotion_show_prompt = 0 | |
let g:EasyMotion_prompt = ' ' | |
let g:EasyMotion_smartcase = 1 | |
nmap <Leader><Leader> <Plug>(easymotion-sn) | |
Plug 'majutsushi/tagbar', #{ on: ['TagbarToggle'], for: ['concourse'] } | |
let g:tagbar_map_togglefold = ['o', '<Space>'] | |
let g:tagbar_sort = 0 | |
let g:tagbar_compact = 1 | |
let g:tagbar_autoclose = 1 | |
let g:tagbar_left = 1 | |
let g:tagbar_type_dockerfile = #{ | |
\ ctagstype: 'dockerfile', | |
\ sro: ' ', | |
\ kinds: ['l:layer', 'a:arg', 'e:env'], | |
\ kind2scope: {'l': 'layer'}, | |
\ } | |
nnoremap <silent> <F4> :TagbarToggle<CR> | |
Plug 'preservim/nerdtree', #{ on: ['NERDTreeToggle', 'NERDTreeFind'] } | |
let g:NERDTreeMinimalUI = 1 | |
let g:NERDTreeQuitOnOpen = 3 | |
let g:NERDTreeShowHidden = 1 | |
let g:NERDTreeDirArrowExpandable = '' | |
let g:NERDTreeDirArrowCollapsible = '' | |
let g:NERDTreeMapCustomOpen = '<CR>' | |
let g:NERDTreeMapUpdir = '<BS>' | |
nnoremap <silent> <F3> :NERDTreeToggle<CR> | |
aug vimrc_nerdtree_loader | |
au! | |
au VimEnter * silent! au! FileExplorer | |
au BufEnter,BufNew * | |
\ if isdirectory(expand('<amatch>')) | | |
\ call plug#load('nerdtree') | | |
\ exe 'au! vimrc_nerdtree_loader' | | |
\ endif | |
aug end | |
Plug 'mbbill/undotree', #{ on: ['UndotreeToggle'] } | |
let g:undotree_HighlightChangedWithSign = 0 | |
let g:undotree_WindowLayout = 2 | |
let g:undotree_SetFocusWhenToggle = 1 | |
nnoremap <silent> U :UndotreeToggle<CR> | |
Plug 'jamessan/vim-gnupg' | |
let g:GPGUsePipes = 1 | |
Plug 'm-pilia/vim-pkgbuild' | |
Plug 'jvirtanen/vim-hcl' | |
Plug 'hashivim/vim-terraform' | |
Plug 'towolf/vim-helm', #{ for: ['helm'] } | |
au BufNewFile,BufReadPost {Chart,values,values.*,templates/*}.yaml setlocal filetype=helm | |
Plug 'luan/vim-concourse', #{ for: ['concourse'] } | |
au FileType concourse setlocal cursorline | setlocal foldmethod=manual | |
Plug 'neoclide/coc.nvim', #{ branch: 'release' } | |
let g:coc_data_home = '~/.vim/coc' | |
let g:coc_global_extensions = ['coc-sh', 'coc-yaml', 'coc-json', 'coc-go', 'coc-rust-analyzer', 'coc-phpls', 'coc-vimlsp'] | |
let g:coc_user_config = { | |
\ 'diagnostic.enable': 'true', | |
\ 'diagnostic.displayByAle': 'true', | |
\ 'rust-analyzer.server.path': 'rust-analyzer', | |
\ 'yaml.schemas': #{ kubernetes: '*.yaml' } } | |
let g:coc_user_config.languageserver = #{ | |
\ terraform: #{ | |
\ command: 'terraform-ls', | |
\ args: ['serve'], | |
\ filetypes: ['terraform', 'tf'], | |
\ rootPatterns: ['.terraform'], | |
\ initializationOptions: {}, | |
\ settings: {} } } | |
Plug 'dense-analysis/ale' | |
let g:ale_set_highlights = 0 | |
let g:ale_set_quickfix = 1 | |
let g:ale_sign_error = '' | |
let g:ale_sign_warning = '' | |
let g:ale_sign_info = '' | |
let g:ale_echo_msg_format = ' %severity% %linter% ┆ %s' | |
let g:ale_echo_msg_error_str = g:ale_sign_error | |
let g:ale_echo_msg_warning_str = g:ale_sign_warning | |
let g:ale_echo_msg_info_str = g:ale_sign_info | |
let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace'] } | |
let g:ale_fixers.sh = ['shfmt'] | |
let g:ale_fixers.go = ['gofmt', 'goimports'] | |
let g:ale_fixers.json = ['prettier', 'jq'] | |
let g:ale_fixers.yaml = ['prettier'] | |
let g:ale_fixers.helm = g:ale_fixers.yaml | |
let g:ale_fixers.terraform = ['terraform'] + g:ale_fixers['*'] | |
let g:ale_sh_shfmt_options = '-i 4' | |
nmap <silent> ]a <Plug>(ale_next_wrap) | |
nmap <silent> [a <Plug>(ale_previous_wrap) | |
nmap <silent> <Leader>f <Plug>(ale_fix) | |
nmap <silent> <Leader>l <Plug>(ale_lint) | |
if has_key(g:plugs, 'coc.nvim') | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
nmap <Leader>r <Plug>(coc-rename) | |
nmap <Leader><CR> gd | |
fun! s:check_back_space() abort | |
let col = col('.') - 1 | return !col || getline('.')[col - 1] =~ '\s' | |
endf | |
inoremap <silent><expr> <Tab> coc#pum#visible() ? coc#pum#next(1): <SID>check_back_space() ? "\<Tab>" : coc#refresh() | |
inoremap <silent><expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" | |
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm() : "\<CR>" | |
aug vimrc_cocnvim | |
au! | |
au CursorHold * silent call CocActionAsync('highlight') | |
aug end | |
fun! s:show_documentation() | |
if (index(['vim', 'help'], &filetype) >= 0) | |
exe 'h' expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endf | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
endif | |
call plug#end() | endif | |
""" OPTIONS | |
set autoindent | |
set autoread | |
set backupdir=/tmp//,. | |
set breakindent | |
set breakindentopt=sbr | |
set colorcolumn=120 | |
set complete-=i cot=longest,menuone | |
set conceallevel=1 | |
set cryptmethod=blowfish2 | |
set cursorline culopt=number | |
set diffopt=filler,internal,algorithm:histogram,indent-heuristic | |
set directory=/tmp//,. | |
set expandtab smarttab | |
set fillchars=vert:│ | |
set foldlevelstart=99 fdc=0 nofen | |
set formatoptions+=j | |
set gdefault | |
set hidden | |
set nohlsearch | |
set ignorecase | |
set iskeyword-=- | |
set laststatus=2 | |
set lazyredraw | |
set list lcs=tab:▏\ ,trail:∙,extends:»,precedes:«,nbsp:⎵ | |
set nofixeol | |
set nojoinspaces | |
set nostartofline | |
set notimeout | |
set nowrap | |
set nrformats-=octal | |
set number relativenumber | |
set path+=** | |
set sessionoptions-=options | |
set shiftwidth=4 | |
set shortmess+=Ic | |
set showmode | |
set showtabline=2 | |
set splitbelow splitright | |
set tabstop=4 | |
set textwidth=0 | |
set title | |
set updatetime=250 | |
set vb noeb t_vb= | |
set viewoptions-=options | |
set virtualedit=block | |
set wildmode=longest,list,full wcm=9 nowic | |
if has('persistent_undo') | |
set undofile undodir=~/.vim/undo | |
if !isdirectory(&undodir) | |
silent call mkdir(&undodir, '', 0700) | |
endif | |
endif | |
set foldtext=CustomFoldText() | |
fun! CustomFoldText() | |
let line = getline(v:foldstart) | |
if match(line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$') == 0 | |
let initial = substitute(line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '') | |
let linenum = v:foldstart + 1 | |
while linenum < v:foldend | |
let line = getline(linenum) | |
let comment_content = substitute(line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g') | |
if comment_content != '' | |
break | |
endif | |
let linenum = linenum + 1 | |
endwhile | |
let sub = initial . ' ' . comment_content | |
else | |
let sub = line | |
let startbrace = substitute(line, '^.*{[ \t]*$', '{', 'g') | |
if startbrace == '{' | |
let line = getline(v:foldend) | |
let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g') | |
if endbrace == '}' | |
let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', ' ... }\1', 'g') | |
endif | |
endif | |
endif | |
let foldtextstart = strpart(sub, 0, winwidth(0)*2/3) | |
let foldtextend = printf("%6d %-10s ", v:foldend - v:foldstart + 1, " ") | |
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn | |
return foldtextstart . repeat(' ', winwidth(0) - foldtextlength) . foldtextend | |
endf | |
let g:vim_json_conceal=0 | |
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' | |
runtime! macros/matchit.vim | |
endif | |
""" COLORS | |
if has('gui_running') | |
set guifont=Iosevka\ Nerd\ Font:h13 | |
endif | |
if has('termguicolors') | |
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_SR = "\<Esc>]50;CursorShape=2\x7" | |
set termguicolors | |
endif | |
fun s:colorscheme() | |
hi EndOfBuffer guibg=bg guifg=bg | |
hi SignColumn guibg=bg | |
hi CursorLineNr guibg=bg guifg=#ffc24b cterm=NONE | |
hi Pmenu guibg=#404040 | |
let fgConceal = synIDattr(synIDtrans(hlID('NonText')), 'fg') | |
exe 'hi LineNr guibg=bg guifg='.fgConceal | |
exe 'hi VertSplit guibg=bg guifg='.fgConceal | |
exe 'hi SpecialKey guibg=bg guifg='.fgConceal | |
hi GitGutterAdd guibg=bg guifg=#009040 | |
hi GitGutterDelete guibg=bg guifg=#C00000 | |
hi GitGutterChange guibg=bg guifg=#A08000 | |
hi GitGutterChangeDelete guibg=bg guifg=#A08000 | |
hi ALEErrorSign guibg=bg guifg=#ff3535 | |
hi ALEWarningSign guibg=bg guifg=#ffc24b | |
hi ALEInfoSign guibg=bg guifg=#2080cc | |
hi link NERDTreeDir Normal | |
hi link NERDTreeFlags CursorLineNr | |
endf | |
aug vimrc_colorscheme | |
au! | |
au ColorScheme * call s:colorscheme() | |
au ColorScheme * hi link ExtraWhitespace SpellBad | |
aug end | |
aug vimrc_whitespaces | |
au! | |
au BufNewFile,BufRead,InsertLeave * | |
\ silent! match ExtraWhitespace /\s\+$/ | |
au InsertEnter * | |
\ silent! match ExtraWhitespace /\s\+\%#\@<!$/ | |
aug end | |
let g:airline_theme = 'tender' | |
silent! colorscheme monokai | |
""" MAPPINGS | |
vnoremap <CR> <NOP> | |
nnoremap <S-Q> <NOP> | |
nnoremap <C-Q> <C-W>q | |
inoremap <C-L> <Esc> | |
" Terminal specific | |
tnoremap <C-Bslash><C-Bslash> <C-Bslash><C-N> | |
tnoremap <C-W>q <C-W>:bd!<CR> | |
tmap <C-W><C-Q> <C-W>q | |
tnoremap <C-W><Up> <C-W>k | |
tnoremap <C-W><Down> <C-W>j | |
tnoremap <C-W><Left> <C-W>h | |
tnoremap <C-W><Right> <C-W>l | |
" Save and exit | |
nnoremap <silent> <F2> :up<CR> | |
inoremap <silent> <F2> <C-O>:up<CR> | |
vnoremap <silent> <F2> <ESC>:up<CR>gv | |
nnoremap <F10> ZZ | |
inoremap <F10> <C-O>ZZ | |
xnoremap <F10> <ESC>ZZ | |
" Navigation | |
nnoremap <C-P> <C-I> | |
nnoremap <Tab> <C-W><C-W> | |
nnoremap <silent> <S-Tab> :bn<CR> | |
nnoremap <BS> <C-^> | |
nnoremap <C-Up> <C-W>k | |
nnoremap <C-Down> <C-W>j | |
nnoremap <C-Left> <C-W>h | |
nnoremap <C-Right> <C-W>l | |
" Tabs | |
nnoremap <Leader>] gt | |
nnoremap <Leader>[ gT | |
for s:i in range(1, 9) | |
exe printf('nnoremap <Leader>%d %dgt', s:i, s:i) | |
endfor | unlet s:i | |
" Folding | |
nnoremap <silent><expr> <Space> foldlevel('.') ? 'za' : "\<Space>" | |
vnoremap <Space> zf | |
" Operations | |
nnoremap Y y$ | |
nnoremap x "_dl | |
nnoremap X "_dh | |
nnoremap <C-X> "_dd | |
inoremap <C-X> <C-O>"_dd | |
xnoremap <BS> "_d | |
xnoremap k :m'<-2<CR>gv | |
xnoremap j :m'>+<CR>gv | |
xnoremap <Tab> >gv | |
xnoremap <S-Tab> <gv | |
xnoremap <C-D> yPgv | |
xnoremap <C-C> "+ygv | |
nnoremap + <C-A> | |
nnoremap - <C-X> | |
xnoremap + <C-A>gv | |
xnoremap - <C-X>gv | |
xnoremap <Leader>xd c<C-R>=system('base64 -d', @")<CR><ESC> | |
xnoremap <Leader>xe c<C-R>=system('base64', @")<CR><ESC> | |
" Help pages | |
noremap <F1> :vert bo h index<CR> | |
aug vimrc_help | |
au! | |
au FileType help nnoremap <buffer> q <C-W>c | |
au BufEnter option-window nnoremap <buffer> q :q<CR> | |
aug end | |
""" COMMANDS | |
aug vimrc | |
au VimResized * silent wincmd = | |
au CursorHold * silent! checktime | |
au InsertLeave * silent! set nopaste | |
au Syntax * syntax sync minlines=2000 | |
au BufWritePost,BufWinLeave * | |
\ if expand('%') != '' && &buftype !~ 'nofile' | mkview | endif | |
au BufWinEnter * | |
\ if expand('%') != '' && &buftype !~ 'nofile' | silent loadview | endif | |
" au BufReadPost * | |
" \ if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | |
aug end | |
com! HI echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), ',') | |
" Open files in the form of path:line:column | |
fun! s:open_at_position() | |
let args = split(expand('%'), ':') | |
if len(args) <= 1 || !filereadable(args[0]) | return | endif | |
bd! | silent execute 'e' args[0] | |
let pos = map(args[1:], 'str2nr(v:val)') | |
exe printf('normal! %dG%d|', get(pos, 0, 1), get(pos, 1, 1)) | |
endf | |
au vimrc BufNewFile * nested call s:open_at_position() | |
" Autosave | |
fun! s:autosave(enable) | |
aug vimrc_autosave | |
au! | |
if a:enable | |
au TextChanged,InsertLeave <buffer> | |
\ if empty(&buftype) && !empty(bufname('')) | silent! up | endif | |
endif | |
aug end | |
endf | |
com! -bang AutoSave call s:autosave(<bang>1) | |
" Git + FZF | |
fun! s:getgitroot(...) | |
let root = systemlist(printf('git -C %s rev-parse --show-toplevel 2>/dev/null', shellescape(expand('%:p:h')))) | |
return !v:shell_error ? root[0] : (a:0 ? a:1 : '') | |
endf | |
fun! s:git_cd() | |
let root = s:getgitroot() | |
if !empty(root) | |
exe 'lcd' root | echo 'Changed directory to: '.root | |
endif | |
endf | |
com! Groot call s:git_cd() | |
fun! s:git_ripgrep(query, bang) | |
let cmd = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true' | |
let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.printf(cmd, '{q}')]} | |
if a:bang | |
let options.dir = s:getgitroot(expand('%:p:h')) | |
endif | |
call fzf#vim#grep(printf(cmd, shellescape(a:query)), 1, fzf#vim#with_preview(options)) | |
endf | |
com! -bang -nargs=* Rg call s:git_ripgrep(<q-args>, <bang>0) | |
nnoremap <silent> <Leader>/ :call <SID>git_ripgrep('', 1)<CR> | |
nnoremap <silent> <Leader>? :call <SID>git_ripgrep(expand('<cWORD>'), 1)<CR> | |
nnoremap <silent> <Leader>. :call fzf#vim#files(<SID>getgitroot(expand('%:p:h')), fzf#vim#with_preview())<CR> | |
" Zoom | |
fun! s:zoom_tabsplit() | |
if winnr('$') > 1 | |
tab sp | |
elseif len(filter(map(range(tabpagenr('$')), 'tabpagebuflist(v:val+1)'), 'index(v:val,'.bufnr('').') >= 0')) > 1 | |
tabc | |
endif | |
endf | |
nnoremap <silent> <Leader>t :call <SID>zoom_tabsplit()<CR> | |
fun! s:zoom_expand() abort | |
if exists('t:zoom_expanded') && t:zoom_expanded | |
exe t:zoom_expand_winrestcmd | |
let t:zoom_expanded = 0 | |
else | |
let t:zoom_expand_winrestcmd = winrestcmd() | |
resize | vertical resize | |
let t:zoom_expanded = 1 | |
endif | |
endf | |
nnoremap <silent> <Leader>z :call <SID>zoom_expand()<CR> | |
fun! s:calc() range | |
try | |
let v = @v | |
norm! gv"vy | |
try | |
let r = eval(@v) | |
call setreg('v', printf('%s', r), visualmode()) | |
norm! gv"vp | |
catch /.*/ | |
throw printf('Invalid expression: %s (%s)', @v, v:exception) | |
endtry | |
finally | |
let @v = v | |
endtry | |
endf | |
vnoremap <silent> <leader><cr> :call <sid>calc()<cr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LANG=en_US.UTF-8 | |
export EDITOR=vim | |
if [[ "$OSTYPE" == darwin* ]]; then | |
ulimit -S -n 10240 | |
export HOMEBREW_PREFIX="/opt/homebrew"; | |
export HOMEBREW_CELLAR="${HOMEBREW_PREFIX}/Cellar" | |
export HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}" | |
export HOMEBREW_CASK_OPTS=" --no-binaries --appdir=$HOME/Applications " | |
export HOMEBREW_GITHUB_API_TOKEN=$GITHUB_TOKEN | |
export MANPATH="${HOMEBREW_PREFIX}/share/man${MANPATH+:$MANPATH}:" | |
export INFOPATH="${HOMEBREW_PREFIX}/share/info:${INFOPATH:-}" | |
export PATH="${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin${PATH+:$PATH}" | |
if [[ -d "${HOMEBREW_PREFIX}/opt/curl/bin" ]]; then | |
export PATH="${HOMEBREW_PREFIX}/opt/curl/bin${PATH+:$PATH}" | |
fi | |
fi | |
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) | |
gpg-connect-agent updatestartuptty /bye > /dev/null | |
export GOPROXY=direct | |
export GOSUMDB=off | |
export GOPATH="$HOME/.golang" | |
export PATH="$GOPATH/bin${PATH+:$PATH}" | |
export HELM_CONFIG_HOME="$HOME/.config/helm" | |
export HELM_DATA_HOME="$HOME/.local/share/helm" | |
export HELM_CACHE_HOME="$HOME/.cache/helm" | |
export PATH="${PATH+:$PATH:}$HOME/.krew/bin" | |
zstyle ':prezto:load' pmodule \ | |
environment spectrum ls-colors \ | |
terminal prompt syntax-highlighting autosuggestions \ | |
history history-substring-search directory utility git \ | |
fzf completion | |
zstyle ':prezto:module:*' color yes | |
zstyle ':prezto:module:utility' safe-ops no | |
zstyle ':prezto:module:utility' correct no | |
zstyle ':prezto:module:git:alias' skip yes | |
zstyle ':prezto:module:prompt' theme pure | |
zstyle ':prompt:pure:path' color 36 | |
zstyle ':prompt:pure:prompt:success' color 240 | |
zstyle ':prezto:module:ls-colors' theme molokai | |
zstyle ':prezto:module:fzf:*' ignore . .git/ .composer/ .golang/ Library/ | |
zstyle ':prezto:module:fzf:ctrl-t' bat-theme 'Monokai Extended Bright' | |
if [[ ! -f $HOME/.zsh/prezto/init.zsh ]]; then | |
for m (sorin-ionescu/prezto arren-ru/prezto-arren) \ | |
git clone --depth=1 --shallow-submodules --recursive --jobs=8 "[email protected]:$m.git" "$HOME/.zsh/${m:t}" | |
unset m | |
fi | |
zstyle ':prezto:load' pmodule-dirs $HOME/.zsh/prezto-* | |
source $HOME/.zsh/prezto/init.zsh | |
autoload -U +X bashcompinit && bashcompinit | |
complete -o nospace -C terraform terraform | |
export PATH="$HOME/.local/bin:/opt/homebrew/opt/mysql-client/bin${PATH+:$PATH}" | |
export DOCKER_DEFAULT_PLATFORM=linux/amd64 | |
alias git-pkgver='git log -1 --format=%cd.$(git rev-list --count HEAD)_%h --date=format:%Y%m%d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
сложна