我的LazyVim配置(Golang, Python...)

lua/plugins/go.lua return { -- add language parsers to treesitter { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) vim.list_extend(opts.ensure_installed, { "go", "gomod", "gowork", }) end, }, -- cmdline tools for LSP servers, DAP servers, formatters and linters { "williamboman/mason.nvim", opts = function(_, opts) vim.list_extend(opts.ensure_installed, { "gopls", "goimports", "gofumpt", "golangci-lint", "golangci-lint-langserver", -- Wraps golangci-lint as a language server "delve", --"staticcheck", "gomodifytags", "impl", }) end, }, -- setup lspconfig servers { "neovim/nvim-lspconfig", ---@class PluginLspOpts opts = { -- server cmdline will be automatically installed with mason and loaded with lspconfig ---@type lspconfig.options servers = { gopls = { gofumpt = true, -- formatter, default "goimports" codelenses = { gc_details = false, generate = true, regenerate_cgo = true, run_govulncheck = true, test = true, tidy = true, upgrade_dependency = true, vendor = true, }, hints = { assignVariableTypes = true, compositeLiteralFields = true, compositeLiteralTypes = true, constantValues = true, functionTypeParameters = true, parameterNames = true, rangeVariableTypes = true, }, analyses = { fieldalignment = true, nilness = true, unusedparams = true, unusedwrite = true, useany = true, }, }, golangci_lint_ls = {}, -- linter }, code_actions = { -- null-ls.nvim: builtins code_actions "gomodifytags", "impl", }, dap = { -- nvim-dap: language specific extensions { "leoluz/nvim-dap-go" }, }, test = { -- neotest: language specific adapters "nvim-neotest/neotest-go", adapters = { ["neotest-go"] = { args = { "-count=1", "-timeout=60s", "-race", "-cover" }, }, }, }, }, }, -- setup code actions { "nvimtools/none-ls.nvim", event = "BufReadPre", dependencies = { "mason.nvim" }, opts = function(_, opts) local nls = require("null-ls") vim.list_extend(opts.sources, { nls.builtins.code_actions.gomodifytags, nls.builtins.code_actions.impl, }) end, }, -- setup neotest adapter { "nvim-neotest/neotest", optional = true, dependencies = { "nvim-neotest/neotest-go", }, opts = function(_, opts) table.insert(opts.adapters, function() return require("neotest-go")({ args = { "-count=1", "-timeout=60s", "-race", "-cover" }, }) end) end, }, } lua/plugins/lspconfig.lua return { { "neovim/nvim-lspconfig", opts = { servers = { gopls = { settings = { gopls = { analyses = { unusedparams = true, }, staticcheck = true, }, }, }, }, }, }, } 前提是在 Lazy Extra 把 Golang , Python, Lsp 等先安装好 ...

一月 14, 2025

Swagger 如何使用vendorExtensions进行扩展

Swagger或者叫OpenAPI是一套完备且通用的API标准,本文并不介绍Swagger的用法,仅针对某些场景需要扩展(扩展需要以"x-")该如何开发做紧要的介绍。 ...

十一月 29, 2019

Emacs

M -> Alt(option) S -> Shift 快捷键 用途 M-v 上(后)一屏 C-v 下(前)一屏 C-x 0 关闭当前窗口 C-l 重绘屏幕,将光标所在行置于屏幕中央 C-u(M-num) 重复执行。C-u 8 C-f(M-8 C-u) 会把光标往前移动8个字符 C-x C-f 查找或者新建一个文件 C-x C-b 列出缓冲区。 C-x 1 关闭缓冲区列表。将需要删除的缓冲区标“d”(选中,按d),然后按“x”执行删除标记的所有缓冲区 C-x b 切换缓冲区,输入缓冲区名字,RET C-x C-q 开启或者关闭buffer的只读模式 C-x k 关闭当前缓冲区 C-x C-s 保存当前文件 C-x s 保存所有文件 C-x h 全选 M-w 复制 C-y 粘贴 C-w 剪切 C-s 往前搜索 C-r 往后搜索. DEL 也可以往后搜索, C-/ undo M-x calendar 打开日历。按 q 退出。【g d 到指定日期】【. 到今日(不居中)】【> 前一个月】【< 后一个月】 M-x *-mode 选择Major mode M-x shell 运行一个shell M-x eshell 运行一个eshell C-a 移到行首 C-a C-k、C-S-backspace 删除整行 C-u 5 C-S-backspace、M-5 C-S-backspace 删除后5行,不加数字则删除4行(默认),如果数字为负数,则往前删 C-g 停止当前的命令 C-k 删除从光标位置到行尾所有字符 M-% 查找及替换。输入要被替换的词,回车,然后输入要替换的词,再回车。输入==y==替换并跳到下一个,输入==n==忽略并跳到下一个,输入==q==结束, 输入 ==!== 替换剩下的全部 M-x occur RET xxx RET 新开一个窗口来列出匹配的行,点击就会跳转到对应的位置,编程时有用 C-x C-t 当前行与上一行换位置 Org-Mode 快捷键 用途 C-c . 插入时间 C-c C-e 导出其它格式 C-c C-s 在标题下面插入一个带有“==SCHEDULED==”关键字的时间戳。 C-c C-d 在标题下面插入一个带有“==DEADLINE==”关键字的时间戳 C-c C-t 将当前项的状态在(unmarked)->TODO->DONE 之间循环切换 M-RET 插入一个同级标题 M-LEFT/RIGHT 将当前的标题提升/降低一个等级 C-c C-c 插入标签tag。 光标在标题中 C-c C-q 插入标签tag。光标在任意位置 C-c , 设置当前标题的优先级,’A‘、’B‘和’C‘。’A‘是最高级别,如不指定,’B‘是默认的 C-c \ 查找标签tag S-Tab 展开所有标题 Tab 展开光标所在标题 [==[== Link ==][== Description]==]== 创建链接 C-c C-l 编辑链接 C-c C-o 打开链接 C-c | (竖线,not L) 输入 列 x 行, 插入一个表格 [/] 或者 [%] 通过在TODO项目下新建一个大纲树,并在子树上标记子任务来实现这个功能。为了能对已经完成的任务有个大致的了解,你可以在标题的任何地方插入‘[/]’或者‘[%]’。当每个子任务的状态变化时,或者当你在标记上按 C-c C-时,这些标记状态也会随之更新 <s Tab 开启一个代码块。 #+begin_src c -n -t -h 7 -w 40: c为所添加的语言,-n 显示行号,-t 清除格式,-h 7 设置高度为7 -w 40设置宽度为40 C-c ' 打开一个buffer, 输入代码,再按一次快捷键,将代码写入buffer C-c C-c 运行源代码,并生成一个RESULT块 内容元数据 详情见文后 Markdown-Mode 快捷键 用途 C-c C-c p 生成临时文件并在浏览器中预览 C-c C-c v 生成 basename.html 并在浏览器中预览 C-c C-a u 插入=<>=这样的链接 C-c C-a f 插入脚注链接 C-c C-a l 插入==这样的链接 Org-Mode 内容元数据 快捷键 内容 用途 s #+begin_src … #+end_src e #+begin_example … #+end_example : 单行的例子以冒号开头 q #+begin_quote … #+end_quote 通常用于引用,与默认格式相比左右都会留出缩进 v #+begin_verse … #+end_verse 默认内容不换行,需要留出空行才能换行 c #+begin_center … #+end_center l #+begin_latex … #+end_latex L #+latex: h #+begin_html … #+end_html H #+html: a #+begin_ascii … #+end_ascii A #+ascii: i #+index: line I #+include: line

十一月 27, 2019