Skip to content

Commit

Permalink
refactor: move codenote plugin to external repository
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangyinzuo committed Apr 26, 2024
1 parent 0af21ea commit 7b9d806
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 379 deletions.
35 changes: 21 additions & 14 deletions root/.config/nvim/lua/dapconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ 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中看到输出。
--
-- 向控制台输入时,切换到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 = {
Expand All @@ -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,
},
}
Expand All @@ -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
6 changes: 6 additions & 0 deletions root/.config/nvim/lua/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions root/.config/nvim/lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions root/.config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
10 changes: 9 additions & 1 deletion root/.config/nvim/lua/plugins/vimplug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -84,6 +90,7 @@ local M = {
ft = 'csv',
},
'jiangyinzuo/open-gitdiff.vim',
'andrewradev/linediff.vim',
'tpope/vim-surround',
'tpope/vim-eunuch',
'AndrewRadev/splitjoin.vim',
Expand All @@ -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',
Expand All @@ -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" },

Expand Down
31 changes: 24 additions & 7 deletions root/.config/nvim/lua/plugins_setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
-- 启用代码高亮模块
Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -180,7 +197,7 @@ function M.lualine()
tabline = {},
winbar = winbar,
inactive_winbar = {},
extensions = { "quickfix" },
extensions = { "fern", "quickfix", "nvim-dap-ui" },
})
end

Expand Down
26 changes: 26 additions & 0 deletions root/.vim/doc/http-proxy.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vim:ft=help

*http-proxy*

WSL启动http proxy server ~
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions root/.vim/doc/mydoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ Markdown等文本编辑添加链接:

查找Hashtag并插入到当前光标位置 :Hashtag

Alternatives:
- https://github.com/epwalsh/obsidian.nvim

-------------------------------------------------------------------------------
*lsp* *formatter* *linter*

Expand Down
3 changes: 3 additions & 0 deletions root/.vim/doc/rg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions root/.vim/ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 7b9d806

Please sign in to comment.