-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer-patch
More file actions
217 lines (196 loc) · 7.14 KB
/
transfer-patch
File metadata and controls
217 lines (196 loc) · 7.14 KB
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
diff --git a/dotvim/right-click-menu.vim b/dotvim/right-click-menu.vim
index 10781f1..2748479 100644
--- a/dotvim/right-click-menu.vim
+++ b/dotvim/right-click-menu.vim
@@ -24,23 +24,37 @@
"menu RightClickMenu.subMenu.test :echo test
map <expr> <RightMouse> RightClickFunc()
-function! PopUpWithHighLight(line, col, win)
+function! PopUpWithHighLight(line, col, win, mode)
+ echom "mode:" . a:mode
exec a:win . "wincmd w"
- call setpos(".", [0, a:line, a:col, 0])
- let mat = matchadd("SpellBad", "\\<\\w*\\%#\\w*\\>*")
- redraw
+ let wlastline = line('w$')
+ let lastline = line('$')
+ "echom "line:" . a:line . " wlast:" . wlastline . " last:" . lastline
let winid = win_getid()
- popup RightClickMenu
- if win_id2win(winid) != 0
- call matchdelete(mat, winid)
+ if a:line > wlastline
+ " on title bar?
+ else
+ call setpos(".", [0, a:line, a:col, 0])
+ let mat = matchadd("SpellBad", "\\<\\w*\\%#\\w*\\>*")
redraw
+ popup RightClickMenu
+ if win_id2win(winid) != 0
+ call matchdelete(mat, winid)
+ redraw
+ endif
endif
endfunction
+" this function fetches all state and returns the command to feed the keys to
+" pop up a menu. we do not want vim to be in the state of executing a mapping
+" when the menu is popped up because it causes problems.
+" OTOH the state must be fetched here. this is why it's a two-stage thing!
function! RightClickFunc()
+ let mode = mode()
call feedkeys("\<LeftMouse>")
let c = getchar()
- let s = ':call feedkeys(":call PopUpWithHighLight(' . v:mouse_lnum . ',' . v:mouse_col . ',' . v:mouse_win . ')\<CR>")'
+ let command = ':call PopUpWithHighLight(' . v:mouse_lnum . ',' . v:mouse_col . ',' . v:mouse_win . ', "' . mode() . '")'
+ let s = ":call feedkeys('" . command . "\<C-v>\<CR>')\<CR>"
return s
endfunction
diff --git a/dotvim/vimrc b/dotvim/vimrc
index 2cc6673..558f5fc 100644
--- a/dotvim/vimrc
+++ b/dotvim/vimrc
@@ -35,15 +38,11 @@ runtime git-mergetool-tweaks.vim
" X window title / task bar text (also for console mode!)
set iconstring=VIM:\ %t
set titlestring=%t\ ~\ [%f]
-set title
-set icon
+set title icon
" statusline / command interface related stuff
set statusline=%<%f\ %h%m%r%=%n\ %-14.(%l,%c%V%)\ %P
-set laststatus=2
-set ruler
-set showcmd
-set wildmenu
+set laststatus=2 ruler showcmd wildmenu
set backspace=2
@@ -60,6 +59,7 @@ set sessionoptions+=resize,localoptions
set autowrite
set cscopequickfix=s-,c-,d-,i-,t-,e-
+" cscope add /repo/hans/slask/.git/cscope.out /repo/hans/slask
" syntax plugin options
let g:is_bash = 1
@@ -100,8 +100,50 @@ filetype plugin on
filetype indent on
" ### Stuff related to whitespace and special characters begin here ###
+function! g:SystemList(cmd)
+ let out = system(a:cmd)
+ return split(out, '\n')
+endfunction
+
+function! g:GitTopLevel()
+ " systemlist() seems like a convenient way to get rid of the newline in the
+ " output from the git command
+ let git_output = g:SystemList("git rev-parse --show-toplevel")
+ if v:shell_error == 0
+ return git_output[0]
+ endif
+ return ''
+endfunction
+
+" maybe chdir if in wrong repo?! but only when no server available! otherwise
+" assume that the remote vim is in the correct WD
+" get git top-level dir
+if argc() == 1
+ " TODO find repo of file being opened
+ let fileName = expand("%:p")
+ if v:servername == ""
+ " TODO! check git toplevel of FILE BEING OPENED! not current dir
+ " XXX ALSO! should handle multiple files! somehow... consider -o -O -p
+ let serverName = g:GitTopLevel()
+ if serverName == ""
+ let serverName = "VIM"
+ endif
+ let slist = serverlist()
+ if match(slist, serverName) != -1
+ call remote_expr(serverName, "execute('tabedit " . fileName . "')")
+ silent !echo -en "\e[?1049lFile opened in vim session for current repo\n"
+ quit
+ endif
+ call remote_startserver(serverName)
+ endif
+endif
+
+" NOTE this line needs to go after the check-running-server stuff above or the
+" screen will blink when open stuff in another window which is not cool!
+" very weird!
let &listchars="tab:‣\ " "set this one using let so it doesn't show up as a space error!
+
set list
" Stuff that we always want to do when a new window is created
@@ -127,8 +169,6 @@ function! g:ToggleListCharsEOL()
endif
endfunction
-cscope add /repo/hans/slask/.git/cscope.out /repo/hans/slask
-
nnoremap <F12> :set hls!<CR>
inoremap <F12> <C-o>:set hls!<CR>
nnoremap <expr> <S-F12> g:ToggleListCharsEOL()
@@ -176,8 +216,8 @@ map <F4> :call DmenuTag("tag")<CR>
map <S-F4> :call DmenuTag("tjump")<CR>
cmap <F3> =CallDmenu("git ls-files --full-name ". g:GitTopLevel())<CR>
-map <F6> :let kalle="vert stag ".expand('<cword>')<CR>:exec kalle<CR>
-map <S-F6> :let kalle="tab stag ".expand('<cword>')<CR>:exec kalle<CR>
+map <F6> :let tmp="vert stag ".expand('<cword>')<CR>:exec tmp<CR>
+map <S-F6> :let tmp="tab stag ".expand('<cword>')<CR>:exec tmp<CR>
cmap <F8> <C-r>=g:GitTop<CR>
@@ -202,7 +242,7 @@ function! SearchForVisualSelection(backward)
return
endif
- let l:sel = getline(lnum1)[ col1 - 1 : col2 - 1]
+ let l:sel = getline(lnum1)[col1 - 1 : col2 - 1]
let l:searchchar = '/'
if a:backward == 1
let l:searchchar = '?'
@@ -213,7 +253,7 @@ function! SearchForVisualSelection(backward)
" to get around the ":help function-search-undo" problem which is that
" last-search pattern and last-search direction is reset when returning
" from a function.
- " using ":normal /pat<CR>" did not work and neither did search() and/or
+ " using ":normal /pat<CR>" does not work and neither does search() and/or
" assigning to the "/ register.
call feedkeys(l:searchchar . l:sel . "\<CR>")
endfunction
@@ -223,7 +263,7 @@ function! g:IncludeExprExample(in)
let top = g:GitTopLevel()
let t2=substitute(a:in,'^b/',top,'g')
let t=substitute(t2,'^a/',top,'g')
-" let t2=substitute(t,'^/',top . '/','g')
+ " let t2=substitute(t,'^/',top . '/','g')
return t2
endfunction
@@ -248,7 +288,7 @@ function! CallDmenu(system_cmd)
return ""
endif
-" Xlib: extension "XINERAMA" missing on display ":1011.0"
+ " Xlib: extension "XINERAMA" missing on display ":1011.0"
let fname2 = substitute(fname, '\n$', '', '')
" first substitute in the case of two "lines" (<CR> or NULL character present at the end)
let fname = substitute(fname2, "Xlib: extension \"XINERAMA\" missing.*\".*.\"\..", '', '')
@@ -341,11 +381,6 @@ function! DmenuFile(cmd)
execute a:cmd . " " . g:GitTopLevel() . "/" . fname
endfunction
-function! g:SystemList(cmd)
- let out = system(a:cmd)
- return split(out, '\n')
-endfunction
-
" get .git dir
function! g:GitDir()
" systemlist() seems like a convenient way to get rid of the newline in the
@@ -357,16 +392,6 @@ function! g:GitDir()
return ''
endfunction
-" get git top-level dir
-function! g:GitTopLevel()
- " systemlist() seems like a convenient way to get rid of the newline in the
- " output from the git command
- let git_output = g:SystemList("git rev-parse --show-toplevel")
- if v:shell_error == 0
- return git_output[0]
- endif
- return ''
-endfunction
function! g:GitUniqueId()
let git_output = g:SystemList("git remote get-url origin")