aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-28 10:59:01 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-28 10:59:01 +1200
commit186591c1201ffd4f204781a2989e0d7049786d41 (patch)
treecd9173e6be9d539310c53981086be98de7c23dc8 /autoload
downloadvim-make-target-186591c1201ffd4f204781a2989e0d7049786d41.tar.gz
vim-make-target-186591c1201ffd4f204781a2989e0d7049786d41.zip
First commitv0.1.0
Diffstat (limited to 'autoload')
-rw-r--r--autoload/make/target.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/autoload/make/target.vim b/autoload/make/target.vim
new file mode 100644
index 0000000..e3c0861
--- /dev/null
+++ b/autoload/make/target.vim
@@ -0,0 +1,32 @@
+" Function to make the target for the recipe under the cursor
+function! make#target#Make() abort
+
+ " Declare list of targets to build
+ let l:targets = []
+
+ " Iterate back through the file starting at the current line looking for the
+ " line with the target
+ for l:li in reverse(range(1, line('.')))
+ let l:line = getline(l:li)
+
+ " If it matches the target format, we've found our line; split the targets
+ " by space, and break
+ let l:matchlist = matchlist(l:line, '^\([^:= \t][^:=]*\):')
+ if len(l:matchlist)
+ let l:targets = split(l:matchlist[1], '\s\+')
+ break
+
+ " If it wasn't the target line and doesn't have leading tabs, we're not in
+ " a recipe block; break with an unset target
+ elseif strpart(l:line, 0, 1) !=# "\t"
+ break
+ endif
+
+ endfor
+
+ " If we found targets, :make them
+ for l:target in l:targets
+ execute 'make! '.l:target
+ endfor
+
+endfunction