Compare commits

..

No commits in common. "b34d120f269ea0b3e1d993627a6a4e6ec158817c" and "1048c54afecc7df87ba0ba31b43555bfcf025df8" have entirely different histories.

22 changed files with 109 additions and 417 deletions

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
*.log
nvim/lazy-lock.json

View file

@ -16,42 +16,22 @@ RUN apt-get update \
&& apt-get install -y \ && apt-get install -y \
libgl1-mesa-dri \ libgl1-mesa-dri \
libgl1-mesa-glx \ libgl1-mesa-glx \
mesa-utils \
mesa-utils-extra \
python3-pip \ python3-pip \
python3-venv \
avahi-daemon \ avahi-daemon \
avahi-utils \ avahi-utils \
libnss-mdns \ libnss-mdns \
iputils-ping \ iputils-ping \
sudo \ sudo \
ripgrep \ vim \
wget \ wget \
byobu \ byobu \
ros-${ROS_DISTR}-rqt-tf-tree \ xmlstarlet \
ros-${ROS_DISTR}-apriltag \
ros-${ROS_DISTR}-plotjuggler-ros \
clang-format \ clang-format \
xclip \ && python3 -m pip install yapf \
# neovim build depends \ rope \
ninja-build \ flake8 \
gettext \ pylint \
cmake \ jedi \
unzip \
curl \
# end neovim build depends \
# && rosdep install --from-paths /ros2_underlay/src -y --ignore-src \
# && rosdep install --from paths /ros2/src -y --ignore-src \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& NODE_MAJOR=20 \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt update \
&& apt-get remove nodejs \
&& apt-get install nodejs \
&& git clone https://github.com/neovim/neovim.git \
&& cd neovim && git checkout stable && make CMAKE_BUILD_TYPE=RelWithDebInfo \
&& sudo make install \
&& groupadd --gid $USER_GID $USERNAME \ && groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
@ -77,28 +57,30 @@ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/
-a 'PATH=$PATH:$HOME/.local/bin' \ -a 'PATH=$PATH:$HOME/.local/bin' \
-a 'export HISTFILE=/zsh_history/.zsh_history' \ -a 'export HISTFILE=/zsh_history/.zsh_history' \
-a 'export TERM=xterm-256color' \ -a 'export TERM=xterm-256color' \
-a 'export COLORTERM=truecolor' \ -a 'eval "$(register-python-argcomplete3 ros2)"' \
-a 'eval "$(register-python-argcomplete3 colcon)"' \
&& mkdir -p "$HOME/.zsh" \ && mkdir -p "$HOME/.zsh" \
&& git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure" \ && git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure" \
&& echo "source /opt/ros/$ROS_DISTR/setup.zsh" >> /home/$USERNAME/.zshrc && echo "source /opt/ros/$ROS_DISTR/setup.zsh" >> /home/$USERNAME/.zshrc
ADD vimrc /home/$USERNAME/.vimrc
ADD ycm_extra_conf.py /home/$USERNAME/.ycm_extra_conf.py
RUN git clone https://github.com/VundleVim/Vundle.vim.git /home/$USERNAME/.vim/bundle/Vundle.vim
RUN vim +PluginInstall +qall
RUN cd /home/$USERNAME/.vim/bundle/YouCompleteMe \
&& python3 install.py --clangd-completer
USER root USER root
RUN mkdir /zsh_history \ RUN mkdir /zsh_history \
&& touch /zsh_history/.zsh_history \ && touch /zsh_history/.zsh_history \
&& chown -R $USERNAME /zsh_history && chown -R $USERNAME /zsh_history
ADD ros2-vim/nvim /home/$USERNAME/.config/nvim ADD cpp.vim /home/$USERNAME/.vim/after/ftplugin/cpp.vim
RUN chown -R $USERNAME /home/$USERNAME/ RUN chown -R $USERNAME /home/$USERNAME/
USER ${USERNAME} ADD entrypoint.sh /entrypoint.sh
RUN nvim --headless "+Lazy! sync" +qa
RUN nvim --headless +"MasonInstall lua-language-server clangd python-lsp-server yaml-language-server" +q
WORKDIR /home/$USERNAME
USER root
ADD ros2-vim/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
RUN chown $USERNAME /entrypoint.sh RUN chown $USERNAME /entrypoint.sh
USER ${USERNAME} USER ${USERNAME}
WORKDIR /home/$USERNAME
RUN wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format.py
# Switch back to dialog for any ad-hoc use of apt-get # Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog ENV DEBIAN_FRONTEND=dialog
CMD [ "/usr/bin/zsh"] CMD [ "/usr/bin/zsh"]

View file

@ -1,25 +0,0 @@
# Update The Base Image
~~~ bash
docker pull osrf/ros:humble-desktop-full
~~~
# Rebuild The Image from Dockerfile
~~~ bash
docker-compose build
~~~
# Run The Container
## NVIDIA
~~~ bash
docker-compose run --rm nvidia
~~~
## Others
~~~ bash
docker-compose run --rm dev
~~~

3
build
View file

@ -1,3 +0,0 @@
#!/usr/bin/bash
docker compose build

View file

@ -1,6 +1,5 @@
services: services:
nvidia: nvidia:
container_name: ros2-vim
extends: extends:
service: dev service: dev
deploy: deploy:
@ -11,16 +10,13 @@ services:
count: all count: all
capabilities: [gpu] capabilities: [gpu]
dev: dev:
container_name: ros2-vim
network_mode: host network_mode: host
build: build:
context: .. context: .
dockerfile: ./ros2-vim/Dockerfile dockerfile: ./Dockerfile
ssh:
- default
stdin_open: true stdin_open: true
tty: true tty: true
entrypoint: ["/entrypoint.sh", "zsh"] entrypoint: ["/entrypoint.sh", "byobu"]
working_dir: /home/ros-user/uuv/ros2 working_dir: /home/ros-user/uuv/ros2
devices: devices:
- "/dev/dri:/dev/dri" - "/dev/dri:/dev/dri"
@ -37,13 +33,8 @@ services:
- type: bind - type: bind
source: /var/run/avahi-daemon/socket source: /var/run/avahi-daemon/socket
target: /var/run/avahi-daemon/socket target: /var/run/avahi-daemon/socket
- type: bind
source: ${HOME}/Documents/ros2-vim/nvim
target: /home/ros-user/.config/nvim
- "ros2_zsh_history:/zsh_history" - "ros2_zsh_history:/zsh_history"
- nvim_data:/home/ros-user/.local/share/nvim
- $SSH_AUTH_SOCK:/ssh-agent - $SSH_AUTH_SOCK:/ssh-agent
- "~/.gitconfig:/etc/gitconfig"
environment: environment:
- DISPLAY=${DISPLAY} - DISPLAY=${DISPLAY}
@ -51,10 +42,6 @@ services:
- SHELL=/usr/bin/zsh - SHELL=/usr/bin/zsh
- ROS_WORKSPACE=/home/ros-user/uuv/ros2 - ROS_WORKSPACE=/home/ros-user/uuv/ros2
- SSH_AUTH_SOCK=/ssh-agent - SSH_AUTH_SOCK=/ssh-agent
- TERM=xterm-256color
- COLORTERM=24bit
- ROS_DOMAIN_ID=29
volumes: volumes:
ros2_zsh_history: ros2_zsh_history:
nvim_data:

View file

@ -1,16 +1,10 @@
#!/bin/bash #!/bin/bash
set -e set -e
PX4_DIR="\$HOME/uuv/PX4-Autopilot"
WORKSPACE_DIR="\$HOME/uuv/ros2" WORKSPACE_DIR="\$HOME/uuv/ros2"
UNDERLAY_DIR="\$HOME/uuv/ros2_underlay" echo "source $PX4_DIR/Tools/setup_gazebo.bash $PX4_DIR $PX4_DIR/build/px4_sitl_default > /dev/null" >> ~/.zshrc
echo "export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:$PX4_DIR" >> ~/.zshrc
echo "alias build_ros=\"env -i HOME=\$HOME USER=\$USER TERM=xterm-256color bash -l -c 'source $UNDERLAY_DIR/install/setup.bash && cd $WORKSPACE_DIR && colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'\"" >> ~/.zshrc echo "export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:$PX4_DIR/Tools/sitl_gazebo" >> ~/.zshrc
echo "alias build_underlay=\"env -i HOME=\$HOME USER=\$USER TERM=xterm-256color bash -l -c 'source /opt/ros/$ROS_DISTR/setup.bash && cd $UNDERLAY_DIR && colcon build'\"" >> ~/.zshrc vim +PluginUpdate +qall
echo 'source $HOME/uuv/ros2_underlay/install/setup.zsh' >> ~/.zshrc
echo 'source $HOME/uuv/ros2/install/local_setup.zsh' >> ~/.zshrc
echo 'export RCUTILS_COLORIZED_OUTPUT=1' >> ~/.zshrc
echo 'eval "$(register-python-argcomplete3 ros2)"' >> ~/.zshrc
echo 'eval "$(register-python-argcomplete3 colcon)"' >> ~/.zshrc
exec $@ exec $@

View file

@ -1,6 +0,0 @@
function ColorMyPencils(color)
color = color or "rose-pine"
vim.cmd.colorscheme(color)
end
ColorMyPencils()

View file

@ -1 +0,0 @@
vim.keymap.set("n", "<leader>gs", vim.cmd.Git);

View file

@ -1,9 +0,0 @@
require('gitsigns').setup {
signs = {
add = {text='+'},
change = {text='~'},
delete = {text='_'},
topdelete = {text=''},
changedelete = {text='~'},
}
}

View file

@ -1,16 +0,0 @@
local mark = require('harpoon.mark')
local ui = require('harpoon.ui')
local cmd_ui = require('harpoon.cmd-ui')
local term = require('harpoon.term')
vim.keymap.set('n', '<leader>a', mark.add_file)
vim.keymap.set('n', '<C-e>', ui.toggle_quick_menu)
vim.keymap.set('n', '<C-h>', function() ui.nav_file(1) end)
vim.keymap.set('n', '<C-t>', function() ui.nav_file(2) end)
vim.keymap.set('n', '<C-n>', function() ui.nav_file(3) end)
vim.keymap.set('n', '<C-s>', function() ui.nav_file(4) end)
vim.keymap.set('n', '<leader>c', cmd_ui.toggle_quick_menu)
vim.keymap.set('n', '<leader>gt1', function() term.gotoTerminal(1) end)
vim.keymap.set('n', '<leader>br', function() term.sendCommand(1, 'build_ros') end)

View file

@ -1,61 +0,0 @@
require('mason').setup({
ui = {
border = 'rounded'
}
})
-- Install language servers
require('mason-lspconfig').setup {
ensure_installed = {
'lua_ls', 'clangd', 'pylsp', 'yamlls'
}
}
local lsp = require('lsp-zero').preset({
manage_nvim_cmp = {
set_sources = 'lsp',
set_basic_mappings = true,
set_extra_mappings = false,
use_luasnip = true,
set_format = true,
documentation_window = true,
}
})
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
-- (Optional) Configure lua language server for neovim
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
lsp.setup()
local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
-- configure auto complete key
cmp.setup({
mapping = {
['<Tab>'] = cmp_action.tab_complete(),
['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
['<C-e>'] = cmp.mapping.abort(),
['<C-space>'] = cmp.mapping.complete(),
['<C-j>'] = cmp.mapping.scroll_docs(1),
['<C-k>'] = cmp.mapping.scroll_docs(-1),
['<CR>'] = cmp.mapping.confirm({ select = false }),
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
})
require('lspconfig').pylsp.setup {
settings = {
pylsp = {
plugins = {
autopep8 = { enabled = false },
yapf = { enabled = true, args = '--style={based_on_style: google column_limit: 80}' },
}
}
}
}

View file

@ -1,6 +0,0 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set("n", "C-p", builtin.git_files, {})
vim.keymap.set("n", "<leader>ps", function()
builtin.grep_string({ search = vim.fn.input("Grep > ") });
end)

View file

@ -1,35 +0,0 @@
require('nvim-treesitter.configs').setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "cpp", "python", "yaml" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for "all")
ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}

View file

@ -1,17 +0,0 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = ' ' -- needs to be set before lazy im
require('lazy').setup('plugins')
require('lennartalff')

View file

@ -1,5 +0,0 @@
require('lennartalff.remap')
require('lennartalff.set')
-- vim.cmd('colorscheme rose-pine')
vim.o.termguicolors = true
vim.cmd.colorscheme 'catppuccin-frappe'

View file

@ -1,65 +0,0 @@
-- packer bootstrapping
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use 'lewis6991/gitsigns.nvim'
use {
'nvim-telescope/telescope.nvim', tag = '0.1.1',
-- or , branch = '0.1.x',
requires = { { 'nvim-lua/plenary.nvim' } }
}
use({ 'rose-pine/neovim', as = 'rose-pine' })
use {
'nvim-treesitter/nvim-treesitter',
run = function()
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
ts_update()
end,
}
use 'tpope/vim-fugitive'
use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
requires = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{ -- Optional
'williamboman/mason.nvim',
run = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
{ 'mhartington/formatter.nvim' },
}
}
use {
"ThePrimeagen/refactoring.nvim",
requires = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-treesitter/nvim-treesitter" }
}
}
if packer_bootstrap then
require('packer').sync()
end
end)

View file

@ -1,34 +0,0 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- move selected text
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
vim.keymap.set('n', 'J', 'mzJ`z')
vim.keymap.set('n', '<C-d>', '<C-d>zz')
vim.keymap.set('n', '<C-u>', '<C-u>zz')
-- yank to clipboard
vim.keymap.set('n', '<leader>y', '"+y')
vim.keymap.set('v', '<leader>y', '"+y')
-- delete to void
vim.keymap.set('n', '<leader>d', '"_d')
vim.keymap.set('v', '<leader>d', '"_d')
vim.keymap.set('i', '<C-c>', '<Esc>')
-- avoid accidentally closing everything!
vim.keymap.set('n', 'Q', '<nop>')
vim.keymap.set('n', '<leader>f', function()
vim.lsp.buf.format()
end)
-- quickfix navigation
vim.keymap.set('n', '<C-j>', '<cmd>cnext<CR>zz')
vim.keymap.set('n', '<C-k>', '<cmd>cprev<CR>zz')
vim.keymap.set('n', '<leader>j', '<cmd>lnext<CR>zz')
vim.keymap.set('n', '<leader>k', '<cmd>lprev<CR>zz')

View file

@ -1,29 +0,0 @@
-- vim.opt.guicursor = ''
-- line numbers
vim.opt.nu = true
vim.opt.relativenumber = true
-- default indentation
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = false
vim.api.nvim_create_autocmd("FileTYpe", {
pattern = "cpp",
callback = function()
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2
end
})
vim.opt.scrolloff = 8
vim.opt.signcolumn = 'yes'
vim.opt.updatetime = 500
vim.opt.colorcolumn = '80'

View file

@ -1,36 +0,0 @@
return {
{ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' },
'lewis6991/gitsigns.nvim',
{
'nvim-telescope/telescope.nvim',
dependencies = {
{ 'nvim-lua/plenary.nvim' } }
},
{ 'rose-pine/neovim', name = 'rose-pine' },
{ 'catppuccin/nvim', name = 'catppuccin', priority = 1000 },
{ 'tpope/vim-fugitive', name = 'fugitive' },
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
dependencies = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{ 'williamboman/mason.nvim' }, -- Optional
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
},
},
{
'ThePrimeagen/harpoon',
dependencies = {
{ 'nvim-lua/plenary.nvim' },
},
},
{ 'ray-x/lsp_signature.nvim', event = 'VeryLazy', opts = {},
config = function(_, opts) require('lsp_signature').setup(opts) end },
}

3
run
View file

@ -1,3 +0,0 @@
#!/usr/bin/bash
docker compose run --rm --name ros2-vim dev

65
vimrc Normal file
View file

@ -0,0 +1,65 @@
set nocompatible
" required for vundle
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'preservim/nerdtree'
Plugin 'ycm-core/YouCompleteMe'
Plugin 'NLKNguyen/papercolor-theme'
Plugin 'tmsvg/pear-tree'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'aonemd/quietlight.vim'
call vundle#end()
filetype plugin indent on
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
"disable soft wraps
set nowrap
augroup WrapLine
autocmd!
autocmd FileType txt setlocal wrap
autocmd FileType rst setlocal wrap
augroup End
" enable line numbers
set number relativenumber
set nu rnu
set ruler
set visualbell
set encoding=utf-8
set ttyfast
let mapleader=","
" always show mode status line
set laststatus=2
" always show mode
set showmode
inoremap jj <ESC>
nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-f> :NERDTreeFind<CR>
set t_Co=256
set background=light
silent! colorscheme quietlight
let g:airline_theme='papercolor'
:set colorcolumn=81,121
let g:clang_format_fallback_style="Google"
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_confirm_extra_conf=0
let g:ycm_always_populate_location_list=1
let g:ycm_clangd_args=['--header-insertion=never']
autocmd FileType c,cpp nnoremap <leader>f :py3f $HOME/clang-format.py<CR>
autocmd FileType c,cpp vnoremap <leader>f :py3f $HOME/clang-format.py<CR>
" autocmd FileType python nnoremap <leader><F> :0,$!yapf<CR><C-o>
autocmd FileType python nnoremap <leader>f :0,$!yapf<CR><C-o>

17
ycm_extra_conf.py Normal file
View file

@ -0,0 +1,17 @@
import os
import shlex
import subprocess
def find_ros_python_packages():
ros_ws = os.environ['ROS_WORKSPACE']
cmd = shlex.split(
f'bash -c "source {ros_ws}/install/setup.bash && echo $PYTHONPATH"')
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
for line in p.stdout:
paths = line.rstrip().split(':')
p.communicate()
return paths
def Settings(**kwargs):
return {'sys_path': find_ros_python_packages()}