neoformat icon indicating copy to clipboard operation
neoformat copied to clipboard

tmp_file_path is empty.

Open haoyun opened this issue 3 years ago • 0 comments

I was trying to use tsmft:

  let g:neoformat_enabled_typescript = ['tsfmt']
  let g:neoformat_verbose = 1

I got the following error:

Neoformat: ./node_modules/.bin/tsfmt --replace --baseDir=src 2>                                           
Neoformat: using tmp file                                                                                 
Error detected while processing function neoformat#Neoformat[5]..<SNR>187_neoformat:                      
line   77:                                                                                                
E482: Can't open file with an empty name

With some research, I found that the tmp_file_path in https://github.com/sbdchd/neoformat/blob/a75d96054618c47fbafef964d4d705525e8e37b9/autoload/neoformat.vim#L286-L294 that is used in https://github.com/sbdchd/neoformat/blob/a75d96054618c47fbafef964d4d705525e8e37b9/autoload/neoformat.vim#L95 is empty.

The path is defined in https://github.com/sbdchd/neoformat/blob/a75d96054618c47fbafef964d4d705525e8e37b9/autoload/neoformat.vim#L262

I know almost nothing about vimscript, but I suppose that the value of expand(tmp_dir . '/' . fnameescape(filename)) should be /tmp/neoformat/<filename> instead of nothing. But with echom expand(tmp_dir . '/' . fnameescape(filename)), I found that its value is actually empty. After changing it to

 let path = !using_stdin ? tmp_dir . '/' . fnameescape(filename) : '' 

The error disappeared.

I am not sure if I was doing something wrong or if there is a tiny bug here.

haoyun avatar Mar 28 '21 11:03 haoyun