-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
142 lines (112 loc) · 3.83 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
set nocompatible
set ruler
set number
set cursorline
set hlsearch
set smartcase
set ignorecase
set tabstop=4
set softtabstop=4
set expandtab
set smarttab
set autoread
"set hidden
set pastetoggle=<F3>
set autoindent
set wildmode=list:longest,full
set completeopt=longest,menuone
set enc=utf8
set fileencodings=utf-8
set foldenable
set foldmethod=marker
set foldlevelstart=99
"set timeoutlen=400
set tags+=.tags
set backupdir=/tmp//
set directory=/tmp//
set undodir=/tmp//
set undofile
set mouse=a
set laststatus=2
set textwidth=0
set wrapmargin=0
set wrap
set scrolloff=8
set showmatch
" clipboard support is only available with installing gvim on Arch
set clipboard=unnamedplus
set splitright
set splitbelow
syntax on
set t_Co=256
" https://github.com/sonph/onehalf/blob/master/vim/colors/onehalflight.vim
colorscheme onehalflight
filetype on
filetype plugin on
filetype indent on
" remove blank lines from end of file
"autocmd BufWritePre * :%s#\($\n\)\+\%$##e
" trim whitespace
"autocmd BufWritePre * :%s/\s\+$//e
autocmd FileType python setl colorcolumn=99
autocmd FileType python :iabbrev pdb import pdb; pdb.set_trace()
autocmd FileType javascript,javascriptreact,typescript,typescriptreact setl tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType html,htmldjango setl tabstop=2 softtabstop=2 shiftwidth=2
" python indentation
let g:pyindent_open_paren = 'shiftwidth()'
let g:pyindent_continue = 'shiftwidth()'
" Plugins
" https://github.com/dense-analysis/ale
" https://github.com/junegunn/fzf.vim
" https://github.com/preservim/nerdtree
" NERDTree
"autocmd BufWinEnter * silent NERDTreeMirror
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
nnoremap <C-n> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
" ALE
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'python': ['black'],
\ 'javascript': ['prettier', 'eslint'],
\ 'javascriptreact': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'eslint'],
\ 'typescriptreact': ['prettier', 'eslint'],
\}
let g:ale_fix_on_save = 1
" FZF
set rtp+=/usr/bin/fzf
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden'
" https://github.com/junegunn/fzf.vim#example-advanced-ripgrep-integration
function! RipgrepFzf(query, fullscreen, smartcase, glob)
if (a:glob != '')
let l:glob_flag = ' --glob="' . a:glob . '"'
else
let l:glob_flag = ''
endif
let command_fmt = 'rg --column --line-number --no-heading --color=always' . a:smartcase . l:glob_flag .' -- %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0, ' --smart-case', '')
command! -nargs=* -bang RGC call RipgrepFzf(<q-args>, <bang>0, '', '')
function! RipgrepFzfWithGlob(qargs, fullscreen)
let l:args = split(a:qargs, ' ')
let l:glob = args[0]
let l:query = join(l:args[1:], ' ')
call RipgrepFzf(l:query, a:fullscreen, '', l:glob)
endfunction
command! -nargs=+ -bang RGG call RipgrepFzfWithGlob(<q-args>, <bang>0)
nnoremap <C-p> :FZF<CR>
" open blame on github
function GitHubBlame()
let line_number = line(".")
let file_path = @%
let remote = substitute(system('git config --get remote.origin.url'), '\n', '', 'g')
let url = 'https://github.com/' . substitute(remote, 'git@github\.com:', '', 'g')
let full_url = substitute(url, '\.git', '', 'g') . '/blame/master/' . file_path . '#L' . line_number
call system('chromium ' . full_url)
echom 'opening ' . full_url
endfunction