2

VIM version:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 14 2020 22:03:16)

OS information:

Microsoft Windows 10 Professional version 2004 (OS Version: 10.0.19041)

Problem Description:

I use gvim as text editor for vivado.

vivado setting capture

In Vivado, I click the verilog source file, the gvim will open the verilog file. And I use ALE for syntax checking. Everything else works, except the include statement.

For example:

There are one verilog file ( FileA.v ) and one verilog headerfile ( FileB.vh ) in the theme directory. In FileA.v, I use include:

`include "FileB.vh"

when I click FileA.v in Vivado, gvim is called to open FileA.v, then a syntax error will be reported:

[VRFC 10-3195] cannot open include file 'FileB.vh'

In fact, since FileA.v and FileB.vh is in the same directory, there should be no syntax error. And what puzzles me is that, at this time, resave this file by :w, the error will disappear.

However, close the opened file and click FileA.v in Vivado again, the problem occurs again.

Here is my _vimrc

set nocompatible
set nobackup
set noswapfile
set history=1024
set autochdir
set whichwrap=b,s,<,>,[,]
set nobomb
set backspace=indent,eol,start whichwrap+=<,>,[,]

set clipboard+=unnamed

set winaltkeys=no

set fileencodings=utf-8,gbk2312,gbk,gb18030,cp936
set encoding=utf-8
set langmenu=zh_CN
let $LANG = 'en_US.UTF-8'

colorscheme smyck

source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set cursorline
set hlsearch
set number

set lines=35 columns=140

set splitbelow
set splitright

set guioptions-=T
set guioptions-=m
set guioptions-=L
" set guioptions-=r
set guioptions-=b

set guioptions-=e
set nolist
" set listchars=tab:▶\ ,eol:¬,trail:·,extends:>,precedes:<
set guifont=Consolas:h12:cANSI

set autoindent
set smartindent
set tabstop=4
set expandtab
set softtabstop=4
syntax on

au BufRead,BufNewFile *.vh set filetype=verilog


" Plugins
execute pathogen#infect()

let g:airline#extensions#ale#enabled = 1

" Airline
let g:airline_theme='papercolor'

2
  • Welcome to Vi and Vim! I see you have set autochdir in your vimrc. That setting often doesn't play well with plug-ins (though in this case one might think it could actually help...) Did you try disabling this option and see whether that helps?
    – filbranden
    Commented Sep 27, 2020 at 5:10
  • @filbranden Thanks for your reply. if disable set autochdir, this error will always exist, even after using :w. So I think I can understand why this error occurs. By :ALEInfo I find ale copy current file to a temporary directory, and Vivado's syntax checker xvlog work in this temporary directory, of course it can not find the include file. I think ale's work directory should change to the file directory. I'm new to vim, I don't how to do.
    – panantao
    Commented Sep 27, 2020 at 5:29

1 Answer 1

1

I found a solution.

For example:

I open Vivado at D:\Vivado_Projects\WorkSpace, when I click to open verilog source file in gvim, execute :cd, then I get D:\Vivado_Projects\WorkSpace, so there if include error.

If enable set autochdir, the work directory will change to file location, then include error will disappear after using :w.

Finally I write a batch file to launch gvim:

@echo off

set /a cnt=0

:loop
set /a cnt+=1
for /f tokens^=%cnt%^ delims^=^"\/ %%i in (%1) do (
    if not "%%i"=="" (
        set A=%A%%%i\
        set B=%A%
        goto loop
    ) 
)

cd /d %B%
gvim %1 +%2

Vivado Custom Editor Definition:

"path/to/gvim_for_vivado.cmd" [file name] [line number]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.