From be8a403722bd85b648b2f9f56cb4309972f0cd71 Mon Sep 17 00:00:00 2001 From: Yinzuo Jiang Date: Thu, 20 Jun 2024 19:29:54 +0800 Subject: [PATCH] fix: update .tmux.conf, nvim_cmp.lua, vimrc --- .vimrc | 21 ++++++++++----------- root/.config/nvim/lua/nvim_cmp.lua | 6 ++++-- root/.tmux.conf | 7 +++++-- root/.vim/doc/docker.txt | 28 +++++++++++++++------------- root/.vim/vimrc | 23 +++++++++++------------ root/.vim/vimrc.d/plugin_setup.vim | 7 ++++--- 6 files changed, 49 insertions(+), 43 deletions(-) diff --git a/.vimrc b/.vimrc index 71afe66..1e30727 100644 --- a/.vimrc +++ b/.vimrc @@ -46,8 +46,9 @@ if has('autocmd') " vim-tiny does not have autocmd set cmdheight=2 " cmd行高2, 减少hit-enter set wildmenu " command自动补全时显示菜单 if v:version >= 900 || has('nvim') - if has('patch-9.1.463') || has('nvim') - set completeopt+=fuzzy + " TODO: wait for https://github.com/neovim/neovim/pull/29429 + if has('patch-9.1.503') " || has('nvim-0.11.0') + set completeopt+=fuzzy,fuzzycollect endif set wildoptions=pum " 显示popup window else @@ -155,20 +156,18 @@ if has('autocmd') " vim-tiny does not have autocmd if has("patch-8.1.0360") set diffopt=vertical,filler,context:3,indent-heuristic,algorithm:patience,internal endif - command -nargs=0 DiffthisPlain :diffthis | setf text + command -nargs=0 DiffthisSetfiletypeText :diffthis | setf text command -nargs=0 DiffoffRestoreFiletype :diffoff | edit """"""""""""""""""""" termdebug set t_Co=256 set t_ut= - if has('nvim') || v:version >= 801 - autocmd Filetype c,cpp,rust,cuda ++once packadd termdebug + if v:version >= 801 + autocmd Filetype c,cpp,rust,cuda ++once if !exists(':Termdebug') | packadd termdebug | endif if exists('&termwinsize') autocmd Filetype termdebug setlocal termwinsize=0*10000 endif - let g:termdebug_config = {} - let g:termdebug_config['command'] = "gdb" - " 设置一个较大的宽度,防止termdebug gdb窗口折行 - let g:termdebug_config['wide'] = 1 + " wide: 设置一个较大的宽度,防止termdebug gdb窗口折行 + let g:termdebug_config = {'command': 'gdb', 'wide': 1} endif """"""""""""""""""""""""""""""""""""""""""""""""""" Netrw Plugin " http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/ @@ -195,10 +194,10 @@ if has('autocmd') " vim-tiny does not have autocmd " #gpt4-answer " jump to the previous function " 向后(b表示backward)搜索一个匹配特定模式的地方,这个模式是一个函数的开始位置。 - autocmd FileType c,cpp nnoremap [f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 + autocmd FileType c,cpp nnoremap [f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 " jump to the next function " 向前(w表示forward)搜索一个匹配特定模式的地方,这个模式是一个函数的开始位置。 - autocmd FileType c,cpp nnoremap ]f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 + autocmd FileType c,cpp nnoremap ]f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 " 搜索的模式是一个正则表达式,用来匹配不是在if, for, while, switch, 和catch后面的左花括号{,因为在C++中函数的定义是以左花括号开始的。 " 需要注意的是,这个搜索模式可能并不完全精确,因为函数的定义还可能包含许多其他的复杂性,比如模板函数,函数指针,宏定义等等。对于一些简单的代码文件,这个方法通常可以工作得很好。 " 这些配置会更好地在代码中快速导航,但如果你需要更精确地识别函数,你可能需要考虑使用一些更高级的插件,比如ctags,cscope等等。 diff --git a/root/.config/nvim/lua/nvim_cmp.lua b/root/.config/nvim/lua/nvim_cmp.lua index 0c828ac..9bea3fb 100644 --- a/root/.config/nvim/lua/nvim_cmp.lua +++ b/root/.config/nvim/lua/nvim_cmp.lua @@ -100,14 +100,16 @@ function M.nvim_cmp() elseif has_words_before() then cmp.complete() else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + fallback() -- The fallback function sends a already mapped key. end end, { "i", "s" }), - [""] = cmp.mapping(function() + [""] = cmp.mapping(function(fallback) -- if cmp.visible() then -- cmp.select_prev_item() if vim.snippet.active({ direction = -1 }) then feedkey("lua vim.snippet.jump(-1)", "") + else + fallback() -- The fallback function sends a already mapped key. end end, { "i", "s" }), }), diff --git a/root/.tmux.conf b/root/.tmux.conf index 280dc66..8db39a5 100644 --- a/root/.tmux.conf +++ b/root/.tmux.conf @@ -1,9 +1,12 @@ # Ubuntu18.04默认安装tmux2.6 -# tmux2.6中,使用fzf的CTRL-R快捷键会卡死,请手动运行 cd ~/vimrc && ./install/build_tmux_from_source.sh安装 +# tmux2.6中,使用fzf的CTRL-R快捷键会卡死,请手动运行 cd ~/vimrc && ./install/build_tmux.sh安装 +# +# 在bash中使用 tmux source-file ~/.tmux.conf 重新加载配置 +# 或者在tmux中使用 :source-file ~/.tmux.conf 重新加载配置 set-window-option -g mode-keys vi # tmux2.1+ setw -g mode-keys vi # tmux1.8 -set-option -g history-limit 20000 +set -g history-limit 40000 bind-key C-e run-shell "~/vimrc/root/scripts/vim-edit-tmux-output" diff --git a/root/.vim/doc/docker.txt b/root/.vim/doc/docker.txt index 4212f65..4479808 100644 --- a/root/.vim/doc/docker.txt +++ b/root/.vim/doc/docker.txt @@ -1,9 +1,23 @@ vim:ft=help -*docker* |nvidia-docker| +*docker* + +------------------------------------------------------------------------------- +*nvidia-docker* nvidia-docker 被achieved了,使用 *nvidia-container-toolkit* - https://github.com/NVIDIA/nvidia-docker - https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html +- https://www.howtogeek.com/devops/how-to-use-an-nvidia-gpu-with-docker-containers/ + + +https://hub.docker.com/r/nvidia/cuda + +nvidia-docker使用nvidia-smi,需要容器能访问GPU +> + docker run --gpus all -it nvidia/cuda:11.0-base nvidia-smi +< + +------------------------------------------------------------------------------- Ubuntu 18.04安装 docker https://roychou121.github.io/2020/07/13/ubuntu-install-docker/ @@ -119,18 +133,6 @@ Docker build 过程中 apt-get update ~ --build-arg "HTTPS_PROXY=http://proxy.example.com:8080/" \ --network host # 可能需要 < -------------------------------------------------------------------------------- - -*nvidia-docker* - -https://hub.docker.com/r/nvidia/cuda - -nvidia-docker使用nvidia-smi,需要容器能访问GPU -> - docker run --gpus all -it nvidia/cuda:11.0-base nvidia-smi -< - - ------------------------------------------------------------------------------- Docker run 示例 ~ diff --git a/root/.vim/vimrc b/root/.vim/vimrc index 0748b19..3ac57e4 100644 --- a/root/.vim/vimrc +++ b/root/.vim/vimrc @@ -103,8 +103,9 @@ if has('autocmd') " vim-tiny does not have autocmd set cmdheight=2 " cmd行高2, 减少hit-enter set wildmenu " command自动补全时显示菜单 if v:version >= 900 || has('nvim') - if has('patch-9.1.463') || has('nvim') - set completeopt+=fuzzy + " TODO: wait for https://github.com/neovim/neovim/pull/29429 + if has('patch-9.1.503') " TODO: remove comment || has('nvim-0.11.0') + set completeopt+=fuzzy,fuzzycollect endif set wildoptions=pum " 显示popup window else @@ -236,23 +237,21 @@ if has('autocmd') " vim-tiny does not have autocmd set undofile endif """"""""""""""""""""""""""""""" - if has("patch-8.1.0360") + if has("patch-8.1.0360") " nvim also has this patch set diffopt=vertical,filler,context:3,indent-heuristic,algorithm:patience,internal endif - command -nargs=0 DiffthisPlain :diffthis | setf text + command -nargs=0 DiffthisSetfiletypeText :diffthis | setf text command -nargs=0 DiffoffRestoreFiletype :diffoff | edit """"""""""""""""""""" termdebug set t_Co=256 set t_ut= - if has('nvim') || v:version >= 801 - autocmd Filetype c,cpp,rust,cuda ++once packadd termdebug + if v:version >= 801 + autocmd Filetype c,cpp,rust,cuda ++once if !exists(':Termdebug') | packadd termdebug | endif if exists('&termwinsize') autocmd Filetype termdebug setlocal termwinsize=0*10000 endif - let g:termdebug_config = {} - let g:termdebug_config['command'] = "gdb" - " 设置一个较大的宽度,防止termdebug gdb窗口折行 - let g:termdebug_config['wide'] = 1 + " wide: 设置一个较大的宽度,防止termdebug gdb窗口折行 + let g:termdebug_config = {'command': 'gdb', 'wide': 1} endif """"""""""""""""""""""""""""""""""""""""""""""""""" Netrw Plugin " http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/ @@ -279,10 +278,10 @@ if has('autocmd') " vim-tiny does not have autocmd " #gpt4-answer " jump to the previous function " 向后(b表示backward)搜索一个匹配特定模式的地方,这个模式是一个函数的开始位置。 - autocmd FileType c,cpp nnoremap [f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 + autocmd FileType c,cpp nnoremap [f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 " jump to the next function " 向前(w表示forward)搜索一个匹配特定模式的地方,这个模式是一个函数的开始位置。 - autocmd FileType c,cpp nnoremap ]f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 + autocmd FileType c,cpp nnoremap ]f :call search('\(\(if\\|for\\|while\\|switch\\|catch\)\_s*\)\@64 " 搜索的模式是一个正则表达式,用来匹配不是在if, for, while, switch, 和catch后面的左花括号{,因为在C++中函数的定义是以左花括号开始的。 " 需要注意的是,这个搜索模式可能并不完全精确,因为函数的定义还可能包含许多其他的复杂性,比如模板函数,函数指针,宏定义等等。对于一些简单的代码文件,这个方法通常可以工作得很好。 " 这些配置会更好地在代码中快速导航,但如果你需要更精确地识别函数,你可能需要考虑使用一些更高级的插件,比如ctags,cscope等等。 diff --git a/root/.vim/vimrc.d/plugin_setup.vim b/root/.vim/vimrc.d/plugin_setup.vim index e978752..6fc06b0 100644 --- a/root/.vim/vimrc.d/plugin_setup.vim +++ b/root/.vim/vimrc.d/plugin_setup.vim @@ -109,9 +109,10 @@ if has('nvim') || v:version >= 800 let g:rainbow_comment_prefix = '#' " 不显示行列位置,防止覆盖search mode下的shortmess提示信息 let g:disable_rainbow_hover = 1 - " 禁用rainbow_csv的高亮 - " let g:rcsv_colorlinks = ['NONE', 'NONE'] - + if has('patch-9.1.497') || has('nvim') + " 禁用rainbow_csv的高亮 + let g:rcsv_colorlinks = ['NONE', 'NONE'] + endif let g:open_gitdiff_exclude_patterns = ['\.pdf$', '\.jpg$', '\.png$', '\.eps$'] let g:open_gitdiff_qf_nmaps = {'open': 'df', 'next': 'dn', 'prev': 'dp'} let command_def = 'command -nargs=* '