forked from serebrov/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc.tools
131 lines (113 loc) · 4.54 KB
/
.vimrc.tools
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
" Manage files and directories in vim
" :Vimdir [directory] - To list files and folders
" :VimdirR [directory] - To list files and folders recursive
" Then change file names, dd to delete and save buffer to apply changes
Plug 'c0r73x/vimdir.vim'
" Similar: vidir from moreutils (https://joeyh.name/code/moreutils/)
" Similar: Plug 'idbrii/renamer.vim'
Plug 'jamessan/vim-gnupg'
Plug 'Shougo/vimproc'
Plug 'Shougo/vimshell.vim'
" Wakatime
" https://wakatime.com
Plug 'wakatime/vim-wakatime'
if has('nvim')
" terminal scrollback buffer size
" set scrollback=100000
" Open terminal with ":term" or ":term ipython" (to run the specific command).
" Create the new split and enter / edit the commands there, send to
" terminal with "Enter" (current line or visual selection).
function! SendCommand(commands) abort
" Send the command to the first terminal buffer found in current tab.
" If there is no terminal - splits the current window and runs terminal
" there.
let commands = a:commands
let term_buffer_id = -1
let term_job_id = 0
for visible_buffer_id in tabpagebuflist()
try
let term_job_id = nvim_buf_get_var(visible_buffer_id, 'terminal_job_id')
let term_buffer_id = visible_buffer_id
break
catch
let term_job_id = 0
endtry
endfor
if term_job_id == 0
new
let term_job_id = termopen($SHELL)
endif
call jobsend(term_job_id, add(commands, ''))
endfunction
function! SendCommandCurrentLine()
" Send current line to terminal buffer.
call SendCommand([getline('.')])
endfunction
function! GetVisualSelection()
" Returns visual selection as list of lines.
" See https://stackoverflow.com/a/6271254/4612064
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
let lines = getline(line_start, line_end)
if len(lines) == 0
return []
endif
let lines[-1] = lines[-1][: column_end - 2]
let lines[0] = lines[0][column_start - 1:]
return lines
endfunction
function! SendCommandVisualSelection()
call SendCommand(GetVisualSelection())
endfunction
function! SendCommandVisualSelectionAsLine()
call SendCommand([join(GetVisualSelection(), " ")])
endfunction
autocmd FileType c,cpp,php,python,javascript,sql,sh nnoremap <buffer> <CR> :<C-u>call SendCommandCurrentLine()<CR>
autocmd FileType c,cpp,php,python,javascript,sql,sh xnoremap <buffer> <CR> :<C-u>call SendCommandVisualSelection()<CR>
" Useful in ipdb where multi-line input is not supported, this mapping can
" be used to send multi-line statement,
" see also discussion here https://github.com/randy3k/SendCode/issues/39,
" this is what they call "fake multi-line" mode:
autocmd FileType c,cpp,php,python,javascript,sql xnoremap <buffer> <leader><CR> :<C-u>call SendCommandVisualSelectionAsLine()<CR>
endif
" Filebrowser
" '-' to open it and to go up dir
" R - refresh;
" f - define the filter for filenames; F - toggle filter;
" gh - toggle hide/show wildeignored files
" <BS> - go back in dirs history
" q - close
" ~ - go home
" + / % - create file
" :ClipPathname / :ClipDirname - copy the full path of the selected file / current dir
Plug 'jeetsukumaran/vim-filebeagle'
let g:filebeagle_suppress_keymaps = 1
let g:filebeagle_show_hidden = 1
let g:filebeagle_check_gitignore = 1
" map <silent> <Leader>f <Plug>FileBeagleOpenCurrentWorkingDir
map <silent> - <Plug>FileBeagleOpenCurrentBufferDir
" Suggest to open existing file instead of creating new one when there
" are multiple matches
" allow using fzf
let g:dym_use_fzf = 1
Plug 'EinfachToll/DidYouMean'
" Ensure dir exists before save the file
" :e some_new_dir/some_new_file and then :w will work
Plug 'dockyard/vim-easydir'
" Auto CD to project root
" Plug 'airblade/vim-rooter'
" disables certain vim features to speedup large file editing
" g:LargeFile (by default, its 100) - 100Mb
Plug 'vim-scripts/LargeFile'
"""""" Commands
"Vim sugar for the UNIX shell commands that need it the most. Commands
"include:
" :Unlink: Delete a buffer and the file on disk simultaneously.
" :Remove: Like :Unlink, but doesn't require a neckbeard.
" :Move: Rename a buffer and the file on disk simultaneously.
" :Chmod: Change the permissions of the current file.
" :Find: Run find and load the results into the quickfix list.
" :Locate: Run locate and load the results into the quickfix list.
" :SudoWrite: Write a privileged file with sudo.
" :W: Write every open window. Handy for kicking off tools like guard.
Plug 'tpope/vim-eunuch'