From aaaaf5b64fc082e8c26349175263362487b75729 Mon Sep 17 00:00:00 2001 From: Nabil Elqatib Date: Thu, 17 Aug 2017 13:58:42 +0200 Subject: [PATCH] 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 `l` mapping to MbedList() * Change MbedGetTargetandToolchain() mapping: F11 -> F12 Closes #5 , #7 , #9 --- README.md | 2 +- plugin/mbed.vim | 53 +++++++++++++++++++++++-------------------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index e8dc112..5e9f716 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # mbed-vim -[![version](https://img.shields.io/badge/version-v0.1-grey.svg)](https://github.com/nelqatib/mbed-vim/releases) +[![version](https://img.shields.io/badge/version-v0.2-blue.svg)](https://github.com/nelqatib/mbed-vim/releases) [![Build Status](https://travis-ci.org/nelqatib/mbed-vim.svg?branch=master)](https://travis-ci.org/nelqatib/mbed-vim) [![license](http://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) diff --git a/plugin/mbed.vim b/plugin/mbed.vim index 23d2b25..26a16cc 100644 --- a/plugin/mbed.vim +++ b/plugin/mbed.vim @@ -1,6 +1,7 @@ " mbed.vim " author: marrakchino (nabilelqatib@gmail.com) -" version: 0.1 +" license: MIT (https://opensource.org/licenses/MIT) +" version: 0.2 " " This file contains routines that may be used to execute mbed CLI commands " from within VIM. It depends on mbed OS. Therefore, @@ -19,8 +20,9 @@ " d: Import missing dependencies " a: Prompt for an mbed library to add " r: Prompt for an mbed library to remove +" l: Display the dependency tree " : Close the error buffer (when open) -" : Set the current application's target and toolchain +" : Set the current application's target and toolchain " " Add -- Add the specified library. When no argument is given, " you are prompted for the name of the library @@ -45,12 +47,6 @@ " is opened. You can close this buffer with . " - -" TODO: transform MbedAdd* and MbedRemove* functions to take a variable number -" of arguments (libraries to add/remove), see vim varags -" (http://learnvimscriptthehardway.stevelosh.com/chapters/24.html) - - " Global variables " XXX: variables should be local to the current window or global? if !exists( "g:mbed_target" ) @@ -153,7 +149,7 @@ endfunction function! MbedCompile(flag) call MbedGetTargetandToolchain ( 0 ) execute 'wa' - let @o = system("!mbed compile" . a:flag) + let @o = system("mbed compile " . "-m" . g:mbed_target . " -t " . g:mbed_toolchain . " " . a:flag) if !empty(@o) " pattern not found if match(getreg("o"), "Image") == -1 @@ -164,30 +160,34 @@ function! MbedCompile(flag) endif endfunction -function! MbedAddLibary(libraryName) - if a:libraryName == "" +function! MbedAdd(...) + if a:0 == 0 call PromptForLibraryToAdd() else - execute '!mbed add ' . a:libraryName + for library in a:000 + execute '!mbed add ' . library + endfor endif endfunction function! PromptForLibraryToAdd() let l:library_name = input("Please enter the name/URL of the library to add: ") - call MbedAddLibary(l:library_name) + call MbedAdd(l:library_name) endfunction -function! MbedRemoveLibary(libraryName) - if a:libraryName == "" +function! MbedRemove(...) + if a:0 == 0 call PromptForLibraryToRemove() else - execute '!mbed remove ' . a:libraryName + for library in a:000 + execute '!mbed remove ' . library + endfor endif endfunction function! PromptForLibraryToRemove() let l:library_name = input("Please enter the name/URL of the library to remove: ") - call MbedRemoveLibary(l:library_name) + call MbedRemove(l:library_name) endfunction function! MbedList() @@ -206,18 +206,14 @@ function! MbedList() if l:newheight < winheight(0) execute "resize " . l:newheight endif - else - echo "@o is empty.." endif endfunction -" TODO function! MbedTest() execute 'wa' - let @t = system("!mbed test") + let @t = system("mbed test") if !empty(@t) - " TODO: find a pattern in the output to notify that the tests were - " successful + " TODO: find a pattern in the output to notify that the tests were successful vnew set buftype=nofile silent put=@t @@ -235,13 +231,14 @@ map n :call MbedNew() map s :call MbedSync() map t :call MbedTest() map d :call MbedDeploy() -map a :call MbedAddLibary("") -map r :call MbedRemoveLibary("") +map a :call MbedAdd("") +map r :call MbedRemove("") +map l :call MbedList() map :call CloseErrorBuffer() -map :call MbedGetTargetandToolchain(1) +map :call MbedGetTargetandToolchain(1) " commands -command! -nargs=? Add :call MbedAddLibary("") -command! -nargs=? Remove :call MbedRemoveLibary("") +command! -nargs=? Add :call MbedAdd("") +command! -nargs=? Remove :call MbedRemove("") command! -nargs=1 SetToolchain :let g:mbed_toolchain="" command! -nargs=1 SetTarget :let g:mbed_target=""