智能硬件论坛
直播中

范嘉琦

6年用户 76经验值
擅长:可编程逻辑 嵌入式技术
私信 关注
[经验]

【KV260视觉入门套件试用体验】kv260 IDE配置并开发一个图像识别程序

注意,本文创建了个子镜像用来配置开发环境。实际上并不需要这么麻烦。我这里只是为了方便换版本,并且在容器来开发省的扫尾。具体容器信息看文章结尾。

对于vscode的配置,其他位置都好说。唯独进入docker的时候不会自动运行入口start.sh。即使是这个脚本已经被放入bashrc。需要添加额外的环境变量配置

对于插件dev containers有如下配置,在远程容器下

@ext:ms-vscode-remote.remote-containers


包含一个关于入口脚本的配置:

Dotfiles: Install Command
(未同步)
克隆点文件存储库后要运行的命令。默认运行点文件存储库根文件夹中找到的第一个文件 "install.sh"、"install"、"bootstrap.sh"、"bootstrap"、"setup.sh" 和 "setup"。


这个配置选项要把之前配置的容器入口文件/start.sh(文件看后面)

填写进去。此时在cmake中就能找到交叉编译器,以及对应CC等编译选项。

但是仍然要注意,此时对于cmake本身来说还缺参数。需要填充一个setting.json

{
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.compilerPath": "/home/vitis-ai-user/petalinux_sdk_2022.2/sysroots/x86_64-petalinux-linux/usr/bin/aarch64-xilinx-linux/aarch64-xilinx-linux-gcc"
}

写入cmake配置文件:

# cmake位置 /home/vitis-ai-user/petalinux_sdk_2022.2/sysroots/x86_64-petalinux-linux/usr/bin/cmake
# gcc位置 /home/vitis-ai-user/petalinux_sdk_2022.2/sysroots/x86_64-petalinux-linux/usr/bin/aarch64-xilinx-linux/

cmake_minimum_required(VERSION 3.20)
project(kv260_test VERSION 0.1.0)


set(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSROOT /home/vitis-ai-user/petalinux_sdk_2022.2/sysroots/cortexa72-cortexa53-xilinx-linux)

SET(CMAKE_C_COMPILER "aarch64-xilinx-linux-gcc")
SET(CMAKE_C_FLAGS "-mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=${CMAKE_SYSROOT}")
SET(CMAKE_CXX_COMPILER "aarch64-xilinx-linux-g++")
SET(CMAKE_CXX_FLAGS "-mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=${CMAKE_SYSROOT}")

include_directories(/usr/include/)
include_directories(/usr/include/opencv4)

link_libraries(vart-runner opencv_videoio opencv_imgcodecs opencv_highgui opencv_imgproc opencv_core glog xir unilog pthread)

message("env: " $ENV{PATH})

add_executable(${PROJECT_NAME} main.cpp)

其实在之前的配置里已经能够正常运行了。不要直接运行main.cpp右上角的构建,它只构建了一个main.cpp。需要点击cmake的构建或者最下方工具栏的构建。或者直接进入build文件夹手动构建:

cmake ..
make

就能够正常编译出文件并运行。main.cpp

#include <vitis/ai/demo.hpp>
#include <iostream>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <glog/logging.h>

int main(int argc, const char** argv) {
    std::cout << "hello world!" << std::endl;
    LOG(INFO) << "test log";
    return 0;
}

Image.png

到此为止,已经成功开发。但是其实它运行在我给定的容器里。而容器配置如下。其实直接run也行。但是我实在windows下进行的,所以!它不能直接用官方脚本。我把官方脚本环境摘出来了,win下用docker的小伙伴可以参考一下。关于docker_build部分还没摘完。

上代码:

#include <iostream>
#include <memory>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <vitis/ai/classification.hpp>
#include <vitis/ai/demo.hpp>
#include <vector>
#include <dirent.h>
void getFiles(const std::string& path, std::vector<std::string>& files){
    DIR* dir = opendir(path.c_str());
    if (dir == nullptr) {
        std::cerr << "Failed to open directory." << std::endl;
        return ;
    }
    struct dirent* entry;
    while ((entry = readdir(dir)) != nullptr) {
        if (entry->d_type == DT_REG) {
            std::cout << entry->d_name << std::endl;
            files.push_back(entry->d_name);
        }
    }
    closedir(dir);
}
int main() {
    // 这里读取到的是resnet50默认的模型。默认在/usr/share/vitis_ai_library/model/resnet50/resnet50.xmodel
    /**
这里也可以通过demo里的源码获取model
auto graph = xir::Graph::deserialize("path to model");
      auto subgraph = get_dpu_subgraph(graph.get());
    */
    auto network = vitis::ai::Classification::create("resnet50");
    std::string path = "../images/";
    std::vector<std::string> files;
    // 获取目录下所有照片
    getFiles(path, files);
    // 循环识别图片
    for (auto item : files) {
        auto image = cv::imread("../images/" + item);
        auto result = network->run(image);
        std::cout << "animl type result:" << std::endl;
        for (const auto &r : result.scores){
            std::cout << result.lookup(r.index) << ": " << r.score << std::endl;
        }
    }
    return 0;
}

Dockerfile:

FROM xilinx/vitis-ai-pytorch-cpu:ubuntu2004-3.0.0.106
USER vitis-ai-user
# 安装所需的软件包和工具
 
# 将脚本复制到容器中
COPY .vimrc /home/vitis-ai-user/.vimrc
COPY onehalfdark.vim /usr/share/vim/vim81/colors/onehalfdark.vim
COPY onehalflight.vim /usr/share/vim/vim81/colors/onehalflight.vim
COPY start.sh /start.sh
COPY Vitis-AI-3.0.tar.gz /Vitis-AI-3.0.tar.gz
 
# 执行初始化文件的命令。并且开始初始化
RUN sudo chmod +x /start.sh && \
	sudo tar -xvf /Vitis-AI-3.0.tar.gz -C /workspace --strip-components 1 && \
	sudo rm /Vitis-AI-3.0.tar.gz
WORKDIR /workspace/board_setup/mpsoc
RUN sudo sed -i 's#~/petalinux_sdk_2022.2#/home/vitis-ai-user/petalinux_sdk_2022.2#g' /workspace/board_setup/mpsoc/host_cross_compiler_setup.sh && \
	sudo bash /workspace/board_setup/mpsoc/host_cross_compiler_setup.sh -d /home/vitis-ai-user/petalinux_sdk_2022.2 && \
	sudo chown vitis-ai-user:vitis-ai-group -R /workspace && \
	echo "source /start.sh" >> /home/vitis-ai-user/.bashrc
	
 
# 定义容器启动时执行的命令
CMD ["/start.sh"]

这里里面用到了一个脚本,/start.sh

#!/bin/bash
unset LD_LIBRARY_PATH
source /home/vitis-ai-user/petalinux_sdk_2022.2/environment-setup-cortexa72-cortexa53-xilinx-linux
sudo chown vitis-ai-user:vitis-ai-group -R /workspace
sudo chown vitis-ai-user:vitis-ai-group -R /home/vitis-ai-user

以上两个文件已经完成了基本环境的配置工作。

但是可以发现在dockerfile里有三组关于vim的脚本。这里只是美化,懒得搞删了也行。

set nu                      " 显示行号
set tabstop=4               " 设置软制表符宽度为4
set softtabstop=4           " 设置软制表符宽度为4
set shiftwidth=4            " 设置缩进的空格数为4
set autoindent              " 设置自动缩进:即每行的缩进值与上一行相等
set cindent                 " 使用 C/C++ 语言的自动缩进方式
set cursorline              " 突出显示当前行
set expandtab               " 空格代替制表符
set showmatch               " 光标遇到圆括号、方括号、大括号时,自动高亮对应的另一个圆括号、方括号和大括号
set ruler                   " 在状态栏显示光标的当前位置(位于哪一行哪一列)
 
"set guifont=Consolas:h15    " 设置字体和字体大小
syntax on
set t_Co=256
"set cursorcolumn
colorscheme onehalfdark     " 设置主题为molokai
let g:airline_theme='onehalfdark'
" lightline
" let g:lightline = { 'colorscheme': 'onehalfdark' }
 
set nobackup                " 取消备份文件
setlocal noswapfile         " 不创建交换文件。交换文件主要用于系统崩溃时恢复文件,文件名的开头是.、结尾是.swp
set noundofile              " 取消生成un文件
 
set hlsearch                " 设置高亮显示搜索字符串
set showmode                " 在底部显示,当前处于命令模式还是插入模式
set showcmd                 " 命令模式下,在底部显示,当前键入的指令。比如输入快捷键将在底部显示具体命令
set noerrorbells            " 出错时不要发出响声
" 高亮显示
" syntax enable

" 解决vim下无法复制的问题
set mouse=v

然后是俩主题文件。这俩主题文件其实根本不用在我这里下载

这里给出原作者地址:
https://github.com/sonph/onehalf
其实这个地址在我给出的文件里有

但是为了方便懒鬼同学。我还是把文件贴出来。我也不知道具体作者更新没,反正我喜欢现在的样子。我拉去文件的时候是[2023/02/01]
前面要是看了我的.vimrc的话知道我用的是onhalfdark

onehalfdark.vim

" ==============================================================================
"   Name:        One Half Dark
"   Author:      Son A. Pham <sp@sonpham.me>
"   Url:         https://github.com/sonph/onehalf
"   License:     The MIT License (MIT)
"
"   A dark vim color scheme based on Atom's One. See github.com/sonph/onehalf
"   for installation instructions, a light color scheme, versions for other
"   editors/terminals, and a matching theme for vim-airline.
" ==============================================================================
set background=dark
highlight clear
syntax reset
let g:colors_name="onehalfdark"
let colors_name="onehalfdark"
let s:black       = { "gui": "#282c34", "cterm": "236" }
let s:red         = { "gui": "#e06c75", "cterm": "168" }
let s:green       = { "gui": "#98c379", "cterm": "114" }
let s:yellow      = { "gui": "#e5c07b", "cterm": "180" }
let s:blue        = { "gui": "#61afef", "cterm": "75"  }
let s:purple      = { "gui": "#c678dd", "cterm": "176" }
let s:cyan        = { "gui": "#56b6c2", "cterm": "73"  }
let s:white       = { "gui": "#dcdfe4", "cterm": "188" }
let s:fg          = s:white
let s:bg          = s:black
let s:comment_fg  = { "gui": "#5c6370", "cterm": "241" }
let s:gutter_bg   = { "gui": "#282c34", "cterm": "236" }
let s:gutter_fg   = { "gui": "#919baa", "cterm": "247" }
let s:non_text    = { "gui": "#373C45", "cterm": "239" }
let s:cursor_line = { "gui": "#313640", "cterm": "237" }
let s:color_col   = { "gui": "#313640", "cterm": "237" }
let s:selection   = { "gui": "#474e5d", "cterm": "239" }
let s:vertsplit   = { "gui": "#313640", "cterm": "237" }
function! s:h(group, fg, bg, attr)
  if type(a:fg) == type({})
    exec "hi " . a:group . " guifg=" . a:fg.gui . " ctermfg=" . a:fg.cterm
  else
    exec "hi " . a:group . " guifg=NONE cterm=NONE"
  endif
  if type(a:bg) == type({})
    exec "hi " . a:group . " guibg=" . a:bg.gui . " ctermbg=" . a:bg.cterm
  else
    exec "hi " . a:group . " guibg=NONE ctermbg=NONE"
  endif
  if a:attr != ""
    exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
  else
    exec "hi " . a:group . " gui=NONE cterm=NONE"
  endif
endfun
" User interface colors {
call s:h("Normal", s:fg, s:bg, "")
call s:h("Cursor", s:bg, s:blue, "")
call s:h("CursorColumn", "", s:cursor_line, "")
call s:h("CursorLine", "", s:cursor_line, "")
call s:h("LineNr", s:gutter_fg, s:gutter_bg, "")
call s:h("CursorLineNr", s:fg, "", "")
call s:h("DiffAdd", s:green, "", "")
call s:h("DiffChange", s:yellow, "", "")
call s:h("DiffDelete", s:red, "", "")
call s:h("DiffText", s:blue, "", "")
call s:h("IncSearch", s:bg, s:yellow, "")
call s:h("Search", s:bg, s:yellow, "")
call s:h("ErrorMsg", s:fg, "", "")
call s:h("ModeMsg", s:fg, "", "")
call s:h("MoreMsg", s:fg, "", "")
call s:h("WarningMsg", s:red, "", "")
call s:h("Question", s:purple, "", "")
call s:h("Pmenu", s:bg, s:fg, "")
call s:h("PmenuSel", s:fg, s:blue, "")
call s:h("PmenuSbar", "", s:selection, "")
call s:h("PmenuThumb", "", s:fg, "")
call s:h("SpellBad", s:red, "", "")
call s:h("SpellCap", s:yellow, "", "")
call s:h("SpellLocal", s:yellow, "", "")
call s:h("SpellRare", s:yellow, "", "")
call s:h("StatusLine", s:blue, s:cursor_line, "")
call s:h("StatusLineNC", s:comment_fg, s:cursor_line, "")
call s:h("TabLine", s:comment_fg, s:cursor_line, "")
call s:h("TabLineFill", s:comment_fg, s:cursor_line, "")
call s:h("TabLineSel", s:fg, s:bg, "")
call s:h("Visual", "", s:selection, "")
call s:h("VisualNOS", "", s:selection, "")
call s:h("ColorColumn", "", s:color_col, "")
call s:h("Conceal", s:fg, "", "")
call s:h("Directory", s:blue, "", "")
call s:h("VertSplit", s:vertsplit, s:vertsplit, "")
call s:h("Folded", s:fg, "", "")
call s:h("FoldColumn", s:fg, "", "")
call s:h("SignColumn", s:fg, "", "")
call s:h("MatchParen", s:blue, "", "underline")
call s:h("SpecialKey", s:fg, "", "")
call s:h("Title", s:green, "", "")
call s:h("WildMenu", s:fg, "", "")
" }
" Syntax colors {
" Whitespace is defined in Neovim, not Vim.
" See :help hl-Whitespace and :help hl-SpecialKey
call s:h("Whitespace", s:non_text, "", "")
call s:h("NonText", s:non_text, "", "")
call s:h("Comment", s:comment_fg, "", "italic")
call s:h("Constant", s:cyan, "", "")
call s:h("String", s:green, "", "")
call s:h("Character", s:green, "", "")
call s:h("Number", s:yellow, "", "")
call s:h("Boolean", s:yellow, "", "")
call s:h("Float", s:yellow, "", "")
call s:h("Identifier", s:red, "", "")
call s:h("Function", s:blue, "", "")
call s:h("Statement", s:purple, "", "")
call s:h("Conditional", s:purple, "", "")
call s:h("Repeat", s:purple, "", "")
call s:h("Label", s:purple, "", "")
call s:h("Operator", s:fg, "", "")
call s:h("Keyword", s:red, "", "")
call s:h("Exception", s:purple, "", "")
call s:h("PreProc", s:yellow, "", "")
call s:h("Include", s:purple, "", "")
call s:h("Define", s:purple, "", "")
call s:h("Macro", s:purple, "", "")
call s:h("PreCondit", s:yellow, "", "")
call s:h("Type", s:yellow, "", "")
call s:h("StorageClass", s:yellow, "", "")
call s:h("Structure", s:yellow, "", "")
call s:h("Typedef", s:yellow, "", "")
call s:h("Special", s:blue, "", "")
call s:h("SpecialChar", s:fg, "", "")
call s:h("Tag", s:fg, "", "")
call s:h("Delimiter", s:fg, "", "")
call s:h("SpecialComment", s:fg, "", "")
call s:h("Debug", s:fg, "", "")
call s:h("Underlined", s:fg, "", "")
call s:h("Ignore", s:fg, "", "")
call s:h("Error", s:red, s:gutter_bg, "")
call s:h("Todo", s:purple, "", "")
" }
" Plugins {
" GitGutter
call s:h("GitGutterAdd", s:green, s:gutter_bg, "")
call s:h("GitGutterDelete", s:red, s:gutter_bg, "")
call s:h("GitGutterChange", s:yellow, s:gutter_bg, "")
call s:h("GitGutterChangeDelete", s:red, s:gutter_bg, "")
" Fugitive
call s:h("diffAdded", s:green, "", "")
call s:h("diffRemoved", s:red, "", "")
" }
" Git {
call s:h("gitcommitComment", s:comment_fg, "", "")
call s:h("gitcommitUnmerged", s:red, "", "")
call s:h("gitcommitOnBranch", s:fg, "", "")
call s:h("gitcommitBranch", s:purple, "", "")
call s:h("gitcommitDiscardedType", s:red, "", "")
call s:h("gitcommitSelectedType", s:green, "", "")
call s:h("gitcommitHeader", s:fg, "", "")
call s:h("gitcommitUntrackedFile", s:cyan, "", "")
call s:h("gitcommitDiscardedFile", s:red, "", "")
call s:h("gitcommitSelectedFile", s:green, "", "")
call s:h("gitcommitUnmergedFile", s:yellow, "", "")
call s:h("gitcommitFile", s:fg, "", "")
hi link gitcommitNoBranch gitcommitBranch
hi link gitcommitUntracked gitcommitComment
hi link gitcommitDiscarded gitcommitComment
hi link gitcommitSelected gitcommitComment
hi link gitcommitDiscardedArrow gitcommitDiscardedFile
hi link gitcommitSelectedArrow gitcommitSelectedFile
hi link gitcommitUnmergedArrow gitcommitUnmergedFile
" }
" Fix colors in neovim terminal buffers {
  if has('nvim')
    let g:terminal_color_0 = s:black.gui
    let g:terminal_color_1 = s:red.gui
    let g:terminal_color_2 = s:green.gui
    let g:terminal_color_3 = s:yellow.gui
    let g:terminal_color_4 = s:blue.gui
    let g:terminal_color_5 = s:purple.gui
    let g:terminal_color_6 = s:cyan.gui
    let g:terminal_color_7 = s:white.gui
    let g:terminal_color_8 = s:black.gui
    let g:terminal_color_9 = s:red.gui
    let g:terminal_color_10 = s:green.gui
    let g:terminal_color_11 = s:yellow.gui
    let g:terminal_color_12 = s:blue.gui
    let g:terminal_color_13 = s:purple.gui
    let g:terminal_color_14 = s:cyan.gui
    let g:terminal_color_15 = s:white.gui
    let g:terminal_color_background = s:bg.gui
    let g:terminal_color_foreground = s:fg.gui
  endif
" }

onehalflight.vim

" ==============================================================================
"   Name:        One Half Light
"   Author:      Son A. Pham <sp@sonpham.me>
"   Url:         https://github.com/sonph/onehalf
"   License:     The MIT License (MIT)
"
"   A light vim color scheme based on Atom's One. See github.com/sonph/onehalf
"   for installation instructions, a dark color scheme, versions for other
"   editors/terminals, and a matching theme for vim-airline.
" ==============================================================================
set background=light
highlight clear
syntax reset
let g:colors_name="onehalflight"
let colors_name="onehalflight"
let s:black       = { "gui": "#383a42", "cterm": "237" }
let s:red         = { "gui": "#e45649", "cterm": "167" }
let s:green       = { "gui": "#50a14f", "cterm": "71" }
let s:yellow      = { "gui": "#c18401", "cterm": "136" }
let s:blue        = { "gui": "#0184bc", "cterm": "31" }
let s:purple      = { "gui": "#a626a4", "cterm": "127" }
let s:cyan        = { "gui": "#0997b3", "cterm": "31" }
let s:white       = { "gui": "#fafafa", "cterm": "231" }
let s:fg          = s:black
let s:bg          = s:white
let s:comment_fg  = { "gui": "#a0a1a7", "cterm": "247" }
let s:gutter_bg   = { "gui": "#fafafa", "cterm": "231" }
let s:gutter_fg   = { "gui": "#d4d4d4", "cterm": "252" }
let s:non_text    = { "gui": "#e5e5e5", "cterm": "252" }
let s:cursor_line = { "gui": "#f0f0f0", "cterm": "255" }
let s:color_col   = { "gui": "#f0f0f0", "cterm": "255" }
let s:selection   = { "gui": "#bfceff", "cterm": "153" }
let s:vertsplit   = { "gui": "#f0f0f0", "cterm": "255" }
function! s:h(group, fg, bg, attr)
  if type(a:fg) == type({})
    exec "hi " . a:group . " guifg=" . a:fg.gui . " ctermfg=" . a:fg.cterm
  else
    exec "hi " . a:group . " guifg=NONE cterm=NONE"
  endif
  if type(a:bg) == type({})
    exec "hi " . a:group . " guibg=" . a:bg.gui . " ctermbg=" . a:bg.cterm
  else
    exec "hi " . a:group . " guibg=NONE ctermbg=NONE"
  endif
  if a:attr != ""
    exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
  else
    exec "hi " . a:group . " gui=NONE cterm=NONE"
  endif
endfun
" User interface colors {
call s:h("Normal", s:fg, s:bg, "")
call s:h("Cursor", s:bg, s:blue, "")
call s:h("CursorColumn", "", s:cursor_line, "")
call s:h("CursorLine", "", s:cursor_line, "")
call s:h("LineNr", s:gutter_fg, s:gutter_bg, "")
call s:h("CursorLineNr", s:fg, "", "")
call s:h("DiffAdd", s:green, "", "")
call s:h("DiffChange", s:yellow, "", "")
call s:h("DiffDelete", s:red, "", "")
call s:h("DiffText", s:blue, "", "")
call s:h("IncSearch", s:bg, s:yellow, "")
call s:h("Search", s:bg, s:yellow, "")
call s:h("ErrorMsg", s:fg, "", "")
call s:h("ModeMsg", s:fg, "", "")
call s:h("MoreMsg", s:fg, "", "")
call s:h("WarningMsg", s:red, "", "")
call s:h("Question", s:purple, "", "")
call s:h("Pmenu", s:fg, s:cursor_line, "")
call s:h("PmenuSel", s:bg, s:blue, "")
call s:h("PmenuSbar", "", s:cursor_line, "")
call s:h("PmenuThumb", "", s:comment_fg, "")
call s:h("SpellBad", s:red, "", "")
call s:h("SpellCap", s:yellow, "", "")
call s:h("SpellLocal", s:yellow, "", "")
call s:h("SpellRare", s:yellow, "", "")
call s:h("StatusLine", s:blue, s:cursor_line, "")
call s:h("StatusLineNC", s:comment_fg, s:cursor_line, "")
call s:h("TabLine", s:comment_fg, s:cursor_line, "")
call s:h("TabLineFill", s:comment_fg, s:cursor_line, "")
call s:h("TabLineSel", s:fg, s:bg, "")
call s:h("Visual", "", s:selection, "")
call s:h("VisualNOS", "", s:selection, "")
call s:h("ColorColumn", "", s:color_col, "")
call s:h("Conceal", s:fg, "", "")
call s:h("Directory", s:blue, "", "")
call s:h("VertSplit", s:vertsplit, s:vertsplit, "")
call s:h("Folded", s:fg, "", "")
call s:h("FoldColumn", s:fg, "", "")
call s:h("SignColumn", s:fg, "", "")
call s:h("MatchParen", s:blue, "", "underline")
call s:h("SpecialKey", s:fg, "", "")
call s:h("Title", s:green, "", "")
call s:h("WildMenu", s:fg, "", "")
" }
" Syntax colors {
" Whitespace is defined in Neovim, not Vim.
" See :help hl-Whitespace and :help hl-SpecialKey
call s:h("Whitespace", s:non_text, "", "")
call s:h("NonText", s:non_text, "", "")
call s:h("Comment", s:comment_fg, "", "italic")
call s:h("Constant", s:cyan, "", "")
call s:h("String", s:green, "", "")
call s:h("Character", s:green, "", "")
call s:h("Number", s:yellow, "", "")
call s:h("Boolean", s:yellow, "", "")
call s:h("Float", s:yellow, "", "")
call s:h("Identifier", s:red, "", "")
call s:h("Function", s:blue, "", "")
call s:h("Statement", s:purple, "", "")
call s:h("Conditional", s:purple, "", "")
call s:h("Repeat", s:purple, "", "")
call s:h("Label", s:purple, "", "")
call s:h("Operator", s:fg, "", "")
call s:h("Keyword", s:red, "", "")
call s:h("Exception", s:purple, "", "")
call s:h("PreProc", s:yellow, "", "")
call s:h("Include", s:purple, "", "")
call s:h("Define", s:purple, "", "")
call s:h("Macro", s:purple, "", "")
call s:h("PreCondit", s:yellow, "", "")
call s:h("Type", s:yellow, "", "")
call s:h("StorageClass", s:yellow, "", "")
call s:h("Structure", s:yellow, "", "")
call s:h("Typedef", s:yellow, "", "")
call s:h("Special", s:blue, "", "")
call s:h("SpecialChar", s:fg, "", "")
call s:h("Tag", s:fg, "", "")
call s:h("Delimiter", s:fg, "", "")
call s:h("SpecialComment", s:fg, "", "")
call s:h("Debug", s:fg, "", "")
call s:h("Underlined", s:fg, "", "")
call s:h("Ignore", s:fg, "", "")
call s:h("Error", s:red, s:gutter_bg, "")
call s:h("Todo", s:purple, "", "")
" }
" Plugins {
" GitGutter
call s:h("GitGutterAdd", s:green, s:gutter_bg, "")
call s:h("GitGutterDelete", s:red, s:gutter_bg, "")
call s:h("GitGutterChange", s:yellow, s:gutter_bg, "")
call s:h("GitGutterChangeDelete", s:red, s:gutter_bg, "")
" Fugitive
call s:h("diffAdded", s:green, "", "")
call s:h("diffRemoved", s:red, "", "")
" }
" Git {
call s:h("gitcommitComment", s:comment_fg, "", "")
call s:h("gitcommitUnmerged", s:red, "", "")
call s:h("gitcommitOnBranch", s:fg, "", "")
call s:h("gitcommitBranch", s:purple, "", "")
call s:h("gitcommitDiscardedType", s:red, "", "")
call s:h("gitcommitSelectedType", s:green, "", "")
call s:h("gitcommitHeader", s:fg, "", "")
call s:h("gitcommitUntrackedFile", s:cyan, "", "")
call s:h("gitcommitDiscardedFile", s:red, "", "")
call s:h("gitcommitSelectedFile", s:green, "", "")
call s:h("gitcommitUnmergedFile", s:yellow, "", "")
call s:h("gitcommitFile", s:fg, "", "")
hi link gitcommitNoBranch gitcommitBranch
hi link gitcommitUntracked gitcommitComment
hi link gitcommitDiscarded gitcommitComment
hi link gitcommitSelected gitcommitComment
hi link gitcommitDiscardedArrow gitcommitDiscardedFile
hi link gitcommitSelectedArrow gitcommitSelectedFile
hi link gitcommitUnmergedArrow gitcommitUnmergedFile
" }
" Fix colors in neovim terminal buffers {
  if has('nvim')
    let g:terminal_color_0 = s:black.gui
    let g:terminal_color_1 = s:red.gui
    let g:terminal_color_2 = s:green.gui
    let g:terminal_color_3 = s:yellow.gui
    let g:terminal_color_4 = s:blue.gui
    let g:terminal_color_5 = s:purple.gui
    let g:terminal_color_6 = s:cyan.gui
    let g:terminal_color_7 = s:white.gui
    let g:terminal_color_8 = s:black.gui
    let g:terminal_color_9 = s:red.gui
    let g:terminal_color_10 = s:green.gui
    let g:terminal_color_11 = s:yellow.gui
    let g:terminal_color_12 = s:blue.gui
    let g:terminal_color_13 = s:purple.gui
    let g:terminal_color_14 = s:cyan.gui
    let g:terminal_color_15 = s:white.gui
    let g:terminal_color_background = s:bg.gui
    let g:terminal_color_foreground = s:fg.gui
  endif
" }

常用vscode插件。一部分已被vscode吸收。但是我还没更新列表。也不是全都用。我这里集合了c/c++,全入市,合宙,FPGA,python开发。自己按需往出摘


常用插件列表:

Chinese (Simplified) (简体中文)

Arm Assembly

Better C++ Syntax

C/C++

C/C++ Advanced Lint

C/C++ Extension Pack

C/C++ Snippets

C/C++ Themes

Cmake

CMake Tools

Code Runner

compareit

Dev Containers

DeviceTree

Doxygen Documentation Generator

GBK to UTF8 for vscode

Include Autocomplete

Jupyter Keymap

One Dark Pro

Rainbow Brackets(这个已经在vscode内置,但是需要在配置,文本编辑器,Bracket Pair Colorization中启用Bracket Pairs括号配对规则。默认是关着的)

Remote - SSH

Remote - SSH: Editing Configuration Files

Remote - Tunnels

Remote Development

Remote Explorer

verilog

Verilog_Testbench

Verilog-HDL/SystemVerilog/Bluespec SystemVerilog

vscode-icons

WSL

Makefile Tools

GitLens—Git supercharged

Git Project Manager

Git History

Python

Pylance

markdownlint

Xml

Xml Tools

Vim

Vim Theme


再分享个给予谷歌和llvm建立的c/c++代码格式化文档。再vscode一般模式shift+alt+f自动格式化代码。或者右键能看到格式化选项:

# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
  AfterCaseLabel: false
  AfterClass: false
  AfterControlStatement: Never
  AfterEnum: false
  AfterFunction: false
  AfterNamespace: false
  AfterUnion: false
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false
  SplitEmptyFunction: false
  SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 2
UseTab: Never

更多回帖

发帖
×
20
完善资料,
赚取积分