Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically manipulate the quickfix window? #22

Closed
liuchengxu opened this issue Nov 24, 2016 · 6 comments
Closed

Automatically manipulate the quickfix window? #22

liuchengxu opened this issue Nov 24, 2016 · 6 comments

Comments

@liuchengxu
Copy link

liuchengxu commented Nov 24, 2016

First of all, this is a nice plugin. But how about opening the quickfix window automatically when AsyncRun? I mean, instead of explicitly opening the quickfix by ourselves, the plugin could do this when necessary.

@skywind3000
Copy link
Owner

skywind3000 commented Nov 24, 2016

嗯,并不是所有人都喜欢这个特性,我见过不少人用 AsyncRun 是默认不显示quickfix开始的时候,把statueline 变成紫色,成功了变成绿色,失败了变成红色,要看自己打开quickfix看结果;还有人喜欢IDE布局,一直开着quickfix;我自己喜欢自己主动 F10切换。

所以 asyncrun如果自动弹出 quickfix会遭致这些人的反感,加个全局配置似乎又太冗余,因为你可以通过vimrc里面加三行配置就完成这个事情:

automate opening quickfix

@liuchengxu
Copy link
Author

非常感谢!还有一个问题:AsyncRun 不能连续 exec 吗?

        nnoremap <F5> :call CompileAndRun()<CR>
        augroup MyGroup
            autocmd User AsyncRunStart call asyncrun#quickfix_toggle(8, 1)
        augroup END
        function! CompileAndRun()
            exec "w"
            if &filetype == 'cpp'
                exec "AsyncRun! g++ -std=c++11 % -o %<"
                exec "AsyncRun! time ./%<"
            endif
        endfunction

上面的配置 似乎只执行了 exec "AsyncRun! g++ -std=c++11 % -o %<", 后一句在 quickfix 中并没有显示。

@skywind3000
Copy link
Owner

对,因为前一个 AsyncRun没结束,后一个没法开始。你可以用分号链接多条命令(linux)或者 & 链接多条命令(windows)

exec "AsyncRun! g++ -stdc++11 % -o %<; time ./%<"

@skywind3000
Copy link
Owner

skywind3000 commented Nov 24, 2016

你的工作如果很复杂,还可以在自己的 .vim 目录下面建立script文件夹,里面一堆你自己的脚本,
按F1-F4快速运行特定的脚本,脚本里面可以用宏来工作:

$VIM_FILEPATH  - File name of current buffer with full path
$VIM_FILENAME  - File name of current buffer without path
$VIM_FILEDIR   - Full path of current buffer without the file name
$VIM_FILEEXT   - File extension of current buffer
$VIM_FILENOEXT - File name of current buffer without path and extension
$VIM_CWD       - Current directory
$VIM_RELDIR    - File path relativize to current directory
$VIM_RELNAME   - File name relativize to current directory 
$VIM_CWORD     - Current word under cursor
$VIM_CFILE     - Current filename under cursor
$VIM_GUI       - Is running under gui ?
$VIM_VERSION   - Value of v:version
$VIM_COLUMNS   - How many columns in vim's screen
$VIM_LINES     - How many lines in vim's screen
$VIM_SVRNAME   - Value of v:servername for +clientserver usage 

这样你把脚本也放到你的 dotfiles里面同步到git上,能做很多复杂的事情了,比如:

F1 - ~/.vim/script/asyncrun.1.sh
F2 - ~/.vim/script/asyncrun.2.sh
F3 - ~/.vim/script/asyncrun.3.sh
F4 - ~/.vim/script/asyncrun.4.sh

或者把 F1换成 <leader>1,或者 <leader>a1 ,多整齐

@liuchengxu
Copy link
Author

非常感谢!

@gatspy
Copy link

gatspy commented Aug 20, 2017

确实够强大。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants