diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-12 11:40:25 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-12 11:40:25 -0500 |
commit | 4fa6aa90ad91f3828da82fe1ba1a063890928e94 (patch) | |
tree | 55d28a9d15828b1e84aaae02e304ca6623c7086c | |
parent | a8860b033f2f6f0ef5354d51c7ccfaa274f7068e (diff) | |
download | rneovim-4fa6aa90ad91f3828da82fe1ba1a063890928e94.tar.gz rneovim-4fa6aa90ad91f3828da82fe1ba1a063890928e94.tar.bz2 rneovim-4fa6aa90ad91f3828da82fe1ba1a063890928e94.zip |
runtime/javascript: 207f009326c8f878defde0e594d7d9ed9860106e
Port javascript and javascript react ftplugins only.
-rw-r--r-- | runtime/ftplugin/javascript.vim | 61 | ||||
-rw-r--r-- | runtime/ftplugin/javascriptreact.vim | 5 |
2 files changed, 54 insertions, 12 deletions
diff --git a/runtime/ftplugin/javascript.vim b/runtime/ftplugin/javascript.vim index af5e4a920c..9a0b29e0ca 100644 --- a/runtime/ftplugin/javascript.vim +++ b/runtime/ftplugin/javascript.vim @@ -1,11 +1,11 @@ " Vim filetype plugin file -" Language: Javascript -" Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2008 Jun 15 -" URL: http://gus.gscit.monash.edu.au/~djkea2/vim/ftplugin/javascript.vim +" Language: Javascript +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Last Change: 2020 Jun 23 +" Contributor: Romain Lafourcade <romainlafourcade@gmail.com> if exists("b:did_ftplugin") - finish + finish endif let b:did_ftplugin = 1 @@ -13,7 +13,7 @@ let s:cpo_save = &cpo set cpo-=C " Set 'formatoptions' to break comment lines but not other lines, -" " and insert the comment leader when hitting <CR> or using "o". +" and insert the comment leader when hitting <CR> or using "o". setlocal formatoptions-=t formatoptions+=croql " Set completion with CTRL-X CTRL-O to autoloaded function. @@ -26,13 +26,50 @@ setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// setlocal commentstring=//%s -" Change the :browse e filter to primarily show Java-related files. -if has("gui_win32") - let b:browsefilter="Javascript Files (*.js)\t*.js\n" . - \ "All Files (*.*)\t*.*\n" +" Change the :browse e filter to primarily show JavaScript-related files. +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = + \ "JavaScript Files (*.js)\t*.js\n" + \ .. "JSX Files (*.jsx)\t*.jsx\n" + \ .. "JavaScript Modules (*.es, *.es6, *.cjs, *.mjs, *.jsm)\t*.es;*.es6;*.cjs;*.mjs;*.jsm\n" + \ .. "Vue Templates (*.vue)\t*.vue\n" + \ .. "JSON Files (*.json)\t*.json\n" + \ .. "All Files (*.*)\t*.*\n" endif - -let b:undo_ftplugin = "setl fo< ofu< com< cms<" + +" The following suffixes should be implied when resolving filenames +setlocal suffixesadd+=.js,.jsx,.es,.es6,.cjs,.mjs,.jsm,.vue,.json + +" The following suffixes should have low priority +" .snap jest snapshot +setlocal suffixes+=.snap + +" Remove irrelevant part of 'path'. +" User is expected to augment it with contextually-relevant paths +setlocal path-=/usr/include + +" Matchit configuration +if exists("loaded_matchit") + let b:match_ignorecase = 0 + let b:match_words = + \ '\<do\>:\<while\>,' + \ .. '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,' + \ .. '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>' +endif + +" Set 'define' to a comprehensive value +let &l:define = + \ '\(^\s*(*async\s\+function\|(*function\)' + \ .. '\|^\s*\(\*\|static\|async\|get\|set\|\i\+\.\)' + \ .. '\|^\s*\(\ze\i\+\)\(([^)]*).*{$\|\s*[:=,]\)' + \ .. '\|^\s*\(export\s\+\|export\s\+default\s\+\)*\(var\|let\|const\|function\|class\)' + \ .. '\|\<as\>' + +let b:undo_ftplugin = + \ "setl fo< ofu< com< cms< sua< su< def< pa<" + \ .. "| unlet! b:browsefilter b:match_ignorecase b:match_words" let &cpo = s:cpo_save unlet s:cpo_save + +" vim: textwidth=78 tabstop=8 shiftwidth=4 softtabstop=4 expandtab diff --git a/runtime/ftplugin/javascriptreact.vim b/runtime/ftplugin/javascriptreact.vim index af318a01d6..b9c39d5e68 100644 --- a/runtime/ftplugin/javascriptreact.vim +++ b/runtime/ftplugin/javascriptreact.vim @@ -1,2 +1,7 @@ +" Vim filetype plugin file +" Language: JavaScript React +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Last Change: 2020 Aug 19 + " Placeholder for backwards compatilibity: .jsx used to stand for JavaScript. runtime! ftplugin/javascript.vim |