From d11e552e0f3123b0fc93f2a79132187be91db343 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Tue, 27 Mar 2018 15:12:45 -0500 Subject: [PATCH] Add exclusions Exclusions can be used to exclude the style from being applied to paths, even if they would match linuxsty_patterns --- README.md | 6 ++++++ plugin/linuxsty.vim | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 7e38043971..23e4797a85 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,12 @@ only projects under /usr/src/ and /linux with the following: let g:linuxsty_patterns = [ "/usr/src/", "/linux" ] +Exclusion patterns can be also be applied. The following example would +exclude anything that had "/foo/" in the path, even if it would match +something in linuxsty_patterns + + let g:linuxsty_exclude_patterns = [ "/foo/" ] + If you want to enable the coding style on demand without checking the filetype, you can use the :LinuxCodingStyle command. For instance, you can map it with the following in your vimrc: diff --git a/plugin/linuxsty.vim b/plugin/linuxsty.vim index 18b2867fd9..935fde6f97 100644 --- a/plugin/linuxsty.vim +++ b/plugin/linuxsty.vim @@ -12,6 +12,12 @@ " options will be applied only if "/linux/" or "/kernel" is in buffer's path. " " let g:linuxsty_patterns = [ "/linux/", "/kernel/" ] +" +" Exclusion patterns can be also be applied. The following example would +" exclude anything that had "/foo/" in the path, even if it would match +" something in linuxsty_patterns +" +" let g:linuxsty_exclude_patterns = [ "/foo/" ] if exists("g:loaded_linuxsty") finish @@ -44,6 +50,16 @@ function s:LinuxConfigure() let apply_style = 1 endif + if exists("g:linuxsty_exclude_patterns") + let path = expand('%:p') + for p in g:linuxsty_exclude_patterns + if path =~ p + let apply_style = 0 + break + endif + endfor + endif + if apply_style call s:LinuxCodingStyle() endif