From 0c4c82e70e6585aef259e0890a50bd900bcdc95a Mon Sep 17 00:00:00 2001 From: baabelfish Date: Thu, 17 Mar 2016 00:13:35 +0200 Subject: [PATCH] Use proper memfiles (max one per buffer) Fix #39 Use tempname when creating temporary files --- autoload/util.vim | 31 +++++++++++++++++-------------- plugin/nim.vim | 6 ++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/autoload/util.vim b/autoload/util.vim index f9bbdd7..2d01cc5 100644 --- a/autoload/util.vim +++ b/autoload/util.vim @@ -54,11 +54,14 @@ endfunction function! util#MemFilePath(file) - return "/tmp/nvimnvimtemp" . substitute(a:file, "\/", "_-_", "g") + if !exists("b:nvim_tmpfile") + let b:nvim_tmpfile = tempname() + endif + return b:nvim_tmpfile endfunction -"" Writes current buffer into a memfile +" Writes current buffer into a memfile function! util#WriteMemfile() let memfile = util#MemFilePath(expand("%:p")) call writefile(getline(1, '$'), memfile) @@ -108,18 +111,18 @@ 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": s:GetModule(path), - \ "location": join(path[0:-2], "."), - \ "lname": path[-1], - \ "kindstr": s:idtypes[res[1]][1], + \ "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": s:GetModule(path), + \ "location": join(path[0:-2], "."), + \ "lname": path[-1], + \ "kindstr": s:idtypes[res[1]][1], \ "kindshort": s:idtypes[res[1]][0], \ } return result diff --git a/plugin/nim.vim b/plugin/nim.vim index 9c4bb68..2e598ce 100644 --- a/plugin/nim.vim +++ b/plugin/nim.vim @@ -105,8 +105,10 @@ if !exists("g:nvim_nim_highlight_builtin") let g:nvim_nim_highlight_builtin = 1 endif -" let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"] -let g:nvim_nim_highlighter_semantics = [] +if !exists("g:nvim_nim_highlighter_semantics") + " let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"] + let g:nvim_nim_highlighter_semantics = [] +endif call highlighter#select_highlights(["skProc", "skTemplate", "skType", "skMacro", "skMethod", "skField", "skForVar", "skIterator"])