parent
44cc3f3e4a
commit
10bd41db5a
3 changed files with 40 additions and 4 deletions
|
|
@ -27,14 +27,14 @@ endfunction
|
|||
function! omni#nimsuggest(file, l, c)
|
||||
let completions = []
|
||||
let tempfile = util#WriteMemfile()
|
||||
|
||||
let query = "sug " . a:file . ";" . tempfile . ":" . a:l . ":" . a:c
|
||||
let jobcmdstr = g:nvim_nim_exec_nimsuggest . " --threads:on --colors:off --compileOnly --experimental --v2 --stdin " . a:file
|
||||
let fullcmd = 'echo -e "' . query . '"|' . jobcmdstr
|
||||
let completions_raw = util#FilterCompletions(split(system(fullcmd), "\n"))
|
||||
|
||||
for line in completions_raw
|
||||
call add(completions, omni#item(util#ParseV2(line)))
|
||||
let parsed = util#ParseV2(line)
|
||||
call add(completions, omni#item(parsed))
|
||||
endfor
|
||||
|
||||
return completions
|
||||
|
|
@ -49,9 +49,27 @@ function! omni#modulesuggest(file, l, c)
|
|||
return completions
|
||||
endfunction
|
||||
|
||||
function! s:findStart()
|
||||
let pos = col(".")
|
||||
let cline = getline(".")
|
||||
|
||||
while pos > 1
|
||||
let ch = char2nr(cline[pos - 2])
|
||||
if !((48 <= ch && ch <= 57)
|
||||
\ || (65 <= ch && ch <= 90)
|
||||
\ || (97 <= ch && ch <= 122)
|
||||
\ || ch == 95)
|
||||
break
|
||||
endif
|
||||
let pos = pos - 1
|
||||
endwhile
|
||||
|
||||
return pos - 1
|
||||
endfunction
|
||||
|
||||
function! omni#nim(findstart, base)
|
||||
if a:findstart && empty(a:base)
|
||||
return col('.')
|
||||
return s:findStart()
|
||||
endif
|
||||
|
||||
let completions = []
|
||||
|
|
|
|||
12
tests/tests/vim/autocomplete.vader
Normal file
12
tests/tests/vim/autocomplete.vader
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Given nim:
|
||||
5.
|
||||
|
||||
Execute:
|
||||
set buftype=
|
||||
saveas! autocomplete.nim
|
||||
|
||||
Do:
|
||||
A\<c-x>\<c-o>\<c-n>\<esc>
|
||||
|
||||
Expect:
|
||||
5.alloc
|
||||
|
|
@ -7,9 +7,15 @@ Given nim:
|
|||
Execute:
|
||||
set buftype=""
|
||||
saveas! vader_workbench.nim
|
||||
w!
|
||||
norm G^
|
||||
NimDefinition
|
||||
|
||||
Then:
|
||||
AssertEqual 2, line(".")
|
||||
|
||||
Do:
|
||||
G^
|
||||
\<c-]>
|
||||
|
||||
Then:
|
||||
AssertEqual 2, line(".")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue