From d458cd39063bc22647b5581eff1bc349f90366a1 Mon Sep 17 00:00:00 2001 From: gryf Date: Sun, 27 Jan 2013 20:59:07 +0100 Subject: [PATCH] Added omnicompletion and indentation for javascript (including node.js). Added Windows configuration. --- .vimrc | 5 +- .../syntax_checkers/java/javac.vim | 3 +- bundle/git_vim-javascript/README.md | 52 ++ bundle/git_vim-javascript/Rakefile | 89 +++ bundle/git_vim-javascript/extras/ctags | 8 + .../ftdetect/javascript.vim | 4 + bundle/git_vim-javascript/indent/html.vim | 539 ++++++++++++++++++ .../git_vim-javascript/indent/javascript.vim | 330 +++++++++++ .../git_vim-javascript/syntax/javascript.vim | 264 +++++++++ bundle/git_vim-javascript/tmp/.keep | 0 bundle/git_vim-nodejs-complete/.gitignore | 6 + bundle/git_vim-nodejs-complete/README.md | 65 +++ .../after/autoload/nodejs-doc.vim | 2 + .../after/autoload/nodejscomplete.vim | 296 ++++++++++ .../after/autoload/update-nodejs-doc.js | 283 +++++++++ .../after/ftplugin/javascript.vim | 3 + bundle_win/ftplugin/python/common.vim | 44 ++ bundle_win/ftplugin/python/pep8.vim | 55 ++ winrc.vim | 102 ++++ 19 files changed, 2146 insertions(+), 4 deletions(-) create mode 100644 bundle/git_vim-javascript/README.md create mode 100644 bundle/git_vim-javascript/Rakefile create mode 100644 bundle/git_vim-javascript/extras/ctags create mode 100644 bundle/git_vim-javascript/ftdetect/javascript.vim create mode 100644 bundle/git_vim-javascript/indent/html.vim create mode 100644 bundle/git_vim-javascript/indent/javascript.vim create mode 100644 bundle/git_vim-javascript/syntax/javascript.vim create mode 100644 bundle/git_vim-javascript/tmp/.keep create mode 100644 bundle/git_vim-nodejs-complete/.gitignore create mode 100644 bundle/git_vim-nodejs-complete/README.md create mode 100644 bundle/git_vim-nodejs-complete/after/autoload/nodejs-doc.vim create mode 100644 bundle/git_vim-nodejs-complete/after/autoload/nodejscomplete.vim create mode 100644 bundle/git_vim-nodejs-complete/after/autoload/update-nodejs-doc.js create mode 100644 bundle/git_vim-nodejs-complete/after/ftplugin/javascript.vim create mode 100755 bundle_win/ftplugin/python/common.vim create mode 100755 bundle_win/ftplugin/python/pep8.vim create mode 100644 winrc.vim diff --git a/.vimrc b/.vimrc index 1568b11..cf30580 100644 --- a/.vimrc +++ b/.vimrc @@ -425,9 +425,8 @@ if $TERM == 'linux' && !has('gui_running') " fallback to basic 8-color colorscheme colorscheme pablo endif - -if has('win32') && $_PMX == '1' - source $VIM/vimfiles/pmxrc.vim +if has('win32') + source $VIM/vimfiles/winrc.vim endif "}}} " vim:ts=4:sw=4:wrap:fdm=marker: diff --git a/bundle/git_syntastic/syntax_checkers/java/javac.vim b/bundle/git_syntastic/syntax_checkers/java/javac.vim index d65baa7..ef2610a 100644 --- a/bundle/git_syntastic/syntax_checkers/java/javac.vim +++ b/bundle/git_syntastic/syntax_checkers/java/javac.vim @@ -121,7 +121,8 @@ function! SyntaxCheckers_java_GetLocList() " add classpathes to javac_classpath for path in split(g:syntastic_java_javac_classpath,"\n") if path != '' - let ps = glob(path,0,1) + "let ps = glob(path,0,1) + let ps = glob(path) if type(ps) == type([]) for p in ps if p != '' | let javac_classpath = s:AddToClasspath(javac_classpath,p) | endif diff --git a/bundle/git_vim-javascript/README.md b/bundle/git_vim-javascript/README.md new file mode 100644 index 0000000..280af92 --- /dev/null +++ b/bundle/git_vim-javascript/README.md @@ -0,0 +1,52 @@ +# vim-javascript + +JavaScript bundle for vim, this bundle provides syntax and indent plugins. + +> Indentation of javascript in vim is terrible, and this is the very end of it. + +## Feature + +1. very correct indentation for javascript +2. support javascript indentation in html (provided by [lepture](https://github.com/lepture)) + +## Installation + +- Install with [Vundle](https://github.com/gmarik/vundle) + +If you are not using vundle, you really should have a try. +Edit your vimrc: + + Bundle "pangloss/vim-javascript" + +And install it: + + :so ~/.vimrc + :BundleInstall + + +- Install with [pathogen](https://github.com/tpope/vim-pathogen) + +If you prefer tpope's pathogen, that's ok. Just clone it: + + cd ~/.vim/bundle + git clone https://github.com/pangloss/vim-javascript.git + +## Configuration + +[html indentation](http://www.vim.org/scripts/script.php?script_id=2075) +provided by Andy Wokula is faster. But you need to make some configuration. + +Suggested configuration: + +```vim +let g:html_indent_inctags = "html,body,head,tbody" +let g:html_indent_script1 = "inc" +let g:html_indent_style1 = "inc" +``` + +Head over to [vim.org](http://www.vim.org/scripts/script.php?script_id=2075) +for more information. + +## Bug report + +Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues). diff --git a/bundle/git_vim-javascript/Rakefile b/bundle/git_vim-javascript/Rakefile new file mode 100644 index 0000000..c6223ba --- /dev/null +++ b/bundle/git_vim-javascript/Rakefile @@ -0,0 +1,89 @@ +require 'rake' +require 'rake/clean' + +files = ['syntax/javascript.vim', 'indent/javascript.vim'] + +CLEAN.include 'tmp/*_ctags' + +desc "Make zip file" +file 'javascript.zip' => files do |t| + File.unlink t.name if File.exists?(t.name) + system('zip','-q',t.name,*t.prerequisites) +end + +desc "Make vimball" +file 'javascript.vba' => files do |t| + File.unlink t.name if File.exists?(t.name) + File.open(t.name,"w") do |out| + out.puts '" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.' + out.puts 'UseVimball' + out.puts 'finish' + t.prerequisites.each do |name| + File.open(name) do |file| + file.each_line {} + out.puts name + out.puts file.lineno + file.rewind + file.each_line {|l|out.puts l} + end + end + end +end + +desc "Install" +task :install do + vimfiles = if ENV['VIMFILES'] + ENV['VIMFILES'] + elsif RUBY_PLATFORM =~ /(win|w)32$/ + File.expand_path("~/vimfiles") + else + File.expand_path("~/.vim") + end + + puts "Installing javascript.vim" + files.each do |file| + target_file = File.join(vimfiles, file) + FileUtils.mkdir_p(File.dirname(target_file)) + FileUtils.rm(target_file) rescue nil + FileUtils.cp(file, target_file) + puts " Copied #{file} to #{target_file}" + end +end + +desc "Copy ~/.ctags to tmp/original_ctags" +task :get_original_ctags do + if File.exists?(File.expand_path("~/.ctags")) + File.unlink('tmp/original_ctags') if File.exists?('tmp/original_ctags') + FileUtils.cp(File.expand_path("~/.ctags"), 'tmp/original_ctags') + elsif not File.exists?("tmp/original_ctags") + File.open("tmp/original_ctags", "w") { } + end +end + +desc "Combine tmp/original_ctags and extras/ctags" +file 'tmp/combined_ctags' => ['tmp/original_ctags', 'extras/ctags'] do |t| + begin_string = '# Begin vim-javascript generated section' + end_string = '# End vim-javascript generated section' + File.unlink t.name if File.exists?(t.name) + File.open(t.name,"w") do |out| + orig = File.read('tmp/original_ctags') + orig.each_line.inject(true) do |can_print, line| + can_print = false if line.chomp == begin_string + out.puts line if can_print + can_print or line.chomp == end_string + end + out.puts begin_string + out.puts "# generated at #{ Time.now }" + out.puts File.read('extras/ctags') + out.puts end_string + end +end + +desc "Add better javascript support to ctags" +task :ctags => [:get_original_ctags, 'tmp/combined_ctags'] do + FileUtils.cp('tmp/combined_ctags', File.expand_path('~/.ctags')) +end + +task 'zip' => 'javascript.zip' +task 'vimball' => 'javascript.vba' +task :default => [:zip, :vimball] diff --git a/bundle/git_vim-javascript/extras/ctags b/bundle/git_vim-javascript/extras/ctags new file mode 100644 index 0000000..cdc4edc --- /dev/null +++ b/bundle/git_vim-javascript/extras/ctags @@ -0,0 +1,8 @@ +--langdef=js +--langmap=js:.js +--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/ +--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/ +--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*([^)])/\1/,function/ +--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/ +--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/ +--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/ diff --git a/bundle/git_vim-javascript/ftdetect/javascript.vim b/bundle/git_vim-javascript/ftdetect/javascript.vim new file mode 100644 index 0000000..6ddc900 --- /dev/null +++ b/bundle/git_vim-javascript/ftdetect/javascript.vim @@ -0,0 +1,4 @@ +au BufNewFile,BufRead *.js setf javascript +au BufNewFile,BufRead *.jsm setf javascript +au BufNewFile,BufRead *.json setf javascript +au BufNewFile,BufRead Jakefile setf javascript diff --git a/bundle/git_vim-javascript/indent/html.vim b/bundle/git_vim-javascript/indent/html.vim new file mode 100644 index 0000000..4e9dcfa --- /dev/null +++ b/bundle/git_vim-javascript/indent/html.vim @@ -0,0 +1,539 @@ +" Vim indent script for HTML +" General: "{{{ +" File: html.vim (Vimscript #2075) +" Author: Andy Wokula +" Last Change: 2012 Jun 05 +" Last Changed By: Hsiaoming Yang +" Version: 0.8 +" Vim Version: Vim7 +" Description: +" Improved version of the distributed html indent script, faster on a +" range of lines. +" +" Customization: +" This section is about variables you can set in your vimrc. +" +" - You can set the indent for the first line after