This commit is contained in:
baabelfish 2016-02-10 22:19:23 +02:00
commit 6b16dade7c
20 changed files with 207 additions and 90 deletions

View file

@ -1,7 +1,7 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
function! features#debug#run() function! features#debug#run()
@ -13,3 +13,7 @@ function! features#debug#run()
echo "Nimble: " . g:nvim_nim_exec_nimble echo "Nimble: " . g:nvim_nim_exec_nimble
echo "Nimsuggest: " . g:nvim_nim_exec_nimsuggest echo "Nimsuggest: " . g:nvim_nim_exec_nimsuggest
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,3 +1,9 @@
scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim
let s:edb_terminal_job = -2 let s:edb_terminal_job = -2
let s:NimDebugger = { let s:NimDebugger = {
@ -89,3 +95,7 @@ function! s:ParseTerminal()
echoerr "WAAAT" echoerr "WAAAT"
echoerr &t_RV echoerr &t_RV
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,7 +1,7 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
let s:DefinitionImpl = {} let s:DefinitionImpl = {}
@ -16,3 +16,7 @@ endfunction
function! features#definition#run() function! features#definition#run()
call suggest#New("def", 0, 0, s:DefinitionImpl) call suggest#New("def", 0, 0, s:DefinitionImpl)
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,7 +1,7 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
let s:InfoImpl = {} let s:InfoImpl = {}
@ -56,3 +56,7 @@ endfunction
function! features#info#run() function! features#info#run()
call suggest#New("def", 0, 0, s:New(0)) call suggest#New("def", 0, 0, s:New(0))
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,7 +1,8 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
function! features#outline#renderable(parsed) function! features#outline#renderable(parsed)
return { return {
@ -13,6 +14,7 @@ endfunction
let s:window = -1 let s:window = -1
let s:goto_table = {} let s:goto_table = {}
let s:buffermap = {}
let s:groups = {} let s:groups = {}
let s:group_order = ["Types", "Routines", "Constants", "Globals", "Imports"] let s:group_order = ["Types", "Routines", "Constants", "Globals", "Imports"]
let s:symbols = { let s:symbols = {
@ -62,6 +64,25 @@ function! s:CreateSymbolRow(symbol)
return result return result
endfunction endfunction
function! s:FindClosest()
if len(s:goto_table) == 0
return
endif
echoerr join(sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n"), ", ")
let bline = line(".")
let closest = 1
for l in sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n")
if l < bline
let closest = l
else
break
endif
endfor
echom closest
endfunction
function! s:ConfigureOutlineBuffer() function! s:ConfigureOutlineBuffer()
if s:IsOpen() if s:IsOpen()
return return
@ -101,6 +122,7 @@ endfunction
function! s:UpdateOutline(groups) function! s:UpdateOutline(groups)
let s:goto_table = {} let s:goto_table = {}
let s:buffermap = {}
let s:groups = a:groups let s:groups = a:groups
call s:ConfigureOutlineBuffer() call s:ConfigureOutlineBuffer()
call s:RenderOutline() call s:RenderOutline()
@ -109,11 +131,17 @@ endfunction
function! s:RenderOutline() function! s:RenderOutline()
let wasFocused = s:IsFocused() let wasFocused = s:IsFocused()
call s:FindClosest()
call s:Focus() call s:Focus()
if !s:IsFocused() if !s:IsFocused()
return return
endif endif
let l = line(".")
let c = line(".")
let w0 = line("w0")
exec "silent vertical resize " . g:nvim_nim_outline_buffer_width exec "silent vertical resize " . g:nvim_nim_outline_buffer_width
let rlines = [] let rlines = []
@ -127,6 +155,7 @@ function! s:RenderOutline()
for symbol in s:groups[groupname] for symbol in s:groups[groupname]
let s:goto_table[len(rlines) + 1] = [symbol.line, symbol.col] let s:goto_table[len(rlines) + 1] = [symbol.line, symbol.col]
let s:goto_table[symbol.line] = [len(rlines) + 1]
call add(rlines, s:CreateSymbolRow(symbol)) call add(rlines, s:CreateSymbolRow(symbol))
endfor endfor
call add(rlines, "") call add(rlines, "")
@ -140,6 +169,11 @@ function! s:RenderOutline()
exec ":" . len(rlines) exec ":" . len(rlines)
normal! dG normal! dG
call cursor(w0, 1)
normal zt
call cursor(l, 2)
if !wasFocused if !wasFocused
wincmd p wincmd p
endif endif
@ -195,3 +229,6 @@ function! features#outline#run(isUpdating)
endif endif
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,7 +1,8 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
let s:RenameImpl = {} let s:RenameImpl = {}
@ -36,3 +37,7 @@ function! features#rename#run(inProject)
call suggest#New("use", 0, 1, s:RenameImpl) call suggest#New("use", 0, 1, s:RenameImpl)
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,7 +1,8 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
let s:repl_pid = -1 let s:repl_pid = -1
let s:repl_window = -1 let s:repl_window = -1
@ -65,3 +66,7 @@ function! features#repl#stop()
echom "No REPL running" echom "No REPL running"
endif endif
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,7 +1,7 @@
if exists("s:loaded") scriptencoding utf-8
finish
endif let s:save_cpo = &cpo
let s:loaded = 1 set cpo&vim
let s:highlights = -1 let s:highlights = -1
@ -56,3 +56,7 @@ function! features#usages#run(findInProject)
call suggest#New("def", 0, 1, s:UsagesDefinitionImpl) call suggest#New("def", 0, 1, s:UsagesDefinitionImpl)
endfunction endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if exists("s:loaded") if exists("s:loaded")
finish finish
endif endif

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if exists("s:loaded") if exists("s:loaded")
finish finish
endif endif

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if exists("s:loaded") if exists("s:loaded")
finish finish
endif endif

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if exists("s:loaded") if exists("s:loaded")
finish finish
endif endif

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if exists("s:loaded") if exists("s:loaded")
finish finish
endif endif
@ -95,7 +98,7 @@ endfunction
function! util#StartQuery() function! util#StartQuery()
echohl Comment | echo "..." " echohl Comment | echo "..."
endfunction endfunction

View file

@ -1,7 +1,2 @@
if exists("g:nvim_nim_ftdetect_loaded") scriptencoding utf-8
finish au BufNewFile,BufRead *.nims,*.nim setlocal filetype=nim
endif
let g:nvim_nim_ftdetect_loaded = 1
au BufNewFile,BufRead *.nim setlocal filetype=nim
au BufNewFile,BufRead *.nims setlocal filetype=nims

View file

@ -1,7 +1,5 @@
if exists("b:loaded") scriptencoding utf-8
finish
endif
let b:loaded = 1
setlocal iskeyword=a-z,A-Z,48-57,128-255,_ setlocal iskeyword=a-z,A-Z,48-57,128-255,_
setlocal formatoptions-=t formatoptions+=l setlocal formatoptions-=t formatoptions+=l
@ -16,41 +14,54 @@ setlocal errorformat=
\%E%f(%l\\,\ %c)\ Error:\ %m, \%E%f(%l\\,\ %c)\ Error:\ %m,
\%W%f(%l\\,\ %c)\ Warning:\ %m \%W%f(%l\\,\ %c)\ Warning:\ %m
command! NimDefinition :call features#definition#run() command! -buffer -nargs=* -complete=buffer NimDefinition :call features#definition#run()
command! NimInfo :call features#info#run() command! -buffer -nargs=* -complete=buffer NimInfo :call features#info#run()
command! NimWeb :call features#info#web() command! -buffer -nargs=* -complete=buffer NimWeb :call features#info#web()
command! NimUsages :call features#usages#run(0) command! -buffer -nargs=* -complete=buffer NimUsages :call features#usages#run(0)
command! NimUsagesProject :call features#usages#run(1) command! -buffer -nargs=* -complete=buffer NimUsagesProject :call features#usages#run(1)
command! NimRenameSymbol :call features#rename#run(0) command! -buffer -nargs=* -complete=buffer NimRenameSymbol :call features#rename#run(0)
command! NimRenameSymbolProject :call features#rename#run(1) command! -buffer -nargs=* -complete=buffer NimRenameSymbolProject :call features#rename#run(1)
command! NimDebug :call features#debug#run() command! -buffer -nargs=* -complete=buffer NimDebug :call features#debug#run()
command! NimOutline :call features#outline#run(0) command! -buffer -nargs=* -complete=buffer NimOutline :call features#outline#run(0)
command! NimEdb :call features#debugger#run() command! -buffer -nargs=* -complete=buffer NimEdb :call features#debugger#run()
command! NimEdbStop :call features#debugger#stop() command! -buffer -nargs=* -complete=buffer NimEdbStop :call features#debugger#stop()
command! NimEdbContinue :call features#debugger#continue() command! -buffer -nargs=* -complete=buffer NimEdbContinue :call features#debugger#continue()
command! NimEdbStepInto :call features#debugger#stepinto() command! -buffer -nargs=* -complete=buffer NimEdbStepInto :call features#debugger#stepinto()
command! NimEdbStepOver :call features#debugger#stepover() command! -buffer -nargs=* -complete=buffer NimEdbStepOver :call features#debugger#stepover()
command! NimEdbSkipCurrent :call features#debugger#skipcurrent() command! -buffer -nargs=* -complete=buffer NimEdbSkipCurrent :call features#debugger#skipcurrent()
command! NimEdbIgonore :call features#debugger#ignore() command! -buffer -nargs=* -complete=buffer NimEdbIgonore :call features#debugger#ignore()
command! NimEdbContinue :call features#debugger#continue() command! -buffer -nargs=* -complete=buffer NimEdbContinue :call features#debugger#continue()
command! NimEdbToggleBP :call features#debugger#togglebp() command! -buffer -nargs=* -complete=buffer NimEdbToggleBP :call features#debugger#togglebp()
command! NimREPL :call features#repl#start() command! -buffer -nargs=* -complete=buffer NimREPL :call features#repl#start()
command! NimREPLEvalFile :call features#repl#send(getline(0, line("$"))) command! -buffer -nargs=* -complete=buffer NimREPLEvalFile :call features#repl#send(getline(0, line("$")))
command! -range NimREPLEval :call features#repl#send(getline(getpos("'<")[1], getpos("'>")[1])) command! -buffer -nargs=* -complete=buffer -range NimREPLEval :call features#repl#send(getline(getpos("'<")[1], getpos("'>")[1]))
nnoremap <buffer> <c-]> :NimDefinition<cr> if exists('g:nvim_nim_enable_default_binds')
nnoremap <buffer> gd :NimDefinition<cr> nnoremap <buffer> <c-]> :NimDefinition<cr>
nnoremap <buffer> gt :NimInfo<cr> nnoremap <buffer> gd :NimDefinition<cr>
nnoremap <buffer> gT :NimWeb<cr> nnoremap <buffer> gt :NimInfo<cr>
nnoremap <buffer> gT :NimWeb<cr>
endif
onoremap <silent>af :<C-U>call util#SelectNimProc(0)<CR> if exists('g:nvim_nim_enable_custom_textobjects')
onoremap <silent>if :<C-U>call util#SelectNimProc(1)<CR> onoremap <buffer> <silent>af :<C-U>call util#SelectNimProc(0)<CR>
vnoremap <silent>af :<C-U>call util#SelectNimProc(0)<CR><Esc>gv onoremap <buffer> <silent>if :<C-U>call util#SelectNimProc(1)<CR>
vnoremap <silent>if :<C-U>call util#SelectNimProc(1)<CR><Esc>gv vnoremap <buffer> <silent>af :<C-U>call util#SelectNimProc(0)<CR><Esc>gv
vnoremap <buffer> <silent>if :<C-U>call util#SelectNimProc(1)<CR><Esc>gv
endif
autocmd! BufReadPost,BufWritePost,CursorHold,InsertLeave,TextChanged,InsertEnter *.nim call highlighter#guard() augroup nvim_nim_highlighter
autocmd! CursorHold,BufWritePost,FileWritePost *.nim call features#outline#run(1) autocmd! BufReadPost,BufWritePost,CursorHold,InsertLeave,TextChanged,InsertEnter *.nim call highlighter#guard()
autocmd! VimResized,WinEnter * call features#outline#render() augroup END
call highlighter#guard()
augroup nvim_nim_outline
" autocmd! CursorHold,BufWritePost,FileWritePost *.nim call features#outline#run(1)
autocmd! CursorHold,FileWritePost *.nim call features#outline#run(1)
autocmd! VimResized,WinEnter * call features#outline#render()
augroup END
if g:nvim_nim_highlighter_enable
call highlighter#guard()
endif

View file

@ -1,3 +1,6 @@
" scriptencoding utf-8
"
"
" if exists("b:loaded") " if exists("b:loaded")
" finish " finish
" endif " endif

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if has('nvim') if has('nvim')
runtime! plugin/python_setup.vim runtime! plugin/python_setup.vim
endif endif

View file

@ -1,8 +1,13 @@
if exists("g:nvim_nim_loaded") scriptencoding utf-8
if exists("g:loaded_nvim_nim")
finish finish
endif endif
let g:nvim_nim_loaded = 1 let g:loaded_nvim_nim = 1
let s:save_cpo = &cpo
set cpo&vim
function! CheckDependency(command) function! CheckDependency(command)
if !executable(a:command) if !executable(a:command)
@ -46,7 +51,13 @@ let g:nvim_nim_outline_buffer_width = 30
let g:nvim_nim_repl_height = 14 let g:nvim_nim_repl_height = 14
let g:nvim_nim_repl_vsplit = 0 let g:nvim_nim_repl_vsplit = 0
let g:nvim_nim_enable_default_binds = 1
let g:nvim_nim_enable_custom_textobjects = 1
let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"] let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"]
au BufNewFile,BufRead *.nim setlocal filetype=nim au BufNewFile,BufRead *.nim setlocal filetype=nim
au BufNewFile,BufRead *.nims setlocal filetype=nims au BufNewFile,BufRead *.nims setlocal filetype=nims
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -1,3 +1,6 @@
scriptencoding utf-8
if exists("b:current_syntax") if exists("b:current_syntax")
finish finish
endif endif

View file

@ -1,5 +1,8 @@
scriptencoding utf-8
syntax keyword nimoTypes Types syntax keyword nimoTypes Types
syntax keyword nimoCallables Callables syntax keyword nimoCallables Routines
syntax keyword nimoConstants Constants syntax keyword nimoConstants Constants
syntax keyword nimoGlobals Globals syntax keyword nimoGlobals Globals
syntax keyword nimoImports Imports syntax keyword nimoImports Imports