Refactor everything to smaller libs
+ autoload
This commit is contained in:
parent
21eb07d075
commit
a8812f5f18
13 changed files with 382 additions and 323 deletions
15
autoload/features/debug.vim
Normal file
15
autoload/features/debug.vim
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
|
||||
function! features#debug#run()
|
||||
echo "Nim tools debugging info"
|
||||
echo "------------------------"
|
||||
echo "\n"
|
||||
echo "-------- Tools ---------"
|
||||
echo "Nim: " . g:nvim_nim_exec_nim
|
||||
echo "Nimble: " . g:nvim_nim_exec_nimble
|
||||
echo "Nimsuggest: " . g:nvim_nim_exec_nimsuggest
|
||||
endfunction
|
||||
20
autoload/features/definition.vim
Normal file
20
autoload/features/definition.vim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
|
||||
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)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! features#definition#run()
|
||||
call suggest#New("def", 0, s:DefinitionImpl)
|
||||
endfunction
|
||||
23
autoload/features/info.vim
Normal file
23
autoload/features/info.vim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
|
||||
let s:InfoImpl = {}
|
||||
|
||||
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 Statement | echon type
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! feature#info#run()
|
||||
call suggest#New("def", 0, s:InfoImpl)
|
||||
endfunction
|
||||
31
autoload/features/outline.vim
Normal file
31
autoload/features/outline.vim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
|
||||
let s:OutlineImpl = {}
|
||||
function! s:OutlineImpl.run(data)
|
||||
for line in a:data.lines
|
||||
if len(line) == 0
|
||||
continue
|
||||
endif
|
||||
let [_, node, fullname, type, filename, line, column, doc, random] = split(line, " ")
|
||||
let name = join(split(fullname, "\\.")[1:], ".")
|
||||
call setqflist([{
|
||||
\ 'filename': filename,
|
||||
\ 'lnum': line,
|
||||
\ 'col': column + 1,
|
||||
\ 'text': node . " : " . name }],
|
||||
\ 'a')
|
||||
endfor
|
||||
copen
|
||||
nnoremap <buffer><silent> <return> :call util#JumpFromQuickfix(0)<cr>
|
||||
nnoremap <buffer><silent> o :call util#JumpFromQuickfix(1)<cr>
|
||||
endfunction
|
||||
|
||||
function! features#outline#run()
|
||||
cclose
|
||||
call setqflist([])
|
||||
call suggest#New("outline", 1, s:OutlineImpl)
|
||||
endfunction
|
||||
41
autoload/features/rename.vim
Normal file
41
autoload/features/rename.vim
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
let s:RenameImpl = {}
|
||||
|
||||
|
||||
function! s:RenameImpl.run(data)
|
||||
if len(a:data.lines) == 1
|
||||
return
|
||||
endif
|
||||
|
||||
let oldName = split(split(util#FirstNonEmpty(a:data.lines), " ")[2], "\\.")[-1]
|
||||
let newName = input("Rename symbol: ", oldName)
|
||||
|
||||
for line in a:data.lines
|
||||
if len(line) == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let [_, _, _, _, filename, line, column, _, _] = split(line, " ")
|
||||
if !s:findInProject && filename != expand("%:p")
|
||||
continue
|
||||
endif
|
||||
|
||||
if filename != expand("%:p")
|
||||
execute ":e " . expand("%:p")
|
||||
endif
|
||||
|
||||
let left = getline(line)[0:column - 1]
|
||||
let right = getline(line)[column + len(oldName):-1]
|
||||
call setline(line, left . newName . right)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
|
||||
function! features#rename#run(inProject)
|
||||
let s:findInProject = a:inProject
|
||||
call suggest#New("use", 1, s:RenameImpl)
|
||||
endfunction
|
||||
43
autoload/features/usages.vim
Normal file
43
autoload/features/usages.vim
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
if exists("s:loaded")
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
|
||||
let s:UsagesImpl = {}
|
||||
|
||||
function! s:UsagesImpl.run(data)
|
||||
for line in a:data.lines
|
||||
if len(line) == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let [ctype, context, fullname, type, filename, line, column, doc, random] = split(line, " ")
|
||||
if !s:findInProject && filename != expand("%:p")
|
||||
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>
|
||||
endfunction
|
||||
|
||||
|
||||
function! features#usages#run(findInProject)
|
||||
cclose
|
||||
call setqflist([])
|
||||
let s:findInProject = a:findInProject
|
||||
call suggest#New("use", 1, s:UsagesImpl)
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue