Permalink
Browse files

Version 0.1: Initial upload

  • Loading branch information...
0 parents commit 0ea6e6139540a44fcf42e7d8290291cefdf9df72 Vivien Didelot committed with Dec 24, 2012
Showing with 58 additions and 0 deletions.
  1. +10 −0 README
  2. +48 −0 indent/linuxsty.vim
10 README
@@ -0,0 +1,10 @@
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=4369
+
+This plugin is meant to help you respecting the Linux kernel coding style, described at:
+http://www.kernel.org/doc/Documentation/CodingStyle
+
+It will automatically apply known rules to kernel related files, such as .c, .h, Kconfig and patch files.
+The main rules are about indentation and syntax error highlighting (like exceeding 80 chars).
+
+If you have any comments, fixes or requests, feel free to contact me or send me a patch.
+The development also takes place at https://github.com/v0n/vim-addon-linux-coding-style.
@@ -0,0 +1,48 @@
+" Vim plugin to fit the Linux kernel coding style and help kernel development
+" Last Change: 2012 Dec 24
+" Maintainer: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
+" License: Distributed under the same terms as Vim itself.
+"
+" This script is inspired from an article written by Bart:
+" http://www.jukie.net/bart/blog/vim-and-linux-coding-style
+" and various user comments.
+
+if exists("g:loaded_linuxsty")
+ finish
+endif
+let g:loaded_linuxsty = 1
+
+set wildignore+=*.ko,*.mod.c,*.order,modules.builtin
+
+augroup linuxsty
+ autocmd!
+
+ autocmd FileType c,cpp call s:LinuxFormatting()
+ autocmd FileType c,cpp call s:LinuxKeywords()
+ autocmd FileType c,cpp call s:LinuxHighlighting()
+ autocmd FileType diff,kconfig setlocal tabstop=8
+augroup END
+
+function s:LinuxFormatting()
+ setlocal tabstop=8
+ setlocal shiftwidth=8
+ setlocal textwidth=80
+ setlocal noexpandtab
+
+ setlocal cindent
+ setlocal formatoptions=tcqlron
+ setlocal cinoptions=:0,l1,t0,g0
+endfunction
+
+function s:LinuxKeywords()
+ syn keyword cOperator likely unlikely
+ syn keyword cType u8 u16 u32 u64 s8 s16 s32 s64
+endfunction
+
+function s:LinuxHighlighting()
+ highlight default link LinuxError ErrorMsg
+
+ match LinuxError " \+\t" " spaces before tab
+ match LinuxError "\s\+$" " trailing whitespaces
+ match LinuxError /\%81v.\+/ " virtual column 81 and more
+endfunction

0 comments on commit 0ea6e61

Please sign in to comment.