Message ID | f6ecfce1-9d60-2d26-9361-f9876e5446d6@suse.cz |
---|---|
State | New |
Headers | show |
Series | Add .pd extension to c_exts. | expand |
On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote: > > Hi. > > I would like to add .pd to c_exts so that one > can have correctly set tab width, etc. But then it will auto-indent with too much spaces, no? Richard. > Ready for trunk? > Thanks, > Martin > > contrib/ChangeLog: > > 2019-08-30 Martin Liska <mliska@suse.cz> > > * vimrc: Add .pd extension. > --- > contrib/vimrc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >
On 8/30/19 2:09 PM, Richard Biener wrote:
> But then it will auto-indent with too much spaces, no?
It's doesn't understand the lisp-like notation
(foo
(bar
(baz
so no auto-indentation is happening.
Martin
On Fri, 30 Aug 2019, Richard Biener wrote: > On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote: > > > > Hi. > > > > I would like to add .pd to c_exts so that one > > can have correctly set tab width, etc. > > But then it will auto-indent with too much spaces, no? I think it's fine, the script does setlocal cindent setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 so it's a bit smarter than indenting everything by 2 spaces :) So +1 from me for the patch, but note that now we have a contrib/vim-gcc-dev "plugin" directory, it might be more natural to add gcc-match indent rules there. Alexander
On Fri, Aug 30, 2019 at 2:31 PM Alexander Monakov <amonakov@ispras.ru> wrote: > > > > On Fri, 30 Aug 2019, Richard Biener wrote: > > > On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote: > > > > > > Hi. > > > > > > I would like to add .pd to c_exts so that one > > > can have correctly set tab width, etc. > > > > But then it will auto-indent with too much spaces, no? > > I think it's fine, the script does > > setlocal cindent > setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 > > so it's a bit smarter than indenting everything by 2 spaces :) > > So +1 from me for the patch, but note that now we have a contrib/vim-gcc-dev > "plugin" directory, it might be more natural to add gcc-match indent rules > there. Yeah, that would be better than claiming .pd is C ... Richard. > > Alexander
On 8/30/19 2:54 PM, Richard Biener wrote: > On Fri, Aug 30, 2019 at 2:31 PM Alexander Monakov <amonakov@ispras.ru> wrote: >> >> >> >> On Fri, 30 Aug 2019, Richard Biener wrote: >> >>> On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote: >>>> >>>> Hi. >>>> >>>> I would like to add .pd to c_exts so that one >>>> can have correctly set tab width, etc. >>> >>> But then it will auto-indent with too much spaces, no? >> >> I think it's fine, the script does >> >> setlocal cindent >> setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 >> >> so it's a bit smarter than indenting everything by 2 spaces :) >> >> So +1 from me for the patch, but note that now we have a contrib/vim-gcc-dev >> "plugin" directory, it might be more natural to add gcc-match indent rules >> there. > > Yeah, that would be better than claiming .pd is C ... > > Richard. > >> >> Alexander Yep, I'm going to apply following patch that does it properly for the gcc-match file type. Martin
On Mon, 2 Sep 2019, Martin Liška wrote: > Yep, I'm going to apply following patch that does it properly for the gcc-match > file type. So just to make sure I understand correctly why you need this: you use some other value of 'tabstop' in Vim, and need to reset it back to its default value of 8, as assumed by coding standards in GCC? If that's the case, we should look into overriding 'tabstop' for all files in the gcc tree, including .md files, not just .pd and C/C++ files, right? Thanks. Alexander
On 9/2/19 11:56 AM, Alexander Monakov wrote: > On Mon, 2 Sep 2019, Martin Liška wrote: > >> Yep, I'm going to apply following patch that does it properly for the gcc-match >> file type. > > So just to make sure I understand correctly why you need this: > > you use some other value of 'tabstop' in Vim, and need to reset it back to its > default value of 8, as assumed by coding standards in GCC? Yes, that was my motivation. > > If that's the case, we should look into overriding 'tabstop' for all files in > the gcc tree, including .md files, not just .pd and C/C++ files, right? Can be done but we don't have any 'au BufRead *.md' rule right now. Martin > > Thanks. > Alexander >
On Mon, 2 Sep 2019, Martin Liška wrote: > > If that's the case, we should look into overriding 'tabstop' for all files in > > the gcc tree, including .md files, not just .pd and C/C++ files, right? > > Can be done but we don't have any 'au BufRead *.md' rule right now. The solution I had in mind was to set expected formatting for all files in our local vimrc like this: --- a/contrib/vimrc +++ b/contrib/vimrc @@ -31,17 +31,17 @@ function! SetStyle() if stridx(l:fname, 'libsanitizer') != -1 return endif + setlocal tabstop=8 + setlocal softtabstop=2 + setlocal shiftwidth=2 + setlocal noexpandtab + setlocal textwidth=80 + setlocal formatoptions-=ro formatoptions+=cqlt let l:ext = fnamemodify(l:fname, ":e") let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java'] if index(l:c_exts, l:ext) != -1 setlocal cindent - setlocal tabstop=8 - setlocal softtabstop=2 - setlocal shiftwidth=2 - setlocal noexpandtab setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 - setlocal textwidth=80 - setlocal formatoptions-=ro formatoptions+=cqlt endif endfunction Alexander
On 9/2/19 1:08 PM, Alexander Monakov wrote: > On Mon, 2 Sep 2019, Martin Liška wrote: > >>> If that's the case, we should look into overriding 'tabstop' for all files in >>> the gcc tree, including .md files, not just .pd and C/C++ files, right? >> >> Can be done but we don't have any 'au BufRead *.md' rule right now. > > The solution I had in mind was to set expected formatting for all files in our > local vimrc like this: > > --- a/contrib/vimrc > +++ b/contrib/vimrc > @@ -31,17 +31,17 @@ function! SetStyle() > if stridx(l:fname, 'libsanitizer') != -1 > return > endif > + setlocal tabstop=8 > + setlocal softtabstop=2 > + setlocal shiftwidth=2 > + setlocal noexpandtab > + setlocal textwidth=80 > + setlocal formatoptions-=ro formatoptions+=cqlt > let l:ext = fnamemodify(l:fname, ":e") > let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java'] > if index(l:c_exts, l:ext) != -1 > setlocal cindent > - setlocal tabstop=8 > - setlocal softtabstop=2 > - setlocal shiftwidth=2 > - setlocal noexpandtab > setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 > - setlocal textwidth=80 > - setlocal formatoptions-=ro formatoptions+=cqlt > endif > endfunction > > > Alexander > Works for me, please include the reversion of r275295. Thanks, Martin
diff --git a/contrib/vimrc b/contrib/vimrc index 7c0c5878c63..a9ec46bf52f 100644 --- a/contrib/vimrc +++ b/contrib/vimrc @@ -32,7 +32,7 @@ function! SetStyle() return endif let l:ext = fnamemodify(l:fname, ":e") - let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java'] + let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java', 'pd'] if index(l:c_exts, l:ext) != -1 setlocal cindent setlocal tabstop=8