https://wiki.dlang.org/api.php?action=feedcontributions&user=Viniarck&feedformat=atomD Wiki - User contributions [en]2024-03-28T16:31:39ZUser contributionsMediaWiki 1.31.2https://wiki.dlang.org/?title=D_in_Vim&diff=9456D in Vim2019-01-06T11:36:52Z<p>Viniarck: Added ncm2-d</p>
<hr />
<div>Vim features and plugins useful for D coding.<br />
<br />
=Installing Vundle=<br />
<br />
Many Vim plugins require a plugin manager for installation.<br />
[https://github.com/gmarik/Vundle.vim Vundle] is one such plugin manager.<br />
<br />
To install Vundle see the [https://github.com/gmarik/Vundle.vim#quick-start Quick Start] section on Vundle's site.<br />
<br />
=UltiSnips=<br />
<br />
[https://github.com/SirVer/ultisnips UltiSnips] is a Vim snippet plugin with<br />
D support. It makes it possible to complete tasks such as writing a loop,<br />
wrapping code in try/catch or adding an operator in a few keystrokes.<br />
<br />
Installing UltiSnips:<br />
<br />
* Make sure you have a plugin manager such as [[#Installing Vundle|Vundle]] installed.<br />
* See the [https://github.com/SirVer/ultisnips#quick-start Quick Start] section at UltiSnips site.<br />
<br />
=DSnips=<br />
<br />
[[File:DSnips_screenshot1.gif]]<br />
[[File:DSnips_screenshot2.gif]]<br />
<br />
[https://github.com/kiith-sa/DSnips#try DSnips] is a (greatly) improved version of UltiSnips D snippets. It covers almost all D features and its snippets are designed to work together (e.g. can be used within one another or in chains). See DSnips [https://github.com/kiith-sa/DSnips#reference reference]<br />
<br />
Installing DSnips:<br />
<br />
* You need to have [[#UltiSnips|UltiSnips]] installed first.<br />
* <pre>git clone https://github.com/kiith-sa/DSnips.git</pre><br />
* Copy the d.snippets file to UltiSnips user snippets directory. On Linux this should be ~/.vim/UltiSnips. <br/><br/> If you don't know where the user snippets directory is, open a D file and type the :UltiSnipsEdit command (after UltiSnips is installed); this will open a user d.snippets file which you can replace by the DSnips version of d.snippets.<br />
<br />
=Dutyl=<br />
The [https://github.com/idanarye/vim-dutyl Dutyl] plugin integrates D tools such as [https://github.com/Hackerpilot/DCD/ DCD], DUB and DScanner to provide autocompletion, syntax checking, documentation search and more features.<br />
<br />
=Vebugger=<br />
The [https://github.com/idanarye/vim-vebugger Vebugger] plugin acts as a frontend for command line debuggers, and can be used to debug D programs with GDB. You'll need to use :VBGstartGDBForD to debug D programs.<br />
<br />
=Tagbar=<br />
<br />
It also possible to display a tagbar of all all declared functions, classes etc.<br />
Please follow the instructions of [https://github.com/majutsushi/tagbar tagbar]'s [https://github.com/majutsushi/tagbar/wiki#d Wiki].<br />
<br />
=Highlighting Phobos=<br />
The [https://github.com/Sirsireesh/vim-dlang-phobos-highlighter vim-dlang-phobos-highlighter] plugin allows highlighting of Phobos (functions, templates and types) and user defined functions, along with version identifiers.<br />
<br />
=Neovim=<br />
<br />
With the rise of Neovim, [https://github.com/ncm2/ncm2-d ncm2-d] or [https://github.com/landaire/deoplete-d deoplete-d] can be used for auto-completion.<br />
<br />
= Errorformat =<br />
<br />
WIth this autocmd D will parse error messages from the compiler and the unit test assertions;<br />
<br />
<pre>autocmd FileType d set efm=%*[^@]@%f\(%l\):\ %m,%f\(%l\\,%c\):\ %m,%f\(%l\):\ %m</pre><br />
<br />
= Unit Testing =<br />
<br />
The following function runs unittests on the current file and displays coverage<br />
information as a split window bound to left of the source window;<br />
<br />
<pre><br />
function! DTest()<br />
let l:fn = substitute(expand('%:r'), '/', '-', 'g') . '.lst'<br />
call delete(l:fn)<br />
cexpr system('dmd -cov -unittest -main -run ' . expand('%'))<br />
if filereadable(l:fn)<br />
normal gg<br />
execute '13vsplit' l:fn<br />
normal gg<br />
set scrollbind<br />
normal ^Wl<br />
set scrollbind<br />
endif<br />
endfunction<br />
</pre><br />
(note the ^W is a an actual CTRL-W, inserted with CTRL-V, CTRL-W)<br />
<br />
<pre>autocmd FileType d nnoremap <f8> :call DTest()<cr></pre><br />
<br />
<br />
[[Category:Text editors]]</div>Viniarck