neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

javascript.vim (2775B)


      1 " Vim filetype plugin file
      2 " Language:     Javascript
      3 " Maintainer:   Doug Kearns <dougkearns@gmail.com>
      4 " Contributor:  Romain Lafourcade <romainlafourcade@gmail.com>
      5 " Last Change:	2024 Jan 14
      6 " 		2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
      7 
      8 if exists("b:did_ftplugin")
      9    finish
     10 endif
     11 let b:did_ftplugin = 1
     12 
     13 let s:cpo_save = &cpo
     14 set cpo-=C
     15 
     16 " Set 'formatoptions' to break comment lines but not other lines,
     17 " and insert the comment leader when hitting <CR> or using "o".
     18 setlocal formatoptions-=t formatoptions+=croql
     19 
     20 " Set completion with CTRL-X CTRL-O to autoloaded function.
     21 if exists('&ofu')
     22    setlocal omnifunc=javascriptcomplete#CompleteJS
     23 endif
     24 
     25 " Set 'comments' to format dashed lists in comments.
     26 setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
     27 
     28 setlocal commentstring=//\ %s
     29 
     30 " Change the :browse e filter to primarily show JavaScript-related files.
     31 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
     32    let b:browsefilter =
     33                \ "JavaScript Files (*.js)\t*.js\n"
     34                \ .. "JSX Files (*.jsx)\t*.jsx\n"
     35                \ .. "JavaScript Modules (*.es, *.es6, *.cjs, *.mjs, *.jsm)\t*.es;*.es6;*.cjs;*.mjs;*.jsm\n"
     36                \ .. "Vue Templates (*.vue)\t*.vue\n"
     37                \ .. "JSON Files (*.json)\t*.json\n"
     38    if has("win32")
     39        let b:browsefilter ..= "All Files (*.*)\t*\n"
     40    else
     41        let b:browsefilter ..= "All Files (*)\t*\n"
     42    endif
     43 endif
     44 
     45 " The following suffixes should be implied when resolving filenames
     46 setlocal suffixesadd+=.js,.jsx,.es,.es6,.cjs,.mjs,.jsm,.vue,.json
     47 
     48 " The following suffixes should have low priority
     49 "   .snap    jest snapshot
     50 setlocal suffixes+=.snap
     51 
     52 " Remove irrelevant part of 'path'.
     53 " User is expected to augment it with contextually-relevant paths
     54 setlocal path-=/usr/include
     55 
     56 " Matchit configuration
     57 if exists("loaded_matchit")
     58    let b:match_ignorecase = 0
     59    let b:match_words =
     60                \ '\<do\>:\<while\>,'
     61                \ .. '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'
     62                \ .. '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
     63 endif
     64 
     65 " Set 'define' to a comprehensive value
     66 let &l:define =
     67            \ '\(^\s*(*async\s\+function\|(*function\)'
     68            \ .. '\|^\s*\(\*\|static\|async\|get\|set\|\i\+\.\)'
     69            \ .. '\|^\s*\(\ze\i\+\)\(([^)]*).*{$\|\s*[:=,]\)'
     70            \ .. '\|^\s*\(export\s\+\|export\s\+default\s\+\)*\(var\|let\|const\|function\|class\)'
     71            \ .. '\|\<as\>'
     72 
     73 let b:undo_ftplugin =
     74            \ "setl fo< ofu< com< cms< sua< su< def< pa<"
     75            \ .. "| unlet! b:browsefilter b:match_ignorecase b:match_words"
     76 
     77 let &cpo = s:cpo_save
     78 unlet s:cpo_save
     79 
     80 " vim: textwidth=78 tabstop=8 shiftwidth=4 softtabstop=4 expandtab