This commit is contained in:
fengbh 2025-04-18 12:07:23 +08:00
commit 2fd2f2516a
5 changed files with 536 additions and 0 deletions

387
.vimrc Normal file
View File

@ -0,0 +1,387 @@
" File : .vimrc
" Project : Your Project
" License : MIT
" Author : Feng Bohan <1953356163@qq.com>
" Date : 2025-04-18 08:39:57
" Last Modified Date: 2025-04-18 08:54:03
" Last Modified By : Feng Bohan <1953356163@qq.com>
" File : .vimrc
" Author : Feng Bohan <fengbohan@fmsh.com.cn>
" Date : 2025-04-17 21:46:23
" Last Modified Date: 2025-04-18 08:35:09
" Last Modified By : Feng Bohan <fengbohan@fmsh.com.cn>
" Copyright © 2025 Shanghai Fudan Microelectronics Group Co.,Ltd. All Rights Reserved.
" 环境检测
function! IsAtCompany()
" 检查 baidu.com 是否能解析
let l:cmd = 'nslookup baidu.com >/dev/null 2>&1'
" 执行命令,返回 0 表示解析成功(不在公司),非 0 表示解析失败(在公司)
if system(l:cmd) == 0
return 0 " 能解析,不在公司
else
return 1 " 不能解析,在公司
endif
endfunction
" 只在 Vim 启动时检测一次
if !exists('g:is_at_company')
let g:is_at_company = IsAtCompany()
endif
" 使用时直接判断
if g:is_at_company
" 公司配置
echo "🏢 公司模式已开启"
else
" 个人配置
echo "🏠 个人模式已开启"
endif
command! RefreshNetworkStatus let g:is_at_company = IsAtCompany() |
\ echo (g:is_at_company ? '🏢 切换到公司配置' : '🏠 切换到个人配置')
" 基础配置
let mapleader = ','
let maplocalleader = ',,'
set number " 显示行号
set relativenumber " 显示相对行号
set incsearch " 实时开启搜索高亮
set hlsearch " 搜索结果高亮
set autoindent " 自动缩进
set nosmartindent " 关闭智能缩进
set tabstop=4 " 设置tab制表符号所占宽度为4
set softtabstop=4 " 设置按tab时缩进宽度为4
set shiftwidth=4 " 设置自动缩进宽度为4
set expandtab " 缩进时将tab制表服转为空格
set smartcase " 开启智能大小写查找
set encoding=utf-8 " Use UTF-8.
set showcmd " Display incomplete commands.
set clipboard=unnamedplus " 开启系统剪切板
set cursorline " 高亮当前行
set ignorecase " 设置忽略大小写
set smartcase " 设置智能大小写
set ruler " 设置显示当前位置
" set autoread
filetype on " 开启文件类型检测
filetype plugin indent on " 开启文件类型插件检测
syntax on " 开启语法高亮
"外观设置
set guifont=JetBrainsMono\ Nerd\ Font\ Bold\ 16
"set guifont=FiraCode\ Nerd\ Font\ Mono\ Bold\ 16
set backspace=2 " 允许退格删除缩进、换行符和插入模式前的字符 "
set laststatus=2 " 启动显示状态行
set t_Co=256 " 开启256色支持
highlight Function cterm=bold,underline ctermbg=red ctermfg=green "color set
"屏蔽相关功能设置
set nocompatible " 不兼容vi
set noerrorbells " 不让vim发出讨厌的滴滴声
set shortmess=ati " 启动的时候不显示那个援助索马里儿童的提示
set novisualbell " 不要闪烁
" 关闭各种按键叮叮声音和闪屏
set vb t_vb=
au GuiEnter * set t_vb=
"禁止相关文件的产生
set noundofile " 禁止un~文件
set nobackup " 禁止~文件
set noswapfile " 禁止swp文件
" 按键映射
inoremap jk <ESC>g,
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
"设置bffer的切换 使用 Ctrl J、K、H切换或者删除{{{
"切换buffer以及删除buffer
nnoremap <C-j> :bn<CR>
nnoremap <C-k> :bp<CR>
nnoremap <C-h> :bwipe<CR>
map <C-L> <Esc>:set guifont=Monospace\ 16<Enter>
map <C-M> <Esc>:set guifont=Monospace\ 14<Enter>
" 特殊配置
let g:polyglot_disabled = ['verilog_systemverilog']
" 插件管理
call plug#begin()
Plug 'vhda/verilog_systemverilog.vim'
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'preservim/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'Yggdroot/indentLine'
Plug 'luochen1990/rainbow'
Plug 'dense-analysis/ale'
Plug 'godlygeek/tabular'
Plug 'itchyny/vim-cursorword'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'mhinz/vim-startify'
Plug 'HonkW93/automatic-verilog'
Plug 'preservim/nerdcommenter'
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'tomasr/molokai'
Plug 'w0ng/vim-hybrid'
Plug 'joshdick/onedark.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-endwise'
Plug 'kshenoy/vim-signature'
Plug 'SirVer/ultisnips'
Plug 'keelii/vim-snippets'
Plug 'junegunn/vim-easy-align'
Plug 'tpope/vim-surround'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-repeat'
Plug 'alpertuna/vim-header'
call plug#end()
"=============================================================================
" configure for verilog_systemverilog
"=============================================================================
"Syntax folding
"To enable syntax folding set the following option:
"set foldmethod=syntax
"This plugin includes the errorformat configurations for the following Verilog tools:
" Synopsys VCS (vcs)
" Mentor Modelsim (msim)
" Icarus Verilog (iverilog)
" GPL Cver (cver)
" Synopsys Leda (leda)
" Verilator (verilator)
" Cadence NCVerilog (ncverilog)
"the second argument disables the detection of lint messages.
" 1:All messages are detected.
" 2:Ignore lint messages.
" 3:Ignore lint and warning messages.
autocmd FileType verilog_systemverilog silent :VerilogErrorFormat vcs 2
autocmd FileType verilog_systemverilog let &makeprg='vlogan +v2k -full64 +vcs+flush+all +lint=all -sverilog +libext+.v+.sv -q %'
autocmd BufWritePost * if &filetype == "verilog_systemverilog" | exec ":make" | endif
"Following an Instance
"A framework is provided to follow a module instance to its module declaration as long as its respective entry exists in the tags file. To do so simply execute within the instance to follow it to its declaration.:VerilogFollowInstance
"Alternatively, if the cursor is placed over a port of the instance the command can be used to navigate to the module declaration and immediately searching for that port.:VerilogFollowPort
nnoremap <leader>i :VerilogFollowInstance<CR>
nnoremap <leader>I :VerilogFollowPort<CR>
"Jump to start of current instance
"The command is provided to move the cursor to the start of the first module instantiation that precedes the current cursor location.:VerilogGotoInstanceStart
nnoremap <leader>u :VerilogGotoInstanceStart<CR>
"=============================================================================
" configure for deoplete
"=============================================================================
let g:deoplete#enable_at_startup = 1
" 选择方法:
"<Up> / <Down> 或 <C-p> / <C-n>:上下移动选择候选项目
"<C-y>:确认选中当前高亮的候选项
"<C-e>:关闭补全菜单而不选择
"=============================================================================
" configure for nerdtree
"=============================================================================
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
let g:NERDTreeFileLines = 1 " 显示行号
let NERDTreeShowHidden=1 " 设置显示隐藏文件
" 设置忽略的文件
let NERDTreeIgnore=[
\ '\.git$','\.svn$','\.DS_Store$'
\ ]
"=============================================================================
" configure for indentLine
"=============================================================================
let g:vim_json_conceal=0
let g:markdown_syntax_conceal=0
"=============================================================================
" configure for rainbow
"=============================================================================
"0 if you want to enable it later via :RainbowToggle"
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody',
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'css': 0,
\ 'nerdtree': 0,
\ }
\}
"=============================================================================
" configure for ale
"=============================================================================
let g:ale_cache_executable_check_failures=1
" ==================== ALE 异步语法检查配置 ====================
" 1. 基础设置
let g:ale_enabled = 1 " 启用ALE
let g:ale_lint_on_enter = 1 " 打开文件时立即检查
let g:ale_lint_on_save = 1 " 保存时检查
let g:ale_lint_on_text_changed = 'normal' " 普通模式下文本改变时检查
let g:ale_open_quickfix = 0 " 不自动打开quickfix窗口
" 2. 错误提示样式
let g:ale_sign_error = '>>' " 错误标志
let g:ale_sign_warning = '--' " 警告标志
highlight link ALEErrorSign Error " 错误标志颜色
highlight link ALEWarningSign WarningMsg " 警告标志颜色
" 3. 状态栏集成 (Airline/lightline)
let g:airline#extensions#ale#enabled = 1 " 启用Airline集成
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok'] " 自定义状态栏显示
" 4. 针对Verilog/SystemVerilog的特定配置
let b:ale_linters = ['xvlog', 'iverilog', 'verilator'] " 推荐添加verilator
let b:ale_verilog_iverilog_options = '-g2012' " 设置IEEE 1800-2012标准
" 5. 快速修复配置
let g:ale_set_quickfix = 1 " 使用quickfix列表
let g:ale_set_loclist = 0 " 禁用loclist
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' " 消息格式
" 6. 自定义状态栏函数 (更简洁的实现)
function! LinterStatus() abort
let l:counts = ale#statusline#Count(bufnr(''))
return l:counts.total == 0 ? '✓' : printf('%d⚠ %d⨉', l:counts.warning + l:counts.style_warning, l:counts.error)
endfunction
set statusline+=%{LinterStatus()} " 添加到状态栏
" 快速跳转错误
nmap <silent> <Leader>e <Plug>(ale_next_wrap)
nmap <silent> <Leader>E <Plug>(ale_previous_wrap)
" 查看错误详情
nnoremap <Leader>d :ALEDetail<CR>
" 为了优化性能
let g:ale_pattern_options = {
\ '\.v$': {'ale_enabled': 1},
\ '\.sv$': {'ale_enabled': 1},
\ '.*': {'ale_enabled': 0}
\ }
"=============================================================================
" configure for tabular
"=============================================================================
vnoremap <C-w> :Tab /
"=============================================================================
" configure for airline
"=============================================================================
let g:airline#extensions#tabline#enabled = 1 " 设置开启tab样式
let g:airline#extensions#tabline#formatter = 'jsformatter' " 设置默认tab栏样式
let g:airline#extensions#tabline#buffer_idx_mode = 1 " 显示buffer number "
let g:airline#extensions#whitespace#enabled = 0 " 清楚traling的警告 "
let g:airline_left_sep = '►'
let g:airline_left_alt_sep = '>'
let g:airline_right_sep = '◄'
let g:airline_right_alt_sep = '<'
" airline-theme
let g:airline_theme='solarized'
"=============================================================================
" configure for NERDCommenterToggle
"=============================================================================
nmap <BS> <plug>NERDCommenterToggle
vmap <BS> <plug>NERDCommenterToggle
"=============================================================================
" configure for theme
"=============================================================================
"colorscheme hybrid
"colorscheme molokai
colorscheme onedark
set background=dark
"=============================================================================
" configure for ultisnips
"=============================================================================
" Trigger configuration. You need to change this to something other than <tab> if you use one of the following:
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
"=============================================================================
" configure for EasyAlign
"=============================================================================
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
cnoremap <C-a> EasyAlign
"=============================================================================
" configure for repeat
"=============================================================================
silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)
"=============================================================================
" configure for vim-header
"=============================================================================
" 启用自动插入(新建文件时)
let g:header_auto_add_header = 1
let g:header_auto_update_header = 1
"let g:header_field_project = 'Your Project'
let g:header_field_filename_path = 0
let g:header_field_last_separator = 1
" 文件类型黑名单(不自动插入的文件类型)
let g:header_field_autocmd_blacklist = ['markdown', 'json']
let g:header_field_author = 'Feng Bohan'
let g:header_field_timestamp_format = '%Y-%m-%d %H:%M:%S'
if g:is_at_company
let g:header_field_author_email = 'fengbohan@fmsh.com.cn'
let g:header_field_company = 'Shanghai Fudan Microelectronics Group Co.,Ltd' " 新增公司字段
let g:header_field_copyright = 'Copyright © '.strftime('%Y').' '.g:header_field_company.'. All Rights Reserved.'
else
let g:header_field_author_email = '1953356163@qq.com'
let g:header_field_license_id = 'MIT'
let g:header_field_copyright = 'Copyright © '.strftime('%Y').' '.g:header_field_author.'. All Rights Reserved.'
endif
map <F4> :AddHeader<CR>
"=============================================================================
" other configure
"=============================================================================

17
ReadMe.md Normal file
View File

@ -0,0 +1,17 @@
# 快速上手
请把下面的代码添加到你的`.bashrc`
```bash
# ~/.bashrc (用户实际使用的文件)
# 1. 加载公共配置
if [ -f ~/.bashrc_common ]; then
source ~/.bashrc_common
fi
# 2. 加载主机特定配置(根据主机名自动选择)
HOSTNAME=$(hostname -s) # 获取主机名
HOST_RC="$HOME/.bashrc_$HOSTNAME"
if [ -f "$HOST_RC" ]; then
source "$HOST_RC"
fi```

26
bash/bashrc_common Normal file
View File

@ -0,0 +1,26 @@
alias e='gvim ~/.bashrc'
alias s='source ~/.bashrc'
alias eg='gvim ~/.vimrc'
#******************** set prompt ********************
free_mem()
{
free -m | awk 'NR==2{printf "%.2fG", $4/1024}'
}
w5(){
current_dir=$(pwd)
IFS='/' read -r -a dir_array <<< "$current_dir"
array_length=${#dir_array[@]}
if [ $array_length -gt 5 ]; then
start_index=$((array_length - 5))
short_path="/"
for (( i=$start_index; i<$array_length; i++ )); do
short_path+="${dir_array[i]}/"
done
echo "${short_path%?}"
else
echo "$current_dir"
fi
}
export PS1="[\[\e[01;32m\]\u@\h\[\e[00m\]-\t \$(free_mem)]:\[\e[01;34m\]\$(w5)\[\e[00m\]\$ "

View File

@ -0,0 +1,72 @@
#========================================
# add FPGA
#========================================
alias vivado2018='source /tools/Xilinx/2018.3/Vivado/2018.3/settings64.sh'
#========================================
# add Synopsys
#========================================
export VCS_HOME=/tools/Synopsys/2018/vcs-mx/O-2018.09-SP2
export VCS_MX_HOME=/tools/Synopsys/2018/vcs-mx/O-2018.09-SP2
export LD_LIBRARY_PATH=/tools/Synopsys/2018/verdi/Verdi_O-2018.09-SP2/share/PLI/VCS/LINUX64
export VERDI_HOME=/tools/Synopsys/2018/verdi/Verdi_O-2018.09-SP2
export SCL_HOME=/tools/Synopsys/2018/scl/2018.06
PATH=$PATH:$VCS_MX_HOME/bin
PATH=$PATH:$VERDI_HOME/bin
PATH=$PATH:$SCL_HOME/linux64/bin
PATH=$PATH:/opt/jetBrans/clion-2024.3.4/bin
export VCS_ARCH_OVERRIDE=linux64
#LICENCE
export LM_LICENSE_FILE=27000@fengbh-MS-7B89
alias lmg="lmgrd -c /tools/Synopsys/2018/scl/2018.06/admin/license/Synopsys.dat"
export http_proxy='http://192.168.3.7:7890'
export https_proxy='http://192.168.3.7:7890'
alias mWork='sudo mount -t nfs 192.168.3.7:/volume2/work /home/fengbh/nasWork'
alias mNas='sudo mount -t nfs 192.168.3.7:/volume3/pt_data /home/fengbh/docker/disk/pt_data'
PATH=$PATH:/home/fengbh/local/sdcc-4.4.0-rc2/bin
PATH=$PATH:/home/fengbh/local/verible/bin
PATH=/home/fengbh/local/vim/bin:$PATH
PATH=/home/fengbh/work/verilator/bin:$PATH
#******************** 一些函数 ********************
set_vnc(){
cvt_2556_1334=$(cvt 2560 1334 60 | awk 'NR==2' | sed 's/Modeline //')
cvt_2556_1334_name=$(cvt 2560 1334 60 | awk 'NR==2' | sed 's/Modeline \(\S\+\) .*/\1/')
if xrandr | grep -q $cvt_2556_1334_name; then
echo "The cvt_2556_1334 is already exists."
else
xrandr --newmode $cvt_2556_1334
xrandr --addmode HDMI-A-1 $cvt_2556_1334_name
xrandr --output HDMI-A-1 --mode $cvt_2556_1334_name
echo "Finish set cvt_2556_1334."
fi
}
set_ssh(){
# 检查SSH相关的环境变量是否存在
if [ -n "$SSH_TTY" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ]; then
echo "这是一个SSH远程会话。"
# 获取SSH连接的客户端IP地址
SSH_CLIENT_IP=$(echo $SSH_CLIENT | awk '{print $1}')
# 检查SSH_CLIENT变量是否存在以防脚本不是通过SSH启动的
if [ -z "$SSH_CLIENT_IP" ]; then
echo "未检测到SSH客户端IP可能不是通过SSH登录。"
else
echo "SSH客户端IP地址: $SSH_CLIENT_IP"
if [[ "$ip_address" == "192.168.3.7" ]]; then
echo "这是经过nas中转的登录不会设置DISPLAY"
else
# 设置DISPLAY变量以便可以远程显示图形界面应用
export DISPLAY="$SSH_CLIENT_IP:0.0"
echo "DISPLAY变量已设置为: $DISPLAY"
fi
fi
else
echo "这不是一个SSH远程会话。"
fi
}

34
setup.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# File : setup.sh
# License : MIT
# Author : Feng Bohan <1953356163@qq.com>
# Date : 2025-04-18 09:02:16
# Last Modified Date: 2025-04-18 11:47:01
# Last Modified By : Feng Bohan <1953356163@qq.com>
# -----
# Copyright © 2025 Feng Bohan. All Rights Reserved.
echo "开始配置VIM"
# 链接配置文件
ln -sf ~/dotfiles/vim/.vimrc ~/.vimrc
# 安装 Vim-Plug如未安装
if [ ! -f ~/.vim/autoload/plug.vim ]; then
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
# 安装插件
vim -c "PlugInstall | q | q"
echo "开始配置bashrc"
# 创建符号链接
ln -sf "$PWD/bash/bashrc_common" ~/.bashrc_common
# 根据当前主机名链接对应的配置
HOSTNAME=$(hostname -s)
ln -sf "$PWD/bash/bashrc_$HOSTNAME" ~/.bashrc_host
# 提示用户手动 source 或重启 Shell
echo "已部署配置!请运行: source ~/.bashrc"