diff --git a/root/.config/nvim/lua/dapconfig.lua b/root/.config/nvim/lua/dapconfig.lua index addd72e..69a5f5a 100644 --- a/root/.config/nvim/lua/dapconfig.lua +++ b/root/.config/nvim/lua/dapconfig.lua @@ -18,7 +18,9 @@ function M.dapconfig() dapui.close() end - vim.api.nvim_create_user_command('DapUiClose', function(opts) dapui.close() end, { nargs = 0 }) + vim.api.nvim_create_user_command("DapUiClose", function(opts) + dapui.close() + end, { nargs = 0 }) -- c, cpp, rust -- 调试有控制台输入输出的程序时,由于gdb的一个issue(https://github.com/microsoft/vscode-cpptools/issues/3953), -- printf必须输出\n,或者手动fflush(stdout)/setbuf(stdout, NULL)后,才能在console中看到输出。 @@ -26,9 +28,9 @@ function M.dapconfig() -- 向控制台输入时,切换到console 窗口(element)需要通过CTRL-W hjkl,输入完后先鼠标单击代码窗口,再鼠标单击REPL窗口, -- 防止出现"Debug adapter reported a frame at line 12 column 1, but: Cursor position outside buffer. Ensure executable is up2date and if using a source mapping ensure it is correct"这样的错误 dap.adapters.cppdbg = { - id = 'cppdbg', - type = 'executable', - command = 'OpenDebugAD7', + id = "cppdbg", + type = "executable", + command = "OpenDebugAD7", } dap.configurations.cpp = { @@ -37,21 +39,21 @@ function M.dapconfig() type = "cppdbg", request = "launch", program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, - cwd = '${workspaceFolder}', + cwd = "${workspaceFolder}", stopAtEntry = true, }, { - name = 'Attach to gdbserver :1234', - type = 'cppdbg', - request = 'launch', - MIMode = 'gdb', - miDebuggerServerAddress = 'localhost:1234', - miDebuggerPath = '/usr/bin/gdb', - cwd = '${workspaceFolder}', + name = "Attach to gdbserver :1234", + type = "cppdbg", + request = "launch", + MIMode = "gdb", + miDebuggerServerAddress = "localhost:1234", + miDebuggerPath = "/usr/bin/gdb", + cwd = "${workspaceFolder}", program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, }, } @@ -60,6 +62,11 @@ function M.dapconfig() dap.configurations.rust = dap.configurations.cpp require("dap-python").setup("python3") + vim.api.nvim_create_user_command("DapPytestMethod", function(_) + local dap_python = require("dap-python") + dap_python.test_runner = "pytest" + dap_python.test_method() + end, { nargs = 0 }) end return M diff --git a/root/.config/nvim/lua/lsp/init.lua b/root/.config/nvim/lua/lsp/init.lua index 2d88725..9748e7c 100644 --- a/root/.config/nvim/lua/lsp/init.lua +++ b/root/.config/nvim/lua/lsp/init.lua @@ -152,7 +152,13 @@ local function setup_lsp(on_attach, capabilities) -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#jsonls -- npm i -g vscode-langservers-extracted + -- "pylsp": too slow + -- "pylyzer": report too many diagnostics local other_servers = { "jsonls", "pyright", "typst_lsp", "gopls" } + if vim.g.python_formatter == "ruff" then + -- pip install ruff-lsp ruff + table.insert(other_servers, "ruff_lsp") + end for _, lsp in ipairs(other_servers) do lspconfig[lsp].setup({ on_attach = on_attach, diff --git a/root/.config/nvim/lua/plugins/init.lua b/root/.config/nvim/lua/plugins/init.lua index b50f4c9..a2950ab 100644 --- a/root/.config/nvim/lua/plugins/init.lua +++ b/root/.config/nvim/lua/plugins/init.lua @@ -150,13 +150,7 @@ return { -- the configs below are lua only bypass_session_save_file_types = nil, - cwd_change_handling = { - restore_upcoming_session = true, -- already the default, no need to specify like this, only here as an example - pre_cwd_changed_hook = nil, -- already the default, no need to specify like this, only here as an example - post_cwd_changed_hook = function() -- example refreshing the lualine status line _after_ the cwd changes - require("lualine").refresh() -- refresh lualine so the new session name is displayed in the status bar - end, - }, + cwd_change_handling = nil, -- 不要监听文件夹切换事件: 不在cd后自动切换会话 -- ⚠️ This will only work if Telescope.nvim is installed -- The following are already the default values, no need to provide them if these are already the settings you want. diff --git a/root/.config/nvim/lua/plugins/lsp.lua b/root/.config/nvim/lua/plugins/lsp.lua index f581d81..e1649fc 100644 --- a/root/.config/nvim/lua/plugins/lsp.lua +++ b/root/.config/nvim/lua/plugins/lsp.lua @@ -122,10 +122,14 @@ if vim.g.vimrc_lsp == "nvim-lsp" then "nvimtools/none-ls.nvim", config = function() local null_ls = require("null-ls") + sources = { + null_ls.builtins.formatting.stylua, + } + if vim.g.python_formatter == "black" then + table.insert(sources, null_ls.builtins.formatting.black) + end null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - }, + sources = sources, }) end, }, diff --git a/root/.config/nvim/lua/plugins/vimplug.lua b/root/.config/nvim/lua/plugins/vimplug.lua index 96f7d6f..6a7c358 100644 --- a/root/.config/nvim/lua/plugins/vimplug.lua +++ b/root/.config/nvim/lua/plugins/vimplug.lua @@ -2,6 +2,12 @@ vim.api.nvim_command('source ~/.vim/vimrc.d/plugin_setup.vim') vim.api.nvim_command('source ~/.vim/vimrc.d/ai.vim') local M = { + -- SQLComplete: the dbext plugin must be loaded for dynamic SQL completion https://github.com/neovim/neovim/issues/14433 + -- let g:omni_sql_default_compl_type = 'syntax' + { + 'vim-scripts/dbext.vim', + ft = 'sql', + }, 'jiangyinzuo/bd.vim', { "lervag/vimtex", @@ -84,6 +90,7 @@ local M = { ft = 'csv', }, 'jiangyinzuo/open-gitdiff.vim', + 'andrewradev/linediff.vim', 'tpope/vim-surround', 'tpope/vim-eunuch', 'AndrewRadev/splitjoin.vim', @@ -103,6 +110,7 @@ local M = { 'tpope/vim-fugitive', 'junegunn/gv.vim', { 'alepez/vim-gtest', ft = { 'c', 'cpp', 'cuda' } }, + -- vim-bookmarks最好作为临时的书签,不要当作代码笔记。否则git版本更新后,会导致书签内容不一致,且难以纠正。 'MattesGroeger/vim-bookmarks', -- Alternatives: https://github.com/HakonHarnes/img-clip.nvim 'jiangyinzuo/img-paste.vim', @@ -120,7 +128,7 @@ local M = { priority = 2000, }, { - dir = "~/.vim/pack/my_plugins/start/codenote", + "jiangyinzuo/codenote" }, { dir = "~/.vim/pack/my_plugins/start/diffbuffer.vim" }, diff --git a/root/.config/nvim/lua/plugins_setup.lua b/root/.config/nvim/lua/plugins_setup.lua index 66ae9d5..4f990b8 100644 --- a/root/.config/nvim/lua/plugins_setup.lua +++ b/root/.config/nvim/lua/plugins_setup.lua @@ -3,7 +3,18 @@ function M.nvim_treesitter() require("nvim-treesitter.configs").setup({ -- 安装 language parser -- :TSInstallInfo 命令查看支持的语言 - ensure_installed = { "cpp", "lua", "vim", "vimdoc", "python", "rust", "html", "query", "markdown", "markdown_inline" }, + ensure_installed = { + "cpp", + "lua", + "vim", + "vimdoc", + "python", + "rust", + "html", + "query", + "markdown", + "markdown_inline", + }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, -- 启用代码高亮模块 @@ -125,12 +136,12 @@ function M.lualine() lualine_b = { "branch" } lualine_c = { -- invoke `coc#status` to get coc status. - [[%{exists("*coc#status")?coc#status():''}]] + [[%{exists("*coc#status")?coc#status():''}]], } winbar = { lualine_c = { - [[%{%get(b:, 'coc_symbol_line', '')%}]] - } + [[%{%get(b:, 'coc_symbol_line', '')%}]], + }, } end @@ -148,8 +159,14 @@ function M.lualine() -- https://github.com/nvim-lualine/lualine.nvim/issues/259#issuecomment-1890485361 section_separators = { left = "", right = "" }, disabled_filetypes = { - statusline = {}, - winbar = {}, + winbar = { + "dap-repl", + "dapui_breakpoints", + "dapui_console", + "dapui_scopes", + "dapui_watches", + "dapui_stacks", + }, }, ignore_focus = {}, always_divide_middle = true, @@ -180,7 +197,7 @@ function M.lualine() tabline = {}, winbar = winbar, inactive_winbar = {}, - extensions = { "quickfix" }, + extensions = { "fern", "quickfix", "nvim-dap-ui" }, }) end diff --git a/root/.vim/doc/http-proxy.txt b/root/.vim/doc/http-proxy.txt index cacdc16..1d01f9e 100644 --- a/root/.vim/doc/http-proxy.txt +++ b/root/.vim/doc/http-proxy.txt @@ -1,3 +1,5 @@ +vim:ft=help + *http-proxy* WSL启动http proxy server ~ @@ -17,6 +19,30 @@ squid --foreground 或者 sudo systemctl start squid +http转发到能连外网的跳板机 ~ + +在跳板机中后台(tmux)执行 +> + ssh -NR 3128:localhost:3128 kiwi +< + +http转发到个人电脑 ~ + +假设目标机器为kiwi-nf,跳板机为cherry01,个人电脑启动squid,端口号为3128. +服务器http proxy也转发到3128 +> +Host kiwi-nf + HostName 10.208.130.1 + User jiangyinzuo + Port 3527 + # 防止长时间断连 + ServerAliveInterval 60 + # ProxyJump grape + ProxyJump cherry01 + # 服务器端口:本地端口 + RemoteForward 3128 localhost:3128 +< + Warning: remote port forwarding failed for listen port 3128 ~ > sudo netstat -tulnp | grep 3128 diff --git a/root/.vim/doc/mydoc.txt b/root/.vim/doc/mydoc.txt index df8e836..e989be3 100644 --- a/root/.vim/doc/mydoc.txt +++ b/root/.vim/doc/mydoc.txt @@ -125,6 +125,9 @@ Markdown等文本编辑添加链接: 查找Hashtag并插入到当前光标位置 :Hashtag +Alternatives: +- https://github.com/epwalsh/obsidian.nvim + ------------------------------------------------------------------------------- *lsp* *formatter* *linter* diff --git a/root/.vim/doc/rg.txt b/root/.vim/doc/rg.txt index 5402fa9..719a416 100644 --- a/root/.vim/doc/rg.txt +++ b/root/.vim/doc/rg.txt @@ -24,6 +24,9 @@ rg 指定文件类型递归查找 rg 'rosetta' --glob '*.md' :RgwithArgs 'rosetta' --glob '*.md' +*rg视为字符串常量* +rg -F 'void foo(int a[1]);' + *leaderf-rg-example* *leaderf搜索当前目录下所有tex文件,大小写敏感,包含raft关键字* :Leaderf rg -g **/*.tex -s raft diff --git a/root/.vim/ftplugin/markdown.vim b/root/.vim/ftplugin/markdown.vim index 1df380c..ffa69d5 100644 --- a/root/.vim/ftplugin/markdown.vim +++ b/root/.vim/ftplugin/markdown.vim @@ -5,10 +5,7 @@ setlocal conceallevel=0 " ASCII of ~ is 126 " See: :h surround-customizing let b:surround_126 = "~~\r~~" -if has('nvim') - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() -else +if !has('nvim') let g:markdown_folding = 1 endif diff --git a/root/.vim/pack/my_plugins/start/codenote/autoload/codenote.vim b/root/.vim/pack/my_plugins/start/codenote/autoload/codenote.vim deleted file mode 100644 index 630c57e..0000000 --- a/root/.vim/pack/my_plugins/start/codenote/autoload/codenote.vim +++ /dev/null @@ -1,308 +0,0 @@ -let s:fd = 'fd' - -sign define code_note_link text=📓 texthl=Search - -" sed -i 's/^+\(.*\) \(.*\)$/\2:\1/' *.md -function! codenote#ConvertFormat(line) - " 使用 substitute() 函数来交换 +linenumber 和 path/to/filename - let converted = substitute(a:line, '+\(\d\+\) \(.*\)', '\2:\1', '') - return converted -endfunction - -function codenote#SignCodeLinks() - if !exists('g:code_link_dict') || !exists('g:coderepo_dir') || !exists('g:noterepo_dir') - return - endif - if g:code_link_dict == {} - return - endif - let l:current_file = expand("%:p") - if l:current_file[0:len(g:coderepo_dir) - 1] == g:coderepo_dir - let l:current_file = l:current_file[len(g:coderepo_dir) + 1:] - if has_key(g:code_link_dict, l:current_file) - sign unplace * group=code_note_link - for l:line in g:code_link_dict[l:current_file] - execute "sign place " . l:line . " line=" . l:line . " group=code_note_link priority=2000 name=code_note_link file=" . l:current_file - endfor - endif - endif -endfunction - -function codenote#GetCodeLinkDict() - if !exists("g:noterepo_dir") - echoerr "g:noterepo_dir is not set" - return - endif - - " 高亮标记支持 - " /path/to/filename.ext:line_number 和 - " +line_number path/to/filename.ext两种格式 - " --max-columns=0 防止rg显示 [ ... xxx more matches ] - let g:code_links = system("rg -INo --max-columns=0 '(^[\\w\\d\\-./]+:[0-9]+$)|(^\\+[0-9]+ .*$)' " . g:noterepo_dir) - let g:code_links = split(g:code_links, "\n") - - let g:code_link_dict = {} - for code_link in g:code_links - if code_link[0] == "+" - let l:dest = split(code_link) - let l:line = l:dest[0][1:] - let l:file = l:dest[1] - else - let l:dest = split(code_link, ":") - let l:line = l:dest[1] - let l:file = l:dest[0] - endif - - if has_key(g:code_link_dict, l:file) - call add(g:code_link_dict[l:file], l:line) - else - let g:code_link_dict[l:file] = [l:line] - endif - endfor -endfunction - -function s:CommonPrefixLength(s1, s2) - let n1 = len(a:s1) - let n2 = len(a:s2) - let min_len = min([n1, n2]) - let i = 0 - - while i < min_len && a:s1[i] ==# a:s2[i] - let i += 1 - endwhile - - return i -endfunction - -" 根据文件名的绝对路径,来判断当前buffer属于coderepo还是noterepo -" return 'code', 'note', or '' -function s:get_repo_type_of_current_buffer() - if !exists('g:coderepo_dir') || !exists('g:noterepo_dir') - echom 'g:coderepo_dir or g:noterepo_dir does not exist!' - return - endif - - let bufpath = expand('%:p') - let prefix_with_coderepo = s:CommonPrefixLength(bufpath, g:coderepo_dir) - let prefix_with_noterepo = s:CommonPrefixLength(bufpath, g:noterepo_dir) - if len(g:coderepo_dir) == prefix_with_coderepo && len(g:noterepo_dir) == prefix_with_noterepo - if prefix_with_coderepo < prefix_with_noterepo - return 'note' - elseif prefix_with_coderepo > prefix_with_noterepo - return 'code' - else - return '' - endif - elseif len(g:coderepo_dir) == prefix_with_coderepo - return 'code' - elseif len(g:noterepo_dir) == prefix_with_noterepo - return 'note' - else - return '' - endif -endfunction - -" 约定第一个tab作为note repo window,第二个tab作为code repo window -function s:goto_code_buffer() - tabnext 2 -endfunction - -function s:goto_note_buffer() - tabfirst -endfunction - -function s:open_file(filename) - execute "tabnew " . a:filename -endfunction - -function codenote#OpenNoteRepo() - call s:open_file(g:noterepo_dir) - tabmove 0 - execute "tcd " . g:noterepo_dir - call codenote#GetAllCodeLinks() -endfunction - -function s:GoToCodeLink() - let l:cur = line('.') - let l:cur_line = getline(l:cur) - - while l:cur >= 0 && l:cur_line !~# s:codelink_regex - let l:cur -= 1 - let l:cur_line = getline(l:cur) - endwhile - - if l:cur < 0 - echoerr "No code link found" - return - endif - - if l:cur_line[0] == '+' - let l:dest = split(l:cur_line) - let l:line = l:dest[0] - let l:file = l:dest[1] - else - " 支持类似 src/execution/operator/aggregate/physical_hash_aggregate.cpp|478 col 7-32| 的格式 - let l:dest = split(l:cur_line, "[:|]") - let l:line = '+' . split(l:dest[1])[0] - let l:file = l:dest[0] - echo l:line l:file - endif - - if s:only_has_one_repo() - call codenote#OpenCodeRepo() - else - call s:goto_code_buffer() - endif - exe "edit " . l:line . " " . g:coderepo_dir . "/" . l:file -endfunction - -function s:GoToNoteLink() - let l:file = expand("%:p")[len(g:coderepo_dir) + 1:] - let l:line = line(".") - let l:pattern = s:filepath(l:file, l:line) - " 将 / 转义为 \/ - let l:pattern = substitute(l:pattern, "/", "\\\\/", "g") - if s:only_has_one_repo() - call codenote#OpenNoteRepo() - else - call s:goto_note_buffer() - endif - silent! exe "vim /" . l:pattern . "/g " . g:noterepo_dir . "/**/*.md" -endfunction - -function codenote#GoToCodeNoteLink() - let buf_repo_type = s:get_repo_type_of_current_buffer() - echom buf_repo_type - if buf_repo_type == "note" - call s:GoToCodeLink() - elseif buf_repo_type == "code" - call s:GoToNoteLink() - else - echoerr "current buffer doesn't belong to codenote repo" - endif -endfunction - -function codenote#OpenCodeRepo() - call s:open_file(g:coderepo_dir) - tabmove 1 - call codenote#GetAllCodeLinks() -endfunction - -function s:only_has_one_repo() - return tabpagenr('$') == 1 -endfunction - -" Supported formats: -" 1) /path/to/file:123 -" 2) +123 /path/to/file -" 3) src/execution/operator/aggregate/physical_hash_aggregate.cpp|478 col 7-32| -" -" 3) 源自coc.nvim/nvim lsp在quickfix list中的显示格式 -let s:codelink_regex = '[A-Za-z0-9\-./]\+\([:|][0-9]\+\)\|\(^\+[0-9]\+\s\)' - -if g:codenote_filepath_style == 'colon' - function! s:filepath(file, line) - return a:file . ":" . a:line - endfunction - command -nargs=0 Rglink :Rg [\w\d\-./]+:[0-9]+ - "command -nargs=0 Rglink :call RipgrepFzf('rg --column -o --no-heading --color=always --smart-case -- %s || true', '[\w\d\-./]+:[0-9]+', 0) -else - function! s:filepath(file, line) - return "+" . a:line . " " . a:file - endfunction - command -nargs=0 Rglink :Rg ^+[0-9]+ .+ - "command -nargs=0 Rglink :call RipgrepFzf('rg --column -o --no-heading --color=always --smart-case -- %s || true', '^\+[0-9]+ .+$', 0) -endif - -function s:yank_registers(file, line, content, need_beginline, need_endline, append) - if a:need_beginline && &filetype != 'markdown' - let l:beginline = "```" . &filetype . "\n" - else - let l:beginline = "" - endif - if a:need_endline && &filetype != 'markdown' - let l:endline = "```\n" - else - let l:endline = "" - endif - let l:filepath = s:filepath(a:file, a:line) - if a:append - let @" .= l:filepath . "\n" . l:beginline . a:content . "\n" . l:endline - echo "append to @" - else - let @" = l:filepath . "\n" . l:beginline . a:content . "\n" . l:endline - endif -endfunction - -" See also: root/vimrc.d/asynctasks.vim -function codenote#YankCodeLink(need_beginline, need_endline, append, goto_buf) - let l:file = expand("%:p")[len(g:coderepo_dir) + 1:] - let l:line = line(".") - let l:content = getline(".") - call s:yank_registers(l:file, l:line, l:content, a:need_beginline, a:need_endline, a:append) - if a:goto_buf - if s:only_has_one_repo() - call codenote#OpenNoteRepo() - endif - call s:goto_note_buffer() - endif -endfunction - -function codenote#YankCodeWithFunctionHeader(shortcut) - let l:file = expand("%:p")[len(g:coderepo_dir) + 1:] - let l:body_line = line(".") - let l:body_content = getline(".") - exe "normal " . a:shortcut - let l:header_line = line(".") - let l:header_content = getline(".") - - call s:yank_registers(l:file, l:header_line, l:header_content, 1, 0, 0) - call s:yank_registers(l:file, l:body_line, l:body_content, 0, 1, 1) - - if s:only_has_one_repo() - call codenote#OpenNoteRepo() - endif - call s:goto_note_buffer() -endfunction - -function codenote#YankCodeLinkVisual(need_beginline, need_endline, append, goto_buf) range - let l:file = expand("%:p")[len(g:coderepo_dir) + 1:] - let [l:line, l:column_start] = getpos("'<")[1:2] - let l:content = GetVisualSelection() - call s:yank_registers(l:file, l:line, l:content, a:need_beginline, a:need_endline, a:append) - if a:goto_buf - if s:only_has_one_repo() - call codenote#OpenNoteRepo() - endif - call s:goto_note_buffer() - endif -endfunction - -function codenote#YankCodeWithFunctionHeaderVisual(shortcut) range - let l:file = expand("%:p")[len(g:coderepo_dir) + 1:] - let [l:body_line, l:column_start] = getpos("'<")[1:2] - let l:body_content = GetVisualSelection() - exe "normal " . a:shortcut - let l:header_line = line(".") - let l:header_content = getline(".") - - call s:yank_registers(l:file, l:header_line, l:header_content, 1, 0, 0) - call s:yank_registers(l:file, l:body_line, l:body_content, 0, 1, 1) - - if s:only_has_one_repo() - call codenote#OpenNoteRepo() - endif - call s:goto_note_buffer() -endfunction - -function codenote#GetAllCodeLinks() - if exists('g:coderepo_dir') && g:coderepo_dir != "" && exists('g:noterepo_dir') && g:noterepo_dir != "" - call codenote#GetCodeLinkDict() - call codenote#SignCodeLinks() - augroup codenote - autocmd! - autocmd BufWinEnter * call codenote#SignCodeLinks() - autocmd BufWritePost *.md call codenote#GetCodeLinkDict() - augroup END - endif -endfunction diff --git a/root/.vim/pack/my_plugins/start/codenote/doc/codenote.txt b/root/.vim/pack/my_plugins/start/codenote/doc/codenote.txt deleted file mode 100644 index e4c1472..0000000 --- a/root/.vim/pack/my_plugins/start/codenote/doc/codenote.txt +++ /dev/null @@ -1,3 +0,0 @@ -*codenote.txt* - -manually set *g:coderepo_dir* and *g:noterepo_dir* diff --git a/root/.vim/pack/my_plugins/start/codenote/plugin/codenote.vim b/root/.vim/pack/my_plugins/start/codenote/plugin/codenote.vim deleted file mode 100644 index fe2e543..0000000 --- a/root/.vim/pack/my_plugins/start/codenote/plugin/codenote.vim +++ /dev/null @@ -1,29 +0,0 @@ -" colon 表示使用 path/to/filename.ext:line_number 格式 -" plus 表示使用 +line_number path/to/filename.ext 格式 -let g:codenote_filepath_style = "colon" - -command -nargs=0 OpenNoteRepo :call codenote#OpenNoteRepo() -command -nargs=0 OpenCodeRepo :call codenote#OpenCodeRepo() -command -nargs=0 RefreshCodeLinks :call codenote#GetAllCodeLinks() - -" need_beginline, need_endline, append, goto_buf -nnoremap nr :call codenote#YankCodeLink(0, 0, 0, 1) -nnoremap ny :call codenote#YankCodeLink(1, 1, 0, 1) -nnoremap nb :call codenote#YankCodeLink(1, 0, 0, 0) -nnoremap na :call codenote#YankCodeLink(0, 0, 1, 0) -nnoremap ne :call codenote#YankCodeLink(0, 1, 1, 1) -nnoremap nf :call codenote#YankCodeWithFunctionHeader('[f') -nnoremap nm :call codenote#YankCodeWithFunctionHeader('[m') - - -vnoremap nf :call codenote#YankCodeWithFunctionHeaderVisual('[f') -vnoremap nm :call codenote#YankCodeWithFunctionHeaderVisual('[m') -vnoremap nr :call codenote#YankCodeLinkVisual(0, 0, 0, 1) -vnoremap ny :call codenote#YankCodeLinkVisual(1, 1, 0, 1) -vnoremap nb :call codenote#YankCodeLinkVisual(1, 0, 0, 0) -vnoremap na :call codenote#YankCodeLinkVisual(0, 0, 1, 0) -vnoremap ne :call codenote#YankCodeLinkVisual(0, 1, 1, 1) - -" 1) goto code/note link -" 2) put the cursor to center of screen -nnoremap :call codenote#GoToCodeNoteLink()z. diff --git a/root/.vim/tasks.ini b/root/.vim/tasks.ini index 02ebd21..a14c90d 100644 --- a/root/.vim/tasks.ini +++ b/root/.vim/tasks.ini @@ -63,3 +63,7 @@ command=gtags [pytest] command=python3 -m pytest -q --tb=no output=terminal + +[doctest] +command:python=python3 -m doctest "$(VIM_FILENAME)" +output=terminal diff --git a/root/.vim/vimrc b/root/.vim/vimrc index a38042c..e9b3e1a 100644 --- a/root/.vim/vimrc +++ b/root/.vim/vimrc @@ -53,6 +53,8 @@ if has('autocmd') " vim-tiny does not have autocmd let g:clangd_args = get(g:, 'clangd_args', ["--clang-tidy", "--compile-commands-dir=build", "--pretty", "--cross-file-rename", "--inlay-hints=true", "--background-index", "--suggest-missing-includes=true", "--header-insertion=iwyu"]) let g:clangd_cmd = [g:clangd_path] + g:clangd_args let g:clang_format = get(g:, 'clang_format', 'clang-format') + " black, ruff + let g:python_formatter = get(g:, 'python_formatter', 'black') let g:ai_complete = get(g:, 'ai_complete', 'copilot') @@ -352,7 +354,12 @@ if has('autocmd') " vim-tiny does not have autocmd set ttymouse=xterm2 " Windows termimal 可以用鼠标改变窗口大小 endif - set foldmethod=marker + if has('nvim') + set foldmethod=expr + set foldexpr=nvim_treesitter#foldexpr() + else + set foldmethod=marker + endif set foldmarker={,} " 默认打开所有折叠,将foldlevelstart设置为较大的值 @@ -364,7 +371,7 @@ if has('autocmd') " vim-tiny does not have autocmd autocmd FileType c,cpp,cuda setlocal foldmethod=expr foldexpr=mycpp#FoldExpr(v:lnum) autocmd FileType c,cpp,cuda setlocal completefunc=mycpp#CompleteFunc - autocmd FileType python,vim,lua,go,sh setlocal foldmethod=indent + autocmd FileType vim,lua,go,sh setlocal foldmethod=indent " zfip折叠当前段落 zf%折叠匹配括号内的内容 zfie折叠\begin{}\end{}之间的内容(vimtex) autocmd FileType tex setlocal foldmethod=manual endif diff --git a/root/.vim/vimrc.d/coc.vim b/root/.vim/vimrc.d/coc.vim index a252dcd..c2ec113 100644 --- a/root/.vim/vimrc.d/coc.vim +++ b/root/.vim/vimrc.d/coc.vim @@ -7,7 +7,7 @@ let g:coc_filetype_map = {'tex': 'latex'} autocmd FileType tex ++once call coc#config('texlab.latexindent.local', $VIMRC_ROOT . "/latexindent.yaml") autocmd FileType lua ++once call coc#config('stylua.styluaPath', $HOME . '/.cargo/bin/stylua') autocmd FileType c,cpp,cuda ++once call coc_clang#setup_coc_clangd() - +autocmd FileType python ++once call coc#config('python.formatting.provider', g:python_formatter) function! s:show_documentation() if CocAction('hasProvider', 'hover') call CocActionAsync('doHover') diff --git a/root/.vim/vimrc.d/vimplug.vim b/root/.vim/vimrc.d/vimplug.vim index ec0d05d..2dd0068 100644 --- a/root/.vim/vimrc.d/vimplug.vim +++ b/root/.vim/vimrc.d/vimplug.vim @@ -64,6 +64,7 @@ if !exists('g:vscode') " Alternative: https://github.com/sindrets/diffview.nvim Plug 'jiangyinzuo/open-gitdiff.vim' + Plug 'andrewradev/linediff.vim' endif " vim-surround和vim-sneak会共享s/S shortcut,但不冲突 @@ -185,6 +186,7 @@ if !exists('g:vscode') " A git commit browser. Plug 'junegunn/gv.vim' + " vim-bookmarks最好作为临时的书签,不要当作代码笔记。否则git版本更新后,会导致书签内容不一致,且难以纠正。 Plug 'MattesGroeger/vim-bookmarks' source ~/.vim/vimrc.d/ai.vim Plug 'bfrg/vim-cpp-modern', {'for': ['c', 'cpp', 'cuda']}