Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions autoload/nim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,29 @@ fun! NimComplete(findstart, base)
if b:nim_caas_enabled == 0
return -1
endif
let curcol = col('.')

if a:findstart
if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment'
return -1
endif
return col('.')

let curline = getline(line('.'))
return curcol - match(reverse(split(curline, '\zs')), '\W') - 1
else
let result = []
let sugOut = NimExec("--suggest")
let baselen = len(a:base)

for line in split(sugOut, '\n')
let lineData = split(line, '\t')
if len(lineData) > 0 && lineData[0] == "sug"
let kind = get(g:nim_symbol_types, lineData[1], '')
let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 }
call add(result, c)
let word = lineData[2]
if a:base ==# word[: baselen - 1] || baselen == 0
let kind = get(g:nim_symbol_types, lineData[1], '')
let c = {'word': word, 'kind': kind, 'menu': lineData[3], 'dup': 1}
call add(result, c)
endif
endif
endfor
return result
Expand Down