Skip to content

Instantly share code, notes, and snippets.

@kwbr
Created May 10, 2021 08:46
Show Gist options
  • Save kwbr/2446e881b7990cc6cf33403767b625ea to your computer and use it in GitHub Desktop.
Save kwbr/2446e881b7990cc6cf33403767b625ea to your computer and use it in GitHub Desktop.
Set proper &path for Next.js and Nuxt.js
autocmd BufNewFile,BufRead * call <SID>DetectFrontEndFramework()
function! s:DetectFrontEndFramework()
if v:version >= 801 && has('patch1803')
let package_json = findfile('package.json', '.;')
if len(package_json)
let dependencies = readfile(package_json)
\ ->join()
\ ->json_decode()
\ ->get('dependencies', {})
\ ->keys()
if dependencies->count('next')
set path=.,,components/**,lib/**,pages/**,public/**,ssl/**,styles/**
endif
if dependencies->count('nuxt')
set path=.,,assets/**,components/**,layouts/**,middleware/**,pages/**,plugins/**,static/**,store/**,test/**,content/**
endif
endif
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment