summaryrefslogtreecommitdiffstats
path: root/ftplugin/purescript.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2017-09-27 19:57:29 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2017-09-27 19:57:29 +0200
commit8b3418cab8eb5267b3a5743e4d5fe5f698d48bc8 (patch)
tree125734ac66307a962eeda16283355dde0d0fbd2e /ftplugin/purescript.vim
parent9bfde7574aa89a91b80ed9c993fc000cfc11aae7 (diff)
downloadvim-polyglot-8b3418cab8eb5267b3a5743e4d5fe5f698d48bc8.tar.gz
vim-polyglot-8b3418cab8eb5267b3a5743e4d5fe5f698d48bc8.zip
Update
Diffstat (limited to 'ftplugin/purescript.vim')
-rw-r--r--ftplugin/purescript.vim37
1 files changed, 37 insertions, 0 deletions
diff --git a/ftplugin/purescript.vim b/ftplugin/purescript.vim
index 4e40143f..695a4108 100644
--- a/ftplugin/purescript.vim
+++ b/ftplugin/purescript.vim
@@ -1,5 +1,42 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'purescript') == -1
setlocal comments=s1fl:{-,mb:\ \ ,ex:-},:--
+setlocal include=^import
+setlocal includeexpr=printf('%s.purs',substitute(v:fname,'\\.','/','g'))
+
+let s:PS = []
+fun! InitPureScript()
+ let dirs = map(
+ \ findfile("psc-package.json", expand("%:p:h") . ";/", -1),
+ \ { idx, val -> fnamemodify(val, ":p:h") }
+ \ )
+ if empty(dirs)
+ let dirs = map(
+ \ findfile("bower.json", expand("%:p:h") . ";/", -1),
+ \ { idx, val -> fnamemodify(val, ":p:h") }
+ \ )
+ if empty(dirs)
+ return
+ endif
+ endif
+
+ let path = expand("%:p")
+ for p in s:PS
+ if stridx(path, p[0], 0) == 0
+ let &l:path=p[1]
+ return
+ endif
+ endfor
+
+ let dir = dirs[len(dirs) - 1]
+ let gp = globpath(dir, "src/**/*.purs", v:true, v:true)
+ if empty(gp)
+ return
+ endif
+
+ let &l:path=join([dir, dir . "/bower_components/**", dir . "/src/**"], ",")
+ call add(s:PS, [dir, &l:path])
+endfun
+call InitPureScript()
endif