From 7e662e4bd70a79c0bf4d282a0b4dba62f0c3e7c3 Mon Sep 17 00:00:00 2001 From: Carlos Ramos Date: Wed, 17 Oct 2018 12:06:03 -0400 Subject: [PATCH] Improve README refactor error message to scan name --- README.md | 12 +++++++----- autoload/pmv/elixir/hexApi.vim | 5 +---- autoload/pmv/elixir/hexUtils.vim | 12 +----------- autoload/pmv/nodejs/utils.vim | 10 +--------- autoload/pmv/rust/utils.vim | 11 +---------- autoload/pmv/utils.vim | 9 +++++++++ 6 files changed, 20 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index af6503f..da218fe 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,13 @@ Vim plugin that provides functions to interact with your package/lib manager for your favorite language and it's generic! +### Supported languages and package managers: + +- [x] Elixir, hex +- [x] NodeJS, npm/yarn +- [x] Ruby, rubygems +- [x] Rust, cargo/cratos + ### Prerequisites This plugin uses [mattn/webapi-vim](https://github.com/mattn/webapi-vim). @@ -91,11 +98,6 @@ By default is: # TODO's -- Supported languages and package managers: - - [x] Elixir, hex - - [x] NodeJS, npm/yarn - - [x] Ruby, rubygems - - [x] Rust, cargo/cratos - Refactor - Async API calls - Test's diff --git a/autoload/pmv/elixir/hexApi.vim b/autoload/pmv/elixir/hexApi.vim index f85656d..e18de57 100644 --- a/autoload/pmv/elixir/hexApi.vim +++ b/autoload/pmv/elixir/hexApi.vim @@ -6,7 +6,7 @@ function! pmv#elixir#hexApi#getPackageInfo(package) if match(l:info, 'No package with name') != 0 return split(l:info, '\n') else - call s:packageNotFound(a:package) + call pmv#utils#packageNotFound(a:package) endif endfunction @@ -30,6 +30,3 @@ function! s:extractDate(str) return l:date endfunction -function! s:packageNotFound(package) - echom 'No package with name ' . a:package -endfunction diff --git a/autoload/pmv/elixir/hexUtils.vim b/autoload/pmv/elixir/hexUtils.vim index 1230609..8432a3e 100644 --- a/autoload/pmv/elixir/hexUtils.vim +++ b/autoload/pmv/elixir/hexUtils.vim @@ -41,7 +41,7 @@ endfunction function! pmv#elixir#hexUtils#getPackageName(qarg) if empty(a:qarg) let l:package = s:scanForPackage() - if s:packageNotFound(l:package) + if pmv#utils#packageNotFound(l:package) return endif return l:package @@ -53,13 +53,3 @@ function! s:scanForPackage() let l:line = getline('.') return matchstr(l:line, '{:\zs[a-z]\w*\ze') endfunction - -function! s:packageNotFound(package) - if empty(a:package) - redraw - echom 'No package found on this line!' - return 1 - endif - - return 0 -endfunction diff --git a/autoload/pmv/nodejs/utils.vim b/autoload/pmv/nodejs/utils.vim index 2025550..4355585 100644 --- a/autoload/pmv/nodejs/utils.vim +++ b/autoload/pmv/nodejs/utils.vim @@ -1,7 +1,7 @@ function! pmv#nodejs#utils#getPackageName(qarg) if empty(a:qarg) let l:package = s:scanForPackage() - if s:packageNotFound(l:package) + if pmv#utils#packageNotFound(l:package) return endif return l:package @@ -20,14 +20,6 @@ function! s:scanForPackage() endif endfunction -function! s:packageNotFound(package) - if empty(a:package) - redraw - echom 'No package found on this line!' - return 1 - endif - return 0 -endfunction function! pmv#nodejs#utils#getApiAllReleases(package) let l:json = pmv#nodejs#utils#getApiPackage(a:package) diff --git a/autoload/pmv/rust/utils.vim b/autoload/pmv/rust/utils.vim index c4fa1b4..c2e0924 100644 --- a/autoload/pmv/rust/utils.vim +++ b/autoload/pmv/rust/utils.vim @@ -1,7 +1,7 @@ function! pmv#rust#utils#getPackageName(qarg) if empty(a:qarg) let l:package = s:scanForPackage() - if s:packageNotFound(l:package) + if pmv#utils#packageNotFound(l:package) return endif return l:package @@ -20,15 +20,6 @@ function! s:scanForPackage() endif endfunction -function! s:packageNotFound(package) - if empty(a:package) - redraw - echom 'No package found on this line!' - return 1 - endif - return 0 -endfunction - function! pmv#rust#utils#getApiAllReleases(package) let l:json = pmv#rust#utils#getApiPackage(a:package) if has_key(l:json, 'versions') diff --git a/autoload/pmv/utils.vim b/autoload/pmv/utils.vim index 7cd6722..87ae964 100644 --- a/autoload/pmv/utils.vim +++ b/autoload/pmv/utils.vim @@ -25,6 +25,15 @@ function! pmv#utils#renderPopup(input, ...) nnoremap q :bd endfunction +function! pmv#utils#packageNotFound(package) + if empty(a:package) + redraw + echom '>>> No package found on this line! <<<' + return 1 + endif + return 0 +endfunction + function! pmv#utils#openUri(uri) if s:is_macunix call system('open ' . shellescape(a:uri))