From a85ccd731838f986da74b10867cb7e68aa76dd73 Mon Sep 17 00:00:00 2001 From: surtur Date: Thu, 6 Oct 2022 15:39:34 +0200 Subject: [PATCH] vimrc: add augroup for filetype autocmds --- .vim/vimrc | 95 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/.vim/vimrc b/.vim/vimrc index eca1c0f..81f1c56 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -610,67 +610,70 @@ augroup save_load_views au BufWinEnter *.* loadview augroup END -au FileType xml setlocal shiftwidth=4 tabstop=4 -au FileType html setlocal shiftwidth=4 tabstop=4 +augroup filetypes + autocmd! + au FileType xml setlocal shiftwidth=4 tabstop=4 + au FileType html setlocal shiftwidth=4 tabstop=4 -au BufNewFile,BufRead *.js - \ setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab autoindent - \ fileformat=unix filetype=js + au BufNewFile,BufRead *.js + \ setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab autoindent + \ fileformat=unix filetype=js -au BufNewFile,BufRead,BufEnter *.md - \ setlocal textwidth=79 foldmethod=manual filetype=markdown - \ fileformat=unix expandtab + au BufNewFile,BufRead,BufEnter *.md + \ setlocal textwidth=79 foldmethod=manual filetype=markdown + \ fileformat=unix expandtab -au FileType sway setl textwidth=99 - \ tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent + au FileType sway setl textwidth=99 + \ tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent -au FileType rust setl - \ tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent ff=unix + au FileType rust setl + \ tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent ff=unix -au BufNewFile,BufRead *.py,*.pyw,*.pyx,?akefil* - \ setlocal tabstop=4 shiftwidth=4 noexpandtab autoindent - \ fileformat=unix + au BufNewFile,BufRead *.py,*.pyw,*.pyx,?akefil* + \ setlocal tabstop=4 shiftwidth=4 noexpandtab autoindent + \ fileformat=unix -" Linux kernel style tabs - not for cpp -" au BufNewFile,BufRead,BufEnter *.c,*.h,*.cpp -au BufNewFile,BufRead,BufEnter *.c,*.h - \ set tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent - \ textwidth=79 fileformat=unix omnifunc=lsp#complete + " Linux kernel style tabs - not for cpp + " au BufNewFile,BufRead,BufEnter *.c,*.h,*.cpp + au BufNewFile,BufRead,BufEnter *.c,*.h + \ set tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent + \ textwidth=79 fileformat=unix omnifunc=lsp#complete -au BufNewFile,BufRead,BufEnter *.cpp,*.h,*.hpp - \ set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent - \ textwidth=79 fileformat=unix omnifunc=lsp#complete ft=cpp - " \ textwidth=79 fileformat=unix -au FileType cpp - \ set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent - \ textwidth=79 fileformat=unix omnifunc=lsp#complete - " \ textwidth=79 fileformat=unix + au BufNewFile,BufRead,BufEnter *.cpp,*.h,*.hpp + \ set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent + \ textwidth=79 fileformat=unix omnifunc=lsp#complete ft=cpp + " \ textwidth=79 fileformat=unix + au FileType cpp + \ set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent + \ textwidth=79 fileformat=unix omnifunc=lsp#complete + " \ textwidth=79 fileformat=unix -au FileType tex setlocal tabstop=2 + au FileType tex setlocal tabstop=2 -au BufNewFile,BufRead,BufEnter *.tex - \ setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab autoindent - \ textwidth=79 fileformat=unix conceallevel=0 + au BufNewFile,BufRead,BufEnter *.tex + \ setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab autoindent + \ textwidth=79 fileformat=unix conceallevel=0 -au BufNewFile,BufRead,BufEnter *.bib - \ setlocal ft=bib tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab autoindent - \ fileformat=unix conceallevel=0 + au BufNewFile,BufRead,BufEnter *.bib + \ setlocal ft=bib tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab autoindent + \ fileformat=unix conceallevel=0 -autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0# - \ indentkeys-=<:> foldmethod=indent nofoldenable + autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0# + \ indentkeys-=<:> foldmethod=indent nofoldenable -au BufNewFile,BufRead,BufEnter *.cs - \ setlocal ft=cs tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent - \ textwidth=79 fileformat=unix conceallevel=0 + au BufNewFile,BufRead,BufEnter *.cs + \ setlocal ft=cs tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent + \ textwidth=79 fileformat=unix conceallevel=0 -au BufNewFile,BufRead *.cshtml - \ setlocal ft=csh tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent - \ textwidth=79 fileformat=unix conceallevel=0 + au BufNewFile,BufRead *.cshtml + \ setlocal ft=csh tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent + \ textwidth=79 fileformat=unix conceallevel=0 -" no autocomments, for example when entering insert mode above or below a -" commented line -autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + " no autocomments, for example when entering insert mode above or below a + " commented line + autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o +augroup END augroup line_too_long