Skip to content

Commit aaaaf5b

Browse files
authored
v0.2 (#6)
# Fixes * Add -t and -m arguments at `mbed compile` call * Missing parentheses fix * Remove '!' from 'system' calls * Fix minor syntax typos # New features - additions * Implement variable-length argument lists for Mbed[Add|Remove] * Add `<leader>l` mapping to MbedList() * Change MbedGetTargetandToolchain() mapping: F11 -> F12 Closes #5 , #7 , #9
1 parent 10f99cb commit aaaaf5b

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mbed-vim
22

3-
[![version](https://img.shields.io/badge/version-v0.1-grey.svg)](https://github.com/nelqatib/mbed-vim/releases)
3+
[![version](https://img.shields.io/badge/version-v0.2-blue.svg)](https://github.com/nelqatib/mbed-vim/releases)
44
[![Build Status](https://travis-ci.org/nelqatib/mbed-vim.svg?branch=master)](https://travis-ci.org/nelqatib/mbed-vim)
55
[![license](http://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)
66

plugin/mbed.vim

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
" mbed.vim
22
" author: marrakchino ([email protected])
3-
" version: 0.1
3+
" license: MIT (https://opensource.org/licenses/MIT)
4+
" version: 0.2
45
"
56
" This file contains routines that may be used to execute mbed CLI commands
67
" from within VIM. It depends on mbed OS. Therefore,
@@ -19,8 +20,9 @@
1920
" <leader>d: Import missing dependencies
2021
" <leader>a: Prompt for an mbed library to add
2122
" <leader>r: Prompt for an mbed library to remove
23+
" <leader>l: Display the dependency tree
2224
" <F9>: Close the error buffer (when open)
23-
" <F11>: Set the current application's target and toolchain
25+
" <F12>: Set the current application's target and toolchain
2426
"
2527
" Add <library_name> -- Add the specified library. When no argument is given,
2628
" you are prompted for the name of the library
@@ -45,12 +47,6 @@
4547
" is opened. You can close this buffer with <F9>.
4648
"
4749

48-
49-
" TODO: transform MbedAdd* and MbedRemove* functions to take a variable number
50-
" of arguments (libraries to add/remove), see vim varags
51-
" (http://learnvimscriptthehardway.stevelosh.com/chapters/24.html)
52-
53-
5450
" Global variables
5551
" XXX: variables should be local to the current window or global?
5652
if !exists( "g:mbed_target" )
@@ -153,7 +149,7 @@ endfunction
153149
function! MbedCompile(flag)
154150
call MbedGetTargetandToolchain ( 0 )
155151
execute 'wa'
156-
let @o = system("!mbed compile" . a:flag)
152+
let @o = system("mbed compile " . "-m" . g:mbed_target . " -t " . g:mbed_toolchain . " " . a:flag)
157153
if !empty(@o)
158154
" <Image> pattern not found
159155
if match(getreg("o"), "Image") == -1
@@ -164,30 +160,34 @@ function! MbedCompile(flag)
164160
endif
165161
endfunction
166162

167-
function! MbedAddLibary(libraryName)
168-
if a:libraryName == ""
163+
function! MbedAdd(...)
164+
if a:0 == 0
169165
call PromptForLibraryToAdd()
170166
else
171-
execute '!mbed add ' . a:libraryName
167+
for library in a:000
168+
execute '!mbed add ' . library
169+
endfor
172170
endif
173171
endfunction
174172

175173
function! PromptForLibraryToAdd()
176174
let l:library_name = input("Please enter the name/URL of the library to add: ")
177-
call MbedAddLibary(l:library_name)
175+
call MbedAdd(l:library_name)
178176
endfunction
179177

180-
function! MbedRemoveLibary(libraryName)
181-
if a:libraryName == ""
178+
function! MbedRemove(...)
179+
if a:0 == 0
182180
call PromptForLibraryToRemove()
183181
else
184-
execute '!mbed remove ' . a:libraryName
182+
for library in a:000
183+
execute '!mbed remove ' . library
184+
endfor
185185
endif
186186
endfunction
187187

188188
function! PromptForLibraryToRemove()
189189
let l:library_name = input("Please enter the name/URL of the library to remove: ")
190-
call MbedRemoveLibary(l:library_name)
190+
call MbedRemove(l:library_name)
191191
endfunction
192192

193193
function! MbedList()
@@ -206,18 +206,14 @@ function! MbedList()
206206
if l:newheight < winheight(0)
207207
execute "resize " . l:newheight
208208
endif
209-
else
210-
echo "@o is empty.."
211209
endif
212210
endfunction
213211

214-
" TODO
215212
function! MbedTest()
216213
execute 'wa'
217-
let @t = system("!mbed test")
214+
let @t = system("mbed test")
218215
if !empty(@t)
219-
" TODO: find a pattern in the output to notify that the tests were
220-
" successful
216+
" TODO: find a pattern in the output to notify that the tests were successful
221217
vnew
222218
set buftype=nofile
223219
silent put=@t
@@ -235,13 +231,14 @@ map <leader>n :call MbedNew()<CR>
235231
map <leader>s :call MbedSync()<CR>
236232
map <leader>t :call MbedTest()<CR>
237233
map <leader>d :call MbedDeploy()<CR>
238-
map <leader>a :call MbedAddLibary("")<CR>
239-
map <leader>r :call MbedRemoveLibary("")<CR>
234+
map <leader>a :call MbedAdd("")<CR>
235+
map <leader>r :call MbedRemove("")<CR>
236+
map <leader>l :call MbedList()<CR>
240237
map <F9> :call CloseErrorBuffer()<CR>
241-
map <F11> :call MbedGetTargetandToolchain(1)<CR>
238+
map <F12> :call MbedGetTargetandToolchain(1)<CR>
242239
243240
" commands
244-
command! -nargs=? Add :call MbedAddLibary("<args>")
245-
command! -nargs=? Remove :call MbedRemoveLibary("<args>")
241+
command! -nargs=? Add :call MbedAdd("<args>")
242+
command! -nargs=? Remove :call MbedRemove("<args>")
246243
command! -nargs=1 SetToolchain :let g:mbed_toolchain="<args>"
247244
command! -nargs=1 SetTarget :let g:mbed_target="<args>"

0 commit comments

Comments
 (0)