Open ghost opened 4 years ago
The plug-in will run the lines it changed through Vim's fomatting functionality. You can prevent this for a template by adding the option noindent
where the maps and menu shortcuts are defined:
== Idioms.function == map:if, shortcut:f, noindent ==
void<CURSOR>
|FUNCTION_NAME| ( <+argument_list+> )
{
<SPLIT>return <+return_value+>;
} /* ----- end of function |FUNCTION_NAME| ----- */
== Idioms.next template ...
Another approach would be to look at the set-up of your formatting. (Run :help C-indenting
as a starting point.) Is normal code, not inserted by the plug-in, indented correctly when you run it through the auto-formatter? (Mark some lines in visual mode and use the map =
.)
I tried setting noindent
for the template, but it didn't work. I also opened a new c file, ran :set noautoindent nocindent nosmartindent indentexpr=
, and it didn't work, but it did ignore the indent in front of <CURSOR>
in the template (which had worked previously). I'm not sure what else to try.
Try with :set paste before to insert the template.
I believe it's related with some other settings or plugins.
The problem seems slightly more diffucult than I initially thought. I could debug it further if you send me the output of :set
(executed on the Vim command-line).
Non C file:
--- Options --- columns=136 helplang=en lines=35 relativenumber showbreak=¶ notimeout expandtab ignorecase number scroll=16 smartcase window=34 runtimepath=~/.config/nvim,
~/.config/nvim/plugged/FastFold,
~/.config/nvim/plugged/delimitMate,
~/.config/nvim/plugged/vim-gitgutter,
~/. config/nvim/plugged/vim-fat-finger,
~/.config/nvim/plugged/vim-fish,
~/.config/nvim/plugged/tabular,
~/.config/nvim/plugged/lightline.vim,
~ /.fzf,
~/.config/nvim/plugged/vimtex,
~/.config/nvim/plugged/neomake,
~/.config/nvim/plugged/vim-markdown,
~/.config/nvim/plugged/SimpylFold ,
~/.config/nvim/plugged/vim-commentary,
~/.config/nvim/plugged/vim-eunuch,
~/.config/nvim/plugged/c.vim,
~/.config/nvim/plugged/ale,
/etc/xd g/xdg-xfce/nvim,
/etc/xdg/nvim,
/etc/xdg/nvim,
~/.local/share/nvim/site,
/usr/share/xfce4/nvim/site,
/usr/share/xfce/nvim/site,
/usr/local/sha re/nvim/site,
/usr/share/nvim/site,
/usr/share/nvim/site,
/usr/share/nvim/runtime,
/usr/share/nvim/runtime/pack/dist/opt/matchit,
/usr/share/ nvim/site/after,
/usr/share/nvim/site/after,
/usr/local/share/nvim/site/after,
/usr/share/xfce/nvim/site/after,
/usr/share/xfce4/nvim/site/a fter,
~/.local/share/nvim/site/after,
/etc/xdg/nvim/after,
/etc/xdg/nvim/after,
/etc/xdg/xdg-xfce/nvim/after,
~/.config/nvim/plugged/tabular/ after,
~/.config/nvim/plugged/vimtex/after,
~/.config/nvim/plugged/vim-markdown/after,
~/.config/nvim/after statusline=%{lightline#link()}%#LightlineLeft_active_0#%( %{lightline#mode()} %)%{(&paste)?"|":""}%( %{&paste?"PASTE":""} %)%#Lightlin eLeft_active_0_1#%#LightlineLeft_active_1#%( %R %)%{(&readonly)&&(1||(&modified||!&modifiable))?"|":""}%( %t %)%{(&modified||!&modifiabl e)?"|":""}%( %M %)%#LightlineLeft_active_1_2#%#LightlineMiddle_active#%=%#LightlineRight_active_2_3#%#LightlineRight_active_2#%( %{&ff} %)%{1||1?"|":""}%( %{&fenc!=#""?&fenc:&enc} %)%{1?"|":""}%( %{&ft!=#""?&ft:"no ft"} %)%#LightlineRight_active_1_2#%#LightlineRight_activ e_1#%( %3p%% %)%#LightlineRight_active_0_1#%#LightlineRight_active_0#%( %3l:%-2v %) tabline=%!lightline#tabline()
C file has the above plus:
--- Options --- cindent filetype=c lines=35 relativenumber smartcase window=34 columns=136 helplang=en modified scroll=16 syntax=c expandtab ignorecase number showbreak=¶ notimeout comments=sO:* -,
mO:* ,
exO:*/,
s1:/*,
mb:*,
ex:*/,
:// dictionary=~/.config/nvim/plugged/c.vim/c-support/wordlists/c-c++-keywords.list,
~/.config/nvim/plugged/c.vim/c-support/wordlists/k+r.l ist,
~/.config/nvim/plugged/c.vim/c-support/wordlists/stl_index.list formatoptions=jcroql omnifunc=ccomplete#Complete runtimepath=~/.config/nvim,
I just came back to this, sorry for the long wait.
One general point: After editing a template file, it is necessary to either restart Vim or to reload the templates using the map \ntr
in a C/C++ buffer.
I'm trying to edit the c.idioms.template file that I have sourced. I can make changes and see them applied, except for the
return
statement. It always gets pushed further in than the previous indent. I would like to make it align. I can't find it in the source code.
Just so I understand you correctly. When you say "... except for the return
statement. It always gets pushed further in than the previous indent. I would like to make it align." Do you mean it should align with the curly brackets? Like so:
void
f ( )
{
return ;
} /* ----- end of function f ----- */
Instead of:
void
f ( )
{
return ;
} /* ----- end of function f ----- */
Then I would still like to confirm that the noindent
template option does not work even if the template are reloaded.
I'm trying to edit the c.idioms.template file that I have sourced. I can make changes and see them applied, except for the
return
statement. It always gets pushed further in than the previous indent. I would like to make it align. I can't find it in the source code.