Added travis script

This commit is contained in:
baabelfish 2016-01-30 20:32:45 +02:00
commit 7953c47a57
16 changed files with 403 additions and 42 deletions

View file

@ -9,12 +9,15 @@ let s:DefinitionImpl = {}
function! s:DefinitionImpl.run(data)
if len(a:data.lines) > 0
let [_, _, _, _, filename, l, c, _] = split(a:data.lines[0], " ")
call util#JumpToLocation(filename, l, c + 2)
let res = util#ParseV1(a:data.lines[0])
call util#JumpToLocation(res.file, res.line, res.col + 1)
else
echohl Comment | echo "Not found"
endif
endfunction
function! features#definition#run()
call util#StartQuery()
call suggest#New("def", 0, s:DefinitionImpl)
endfunction

View file

@ -6,18 +6,67 @@ let s:loaded = 1
let s:InfoImpl = {}
let s:idtypes = {
\ 'skProc': "Function",
\ 'skTemplate': "Template",
\ 'skType': "Type",
\ 'skMacro': "Macro",
\ 'skMethod': "Method",
\ 'skField': "Field",
\ 'skAlias': "Alias",
\ 'skConditional': "Conditional",
\ 'skConst': "Constant",
\ 'skConverter': "Converter",
\ 'skDynLib': "Dynamic library",
\ 'skEnumField': "Enum field",
\ 'skForVar': "Loop variable",
\ 'skGenericParam': "Generic parameter",
\ 'skGlobalVar': "Global variable",
\ 'skGlobalLet': "Global constant",
\ 'skIterator': "Iterator",
\ 'skLabel': "Label",
\ 'skLet': "Runtime constant",
\ 'skModule': "Module",
\ 'skPackage': "Package",
\ 'skParam': "Parameter",
\ 'skResult': "Result",
\ 'skStub': "Stub",
\ 'skTemp': "Temporary",
\ 'skUnknown': "Unknown",
\ 'skVar': "Variable"
\ }
function! s:InfoImpl.run(data)
if len(a:data.lines) == 0
echo "No information found"
else
let [_, ctype, name, type, filename, l, c, doc] = split(a:data.lines[0], " ")
echohl Function | echon "Type"
echohl Comment | echon ": "
echohl Typedef | echon type
echohl None
let [_, ctype, name, type, filename, l, c, doc] = split(a:data.lines[0], "\\t")
let path = join(split(name, '\.')[0:-2], ".")
let module = split(name, '\.')[0]
let name = split(name, '\.')[-1]
let node_type = s:idtypes[ctype]
echohl Function | echon name
echohl Comment | echon "\n » "
echohl Type | echon node_type
if len(type) > 0 && name != type
echon "\n"
echohl Comment | echon " » "
echohl Typedef | echon type
end
echohl Comment | echon "\n » "
echohl Include | echon path
echohl Comment | echon " ("
echohl String | echon filename
echohl Comment | echon ")"
endif
endfunction
function! features#info#run()
call util#StartQuery()
call suggest#New("def", 0, s:InfoImpl)
endfunction

View file

@ -4,37 +4,56 @@ endif
let s:loaded = 1
let s:highlights = -1
let s:UsagesImpl = {}
function! s:UsagesImpl.run(data)
for line in a:data.lines
if len(line) == 0
continue
endif
if s:highlights >= 0
call matchdelete(s:highlights)
end
let s:highlights = -1
let highlights = []
let [ctype, context, fullname, type, filename, line, column, doc, random] = split(line, " ")
if !s:findInProject && filename != expand("%:p")
continue
endif
if len(a:data.lines) < 1
echohl Comment | echo "No usages found"
else
for line in a:data.lines
if len(line) == 0
continue
endif
let module = split(fullname, '\.')[0]
let name = split(fullname, '\.')[-1]
call setqflist([{
\ 'filename': filename,
\ 'lnum': line,
\ 'col': column + 1,
\ 'text': ctype . ": " . name . " (" . fullname . ")"}],
\ 'a')
endfor
copen
nnoremap <buffer><silent> <return> :call util#JumpFromQuickfix(0)<cr>
nnoremap <buffer><silent> o :call util#JumpFromQuickfix(1)<cr>
let res = util#ParseV2(line)
if !s:findInProject && res.file != expand("%:p")
continue
endif
call setqflist([{
\ 'filename': res.file,
\ 'lnum': res.line,
\ 'col': res.col + 1,
\ 'text': res.ctype . ": " . res.name . " (" . res.location . ")"}],
\ 'a')
" call add(highlights, [line, column + 1, len(name)])
endfor
" let s:highlights = matchaddpos("Search", highlights)
copen
nnoremap <buffer><silent> <return> :call util#JumpFromQuickfix(0)<cr>
nnoremap <buffer><silent> o :call util#JumpFromQuickfix(1)<cr>
endif
endfunction
let s:UsagesDefinitionImpl = {}
function! s:UsagesDefinitionImpl.run(data)
let res = util#ParseV1(a:data.lines[0])
call suggest#NewKnown("use", 1, res.file, res.line, res.col + 1, s:UsagesImpl)
endfunction
function! features#usages#run(findInProject)
call util#StartQuery()
cclose
call setqflist([])
let s:findInProject = a:findInProject
call suggest#New("use", 1, s:UsagesImpl)
call suggest#New("def", 0, s:UsagesDefinitionImpl)
endfunction

View file

@ -15,7 +15,7 @@ function! s:NimHighlighter.on_stderr(job, chunk)
endfunction
function! s:NimHighlighter.on_exit()
if self.file != expand("%:p")
if empty(self.lines) && self.file != expand("%:p")
return
endif
let highlights = {
@ -52,7 +52,12 @@ function! s:NimHighlighter.on_exit()
if len(line) == 0
continue
endif
let p = split(line, " ")
if len(p) < 5
continue
endif
let line = p[2] + 0
let c = p[3] + 1
let s = p[4] + 0
@ -90,7 +95,9 @@ endfunction
function! highlighter#guard()
if line("$") + 0 < 500
call highlighter#New()
if g:nvim_nim_enable_highlighter
if line("$") + 0 < 500
call highlighter#New()
endif
endif
endfunction

View file

@ -19,16 +19,20 @@ function! s:NimSuggest.on_stderr()
endfunction
function! s:NimSuggest.on_exit()
call self.handler.run(self)
if len(self.lines) > 0
call self.handler.run(self)
else
echo ""
endif
endfunction
function! suggest#New(command, useV2, handler)
function! suggest#NewKnown(command, useV2, file, line, col, handler)
let result = copy(s:NimSuggest)
let result.lines = []
let result.file = expand("%:p")
let result.file = a:file
let result.tempfile = result.file . ".temp"
let result.line = line(".")
let result.col = col(".")
let result.line = a:line
let result.col = a:col
let result.handler = a:handler
" if a:useTempFile
" call writefile(getline(1, '$'), result.tempfile)
@ -38,3 +42,8 @@ function! suggest#New(command, useV2, handler)
call jobsend(result.job, a:command . " " . result.file . ":" . result.line . ":" . result.col . "\nquit\n")
return result
endfunction
function! suggest#New(command, useV2, handler)
return suggest#NewKnown(a:command, a:useV2, expand("%:p"), line("."), col("."), a:handler)
endfunction

View file

@ -27,7 +27,7 @@ function! util#JumpToLocation(file, line, col)
execute ":e " . a:file
endif
execute ":" . a:line
execute ":norm " . (a:col - 1) . "|"
execute ":norm " . (a:col) . "|"
endfunction
@ -35,8 +35,55 @@ function! util#JumpFromQuickfix(shouldReturn)
let [file, location, _] = split(getline(line(".")), "|")
let [l, c] = split(location, " col ")
wincmd p
call s:JumpToLocation(file, l, c)
call util#JumpToLocation(file, l, c)
if a:shouldReturn
norm zt
wincmd p
endif
endfunction
function! util#StartQuery()
echohl Comment | echo "..."
endfunction
function! util#ParseV1(line)
let res = split(a:line, " ")
let path = split(res[2], "\\.")
let result = {
\ "ctype": res[0],
\ "kind": res[1],
\ "symbol": res[2],
\ "name": res[3],
\ "file": res[4],
\ "line": res[5],
\ "col": res[6],
\ "doc": res[7],
\ "module": join(path[0:-3], "."),
\ "location": join(path[0:-2], "."),
\ "lname": path[-1],
\ }
return result
endfunction
function! util#ParseV2(line)
let res = split(a:line, " ")
let path = split(res[2], "\\.")
let result = {
\ "ctype": res[0],
\ "kind": res[1],
\ "symbol": res[2],
\ "type": res[3],
\ "file": res[4],
\ "line": res[5],
\ "col": res[6],
\ "doc": res[7],
\ "module": join(path[0:-3], "."),
\ "location": join(path[0:-2], "."),
\ "name": path[-1],
\ "lname": path[-1],
\ }
return result
endfunction