リビジョン | cb615394967242bfade75197de95fd14c07f2aed (tree) |
---|---|
日時 | 2023-02-27 01:41:38 |
作者 | badcoff33 <none@none> |
コミッター | badcoff33 |
updates
@@ -44,9 +44,13 @@ export def CloseCb(ch: channel) | ||
44 | 44 | for d in g:run_dict |
45 | 45 | if d.channel == ch_nr |
46 | 46 | |
47 | - timer_stop(d.timer) | |
47 | + if has_key(d, "timer") | |
48 | + timer_stop(d.timer) | |
49 | + endif | |
48 | 50 | g:run_2_tid = timer_start(500, (_) => { |
49 | - popup_close(d.winid) | |
51 | + if has_key(d, "winid") | |
52 | + popup_close(d.winid) | |
53 | + endif | |
50 | 54 | RemoveChannelFromDict(d.channel) |
51 | 55 | }, {repeat: 1}) |
52 | 56 |
@@ -86,7 +90,9 @@ export def HiddenErrorCb(ch: channel, msg: string) | ||
86 | 90 | for d in g:run_dict |
87 | 91 | if d.channel == ch_nr |
88 | 92 | timer_stop(d.timer) |
89 | - popup_close(d.winid) | |
93 | + if has_key(d, "winid") | |
94 | + popup_close(d.winid) | |
95 | + endif | |
90 | 96 | echohl ErrorMsg |
91 | 97 | echo "error reported by channel" ch_info(ch)["id"] "-->" msg |
92 | 98 | echohl None |
@@ -110,21 +116,23 @@ def ConditionalWriteAll(dict: dict<any>) | ||
110 | 116 | enddef |
111 | 117 | |
112 | 118 | def RunTimerCb(tid: number) |
113 | - var max_width = 30 | |
119 | + var max_width = 20 | |
114 | 120 | var popup_text: string |
115 | 121 | |
116 | 122 | for d in g:run_dict |
117 | - if d.timer == tid | |
123 | + if has_key(d, "timer") && d.timer == tid | |
118 | 124 | if len(d.cmd) > max_width |
119 | - popup_text = "Running " .. d.cmd[0 : max_width] | |
120 | - .. "..." | |
125 | + popup_text = job_status(d.job) .. " " | |
121 | 126 | .. (localtime() - d.started) |
122 | - .. "sec" | |
127 | + .. "sec (" | |
128 | + .. d.cmd[0 : max_width] | |
129 | + .. "...)" | |
123 | 130 | else |
124 | - popup_text = "Running " .. d.cmd | |
125 | - .. " " | |
131 | + popup_text = job_status(d.job) .. " " | |
126 | 132 | .. (localtime() - d.started) |
127 | - .. "sec" | |
133 | + .. "sec (" | |
134 | + .. d.cmd | |
135 | + .. ")" | |
128 | 136 | endif |
129 | 137 | popup_settext(d.winid, popup_text) |
130 | 138 | break |
@@ -133,11 +141,12 @@ def RunTimerCb(tid: number) | ||
133 | 141 | enddef |
134 | 142 | |
135 | 143 | export def Run(dict: dict<any>): job |
136 | - var job: job | |
144 | + var v_job: job | |
137 | 145 | var v_bufnr: number |
138 | 146 | var v_winid: number |
139 | 147 | var v_bufname: string |
140 | 148 | var v_regexp: string |
149 | + var save_winid = win_getid(winnr()) | |
141 | 150 | |
142 | 151 | var job_opts = {} |
143 | 152 |
@@ -156,7 +165,7 @@ export def Run(dict: dict<any>): job | ||
156 | 165 | if has_key(dict, "hidden") && (dict.hidden == true) |
157 | 166 | job_opts.cwd = has_key(dict, "cwd") ? dict.cwd : getcwd() |
158 | 167 | job_opts.err_cb = function("run#HiddenErrorCb") |
159 | - job = job_start('cmd /C ' .. escape(dict.cmd, '\'), job_opts) | |
168 | + v_job = job_start('cmd /C ' .. escape(dict.cmd, '\'), job_opts) | |
160 | 169 | else |
161 | 170 | if v_bufname == "" |
162 | 171 | v_bufnr = bufadd(dict.cmd) |
@@ -171,7 +180,7 @@ export def Run(dict: dict<any>): job | ||
171 | 180 | v_bufnr = bufadd(v_bufname) |
172 | 181 | setbufvar(v_bufnr, "&buftype", "nofile") |
173 | 182 | endif |
174 | - execute "buffer" v_bufnr | |
183 | + | |
175 | 184 | nnoremap <buffer> <Esc> <Cmd>bw!<CR> |
176 | 185 | appendbufline(v_bufnr, "$", "-----" .. strftime("%X") .. "------" .. dict.cmd .. "-----") |
177 | 186 | normal G |
@@ -184,30 +193,52 @@ export def Run(dict: dict<any>): job | ||
184 | 193 | job_opts.out_io = "buffer" |
185 | 194 | job_opts.close_cb = function("run#CloseCb") |
186 | 195 | |
187 | - job = job_start('cmd /C ' .. escape(dict.cmd, ''), job_opts) | |
188 | - var v_channel = split(string(job_getchannel(job)), " ")[1] | |
196 | + v_job = job_start('cmd /C ' .. escape(dict.cmd, ''), job_opts) | |
197 | + var v_channel = split(string(job_getchannel(v_job)), " ")[1] | |
189 | 198 | var popup_text: string |
190 | 199 | |
191 | - if len(dict.cmd) > 40 | |
192 | - popup_text = dict.cmd[0 : 40] .. "..." | |
200 | + | |
201 | + if !has_key(dict, "no_popup") || (dict.no_popup == false) | |
202 | + # split | |
203 | + # execute "buffer" v_bufnr | |
204 | + # wincmd J | |
205 | + | |
206 | + if len(dict.cmd) > 40 | |
207 | + popup_text = "Started (" .. dict.cmd[0 : 40] .. "...)" | |
208 | + else | |
209 | + popup_text = "Started (" .. dict.cmd .. ")" | |
210 | + endif | |
211 | + v_winid = popup_create(popup_text, g:Winopts()) | |
212 | + execute "buffer" v_bufnr | |
213 | + add(g:run_dict, { | |
214 | + winid: v_winid, | |
215 | + timer: timer_start(1000, RunTimerCb, {repeat: -1}), | |
216 | + job: v_job, | |
217 | + channel: v_channel, | |
218 | + cmd: dict.cmd, | |
219 | + regexp: v_regexp, | |
220 | + bufname: v_bufname, | |
221 | + bufnr: v_bufnr, | |
222 | + started: localtime() | |
223 | + }) | |
193 | 224 | else |
194 | - popup_text = dict.cmd | |
225 | + add(g:run_dict, { | |
226 | + job: v_job, | |
227 | + channel: v_channel, | |
228 | + cmd: dict.cmd, | |
229 | + regexp: v_regexp, | |
230 | + bufname: v_bufname, | |
231 | + bufnr: v_bufnr, | |
232 | + started: localtime() | |
233 | + }) | |
195 | 234 | endif |
196 | - v_winid = popup_create("Started " .. popup_text, g:Winopts()) | |
197 | - | |
198 | - add(g:run_dict, { | |
199 | - channel: v_channel, | |
200 | - winid: v_winid, | |
201 | - cmd: dict.cmd, | |
202 | - regexp: v_regexp, | |
203 | - bufname: v_bufname, | |
204 | - bufnr: v_bufnr, | |
205 | - timer: timer_start(1000, RunTimerCb, {repeat: -1}), | |
206 | - started: localtime() | |
207 | - }) | |
235 | + | |
236 | + | |
208 | 237 | endif |
209 | 238 | |
210 | - return job | |
239 | + win_gotoid(save_winid) | |
240 | + | |
241 | + return v_job | |
211 | 242 | enddef |
212 | 243 | |
213 | 244 | augroup GroupRun |
@@ -13,6 +13,9 @@ export def TorchlightClearAll() | ||
13 | 13 | endfor |
14 | 14 | enddef |
15 | 15 | |
16 | +# Clear properties on current line | |
17 | +# This might work for you | |
18 | +# `autocmd TextChanged * torchlight.TorchlightChanged()` | |
16 | 19 | export def TorchlightChanged() |
17 | 20 | prop_clear(line(".")) |
18 | 21 | enddef |
@@ -33,7 +33,9 @@ enddef | ||
33 | 33 | |
34 | 34 | command! -complete=custom,CompleteHg -nargs=+ Hg run.Run({cmd: 'hg <args>', name: "HG-OUTPUT"}) |
35 | 35 | |
36 | -nnoremap <Leader>v :<C-u>Hg<Space> | |
36 | +nnoremap <Leader>vv :<C-u>Hg<Space> | |
37 | +nnoremap <Leader>vs <Cmd>Hg status<CR> | |
38 | +nnoremap <Leader>vl <Cmd>Hg sl<CR> | |
37 | 39 | |
38 | 40 | # Uncomment when testing |
39 | 41 | defcompile |
@@ -44,8 +44,8 @@ set grepprg=rg\ --vimgrep\ $* | ||
44 | 44 | set grepformat=%f:%l:%c:%m |
45 | 45 | |
46 | 46 | command! -complete=file -nargs=* RgFiles run.Run({cmd: "rg --files" .. g:RgGlobSwitch() .. join(split(<q-args>, " "), g:RgGlobSwitch() ), name: "RG-OUTPUT"}) |
47 | -command! -complete=file -nargs=* Rg run.Run({cmd: 'rg --vimgrep ' .. ' <args> ' .. join(g:rg_paths, " "), regexp: &grepformat}) | |
48 | -command! -complete=file -nargs=* RgNoDir run.Run({cmd: 'rg --vimgrep ' .. ' <args> ', regexp: &grepformat}) | |
47 | +command! -complete=file -nargs=* Rg run.Run({cmd: 'rg --vimgrep ' .. ' <args> ' .. join(g:rg_paths, " "), regexp: &grepformat, no_popup: true}) | |
48 | +command! -complete=file -nargs=* RgNoDir run.Run({cmd: 'rg --vimgrep ' .. ' <args> ', regexp: &grepformat, no_popup: true}) | |
49 | 49 | |
50 | 50 | nnoremap <Leader>F :RgFiles<C-r>=g:RgExcludes()<CR><C-r>=g:RgGlobSwitch()<CR> **<Left> |
51 | 51 | nnoremap <Leader>R :Rg <C-r>=g:RgExcludes()<CR> <C-r>=RgIncludes(&ft)<CR> <C-r>=RgPattern()<CR> |
@@ -3,7 +3,7 @@ import autoload "torchlight.vim" | ||
3 | 3 | |
4 | 4 | augroup GroupTorchlight |
5 | 5 | autocmd! |
6 | - autocmd TextChanged * torchlight.TorchlightChanged() | |
6 | + # autocmd TextChanged * torchlight.TorchlightChanged() | |
7 | 7 | autocmd QuickFixCmdPre make torchlight.TorchlightClearAll() |
8 | 8 | autocmd QuickFixCmdPost make torchlight.TorchlightUpdate() |
9 | 9 | augroup END |
@@ -19,6 +19,10 @@ set tagcase=match | ||
19 | 19 | compiler gcc |
20 | 20 | set makeprg=make |
21 | 21 | |
22 | -" Markdown, please | |
23 | -autocmd BufRead *.txt setfiletype markdown | |
24 | - | |
22 | +augroup GroupLocal | |
23 | + au! | |
24 | + " Markdown, please | |
25 | + au BufRead *.txt setfiletype markdown | |
26 | + " Remember last state of work | |
27 | + autocmd VimLeave * mksession! .session | |
28 | +augroup END |
@@ -139,8 +139,6 @@ inoremap <C-x><C-CR> <C-x><C-]> | ||
139 | 139 | |
140 | 140 | " Switching modes |
141 | 141 | inoremap <k0> <Esc> |
142 | -imap <Char-252> <Esc> | |
143 | -nmap <Char-252> : | |
144 | 142 | |
145 | 143 | " Consistent cursor movement |
146 | 144 | noremap! <A-Left> <Home> |
@@ -205,10 +203,9 @@ iabbrev {} { }<Left><Left> | ||
205 | 203 | |
206 | 204 | " }}} |
207 | 205 | |
208 | - | |
209 | 206 | let FilePath = { -> expand("%:h") == "" ? "" : expand("%:h") .. g:slash } |
210 | -cnoremap <expr> <A-.> (FilePath() == ".") ? "." : FilePath() | |
211 | -cnoremap <expr> <A-,> $HOME .. g:slash .. 'vimfiles' .. g:slash | |
207 | +cnoremap <expr> <C-r>. (FilePath() == ".") ? "." : FilePath() | |
208 | +cnoremap <expr> <C-r>, $HOME .. g:slash .. 'vimfiles' .. g:slash | |
212 | 209 | cmap <C-BS> <C-w> |
213 | 210 | cmap <C-Del> <C-Right><C-w> |
214 | 211 |
@@ -268,7 +265,6 @@ nnoremap <Leader>e :edit <C-r>=(FilePath() == ".") ? "." : FilePath()<CR> | ||
268 | 265 | nnoremap <Leader>f :find<Space> |
269 | 266 | nnoremap <Leader>b :buffer<Space> |
270 | 267 | nnoremap <Leader>d <cmd>bdelete<CR> |
271 | -nnoremap <Leader>. :tjump / | |
272 | 268 | |
273 | 269 | " Leader-t space |
274 | 270 | nnoremap <Leader>tt <Cmd>tab split<CR> |