From f920e412bca99d782176d0eaa82d696de4488dcd Mon Sep 17 00:00:00 2001 From: Martin Thoresen Date: Sat, 17 Jan 2015 17:41:23 +0100 Subject: [PATCH 1/2] Added rust support --- plugin/comments.vim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugin/comments.vim b/plugin/comments.vim index 01bbfa5..d489546 100644 --- a/plugin/comments.vim +++ b/plugin/comments.vim @@ -83,6 +83,11 @@ " ********************************************************************************************* " Jasmeet Anand 11th January 2009 v2.12 " bug fix for haskel files as prpvided by Jean-Marie +" ********************************************************************************************* +" Martin H. Thoresen 17th January 2015 v2.13 +" Added support for Rust +" Incremented version number +" ********************************************************************************************* " " Exit if already loaded @@ -90,7 +95,7 @@ if exists("loaded_comments_plugin") finish endif -let loaded_comments_plugin="v2.10" +let loaded_comments_plugin="v2.13" " key-mappings for comment line in normal mode noremap :call CommentLine() @@ -109,8 +114,8 @@ function! CommentLine() " for .cpp or .hpp or .java or .C files use // if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$' execute ":silent! normal ^i//\==\^" - " for .c or .h or .pc or .css files use /* */ - elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' + " for .c or .h or .pc or .css or rs files use /* */ + elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' " if there are previous comments on this line ie /* ... */ if stridx(getline("."), "\/\*") != -1 && stridx(getline("."), "\*\/") != -1 execute ":silent! normal :nohlsearch\:s/\\([^\\/\\*]*\\)\\(\\/\\*.*\\*\\/\\)/\\1\\*\\/\\2/\:s/\\([^[:blank:]]\\+\\)/\\/\\*\\1/\:nohlsearch\==" @@ -179,7 +184,7 @@ function! UnCommentLine() execute ":silent! normal :nohlsearch\:s/(\\*//\:nohlsearch\" execute ":silent! normal :nohlsearch\:s/\\*)//\:nohlsearch\==" " for .c or .h or .pc or .css files use /* */ - elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' + elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' execute ":silent! normal :nohlsearch\:s/\\/\\*//\:s/\\*\\///\:nohlsearch\==" " for .vim files use " elseif file_name =~ '\.vim$' || file_name =~ '\.vimrc$' @@ -220,7 +225,7 @@ function! RangeCommentLine() if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$' execute ":silent! normal :s/\\S/\\/\\/\\0/\:nohlsearch==" " for .c or .h or .pc or .css files use /* */ - elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' + elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' " if there are previous comments on this line ie /* ... */ if stridx(getline("."), "\/\*") != -1 && stridx(getline("."), "\*\/") != -1 execute ":silent! normal :nohlsearch\:s/\\([^\\/\\*]*\\)\\(\\/\\*.*\\*\\/\\)/\\1\\*\\/\\2/\:s/\\([^[:blank:]]\\+\\)/\\/\\*\\1/\:nohlsearch\==" @@ -285,7 +290,7 @@ function! RangeUnCommentLine() if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$' execute ":silent! normal :s/\\/\\///\:nohlsearch\==" " for .c or .h or .pc or .css files use /* */ - elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' + elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' execute ":silent! normal :nohlsearch\:s/\\/\\*//\:s/\\*\\///\:nohlsearch\==" " for .vim files use " elseif file_name =~ '\.vim$' || file_name =~ '\.vimrc$' From 023b23be8d563ccafbad5a21158d81b355a53323 Mon Sep 17 00:00:00 2001 From: Martin Thoresen Date: Sat, 17 Jan 2015 17:44:05 +0100 Subject: [PATCH 2/2] Updated comments to include .rs --- plugin/comments.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/comments.vim b/plugin/comments.vim index d489546..f47a277 100644 --- a/plugin/comments.vim +++ b/plugin/comments.vim @@ -183,7 +183,7 @@ function! UnCommentLine() elseif file_name =~ '\.ml$' || file_name =~ '\.mli$' execute ":silent! normal :nohlsearch\:s/(\\*//\:nohlsearch\" execute ":silent! normal :nohlsearch\:s/\\*)//\:nohlsearch\==" - " for .c or .h or .pc or .css files use /* */ + " for .c or .h or .pc or .css or rs files use /* */ elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' execute ":silent! normal :nohlsearch\:s/\\/\\*//\:s/\\*\\///\:nohlsearch\==" " for .vim files use " @@ -224,7 +224,7 @@ function! RangeCommentLine() " for .cpp or .hpp or .java or .C files use // if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$' execute ":silent! normal :s/\\S/\\/\\/\\0/\:nohlsearch==" - " for .c or .h or .pc or .css files use /* */ + " for .c or .h or .pc or .css or rs files use /* */ elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' " if there are previous comments on this line ie /* ... */ if stridx(getline("."), "\/\*") != -1 && stridx(getline("."), "\*\/") != -1 @@ -289,7 +289,7 @@ function! RangeUnCommentLine() " for .cpp or .hpp or .java files use // if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$' execute ":silent! normal :s/\\/\\///\:nohlsearch\==" - " for .c or .h or .pc or .css files use /* */ + " for .c or .h or .pc or .css or rs files use /* */ elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$' execute ":silent! normal :nohlsearch\:s/\\/\\*//\:s/\\*\\///\:nohlsearch\==" " for .vim files use "