From e9b26cf5aa367a199db1672618485d9e50fcbbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ot=C3=A1vio=20Rizzatti?= Date: Sat, 3 May 2014 17:12:22 -0400 Subject: [PATCH] Remove processing of plist --- autoload/dash.vim | 19 ------------- autoload/dash/cache.vim | 57 --------------------------------------- autoload/dash/docset.vim | 53 ------------------------------------ autoload/dash/profile.vim | 17 ------------ plugin/dash.vim | 10 ------- 5 files changed, 156 deletions(-) delete mode 100644 autoload/dash/docset.vim delete mode 100644 autoload/dash/profile.vim diff --git a/autoload/dash.vim b/autoload/dash.vim index ee6ee30..933c236 100644 --- a/autoload/dash.vim +++ b/autoload/dash.vim @@ -34,10 +34,6 @@ function! s:check_for_dash() call s:dummy() endfunction - function! dash#settings(...) - call s:dummy() - endfunction - finish endfunction "}}} @@ -109,27 +105,12 @@ function! dash#search(bang, ...) "{{{ call add(keywords, keyword) endif endif - call filter(keywords, 'index(s:cache.keywords(), v:val) != -1') call s:search(term, keywords) endfunction "}}} -function! dash#settings() "{{{ - redraw - for profile in s:cache.profiles - let docsets = join(map(copy(profile.docsets), "v:val.name"), ', ') - echo 'Profile: ' . profile.name . '; Keyword: ' . profile.keyword . - \ '; Docsets: ' . docsets - endfor - for docset in s:cache.docsets - echo 'Docset: ' . docset.name . '; Keyword: ' . docset.keyword() - endfor -endfunction -"}}} - function! s:add_buffer_keywords(keyword_list) "{{{ let keywords = map(copy(a:keyword_list), 'get(s:aliases, v:val, v:val)') - call filter(keywords, 'index(s:cache.keywords(), v:val) != -1') if exists('b:dash_keywords') call extend(b:dash_keywords, keywords) return diff --git a/autoload/dash/cache.vim b/autoload/dash/cache.vim index 8be2d07..2088959 100644 --- a/autoload/dash/cache.vim +++ b/autoload/dash/cache.vim @@ -2,72 +2,15 @@ " Author: José Otávio Rizzatti " License: MIT -let s:docset = dash#docset#class -let s:plist = funcoo#plist#module -let s:profile = dash#profile#class - let s:class = funcoo#object#class.extend() let s:proto = {} function! s:proto.constructor() dict abort "{{{ - call self._createDocsetList() - call self._createDocsetPathMap() - call self._createProfileList() let self._keywords = [] endfunction "}}} -function! s:proto._createDocsetList() dict abort "{{{ - let docsetList = eval(s:plist.read('com.kapeli.dash docsets')) - let docsets = [] - for docset in docsetList - call add(docsets, s:docset.new(docset)) - endfor - try - call sort(docsets, s:docset.sort, s:docset) - catch /^Vim\%((\a\+)\)\=:E118/ - endtry - let self.docsets = docsets -endfunction -"}}} - -function! s:proto._createDocsetPathMap() dict abort "{{{ - let paths = {} - for docset in self.docsets - let paths[docset.path] = docset - endfor - let self._pathMap = paths -endfunction -"}}} - -function! s:proto._createProfileList() dict abort "{{{ - let profileList = eval(s:plist.read('com.kapeli.dash profiles')) - let profiles = [] - for profile in profileList - let triggers = get(profile, 'triggers', []) - if !empty(triggers) - for trigger in triggers - if get(trigger, 'isKeywordTrigger') - break - endif - endfor - let keyword = get(trigger, 'keyword', '') - let name = get(profile, 'name', 'No name') - let docsets = map(get(profile, 'docsets', []), 'self._pathMap[v:val]') - call add(profiles, s:profile.new(name, keyword, docsets)) - endif - endfor - let self.profiles = profiles -endfunction -"}}} - function! s:proto.keywords() dict abort "{{{ - if !empty(self._keywords) - return self._keywords - endif - call extend(self._keywords, map(copy(self.profiles), "v:val.keyword")) - call extend(self._keywords, map(copy(self.docsets), "v:val.keyword()")) - call sort(self._keywords) return self._keywords endfunction "}}} diff --git a/autoload/dash/docset.vim b/autoload/dash/docset.vim deleted file mode 100644 index 30503a4..0000000 --- a/autoload/dash/docset.vim +++ /dev/null @@ -1,53 +0,0 @@ -" Description: Search Dash.app from Vim -" Author: José Otávio Rizzatti -" License: MIT - -let s:class = funcoo#object#class.extend() - -function! s:class.sort(left, right) dict abort "{{{ - if a:left.name == a:right.name - return 0 - endif - return a:left.name > a:right.name ? 1 : -1 -endfunction -"}}} - -let s:proto = {} - -let s:special_cases = { - \ "Python 2:python" : 'python2', - \ "Python 3:python" : 'python3', - \ "Java SE7:java" : 'java7', - \ "Java SE6:java" : 'java6', - \ "Qt 5:qt" : 'qt5', - \ "Qt 4:qt" : 'qt4', - \ "Cocos3D:cocos2d" : 'cocos3d' - \ } - -function! s:proto.constructor(dict) dict abort "{{{ - let self.name = get(a:dict, 'docsetName', 'No name') - let self.path = get(a:dict, 'docsetPath', '') - let self._platform = get(a:dict, 'platform', '') - let self._keyword = substitute(get(a:dict, 'keyword', ''), ':', '', '') - call self._handleSpecialCases() -endfunction -"}}} - -function! s:proto._handleSpecialCases() dict abort "{{{ - if !empty(self._keyword) - return - endif - let key = join([self.name, self._platform], ':') - let self._keyword = get(s:special_cases, key, '') -endfunction -"}}} - -function! s:proto.keyword() dict abort "{{{ - let value = empty(self._keyword) ? self._platform : self._keyword - return tolower(value) -endfunction -"}}} - -call s:class.include(s:proto) - -let dash#docset#class = s:class diff --git a/autoload/dash/profile.vim b/autoload/dash/profile.vim deleted file mode 100644 index 0c5db0a..0000000 --- a/autoload/dash/profile.vim +++ /dev/null @@ -1,17 +0,0 @@ -" Description: Search Dash.app from Vim -" Author: José Otávio Rizzatti -" License: MIT - -let s:class = funcoo#object#class.extend() -let s:proto = {} - -function! s:proto.constructor(name, keyword, docsets) dict abort "{{{ - let self.name = a:name - let self.keyword = tolower(substitute(a:keyword, ':', '', '')) - let self.docsets = a:docsets -endfunction -"}}} - -call s:class.include(s:proto) - -let dash#profile#class = s:class diff --git a/plugin/dash.vim b/plugin/dash.vim index 3c4eee9..afeaec0 100644 --- a/plugin/dash.vim +++ b/plugin/dash.vim @@ -53,16 +53,6 @@ else endif "}}} -"{{{ DashSettings command -if exists(':DashSettings') == 2 - echohl WarningMsg - echomsg 'dash.vim: could not create command DashSettings' - echohl None -else - command -nargs=0 DashSettings call dash#settings() -endif -"}}} - if !exists('g:dash_autocommands') let g:dash_autocommands = 1 call dash#autocommands()