Skip to content

Commit f72442e

Browse files
author
Marcin Szamotulski
committed
set include, includeexpr and path
This enables: * gf normal command over module name in the import section * ]i, ]I normal commands * :find command to navigate through all the source files
1 parent 2c55bce commit f72442e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

ftplugin/purescript.vim

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
11
setlocal comments=s1fl:{-,mb:\ \ ,ex:-},:--
2+
setlocal include=^import
3+
setlocal includeexpr=printf('%s.purs',substitute(v:fname,'\\.','/','g'))
4+
5+
let s:PS = []
6+
fun! InitPureScript()
7+
let dirs = map(
8+
\ findfile("psc-package.json", expand("%:p:h") . ";/", -1),
9+
\ { idx, val -> fnamemodify(val, ":p:h") }
10+
\ )
11+
if empty(dirs)
12+
let dirs = map(
13+
\ findfile("bower.json", expand("%:p:h") . ";/", -1),
14+
\ { idx, val -> fnamemodify(val, ":p:h") }
15+
\ )
16+
if empty(dirs)
17+
return
18+
endif
19+
endif
20+
21+
let path = expand("%:p")
22+
for p in s:PS
23+
if stridx(path, p[0], 0) == 0
24+
let &l:path=p[1]
25+
return
26+
endif
27+
endfor
28+
29+
let dir = dirs[len(dirs) - 1]
30+
let gp = globpath(dir, "src/**/*.purs", v:true, v:true)
31+
if empty(gp)
32+
return
33+
endif
34+
35+
let &l:path=join([dir, dir . "/bower_components/**", dir . "/src/**"], ",")
36+
call add(s:PS, [dir, &l:path])
37+
endfun
38+
call InitPureScript()

0 commit comments

Comments
 (0)