From b2397c3a807f7ddad36771dc7849ae53427f75b8 Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Thu, 24 Aug 2023 12:45:47 +0200 Subject: [PATCH 1/3] initial working version with nvim --- Dockerfile | 38 ++++++++++-------- docker-compose.yml | 4 +- entrypoint.sh | 10 ++--- nvim/after/plugin/color.lua | 6 +++ nvim/after/plugin/fugitive.lua | 1 + nvim/after/plugin/gitsigns.lua | 9 +++++ nvim/after/plugin/harpoon.lua | 10 +++++ nvim/after/plugin/lsp.lua | 51 ++++++++++++++++++++++++ nvim/after/plugin/telescope.lua | 6 +++ nvim/after/plugin/treesitter.lua | 35 ++++++++++++++++ nvim/init.lua | 17 ++++++++ nvim/lazy-lock.json | 16 ++++++++ nvim/lua/lennartalff/init.lua | 3 ++ nvim/lua/lennartalff/packer.lua | 65 ++++++++++++++++++++++++++++++ nvim/lua/lennartalff/remap.lua | 34 ++++++++++++++++ nvim/lua/lennartalff/set.lua | 29 ++++++++++++++ nvim/lua/plugins/init.lua | 33 ++++++++++++++++ vimrc | 68 -------------------------------- ycm_extra_conf.py | 17 -------- 19 files changed, 344 insertions(+), 108 deletions(-) create mode 100644 nvim/after/plugin/color.lua create mode 100644 nvim/after/plugin/fugitive.lua create mode 100644 nvim/after/plugin/gitsigns.lua create mode 100644 nvim/after/plugin/harpoon.lua create mode 100644 nvim/after/plugin/lsp.lua create mode 100644 nvim/after/plugin/telescope.lua create mode 100644 nvim/after/plugin/treesitter.lua create mode 100644 nvim/init.lua create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lua/lennartalff/init.lua create mode 100644 nvim/lua/lennartalff/packer.lua create mode 100644 nvim/lua/lennartalff/remap.lua create mode 100644 nvim/lua/lennartalff/set.lua create mode 100644 nvim/lua/plugins/init.lua delete mode 100644 vimrc delete mode 100644 ycm_extra_conf.py diff --git a/Dockerfile b/Dockerfile index 60fd2fc..8663c5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM osrf/ros:humble-desktop-full -ARG ROS_DISTR=humble +FROM osrf/ros:iron-desktop-full +ARG ROS_DISTR=iron ENV DEBIAN_FRONTEND=noninteractive ENV NVIDIA_VISIBLE_DEVICES \ @@ -11,12 +11,6 @@ ARG USER_UID=1000 ARG USER_GID=$USER_UID ENV ROS_DISTR=$ROS_DISTR -RUN mkdir -p /ros2/src -RUN mkdir -p /ros2_underlay/src - -ADD ros2/src /ros2/src -ADD ros2_underlay/src /ros2_underlay/src - RUN apt-get update \ && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ && apt-get install -y \ @@ -25,25 +19,35 @@ RUN apt-get update \ mesa-utils \ mesa-utils-extra \ python3-pip \ + python3-venv \ avahi-daemon \ avahi-utils \ libnss-mdns \ iputils-ping \ sudo \ - neovim \ ripgrep \ wget \ byobu \ ros-${ROS_DISTR}-rqt-tf-tree \ ros-${ROS_DISTR}-apriltag \ clang-format \ - && python3 -m pip install yapf \ - rope \ - flake8 \ - pylint \ - jedi \ - && rosdep install --from-paths /ros2_underlay/src -y --ignore-src \ + 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/src -y --ignore-src \ + && curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh \ + && bash nodesource_setup.sh \ + && 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\ @@ -79,14 +83,14 @@ USER root RUN mkdir /zsh_history \ && touch /zsh_history/.zsh_history \ && chown -R $USERNAME /zsh_history -ADD ros2-vim/cpp.vim /home/$USERNAME/.vim/after/ftplugin/cpp.vim +ADD ros2-vim/nvim /home/$USERNAME/.config/nvim RUN chown -R $USERNAME /home/$USERNAME/ ADD ros2-vim/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh RUN chown $USERNAME /entrypoint.sh USER ${USERNAME} +RUN nvim --headless "+Lazy! sync" +qa 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 ENV DEBIAN_FRONTEND=dialog CMD [ "/usr/bin/zsh"] diff --git a/docker-compose.yml b/docker-compose.yml index 7a133ab..94fe8fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: - default stdin_open: true tty: true - entrypoint: ["/entrypoint.sh", "byobu"] + entrypoint: ["/entrypoint.sh", "zsh"] working_dir: /home/ros-user/uuv/ros2 devices: - "/dev/dri:/dev/dri" @@ -47,6 +47,8 @@ services: - SHELL=/usr/bin/zsh - ROS_WORKSPACE=/home/ros-user/uuv/ros2 - SSH_AUTH_SOCK=/ssh-agent + - TERM=xterm-256color + - COLORTERM=24bit volumes: ros2_zsh_history: diff --git a/entrypoint.sh b/entrypoint.sh index a5033f6..a5f030f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,15 +1,15 @@ #!/bin/bash set -e -PX4_DIR="\$HOME/uuv/PX4-Autopilot" WORKSPACE_DIR="\$HOME/uuv/ros2" -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 "export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:$PX4_DIR/Tools/sitl_gazebo" >> ~/.zshrc +UNDERLAY_DIR="\$HOME/uuv/ros2_underlay" + +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 "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 + echo 'source $HOME/uuv/ros2_underlay/install/setup.zsh' >> ~/.zshrc echo 'source $HOME/uuv/ros2/install/local_setup.zsh' >> ~/.zshrc echo 'eval "$(register-python-argcomplete3 ros2)"' >> ~/.zshrc echo 'eval "$(register-python-argcomplete3 colcon)"' >> ~/.zshrc -vim +PluginUpdate +qall exec $@ diff --git a/nvim/after/plugin/color.lua b/nvim/after/plugin/color.lua new file mode 100644 index 0000000..6c3e1c5 --- /dev/null +++ b/nvim/after/plugin/color.lua @@ -0,0 +1,6 @@ +function ColorMyPencils(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) +end + +ColorMyPencils() diff --git a/nvim/after/plugin/fugitive.lua b/nvim/after/plugin/fugitive.lua new file mode 100644 index 0000000..73b78b8 --- /dev/null +++ b/nvim/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git); diff --git a/nvim/after/plugin/gitsigns.lua b/nvim/after/plugin/gitsigns.lua new file mode 100644 index 0000000..d6905c9 --- /dev/null +++ b/nvim/after/plugin/gitsigns.lua @@ -0,0 +1,9 @@ +require('gitsigns').setup { + signs = { + add = {text='+'}, + change = {text='~'}, + delete = {text='_'}, + topdelete = {text='‾'}, + changedelete = {text='~'}, + } +} diff --git a/nvim/after/plugin/harpoon.lua b/nvim/after/plugin/harpoon.lua new file mode 100644 index 0000000..5abda8b --- /dev/null +++ b/nvim/after/plugin/harpoon.lua @@ -0,0 +1,10 @@ +local mark = require('harpoon.mark') +local ui = require('harpoon.ui') + +vim.keymap.set('n', 'a', mark.add_file) +vim.keymap.set('n', '', ui.toggle_quick_menu) + +vim.keymap.set('n', '', function() ui.nav_file(1) end) +vim.keymap.set('n', '', function() ui.nav_file(2) end) +vim.keymap.set('n', '', function() ui.nav_file(3) end) +vim.keymap.set('n', '', function() ui.nav_file(4) end) diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..0ccfca9 --- /dev/null +++ b/nvim/after/plugin/lsp.lua @@ -0,0 +1,51 @@ +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({}) + +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 = { + [''] = cmp_action.tab_complete(), + [''] = cmp_action.select_prev_or_fallback(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.scroll_docs(1), + [''] = cmp.mapping.scroll_docs(-1), + }, + 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}' }, + } + } + } +} diff --git a/nvim/after/plugin/telescope.lua b/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..27cc97e --- /dev/null +++ b/nvim/after/plugin/telescope.lua @@ -0,0 +1,6 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set("n", "C-p", builtin.git_files, {}) +vim.keymap.set("n", "ps", function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }); +end) diff --git a/nvim/after/plugin/treesitter.lua b/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..5a8068b --- /dev/null +++ b/nvim/after/plugin/treesitter.lua @@ -0,0 +1,35 @@ +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, + }, +} diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..f6b1390 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,17 @@ +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') diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..b88bf58 --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,16 @@ +{ + "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" }, + "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, + "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "f084f4a6a716f55bf9c4026e73027bb24a0325a3" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, + "mason.nvim": { "branch": "main", "commit": "a51c2d063c5377ee9e58c5f9cda7c7436787be72" }, + "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, + "nvim-lspconfig": { "branch": "master", "commit": "f7922e59aeb9bc3e31a660ea4e7405ffa3fc2c3a" }, + "nvim-treesitter": { "branch": "master", "commit": "99eef501a3d9128c15440296850b5bb178d6d560" }, + "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, + "rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" }, + "telescope.nvim": { "branch": "master", "commit": "2d92125620417fbea82ec30303823e3cd69e90e8" } +} \ No newline at end of file diff --git a/nvim/lua/lennartalff/init.lua b/nvim/lua/lennartalff/init.lua new file mode 100644 index 0000000..af9c333 --- /dev/null +++ b/nvim/lua/lennartalff/init.lua @@ -0,0 +1,3 @@ +require('lennartalff.remap') +require('lennartalff.set') +vim.cmd('colorscheme rose-pine') diff --git a/nvim/lua/lennartalff/packer.lua b/nvim/lua/lennartalff/packer.lua new file mode 100644 index 0000000..70b9c01 --- /dev/null +++ b/nvim/lua/lennartalff/packer.lua @@ -0,0 +1,65 @@ +-- 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) diff --git a/nvim/lua/lennartalff/remap.lua b/nvim/lua/lennartalff/remap.lua new file mode 100644 index 0000000..fca9097 --- /dev/null +++ b/nvim/lua/lennartalff/remap.lua @@ -0,0 +1,34 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) + +-- move selected text +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") + +vim.keymap.set('n', 'J', 'mzJ`z') + +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') + +-- yank to clipboard +vim.keymap.set('n', 'y', '"+y') +vim.keymap.set('v', 'y', '"+y') + +-- delete to void +vim.keymap.set('n', 'd', '"_d') +vim.keymap.set('v', 'd', '"_d') + +vim.keymap.set('i', '', '') + +-- avoid accidentally closing everything! +vim.keymap.set('n', 'Q', '') + +vim.keymap.set('n', 'f', function() + vim.lsp.buf.format() +end) + +-- quickfix navigation +vim.keymap.set('n', '', 'cnextzz') +vim.keymap.set('n', '', 'cprevzz') +vim.keymap.set('n', 'k', 'lnextzz') +vim.keymap.set('n', 'j', 'lprevzz') diff --git a/nvim/lua/lennartalff/set.lua b/nvim/lua/lennartalff/set.lua new file mode 100644 index 0000000..0a97f37 --- /dev/null +++ b/nvim/lua/lennartalff/set.lua @@ -0,0 +1,29 @@ +-- 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' + diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..dcfbf4e --- /dev/null +++ b/nvim/lua/plugins/init.lua @@ -0,0 +1,33 @@ +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' }, + -- 'tpope/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' }, + }, + }, + +} diff --git a/vimrc b/vimrc deleted file mode 100644 index e3774a4..0000000 --- a/vimrc +++ /dev/null @@ -1,68 +0,0 @@ -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' -Plugin 'octol/vim-cpp-enhanced-highlight' - -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 -" highlight current line -set cursorline -" 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 - -nnoremap t :NERDTreeToggle -nnoremap n :NERDTreeFocus -nnoremap :NERDTreeFind - -set t_Co=256 -set background=light -silent! colorscheme PaperColor -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 f :py3f $HOME/clang-format.py -autocmd FileType c,cpp vnoremap f :py3f $HOME/clang-format.py -" autocmd FileType python nnoremap :0,$!yapf -autocmd FileType python nnoremap f :0,$!yapf diff --git a/ycm_extra_conf.py b/ycm_extra_conf.py deleted file mode 100644 index 5ae8e0f..0000000 --- a/ycm_extra_conf.py +++ /dev/null @@ -1,17 +0,0 @@ -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()} From ec1a6cd00f692e9001c0df89af4e7bc8c8074ab1 Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Wed, 30 Aug 2023 11:21:42 +0200 Subject: [PATCH 2/3] default installation of several language servers added to improve offline usage --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 8663c5c..85b6213 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,6 +90,7 @@ RUN chmod +x /entrypoint.sh RUN chown $USERNAME /entrypoint.sh USER ${USERNAME} RUN nvim --headless "+Lazy! sync" +qa +RUN nvim --headless +"MasonInstall lua-language-server clangd python-lsp-server yaml-language-server" +q WORKDIR /home/$USERNAME # Switch back to dialog for any ad-hoc use of apt-get ENV DEBIAN_FRONTEND=dialog From 26b5d14b4795df273ac3f2c8e5496a55762daddf Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Sun, 3 Sep 2023 20:23:07 +0200 Subject: [PATCH 3/3] updated nvim config --- .gitignore | 2 ++ Dockerfile | 17 ++++++++++++----- build | 3 +++ docker-compose.yml | 6 ++++++ entrypoint.sh | 1 + nvim/after/plugin/harpoon.lua | 6 ++++++ nvim/after/plugin/lsp.lua | 12 +++++++++++- nvim/lazy-lock.json | 23 +++++++++++++---------- nvim/lua/lennartalff/init.lua | 4 +++- nvim/lua/lennartalff/remap.lua | 8 ++++---- nvim/lua/plugins/init.lua | 5 ++++- run | 3 +++ 12 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 .gitignore create mode 100755 build create mode 100755 run diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be921cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.log +nvim/lazy-lock.json diff --git a/Dockerfile b/Dockerfile index 85b6213..92ffd2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,7 @@ RUN apt-get update \ byobu \ ros-${ROS_DISTR}-rqt-tf-tree \ ros-${ROS_DISTR}-apriltag \ + ros-${ROS_DISTR}-plotjuggler-ros \ clang-format \ xclip \ # neovim build depends \ @@ -41,8 +42,11 @@ RUN apt-get update \ # end neovim build depends \ # && rosdep install --from-paths /ros2_underlay/src -y --ignore-src \ # && rosdep install --from paths /ros2/src -y --ignore-src \ - && curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh \ - && bash nodesource_setup.sh \ + && 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 \ @@ -85,13 +89,16 @@ RUN mkdir /zsh_history \ && chown -R $USERNAME /zsh_history ADD ros2-vim/nvim /home/$USERNAME/.config/nvim RUN chown -R $USERNAME /home/$USERNAME/ -ADD ros2-vim/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh -RUN chown $USERNAME /entrypoint.sh USER ${USERNAME} 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 chown $USERNAME /entrypoint.sh +USER ${USERNAME} # Switch back to dialog for any ad-hoc use of apt-get ENV DEBIAN_FRONTEND=dialog CMD [ "/usr/bin/zsh"] diff --git a/build b/build new file mode 100755 index 0000000..e7ad396 --- /dev/null +++ b/build @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +docker compose build diff --git a/docker-compose.yml b/docker-compose.yml index 94fe8fd..ea52b14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,11 @@ services: - type: bind source: /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" + - nvim_data:/home/ros-user/.local/share/nvim - $SSH_AUTH_SOCK:/ssh-agent - "~/.gitconfig:/etc/gitconfig" @@ -49,6 +53,8 @@ services: - SSH_AUTH_SOCK=/ssh-agent - TERM=xterm-256color - COLORTERM=24bit + - ROS_DOMAIN_ID=29 volumes: ros2_zsh_history: + nvim_data: diff --git a/entrypoint.sh b/entrypoint.sh index a5f030f..14801e7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,6 +9,7 @@ echo "alias build_underlay=\"env -i HOME=\$HOME USER=\$USER TERM=xterm-256color 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 diff --git a/nvim/after/plugin/harpoon.lua b/nvim/after/plugin/harpoon.lua index 5abda8b..efcab1d 100644 --- a/nvim/after/plugin/harpoon.lua +++ b/nvim/after/plugin/harpoon.lua @@ -1,5 +1,7 @@ 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', 'a', mark.add_file) vim.keymap.set('n', '', ui.toggle_quick_menu) @@ -8,3 +10,7 @@ vim.keymap.set('n', '', function() ui.nav_file(1) end) vim.keymap.set('n', '', function() ui.nav_file(2) end) vim.keymap.set('n', '', function() ui.nav_file(3) end) vim.keymap.set('n', '', function() ui.nav_file(4) end) + +vim.keymap.set('n', 'c', cmd_ui.toggle_quick_menu) +vim.keymap.set('n', 'gt1', function() term.gotoTerminal(1) end) +vim.keymap.set('n', 'br', function() term.sendCommand(1, 'build_ros') end) diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua index 0ccfca9..83ccf0e 100644 --- a/nvim/after/plugin/lsp.lua +++ b/nvim/after/plugin/lsp.lua @@ -9,7 +9,16 @@ require('mason-lspconfig').setup { 'lua_ls', 'clangd', 'pylsp', 'yamlls' } } -local lsp = require('lsp-zero').preset({}) +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 }) @@ -32,6 +41,7 @@ cmp.setup({ [''] = cmp.mapping.complete(), [''] = cmp.mapping.scroll_docs(1), [''] = cmp.mapping.scroll_docs(-1), + [''] = cmp.mapping.confirm({ select = false }), }, window = { completion = cmp.config.window.bordered(), diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index b88bf58..d66afc7 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,16 +1,19 @@ { - "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, + "LuaSnip": { "branch": "master", "commit": "ea7d7ea510c641c4f15042becd27f35b3e5b3c2b" }, + "catppuccin": { "branch": "main", "commit": "2e3e5ebcdc24ef0d5b14a0a999dbbe7936512c46" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" }, + "fugitive": { "branch": "master", "commit": "572c8510123cbde02e8a1dafcd376c98e1e13f43" }, + "gitsigns.nvim": { "branch": "main", "commit": "44adf808ace6cb65a3353bd61fa585a2d8fe0db3" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, - "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, + "lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" }, "lsp-zero.nvim": { "branch": "v2.x", "commit": "f084f4a6a716f55bf9c4026e73027bb24a0325a3" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, - "mason.nvim": { "branch": "main", "commit": "a51c2d063c5377ee9e58c5f9cda7c7436787be72" }, - "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, - "nvim-lspconfig": { "branch": "master", "commit": "f7922e59aeb9bc3e31a660ea4e7405ffa3fc2c3a" }, - "nvim-treesitter": { "branch": "master", "commit": "99eef501a3d9128c15440296850b5bb178d6d560" }, - "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, + "lsp_signature.nvim": { "branch": "master", "commit": "58d4e810801da74c29313da86075d6aea537501f" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "dfdd771b792fbb4bad8e057d72558255695aa1a7" }, + "mason.nvim": { "branch": "main", "commit": "0942198fb9a998b6ccee36fb8dd7495eb8ba659c" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, + "nvim-treesitter": { "branch": "master", "commit": "f8c2825220bff70919b527ee68fe44e7b1dae4b2" }, + "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, "rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" }, - "telescope.nvim": { "branch": "master", "commit": "2d92125620417fbea82ec30303823e3cd69e90e8" } + "telescope.nvim": { "branch": "master", "commit": "2c1ed33a6f6f2db3b69f5421f6b405eda1b07748" } } \ No newline at end of file diff --git a/nvim/lua/lennartalff/init.lua b/nvim/lua/lennartalff/init.lua index af9c333..5d8957e 100644 --- a/nvim/lua/lennartalff/init.lua +++ b/nvim/lua/lennartalff/init.lua @@ -1,3 +1,5 @@ require('lennartalff.remap') require('lennartalff.set') -vim.cmd('colorscheme rose-pine') +-- vim.cmd('colorscheme rose-pine') +vim.o.termguicolors = true +vim.cmd.colorscheme 'catppuccin-frappe' diff --git a/nvim/lua/lennartalff/remap.lua b/nvim/lua/lennartalff/remap.lua index fca9097..ac97925 100644 --- a/nvim/lua/lennartalff/remap.lua +++ b/nvim/lua/lennartalff/remap.lua @@ -28,7 +28,7 @@ vim.keymap.set('n', 'f', function() end) -- quickfix navigation -vim.keymap.set('n', '', 'cnextzz') -vim.keymap.set('n', '', 'cprevzz') -vim.keymap.set('n', 'k', 'lnextzz') -vim.keymap.set('n', 'j', 'lprevzz') +vim.keymap.set('n', '', 'cnextzz') +vim.keymap.set('n', '', 'cprevzz') +vim.keymap.set('n', 'j', 'lnextzz') +vim.keymap.set('n', 'k', 'lprevzz') diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index dcfbf4e..30306e1 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -7,7 +7,8 @@ return { { 'nvim-lua/plenary.nvim' } } }, { 'rose-pine/neovim', name = 'rose-pine' }, - -- 'tpope/fugitive', + { 'catppuccin/nvim', name = 'catppuccin', priority = 1000 }, + { 'tpope/vim-fugitive', name = 'fugitive' }, { 'VonHeikemen/lsp-zero.nvim', branch = 'v2.x', @@ -29,5 +30,7 @@ return { { 'nvim-lua/plenary.nvim' }, }, }, + { 'ray-x/lsp_signature.nvim', event = 'VeryLazy', opts = {}, + config = function(_, opts) require('lsp_signature').setup(opts) end }, } diff --git a/run b/run new file mode 100755 index 0000000..7b93e04 --- /dev/null +++ b/run @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +docker compose run --rm --name ros2-vim dev