vhda / verilog_systemverilog.vim

Verilog/SystemVerilog Syntax and Omni-completion
360 stars 87 forks source link

SyntaxComplete of Verilog / SystemVerilog Keywords #171

Closed henry-hsieh closed 5 years ago

henry-hsieh commented 5 years ago

Vim has provided the syntax completion. Howerver, it uses omnifunc to complete SystemVerilog keywords, which conflict with this repo. My solution is adding SystemVerilog keywords to dictionaray and using dictionaray completion. Do you have better idea of this?

vhda commented 5 years ago

Maybe you could set 'completefunc' instead and use i_CTRL-X_CTRL-U when you want to use that second plugin? Or even better, the Supertab plugin includes a completion chaining option:

set completefunc=syntaxcomplete#Complete
autocmd FileType verilog_systemverilog
  \ if &omnifunc != '' |
  \   call SuperTabChain(&omnifunc, "<c-u>") |
  \ endif

I have to be honest though, I tried this and it didn't work in a verilog_systemverilog FileType file, so it is possible something in my syntax makes it incompatible.

henry-hsieh commented 5 years ago

I use completefunc in replacement of omnifunc and use following vim script:

set completefunc=syntaxcomplete#Complete
let g:omni_syntax_group_include_verilog_systemverilog = 'verilog\w\+'

Because syntax group name of verilog_systemverilog are beginning with verilog, e.g., verilogStatement, you need to set g:omni_syntax_groupinclude{filetype} beginning with verilog.

However, using Supertab will cause some problems. Using another key mapping or dictionary completion may be a better solution.

vhda commented 5 years ago

Did you end up choosing any solution that you might want to share for other people to use?

henry-hsieh commented 5 years ago

I think dictionary completion is a good solution. Add following statement in .vimrc to enable dictionary completion.

autocmd FileType verilog_systemverilog set dictionary+=~/.vim/dict/verilog_systemverilog_keyword
autocmd FileType verilog_systemverilog set dictionary+=~/.vim/dict/verilog_systemverilog_system
autocmd FileType verilog_systemverilog set dictionary+=~/.vim/dict/verilog_systemverilog_directive
autocmd FileType verilog_systemverilog set dictionary+=~/.vim/dict/verilog_systemverilog_synopsys
autocmd FileType verilog_systemverilog set iskeyword+=36

The contents of these files are very simple. default

vhda commented 5 years ago

Thanks for sharing!

flyxia624 commented 10 months ago

@henry-hsieh ,can you share the 4 dictionary files with me ,greatly appreciate crystallang624@gmail.com