many updates :-)

This commit is contained in:
Thies Lennart Alff 2023-10-12 14:34:01 +02:00
parent a6487fb9c6
commit 159fadd35b
12 changed files with 255 additions and 122 deletions

View file

@ -1,14 +1,38 @@
FROM osrf/ros:humble-desktop-full FROM osrf/ros:iron-desktop-full AS base-ros-nvim
ARG ROS_DISTR=humble
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get install -y \
ripgrep \
ninja-build \
gettext \
cmake \
unzip \
curl \
clang-format \
xclip \
wl-clipboard \
&& 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 \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
FROM base-ros-nvim AS base-ros-nvim-graphics
ARG ROS_DISTR=iron
ENV NVIDIA_VISIBLE_DEVICES \ ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all} ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \ ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
ARG USERNAME=ros-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV ROS_DISTR=$ROS_DISTR ENV ROS_DISTR=$ROS_DISTR
RUN apt-get update \ RUN apt-get update \
@ -25,40 +49,26 @@ RUN apt-get update \
libnss-mdns \ libnss-mdns \
iputils-ping \ iputils-ping \
sudo \ sudo \
ripgrep \
wget \ wget \
byobu \
ros-${ROS_DISTR}-rqt-tf-tree \ ros-${ROS_DISTR}-rqt-tf-tree \
ros-${ROS_DISTR}-apriltag \ ros-${ROS_DISTR}-apriltag \
ros-${ROS_DISTR}-plotjuggler-ros \ ros-${ROS_DISTR}-plotjuggler-ros \
clang-format \
xclip \
# neovim build depends \
ninja-build \
gettext \
cmake \
unzip \
curl \
# end neovim build depends \
# && rosdep install --from-paths /ros2_underlay/src -y --ignore-src \ # && rosdep install --from-paths /ros2_underlay/src -y --ignore-src \
# && rosdep install --from paths /ros2/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 \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& apt-get autoremove -y \ && apt-get autoremove -y \
&& apt-get clean -y \ && apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
FROM base-ros-nvim-graphics AS individual
ARG USERNAME=ros-user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME
USER ${USERNAME} USER ${USERNAME}
ENV TERM xterm-256color ENV TERM xterm-256color
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- \ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.1/zsh-in-docker.sh)" -- \
@ -80,8 +90,13 @@ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/
-a 'export COLORTERM=truecolor' \ -a 'export COLORTERM=truecolor' \
&& 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 \
&& pip3 install yapf pre-commit ruff \
&& sudo wget https://hippocampusrobotics.github.io/docs/_downloads/6055b3168d4f0a8cd764ebc481280219/ros-iron-px4-msgs_2.0.1-0jammy_amd64.deb \
&& sudo apt-get install ./ros-iron-px4-msgs_2.0.1-0jammy_amd64.deb \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
USER root USER root
RUN mkdir /zsh_history \ RUN mkdir /zsh_history \
@ -91,7 +106,7 @@ ADD ros2-vim/nvim /home/$USERNAME/.config/nvim
RUN chown -R $USERNAME /home/$USERNAME/ RUN chown -R $USERNAME /home/$USERNAME/
USER ${USERNAME} USER ${USERNAME}
RUN nvim --headless "+Lazy! sync" +qa RUN nvim --headless "+Lazy! sync" +qa
RUN nvim --headless +"MasonInstall lua-language-server clangd python-lsp-server yaml-language-server" +q RUN nvim --headless +"MasonInstall lua-language-server clangd python-lsp-server yaml-language-server yapf" +q
WORKDIR /home/$USERNAME WORKDIR /home/$USERNAME
USER root USER root

View file

@ -1,7 +1,7 @@
# Update The Base Image # Update The Base Image
~~~ bash ~~~ bash
docker pull osrf/ros:humble-desktop-full docker pull osrf/ros:iron-desktop-full
~~~ ~~~
# Rebuild The Image from Dockerfile # Rebuild The Image from Dockerfile

View file

@ -1,4 +0,0 @@
setlocal cindent
setlocal shiftwidth=2
setlocal expandtab
setlocal tabstop=2

View file

@ -40,6 +40,9 @@ services:
- type: bind - type: bind
source: ${HOME}/Documents/ros2-vim/nvim source: ${HOME}/Documents/ros2-vim/nvim
target: /home/ros-user/.config/nvim target: /home/ros-user/.config/nvim
- type: bind
source: $XDG_RUNTIME_DIR/${WAYLAND_DISPLAY}
target: /tmp/${WAYLAND_DISPLAY}
- "ros2_zsh_history:/zsh_history" - "ros2_zsh_history:/zsh_history"
- nvim_data:/home/ros-user/.local/share/nvim - nvim_data:/home/ros-user/.local/share/nvim
- $SSH_AUTH_SOCK:/ssh-agent - $SSH_AUTH_SOCK:/ssh-agent
@ -47,6 +50,8 @@ services:
environment: environment:
- DISPLAY=${DISPLAY} - DISPLAY=${DISPLAY}
- XDG_RUNTIME_DIR=/tmp
- WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
- QT_X11_NO_MITSHM=1 - QT_X11_NO_MITSHM=1
- SHELL=/usr/bin/zsh - SHELL=/usr/bin/zsh
- ROS_WORKSPACE=/home/ros-user/uuv/ros2 - ROS_WORKSPACE=/home/ros-user/uuv/ros2

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

@ -15,3 +15,4 @@ vim.g.mapleader = ' ' -- needs to be set before lazy im
require('lazy').setup('plugins') require('lazy').setup('plugins')
require('lennartalff') require('lennartalff')
require('plugins.lsp')

View file

@ -33,9 +33,6 @@ 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>j', '<cmd>lnext<CR>zz')
vim.keymap.set('n', '<leader>k', '<cmd>lprev<CR>zz') vim.keymap.set('n', '<leader>k', '<cmd>lprev<CR>zz')
vim.keymap.set('n', '<leader>i', vim.lsp.buf.hover)
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename)
vim.keymap.set('n', '<leader>dq', vim.diagnostic.setqflist) vim.keymap.set('n', '<leader>dq', vim.diagnostic.setqflist)
local function quickfix() local function quickfix()
vim.lsp.buf.code_action({ vim.lsp.buf.code_action({

View file

@ -4,6 +4,8 @@
vim.opt.nu = true vim.opt.nu = true
vim.opt.relativenumber = true vim.opt.relativenumber = true
vim.opt.breakindent = true
-- default indentation -- default indentation
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.softtabstop = 4 vim.opt.softtabstop = 4
@ -14,7 +16,7 @@ vim.opt.smartindent = true
vim.opt.wrap = false vim.opt.wrap = false
vim.api.nvim_create_autocmd("FileTYpe", { vim.api.nvim_create_autocmd("FileType", {
pattern = "cpp", pattern = "cpp",
callback = function() callback = function()
vim.opt_local.shiftwidth = 2 vim.opt_local.shiftwidth = 2
@ -27,3 +29,15 @@ vim.opt.signcolumn = 'yes'
vim.opt.updatetime = 500 vim.opt.updatetime = 500
vim.opt.colorcolumn = '80' vim.opt.colorcolumn = '80'
vim.api.nvim_create_autocmd('FileType', {
pattern = 'rst',
callback = function()
vim.opt.wrap = true -- softwrap the text
vim.opt.linebreak = true -- do not break in the middle of words
-- rst uses 3 space indents
vim.opt.tabstop = 3
vim.opt.softtabstop = 3
vim.opt.shiftwidth = 3
vim.opt.expandtab = true
end
})

45
nvim/lua/plugins/cmp.lua Normal file
View file

@ -0,0 +1,45 @@
return {
'hrsh7th/nvim-cmp',
dependencies = {
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-nvim-lua'},
{'L3MON4D3/LuaSnip'},
},
config = function()
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
},
mapping = cmp.mapping.preset.insert({
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end),
['<C-e>'] = cmp.mapping.abort(),
['<C-space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = false }),
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
})
end
}

View file

@ -1,5 +1,10 @@
return { return {
{ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' }, { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' },
{
'L3MON4D3/LuaSnip',
tag = 'v2.*',
build = 'make install_jsregexp',
},
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
{ {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
@ -9,28 +14,22 @@ return {
{ 'rose-pine/neovim', name = 'rose-pine' }, { 'rose-pine/neovim', name = 'rose-pine' },
{ 'catppuccin/nvim', name = 'catppuccin', priority = 1000 }, { 'catppuccin/nvim', name = 'catppuccin', priority = 1000 },
{ 'tpope/vim-fugitive', name = 'fugitive' }, { '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', 'ThePrimeagen/harpoon',
dependencies = { dependencies = {
{ 'nvim-lua/plenary.nvim' }, { 'nvim-lua/plenary.nvim' },
}, },
}, },
{ 'ray-x/lsp_signature.nvim', event = 'VeryLazy', opts = {}, {
config = function(_, opts) require('lsp_signature').setup(opts) end }, 'ray-x/lsp_signature.nvim',
event = 'VeryLazy',
opts = {},
config = function(_, opts) require('lsp_signature').setup(opts) end
},
'rcarriga/nvim-notify',
{
'danymat/neogen',
dependencies = 'nvim-treesitter/nvim-treesitter',
config = true,
},
} }

View file

@ -0,0 +1,88 @@
--local lspconfig = require('lspconfig')
--local lsp_defaults = lspconfig.util.default_config
--
--lsp_defaults.capabilities = vim.tbl_deep_extend(
-- 'force',
-- lsp_defaults.capabilities,
-- require('cmp_nvim_lsp').default_capabilities()
--)
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = { buffer = event.buf }
vim.keymap.set('n', '<leader>i', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
vim.keymap.set('n', '<leader>r', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
vim.keymap.set('n', '<leader>f', '<cmd>lua vim.lsp.buf.format({async=true})<cr>', opts)
vim.keymap.set('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
vim.keymap.set('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>', opts)
vim.keymap.set('n', '[d', '<cmd>lua vim.diagnostic.goto_prev({float = {border = "rounded"}})<cr>', opts)
vim.keymap.set('n', ']d', '<cmd>lua vim.diagnostic.goto_next({float = {border = "rounded"}})<cr>', opts)
vim.keymap.set('n', '<leader>vd', '<cmd>lua vim.diagnostic.open_float({border = "rounded"})<cr>', opts)
end
})
local handlers = {
function(server)
require('lspconfig')[server].setup({})
end,
pylsp = function()
require('lspconfig').pylsp.setup({
settings = {
pylsp = {
plugins = {
pyflakes = { enabled = false },
mccabe = { enabled = false },
pycodestyle = { enabled = false },
flake8 = { enabled = false },
pylint = { enabled = false },
autopep8 = { enabled = false },
yapf = { enabled = true },
},
},
},
})
end,
ruff_lsp = function()
require('lspconfig').ruff_lsp.setup({
on_attach = function(client, bufnr)
client.server_capabilities.hoverProvider = false
client.server_capabilities.documentFormattingProver = false
end,
})
end,
}
return {
{
'williamboman/mason.nvim',
config = function()
require('mason').setup({
ui = {
border = 'rounded'
}
})
require('mason-registry'):on('package:install:success', require('plugins.lsp.python').mason_post_install)
end
},
{
'williamboman/mason-lspconfig.nvim',
dependencies = {
'rcarriga/nvim-notify',
},
opts = {
handlers = handlers,
ensure_installed = {
'lua_ls', 'clangd', 'pylsp', 'yamlls', 'esbonio', 'ruff_lsp',
},
},
},
{ 'neovim/nvim-lspconfig' },
}

View file

@ -0,0 +1,34 @@
local M = {}
local notify = require('notify')
M.mason_post_install = function(pkg)
--if pkg.name ~= 'python-lsp-server' then
-- return
--end
--local venv = vim.fn.stdpath('data') .. '/mason/packages/python-lsp-server/venv'
--local job = require('plenary.job')
--job:new({
-- command = venv .. '/bin/pip',
-- args = {
-- 'install',
-- '-U',
-- '--disable-pip-version-check',
-- 'pylsp-mypy',
-- },
-- cwd = venv,
-- env = { VIRTUAL_ENV = venv },
-- on_exit = function()
-- notify('Finished installing pylsp modules.')
-- end,
-- on_start = function()
-- notify('Installing pylsp modules...')
-- end,
--}):start()
end
M.ruff = function()
local config = {}
return config
end
return M