From 1bc0ad837790134fad2419c02520af7e2364821d Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 20 May 2022 11:26:05 +0800 Subject: [PATCH] feat(verilog): add code runner for verilog --- autoload/SpaceVim/layers/lang/verilog.vim | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/autoload/SpaceVim/layers/lang/verilog.vim b/autoload/SpaceVim/layers/lang/verilog.vim index bc4e0ad2d..fb6e083f9 100644 --- a/autoload/SpaceVim/layers/lang/verilog.vim +++ b/autoload/SpaceVim/layers/lang/verilog.vim @@ -22,9 +22,42 @@ function! SpaceVim#layers#lang#verilog#plugins() abort return plugins endfunction +" ref: +" https://zhuanlan.zhihu.com/p/95081329 function! SpaceVim#layers#lang#verilog#config() abort + call SpaceVim#plugins#runner#reg_runner('verilog', ['iverilog -o #TEMP# %s', '#TEMP#']) + call SpaceVim#mapping#space#regesit_lang_mappings('verilog', function('s:language_specified_mappings')) +endfunction +function! s:language_specified_mappings() abort + + call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], + \ 'call SpaceVim#plugins#runner#open()', + \ 'execute current file', 1) + if SpaceVim#layers#lsp#check_filetype('verilog') + " \ || SpaceVim#layers#lsp#check_server('clangd') + nnoremap K :call SpaceVim#lsp#show_doc() + + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'call SpaceVim#lsp#show_doc()', 'show_document', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], + \ 'call SpaceVim#lsp#rename()', 'rename symbol', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'x'], + \ 'call SpaceVim#lsp#references()', 'show-references', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'i'], + \ 'call SpaceVim#lsp#go_to_impl()', 'implementation', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'h'], + \ 'call SpaceVim#lsp#show_line_diagnostics()', 'show-line-diagnostics', 1) + let g:_spacevim_mappings_space.l.w = {'name' : '+Workspace'} + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'l'], + \ 'call SpaceVim#lsp#list_workspace_folder()', 'list-workspace-folder', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'a'], + \ 'call SpaceVim#lsp#add_workspace_folder()', 'add-workspace-folder', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'r'], + \ 'call SpaceVim#lsp#remove_workspace_folder()', 'remove-workspace-folder', 1) + + endif endfunction