Merge branch 'master' of git.coding.net:linklink/mynote
This commit is contained in:
commit
67ead42919
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
*.pyc
|
*.pyc
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.tags
|
||||||
|
|||||||
22
cartographer/install.md
Normal file
22
cartographer/install.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# install cartographer
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y \
|
||||||
|
cmake \
|
||||||
|
g++ \
|
||||||
|
git \
|
||||||
|
google-mock \
|
||||||
|
libboost-all-dev \
|
||||||
|
libcairo2-dev \
|
||||||
|
libeigen3-dev \
|
||||||
|
libgflags-dev \
|
||||||
|
libgoogle-glog-dev \
|
||||||
|
liblua5.2-dev \
|
||||||
|
libprotobuf-dev \
|
||||||
|
libsuitesparse-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
ninja-build \
|
||||||
|
protobuf-compiler \
|
||||||
|
python-sphinx
|
||||||
|
```
|
||||||
@ -11,7 +11,16 @@ cd ~
|
|||||||
mkdir mysql
|
mkdir mysql
|
||||||
cd mysql
|
cd mysql
|
||||||
|
|
||||||
docker run -p 3306:3306 --name mymysql -v ~/mysql/conf:/etc/mysql/conf.d -v ~/mysql/logs:/logs -v ~/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
|
docker run -p 3306:3306 -p 8090:80 --name mymysql -v ~/mysql/conf:/etc/mysql/conf.d -v ~/mysql/logs:/logs -v ~/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
|
||||||
|
|
||||||
docker exec -i -t id /bin/bash
|
docker exec -i -t id /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 可视化
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull quantumobject/docker-mywebsql
|
||||||
|
docker run --rm-p 8090:80 --name mywebsql quantumobject/docker-mywebsql
|
||||||
|
docker run -dit --name mywebsql --network=container:mymysql quantumobject/docker-mywebsql
|
||||||
|
```
|
||||||
|
|||||||
@ -53,3 +53,13 @@ reboot # or relogin
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install docker.io
|
||||||
|
sudo systemctl start docker
|
||||||
|
sudo systemctl enable docker
|
||||||
|
sudo adduser $USER docker
|
||||||
|
|
||||||
|
```
|
||||||
|
|||||||
8
docker/gitlite.md
Normal file
8
docker/gitlite.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# normal
|
||||||
|
|
||||||
|
## add git user
|
||||||
|
|
||||||
|
```bash
|
||||||
|
useradd -ms /bin/bash git
|
||||||
|
|
||||||
|
```
|
||||||
10
env/fzf.md
vendored
Normal file
10
env/fzf.md
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# install fzf ag autojump
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
||||||
|
~/.fzf/install
|
||||||
|
sudo apt install silversearcher-ag
|
||||||
|
sudo apt install autojump
|
||||||
|
echo ". /usr/share/autojump/autojump.sh" >> ~/.zshrc
|
||||||
|
```
|
||||||
2
env/sysmonitor.sh
vendored
2
env/sysmonitor.sh
vendored
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor -y
|
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor -y
|
||||||
sudo apt-get -y install indicator-sysmonitor
|
sudo apt -y install indicator-sysmonitor
|
||||||
|
|||||||
@ -26,6 +26,11 @@ sudo pip install shadowsocks
|
|||||||
}
|
}
|
||||||
ssserver -c /etc/shadowsocks.json -d start
|
ssserver -c /etc/shadowsocks.json -d start
|
||||||
ssserver -c /etc/shadowsocks.json -d stop
|
ssserver -c /etc/shadowsocks.json -d stop
|
||||||
|
|
||||||
|
docker pull mritd/shadowsocks
|
||||||
|
|
||||||
|
docker run -dt --name ss -p 3801:3801 mritd/shadowsocks -s "-s 0.0.0.0 -p 3801 -m rc4-md5 -k ssserver123 --fast-open"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,33 +1,35 @@
|
|||||||
# 如何迁移git项目
|
# 如何迁移git项目
|
||||||
|
|
||||||
#### Create a new repository
|
|
||||||
|
|
||||||
``` bash
|
- git remote set-url origin ************(项目地址)
|
||||||
git clone *************.git
|
- git push
|
||||||
cd existing_repo
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#Git global setup
|
||||||
|
git config --global user.name "light"
|
||||||
|
git config --global user.email "1870499383@qq.com"
|
||||||
|
|
||||||
|
#Create a new repository
|
||||||
|
git clone git@git.vueadmin.com:light/test.git
|
||||||
|
cd test
|
||||||
touch README.md
|
touch README.md
|
||||||
git add README.md
|
git add README.md
|
||||||
git commit -m "add README"
|
git commit -m "add README"
|
||||||
git push -u origin master
|
git push -u origin master
|
||||||
```
|
|
||||||
|
|
||||||
#### Existing folder
|
#Existing folder
|
||||||
|
|
||||||
``` bash
|
|
||||||
cd existing_folder
|
cd existing_folder
|
||||||
git init
|
git init
|
||||||
git remote add origin *************.git
|
git remote add origin git@git.vueadmin.com:light/test.git
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Initial commit"
|
git commit -m "Initial commit"
|
||||||
git push -u origin master
|
git push -u origin master
|
||||||
```
|
|
||||||
|
|
||||||
#### Existing Git repository
|
#Existing Git repository
|
||||||
|
|
||||||
```bash
|
|
||||||
cd existing_repo
|
cd existing_repo
|
||||||
git remote rename origin old-origin
|
git remote rename origin old-origin
|
||||||
git remote add origin *************.git
|
git remote add origin git@git.vueadmin.com:light/test.git
|
||||||
git push -u origin --all
|
git push -u origin --all
|
||||||
git push -u origin --tags
|
git push -u origin --tags
|
||||||
```
|
```
|
||||||
@ -1,4 +1,16 @@
|
|||||||
|
# git command
|
||||||
|
|
||||||
|
## 强制拉取
|
||||||
|
|
||||||
|
``` bash:
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
git fetch --all
|
git fetch --all
|
||||||
git reset --hard origin/master
|
git reset --hard origin/master
|
||||||
git pull
|
git pull
|
||||||
|
```
|
||||||
|
|
||||||
|
## 统计代码量
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
|
||||||
|
```
|
||||||
|
|||||||
6
go/gocode.md
Normal file
6
go/gocode.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# gocode vim不更新提示
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 退出gocode 服务
|
||||||
|
gocode exit
|
||||||
|
```
|
||||||
12
go/iris/source.md
Normal file
12
go/iris/source.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 源码分析
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 入口
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
app.Run(iris.Addr("0.0.0.0:8080"))
|
||||||
|
|
||||||
|
```
|
||||||
8
openstack/docker.md
Normal file
8
openstack/docker.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# deploy with docker
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -dit --privileged --cap-add=ALL --network=host --name=controller -h controller -v /lib/modules:/lib/modules openstack_base:rocky_ovs
|
||||||
|
docker run -dit --privileged --cap-add=ALL --network=host --name=compute -h compute -v /lib/modules:/lib/modules openstack_compute:rocky_ovs
|
||||||
|
docker run -dit --privileged --cap-add=ALL --network=host --name=cinder -h cinder -v /lib/modules:/lib/modules openstack_cinder:dscloud
|
||||||
|
```
|
||||||
47
openstack/ip.md
Normal file
47
openstack/ip.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# openstack ip conf
|
||||||
|
|
||||||
|
|
||||||
|
## mysql
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /etc/mysql/mariadb.conf.d/99-openstack.cnf
|
||||||
|
bind-address = controller
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## memcache
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /etc/memcached.conf
|
||||||
|
|
||||||
|
-l controller
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## etcd
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /etc/default/etcd
|
||||||
|
|
||||||
|
ETCD_NAME="controller"
|
||||||
|
ETCD_DATA_DIR="/var/lib/etcd"
|
||||||
|
ETCD_INITIAL_CLUSTER_STATE="new"
|
||||||
|
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
|
||||||
|
ETCD_INITIAL_CLUSTER="controller=http://controller:2380"
|
||||||
|
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://controller:2380"
|
||||||
|
ETCD_ADVERTISE_CLIENT_URLS="http://controller:2379"
|
||||||
|
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
|
||||||
|
ETCD_LISTEN_CLIENT_URLS="http://controller:2379"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## nova
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /etc/nova/nova.conf
|
||||||
|
[DEFAULT]
|
||||||
|
# ...
|
||||||
|
my_ip = local_ip (be set on contorller and compute)
|
||||||
|
|
||||||
|
```
|
||||||
62
openstack/neutron.md
Normal file
62
openstack/neutron.md
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# neutron 配置网络
|
||||||
|
|
||||||
|
|
||||||
|
## flat
|
||||||
|
|
||||||
|
用于配置外部网络
|
||||||
|
|
||||||
|
> https://blog.csdn.net/CloudMan6/article/details/52529828
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /etc/neutron/plugins/ml2/ml2_conf.ini
|
||||||
|
|
||||||
|
[ml2]
|
||||||
|
tenant_network_types = flat
|
||||||
|
|
||||||
|
[ml2_type_flat]
|
||||||
|
flat_networks=default
|
||||||
|
#flat_networks = flat1,flat2
|
||||||
|
|
||||||
|
|
||||||
|
[linux_bridge]
|
||||||
|
physical_interface_mappings=default:eth1
|
||||||
|
#physical_interface_mappings = flat1:eth1,flat2:eth2
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## vxlan
|
||||||
|
|
||||||
|
用于配置用户虚拟网络
|
||||||
|
|
||||||
|
|
||||||
|
> https://blog.csdn.net/CloudMan6/article/details/53082157
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# /etc/neutron/plugins/ml2/ml2_conf.ini
|
||||||
|
|
||||||
|
[ml2]
|
||||||
|
tenant_network_types = vxlan
|
||||||
|
vni_ranges = 1001 - 2000
|
||||||
|
|
||||||
|
# on controler
|
||||||
|
[vxlan]
|
||||||
|
l2_population = true
|
||||||
|
local_ip = controller_ip
|
||||||
|
enable_vxlan = true
|
||||||
|
|
||||||
|
|
||||||
|
# on compute
|
||||||
|
[vxlan]
|
||||||
|
l2_population = true
|
||||||
|
local_ip = compute_ip
|
||||||
|
enable_vxlan = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
21
openstack/ovs.md
Normal file
21
openstack/ovs.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# open vswitch
|
||||||
|
|
||||||
|
## install
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/openvswitch/ovs.git
|
||||||
|
cd ovs
|
||||||
|
git checkout v2.7.0
|
||||||
|
sudo apt-get install git autoconf automake libtool openssl libssl-dev make python-six -y
|
||||||
|
|
||||||
|
./boot.sh
|
||||||
|
|
||||||
|
./configure
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
sudo modprobe openvswitch
|
||||||
|
```
|
||||||
6
openstack/version.md
Normal file
6
openstack/version.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apt install software-properties-common
|
||||||
|
add-apt-repository cloud-archive:rocky
|
||||||
|
```
|
||||||
@ -1,6 +1,22 @@
|
|||||||
# virtualenv not
|
# virtualenv not
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install virtualenv
|
||||||
|
pip install virtualenvwrapper
|
||||||
|
```
|
||||||
|
|
||||||
> virtualenv -p /usr/bin/python3 --system-site-packages venv
|
> virtualenv -p /usr/bin/python3 --system-site-packages venv
|
||||||
|
|
||||||
> virtualenv -p /usr/bin/python2 --no-site-packages env
|
> virtualenv -p /usr/bin/python2 --no-site-packages env
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# .zshrc
|
||||||
|
|
||||||
|
WORKON_HOME=~/.virtualenv
|
||||||
|
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
|
||||||
|
source /usr/local/bin/virtualenvwrapper.sh
|
||||||
|
|
||||||
|
mkvirtualenv rospy2 -p /usr/bin/python
|
||||||
|
|
||||||
|
```
|
||||||
|
|||||||
@ -88,6 +88,5 @@ esac
|
|||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
docker pull redis
|
docker pull redis
|
||||||
mkdir /db/redis/
|
|
||||||
docker run -p 127.0.0.1:6379:6379 --name myredis -v /db/redis/:/data -d redis redis-server --appendonly yes --requirepass "abc123456"
|
docker run -p 127.0.0.1:6379:6379 --name myredis -v /db/redis/:/data -d redis redis-server --appendonly yes --requirepass "abc123456"
|
||||||
```
|
```
|
||||||
32
ros/env.md
Normal file
32
ros/env.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# ros base env
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## use py3 with ros
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
source ...../python3
|
||||||
|
pip install catkin_pkg pyyaml empy rospkg numpy
|
||||||
|
mkdir -p catkin_ws/src # 用户开发目录
|
||||||
|
cd catkin_ws
|
||||||
|
catkin_make
|
||||||
|
|
||||||
|
cd ~
|
||||||
|
mkdir -p catkin_base/src # 第三方包编译目录
|
||||||
|
cd catkin_base/src
|
||||||
|
git clone https://github.com/ros/geometry
|
||||||
|
git clone https://github.com/ros/geometry2
|
||||||
|
cd ..
|
||||||
|
catkin_make
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 安装依赖包
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
|
||||||
|
|
||||||
|
```
|
||||||
22
ros/errors.md
Normal file
22
ros/errors.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# errors
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### error1
|
||||||
|
|
||||||
|
```bash
|
||||||
|
-- +++ processing catkin package: 'tf2_bullet'
|
||||||
|
-- ==> add_subdirectory(geometry2/tf2_bullet)
|
||||||
|
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
|
||||||
|
-- Checking for module 'bullet'
|
||||||
|
-- No package 'bullet' found
|
||||||
|
CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:367 (message):
|
||||||
|
A required package was not found
|
||||||
|
Call Stack (most recent call first):
|
||||||
|
/usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:532 (_pkg_check_modules_internal)
|
||||||
|
geometry2/tf2_bullet/CMakeLists.txt:7 (pkg_check_modules)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
> sudo apt install libbullet-dev
|
||||||
17
ubuntu/apt_source.md
Normal file
17
ubuntu/apt_source.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# apt 源
|
||||||
|
|
||||||
|
## ubuntu 18.04
|
||||||
|
|
||||||
|
```bash
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic universe
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates universe
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic multiverse
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-security universe
|
||||||
|
deb http://mirrors.aliyun.com/ubuntu/ bionic-security multiverse
|
||||||
|
|
||||||
|
```
|
||||||
13
ubuntu/interface.md
Normal file
13
ubuntu/interface.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# /etc/network/interface 配置
|
||||||
|
|
||||||
|
|
||||||
|
## static ip
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address 192.168.2.34
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway 192.0.2.254
|
||||||
|
dns-nameservers 114.114.114.114
|
||||||
|
```
|
||||||
6
ubuntu/synergy.md
Normal file
6
ubuntu/synergy.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# synergy
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install synergy
|
||||||
|
sudo apt-get install sni-qt
|
||||||
|
```
|
||||||
24
ubuntu/user.md
Normal file
24
ubuntu/user.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# user
|
||||||
|
|
||||||
|
|
||||||
|
## create user
|
||||||
|
|
||||||
|
```bash
|
||||||
|
useradd git
|
||||||
|
|
||||||
|
# 制定用户默认的shell
|
||||||
|
chsh git -s /bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
# 更改权限
|
||||||
|
chown -R git:git /home/git
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## auth
|
||||||
|
|
||||||
|
```bash
|
||||||
|
## 只修改文件权限 -type d 为修改目录权限
|
||||||
|
find workspace -type f -exec chmod 644 {} \;
|
||||||
|
```
|
||||||
@ -1,9 +1,54 @@
|
|||||||
|
nnoremap <leader>[ :bp<CR>
|
||||||
|
nnoremap <leader>] :bn<CR>
|
||||||
|
" 映射<leader>num到num buffer
|
||||||
|
"nmap <tab> :bn<cr>
|
||||||
|
map <leader>1 :b 1<CR>
|
||||||
|
map <leader>2 :b 2<CR>
|
||||||
|
map <leader>3 :b 3<CR>
|
||||||
|
map <leader>4 :b 4<CR>
|
||||||
|
map <leader>5 :b 5<CR>
|
||||||
|
map <leader>6 :b 6<CR>
|
||||||
|
map <leader>7 :b 7<CR>
|
||||||
|
map <leader>8 :b 8<CR>
|
||||||
|
map <leader>9 :b 9<CR>
|
||||||
|
map q :bwipeout<CR>
|
||||||
|
|
||||||
|
nmap J 5j
|
||||||
|
nmap K 5k
|
||||||
|
nmap H 5h
|
||||||
|
nmap L 5l
|
||||||
|
|
||||||
|
nnoremap <c-h> <c-w>h
|
||||||
|
nnoremap <c-l> <c-w>l
|
||||||
|
nnoremap <c-j> <c-w>j
|
||||||
|
nnoremap <c-k> <c-w>k
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" 在文件外修改时自动加载
|
" 在文件外修改时自动加载
|
||||||
set autoread
|
set autoread
|
||||||
|
|
||||||
" make 项目
|
" make 项目
|
||||||
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
|
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
|
||||||
|
map <F5> :call CompileRunGcc()<CR>
|
||||||
|
|
||||||
|
func! CompileRunGcc()
|
||||||
|
exec "w"
|
||||||
|
if &filetype == 'c'
|
||||||
|
exec '!g++ % -o %<'
|
||||||
|
exec '!time ./%<'
|
||||||
|
elseif &filetype == 'cpp'
|
||||||
|
exec '!g++ % -o %<'
|
||||||
|
exec '!time ./%<'
|
||||||
|
elseif &filetype == 'python'
|
||||||
|
exec '!time python %'
|
||||||
|
elseif &filetype == 'sh'
|
||||||
|
:!time bash %
|
||||||
|
elseif &filetype == 'go'
|
||||||
|
exec 'GoRun'
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
"从不备份
|
"从不备份
|
||||||
set nobackup
|
set nobackup
|
||||||
@ -49,6 +94,11 @@ set nobackup
|
|||||||
set noswapfile
|
set noswapfile
|
||||||
"搜索忽略大小写
|
"搜索忽略大小写
|
||||||
set ignorecase
|
set ignorecase
|
||||||
|
" 搜索时忽略大小写,但在有一个或以上大写字母时仍大小写敏感
|
||||||
|
set ignorecase
|
||||||
|
set smartcase
|
||||||
|
|
||||||
|
|
||||||
"搜索逐字符高亮
|
"搜索逐字符高亮
|
||||||
set hlsearch
|
set hlsearch
|
||||||
set incsearch
|
set incsearch
|
||||||
@ -90,8 +140,16 @@ set whichwrap+=<,>,h,l
|
|||||||
map <space>ma :set mouse=a<CR>:set nu<CR>:set nopaste<CR>
|
map <space>ma :set mouse=a<CR>:set nu<CR>:set nopaste<CR>
|
||||||
map <space>mc :set mouse=c<CR>:set nu!<CR>:set paste<CR>
|
map <space>mc :set mouse=c<CR>:set nu!<CR>:set paste<CR>
|
||||||
set mouse=a
|
set mouse=a
|
||||||
set selection=exclusive
|
|
||||||
set selectmode=mouse,key
|
" 选中状态下 Ctrl+c 复制
|
||||||
|
vnoremap <c-c> "+y
|
||||||
|
|
||||||
|
" Ctrl+v
|
||||||
|
"nmap <silent> <C-v> "+p
|
||||||
|
|
||||||
|
|
||||||
|
"set selection=exclusive
|
||||||
|
"set selectmode=mouse,key
|
||||||
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
|
" 通过使用: commands命令,告诉我们文件的哪一行被改变过
|
||||||
set report=0
|
set report=0
|
||||||
" 在被分割的窗口间显示空白,便于阅读
|
" 在被分割的窗口间显示空白,便于阅读
|
||||||
@ -106,22 +164,6 @@ set scrolloff=3
|
|||||||
set smartindent
|
set smartindent
|
||||||
" 高亮显示普通txt文件(需要txt.vim脚本)
|
" 高亮显示普通txt文件(需要txt.vim脚本)
|
||||||
au BufRead,BufNewFile * setfiletype txt
|
au BufRead,BufNewFile * setfiletype txt
|
||||||
"自动补全
|
|
||||||
:inoremap ( ()<ESC>i
|
|
||||||
:inoremap ) <c-r>=ClosePair(')')<CR>
|
|
||||||
":inoremap { {<CR>}<ESC>O
|
|
||||||
":inoremap } <c-r>=ClosePair('}')<CR>
|
|
||||||
:inoremap [ []<ESC>i
|
|
||||||
:inoremap ] <c-r>=ClosePair(']')<CR>
|
|
||||||
:inoremap " ""<ESC>i
|
|
||||||
:inoremap ' ''<ESC>i
|
|
||||||
function! ClosePair(char)
|
|
||||||
if getline('.')[col('.') - 1] == a:char
|
|
||||||
return "\<Right>"
|
|
||||||
else
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
"打开文件类型检测, 加了这句才可以用智能补全
|
"打开文件类型检测, 加了这句才可以用智能补全
|
||||||
set completeopt=longest,menu
|
set completeopt=longest,menu
|
||||||
@ -146,3 +188,9 @@ if has("autocmd")
|
|||||||
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee,*.vue :call CleanExtraSpaces()
|
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee,*.vue :call CleanExtraSpaces()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
colorscheme slate
|
||||||
|
highlight Comment ctermfg=blue
|
||||||
|
|
||||||
|
|
||||||
|
au BufNewFile,BufRead *.launch,*.urdf set filetype=xml
|
||||||
|
|||||||
14
vim/vimrc
14
vim/vimrc
@ -9,12 +9,15 @@ Plugin 'VundleVim/Vundle.vim'
|
|||||||
|
|
||||||
|
|
||||||
Plugin 'junegunn/fzf.vim'
|
Plugin 'junegunn/fzf.vim'
|
||||||
|
" 搜索
|
||||||
nmap <Leader>l :BLines
|
nmap <Leader>l :BLines
|
||||||
nmap <Leader>L :Lines
|
nmap <Leader>L :Lines
|
||||||
|
|
||||||
|
" 全局搜索,即使文件没打开
|
||||||
Plugin 'rking/ag.vim'
|
Plugin 'rking/ag.vim'
|
||||||
|
|
||||||
|
|
||||||
|
" 新建文件自动添加模板
|
||||||
Plugin 'aperezdc/vim-template.git'
|
Plugin 'aperezdc/vim-template.git'
|
||||||
let g:templates_directory = '~/.vim/templates'
|
let g:templates_directory = '~/.vim/templates'
|
||||||
|
|
||||||
@ -83,8 +86,8 @@ let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM基于
|
|||||||
"let g:syntastic_ignore_files=[".*\.py$"]
|
"let g:syntastic_ignore_files=[".*\.py$"]
|
||||||
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
|
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
|
||||||
let g:ycm_confirm_extra_conf = 0 " 关闭加载.ycm_extra_conf.py提示
|
let g:ycm_confirm_extra_conf = 0 " 关闭加载.ycm_extra_conf.py提示
|
||||||
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
|
let g:ycm_key_list_select_completion = ['<Down>'] " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
|
||||||
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
|
let g:ycm_key_list_previous_completion = ['<Up>']
|
||||||
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
|
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
|
||||||
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
|
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
|
||||||
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
|
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
|
||||||
@ -103,7 +106,7 @@ let g:SuperTabDefaultCompletionType = "<c-n>"
|
|||||||
" xml html auto close
|
" xml html auto close
|
||||||
Plugin 'alvan/vim-closetag'
|
Plugin 'alvan/vim-closetag'
|
||||||
let g:jedi#documentation_command = ""
|
let g:jedi#documentation_command = ""
|
||||||
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.launch'
|
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.launch,*.vue'
|
||||||
|
|
||||||
|
|
||||||
Plugin 'jiangmiao/auto-pairs'
|
Plugin 'jiangmiao/auto-pairs'
|
||||||
@ -207,9 +210,10 @@ Plugin 'posva/vim-vue'
|
|||||||
"Plugin 'https://github.com/taketwo/vim-ros.git'
|
"Plugin 'https://github.com/taketwo/vim-ros.git'
|
||||||
|
|
||||||
|
|
||||||
|
Plugin 'ctrlpvim/ctrlp.vim'
|
||||||
|
|
||||||
|
Plugin 'terryma/vim-multiple-cursors'
|
||||||
|
"Plugin 'Shougo/neocomplete.vim'
|
||||||
|
|
||||||
|
|
||||||
call vundle#end() " required
|
call vundle#end() " required
|
||||||
|
|||||||
@ -1,102 +1,183 @@
|
|||||||
#!/usr/bin/env python
|
# This file is NOT licensed under the GPLv3, which is the license for the rest
|
||||||
|
# of YouCompleteMe.
|
||||||
|
#
|
||||||
|
# Here's the license text for this file:
|
||||||
|
#
|
||||||
|
# This is free and unencumbered software released into the public domain.
|
||||||
|
#
|
||||||
|
# Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
# distribute this software, either in source code form or as a compiled
|
||||||
|
# binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
# means.
|
||||||
|
#
|
||||||
|
# In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
# of this software dedicate any and all copyright interest in the
|
||||||
|
# software to the public domain. We make this dedication for the benefit
|
||||||
|
# of the public at large and to the detriment of our heirs and
|
||||||
|
# successors. We intend this dedication to be an overt act of
|
||||||
|
# relinquishment in perpetuity of all present and future rights to this
|
||||||
|
# software under copyright law.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# For more information, please refer to <http://unlicense.org/>
|
||||||
|
|
||||||
|
from distutils.sysconfig import get_python_inc
|
||||||
|
import platform
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import ycm_core
|
import ycm_core
|
||||||
|
|
||||||
|
# DIR_OF_THIS_SCRIPT = "/home/light/.vim/bundle/YouCompleteMe/third_party/ycmd"
|
||||||
|
# DIR_OF_THIRD_PARTY = os.path.join(DIR_OF_THIS_SCRIPT, 'third_party')
|
||||||
|
DIR_OF_THIS_SCRIPT = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
SOURCE_EXTENSIONS = ['.cpp', '.cxx', '.cc', '.c', '.m', '.mm']
|
||||||
|
|
||||||
|
# These are the compilation flags that will be used in case there's no
|
||||||
|
# compilation database set (by default, one is not set).
|
||||||
|
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
|
||||||
flags = [
|
flags = [
|
||||||
'-Wall',
|
'-Wall',
|
||||||
'-Wextra',
|
'-Wextra',
|
||||||
'-Werror',
|
'-Werror',
|
||||||
'-fexceptions',
|
'-Wno-long-long',
|
||||||
'-DNDEBUG',
|
'-Wno-variadic-macros',
|
||||||
'-std=c++11',
|
'-fexceptions',
|
||||||
'-x',
|
'-DNDEBUG',
|
||||||
'c++',
|
# You 100% do NOT need -DUSE_CLANG_COMPLETER and/or -DYCM_EXPORT in your flags;
|
||||||
'-isystem',
|
# only the YCM source code needs it.
|
||||||
'/usr/include',
|
'-DUSE_CLANG_COMPLETER',
|
||||||
'-isystem',
|
'-DYCM_EXPORT=',
|
||||||
'/usr/local/include',
|
# THIS IS IMPORTANT! Without the '-x' flag, Clang won't know which language to
|
||||||
'-isystem',
|
# use when compiling headers. So it will guess. Badly. So C++ headers will be
|
||||||
'/opt/ros/' + os.getenv('ROS_DISTRO') + '/include',
|
# compiled as C headers. You don't want that so ALWAYS specify the '-x' flag.
|
||||||
'-isystem',
|
# For a C project, you would set this to 'c' instead of 'c++'.
|
||||||
'~/catkin_ws/devel/include',
|
'-x',
|
||||||
|
'c++',
|
||||||
|
'-I',
|
||||||
|
'/usr/include',
|
||||||
|
'-isystem',
|
||||||
|
'includes',
|
||||||
|
'-I',
|
||||||
|
'src',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Clang automatically sets the '-std=' flag to 'c++14' for MSVC 2015 or later,
|
||||||
|
# which is required for compiling the standard library, and to 'c++11' for older
|
||||||
|
# versions.
|
||||||
|
if platform.system() != 'Windows':
|
||||||
|
flags.append('-std=c++11')
|
||||||
|
|
||||||
|
|
||||||
|
# Set this to the absolute path to the folder (NOT the file!) containing the
|
||||||
|
# compile_commands.json file to use that instead of 'flags'. See here for
|
||||||
|
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
|
||||||
|
#
|
||||||
|
# You can get CMake to generate this file for you by adding:
|
||||||
|
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
|
||||||
|
# to your CMakeLists.txt file.
|
||||||
|
#
|
||||||
|
# Most projects will NOT need to set this to anything; you can just change the
|
||||||
|
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
|
||||||
compilation_database_folder = ''
|
compilation_database_folder = ''
|
||||||
|
|
||||||
if os.path.exists( compilation_database_folder ):
|
if os.path.exists(compilation_database_folder):
|
||||||
database = ycm_core.CompilationDatabase( compilation_database_folder )
|
database = ycm_core.CompilationDatabase(compilation_database_folder)
|
||||||
else:
|
else:
|
||||||
database = None
|
database = None
|
||||||
|
|
||||||
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c' ]
|
|
||||||
|
|
||||||
def DirectoryOfThisScript():
|
|
||||||
return os.path.dirname( os.path.abspath( __file__ ) )
|
|
||||||
|
|
||||||
|
|
||||||
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
|
def IsHeaderFile(filename):
|
||||||
if not working_directory:
|
extension = os.path.splitext(filename)[1]
|
||||||
return list( flags )
|
return extension in ['.h', '.hxx', '.hpp', '.hh']
|
||||||
new_flags = []
|
|
||||||
make_next_absolute = False
|
|
||||||
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
|
|
||||||
for flag in flags:
|
|
||||||
new_flag = flag
|
|
||||||
|
|
||||||
if make_next_absolute:
|
|
||||||
make_next_absolute = False
|
|
||||||
if not flag.startswith( '/' ):
|
|
||||||
new_flag = os.path.join( working_directory, flag )
|
|
||||||
|
|
||||||
for path_flag in path_flags:
|
|
||||||
if flag == path_flag:
|
|
||||||
make_next_absolute = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if flag.startswith( path_flag ):
|
|
||||||
path = flag[ len( path_flag ): ]
|
|
||||||
new_flag = path_flag + os.path.join( working_directory, path )
|
|
||||||
break
|
|
||||||
|
|
||||||
if new_flag:
|
|
||||||
new_flags.append( new_flag )
|
|
||||||
return new_flags
|
|
||||||
|
|
||||||
|
|
||||||
def IsHeaderFile( filename ):
|
def FindCorrespondingSourceFile(filename):
|
||||||
extension = os.path.splitext( filename )[ 1 ]
|
if IsHeaderFile(filename):
|
||||||
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
|
basename = os.path.splitext(filename)[0]
|
||||||
|
for extension in SOURCE_EXTENSIONS:
|
||||||
|
replacement_file = basename + extension
|
||||||
|
if os.path.exists(replacement_file):
|
||||||
|
return replacement_file
|
||||||
|
return filename
|
||||||
|
|
||||||
|
|
||||||
def GetCompilationInfoForFile( filename ):
|
def PathToPythonUsedDuringBuild():
|
||||||
if IsHeaderFile( filename ):
|
try:
|
||||||
basename = os.path.splitext( filename )[ 0 ]
|
filepath = os.path.join(
|
||||||
for extension in SOURCE_EXTENSIONS:
|
DIR_OF_THIS_SCRIPT, 'PYTHON_USED_DURING_BUILDING')
|
||||||
replacement_file = basename + extension
|
with open(filepath) as f:
|
||||||
if os.path.exists( replacement_file ):
|
return f.read().strip()
|
||||||
compilation_info = database.GetCompilationInfoForFile(
|
# We need to check for IOError for Python 2 and OSError for Python 3.
|
||||||
replacement_file )
|
except (IOError, OSError):
|
||||||
if compilation_info.compiler_flags_:
|
return None
|
||||||
return compilation_info
|
|
||||||
return None
|
|
||||||
return database.GetCompilationInfoForFile( filename )
|
|
||||||
|
|
||||||
|
|
||||||
def FlagsForFile( filename, **kwargs ):
|
def Settings(**kwargs):
|
||||||
if database:
|
language = kwargs['language']
|
||||||
compilation_info = GetCompilationInfoForFile( filename )
|
|
||||||
if not compilation_info:
|
|
||||||
return None
|
|
||||||
|
|
||||||
final_flags = MakeRelativePathsInFlagsAbsolute(
|
if language == 'cfamily':
|
||||||
compilation_info.compiler_flags_,
|
# If the file is a header, try to find the corresponding source file and
|
||||||
compilation_info.compiler_working_dir_ )
|
# retrieve its flags from the compilation database if using one. This is
|
||||||
else:
|
# necessary since compilation databases don't have entries for header files.
|
||||||
relative_to = DirectoryOfThisScript()
|
# In addition, use this source file as the translation unit. This makes it
|
||||||
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
|
# possible to jump from a declaration in the header file to its definition
|
||||||
|
# in the corresponding source file.
|
||||||
|
filename = FindCorrespondingSourceFile(kwargs['filename'])
|
||||||
|
|
||||||
return {
|
if not database:
|
||||||
'flags': final_flags,
|
return {
|
||||||
'do_cache': True
|
'flags': flags,
|
||||||
}
|
'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT,
|
||||||
|
'override_filename': filename
|
||||||
|
}
|
||||||
|
|
||||||
|
compilation_info = database.GetCompilationInfoForFile(filename)
|
||||||
|
if not compilation_info.compiler_flags_:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
|
||||||
|
# python list, but a "list-like" StringVec object.
|
||||||
|
final_flags = list(compilation_info.compiler_flags_)
|
||||||
|
|
||||||
|
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
|
||||||
|
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
|
||||||
|
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
|
||||||
|
try:
|
||||||
|
final_flags.remove('-stdlib=libc++')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return {
|
||||||
|
'flags': final_flags,
|
||||||
|
'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
|
||||||
|
'override_filename': filename
|
||||||
|
}
|
||||||
|
|
||||||
|
if language == 'python':
|
||||||
|
return {
|
||||||
|
'interpreter_path': PathToPythonUsedDuringBuild()
|
||||||
|
}
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def GetStandardLibraryIndexInSysPath(sys_path):
|
||||||
|
for index, path in enumerate(sys_path):
|
||||||
|
if os.path.isfile(os.path.join(path, 'os.py')):
|
||||||
|
return index
|
||||||
|
raise RuntimeError('Could not find standard library path in Python path.')
|
||||||
|
|
||||||
|
|
||||||
|
def PythonSysPath(**kwargs):
|
||||||
|
sys_path = kwargs['sys_path']
|
||||||
|
|
||||||
|
sys_path.insert(0, DIR_OF_THIS_SCRIPT)
|
||||||
|
|
||||||
|
return sys_path
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user