feat: plugin support
This commit is contained in:
parent
47818963c1
commit
3427634b18
|
@ -0,0 +1,19 @@
|
|||
## neovim
|
||||
|
||||
一个neovim配置
|
||||
|
||||
### usage hello world me help, good.
|
||||
|
||||
安装插件管理工具
|
||||
|
||||
```bash
|
||||
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
|
||||
~/.local/share/nvim/site/pack/packer/start/packer.nvim
|
||||
```
|
||||
|
||||
安装依赖
|
||||
|
||||
```bash
|
||||
sudo dnf install fd-find ripgrep -y
|
||||
go install github.com/jesseduffield/lazygit@latest
|
||||
```
|
20
init.lua
20
init.lua
|
@ -19,22 +19,36 @@ require("plugins.notify")
|
|||
require("plugins.telescope")
|
||||
-- 缩进线
|
||||
require("plugins.indent-blackline")
|
||||
-- 重命名工具
|
||||
require("plugins.renamer")
|
||||
-- git管理
|
||||
require("plugins.gitsigns")
|
||||
-- 终端管理
|
||||
require("plugins.terminal")
|
||||
-- 错误列表
|
||||
require("plugins.trouble")
|
||||
-- 代码大纲
|
||||
require("plugins.aerial")
|
||||
-- 跳转
|
||||
require("plugins.leap")
|
||||
-- LSP管理
|
||||
require("plugins.mason")
|
||||
require("lsp.init")
|
||||
require("lsp.lua")
|
||||
require("lsp.go")
|
||||
require("lsp.yaml")
|
||||
require("lsp.json")
|
||||
require("lsp.toml")
|
||||
require("lsp.protocol")
|
||||
require("lsp.bash")
|
||||
require("lsp.docker")
|
||||
require("lsp.html")
|
||||
require("lsp.volar")
|
||||
require("plugins.lspsaga")
|
||||
-- golang ide config
|
||||
require("plugins.go")
|
||||
-- 格式化
|
||||
require("plugins.format")
|
||||
-- 优化启动速度
|
||||
require("plugins.impatient")
|
||||
-- TODO 管理
|
||||
require("plugins.todo")
|
||||
-- 按键绑定
|
||||
require("basics.keybinding")
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"workspace.library": [
|
||||
"/home/x/.config/nvim",
|
||||
"/home/x/.local/share/nvim/site",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/Comment.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/alpha-nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/auto-save.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/bufferline.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/go.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/guihua.lua",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/lazygit.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/lualine.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/mason.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/navigator.lua",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/nvim-notify",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/packer.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/plenary.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/renamer.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/telescope.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/toggleterm.nvim",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/tokyonight.nvim",
|
||||
"/usr/share/nvim/runtime",
|
||||
"/usr/share/nvim/runtime/pack/dist/opt/matchit",
|
||||
"/home/x/.local/share/nvim/site/pack/packer/start/go.nvim/after",
|
||||
"/usr/share/vim/vimfiles/",
|
||||
"${3rd}/luassert/library",
|
||||
"${3rd}/luv/library",
|
||||
"${3rd}/lfs/library"
|
||||
],
|
||||
"diagnostics.globals": [
|
||||
"vim",
|
||||
"lfs"
|
||||
]
|
||||
}
|
|
@ -70,5 +70,7 @@ vim.o.showmode = false
|
|||
vim.opt.clipboard = "unnamedplus"
|
||||
-- Some servers have issues with backup files, see #649
|
||||
vim.opt.backup = false
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.writebackup = false
|
||||
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
|
|
|
@ -2,36 +2,171 @@ vim.g.mapleader = " "
|
|||
vim.g.maplocalleader = " "
|
||||
|
||||
local map = vim.api.nvim_set_keymap
|
||||
local noreopt = {noremap = true, silent = true }
|
||||
local noreopt = { noremap = true, silent = true }
|
||||
|
||||
-- 友好正常模式命令框
|
||||
map("n", ":", "<cmd>FineCmdline<CR>", noreopt)
|
||||
-- 重置窗口大小
|
||||
map("n", "<C-Up>", ":resize -2<CR>", noreopt)
|
||||
map("n", "<C-Down>", ":resize +2<CR>", noreopt)
|
||||
map("n", "<C-Left>", ":vertical resize -2<CR>", noreopt)
|
||||
map("n", "<C-Right>", ":vertical resize +2<CR>", noreopt)
|
||||
-- 窗口切换
|
||||
map("n", "<C-h>", "<C-w>h", noreopt)
|
||||
map("n", "<C-j>", "<C-w>j", noreopt)
|
||||
map("n", "<C-k>", "<C-w>k", noreopt)
|
||||
map("n", "<C-l>", "<C-w>l", noreopt)
|
||||
-- 代码块移动
|
||||
map("n", "<A-j>", "<Esc>:m .+1<CR>==gi", noreopt)
|
||||
map("n", "<A-k>", "<Esc>:m .-2<CR>==gi", noreopt)
|
||||
map("v", "<", "<gv", noreopt)
|
||||
map("v", ">", ">gv", noreopt)
|
||||
map("v", "<A-j>", ":m .+1<CR>==", noreopt)
|
||||
map("v", "<A-k>", ":m .-2<CR>==", noreopt)
|
||||
map("x", "J", ":move '>+1<CR>gv-gv", noreopt)
|
||||
map("x", "K", ":move '<-2<CR>gv-gv", noreopt)
|
||||
map("x", "<A-j>", ":move '>+1<CR>gv-gv", noreopt)
|
||||
map("x", "<A-k>", ":move '<-2<CR>gv-gv", noreopt)
|
||||
-- 快所退出
|
||||
map("n", "q", ":wq<CR>", noreopt)
|
||||
map("n", "qq", ":q!<CR>", noreopt)
|
||||
map("i", "jk", "<ESC>", noreopt)
|
||||
-- git 管理
|
||||
map('n', '<leader>lg', ':LazyGit<CR>', noreopt)
|
||||
map("n", "<leader>lg", ":LazyGit<CR>", noreopt)
|
||||
-- 开关文件树
|
||||
map('n', '<leader>t', ':NvimTreeToggle<CR>', noreopt)
|
||||
map("n", "<leader>t", ":NvimTreeToggle<CR>", noreopt)
|
||||
-- 文件页切换
|
||||
map('n', '<leader>ll', ':BufferLineCyclePrev<CR>', noreopt)
|
||||
map('n', '<leader>rr', ':BufferLineCycleNext<CR>', noreopt)
|
||||
map("n", "<leader>ll", ":BufferLineCyclePrev<CR>", noreopt)
|
||||
map("n", "<leader>rr", ":BufferLineCycleNext<CR>", noreopt)
|
||||
map("n", "<leader>pc", ":BufferLinePickClose<CR>", noreopt)
|
||||
-- 模糊搜索
|
||||
map('n', '<leader>ff', '<Cmd>Telescope find_files<CR>', noreopt)
|
||||
map('n', '<leader>fg', '<Cmd>Telescope live_grep<CR>', noreopt)
|
||||
map("n", "<leader>ff", "<Cmd>Telescope find_files<CR>", noreopt)
|
||||
map("n", "<leader>fg", "<Cmd>Telescope live_grep<CR>", noreopt)
|
||||
-- 重命名
|
||||
vim.keymap.set({'i','n','v'}, '<F6>', '<cmd>lua require("renamer").rename()<cr>')
|
||||
vim.keymap.set({ "i", "n", "v" }, "<F6>", '<cmd>lua require("renamer").rename()<cr>')
|
||||
-- 终端管理
|
||||
map('n', '<leader>te', '<Cmd>ToggleTerm<CR>', noreopt)
|
||||
map("n", "<leader>te", "<Cmd>ToggleTerm<CR>", noreopt)
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = {buffer = 0}
|
||||
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||||
local opts = { buffer = 0 }
|
||||
vim.keymap.set("t", "<esc>", [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set("t", "jk", [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set("t", "<C-h>", [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-j>", [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-k>", [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set("t", "<C-l>", [[<Cmd>wincmd l<CR>]], opts)
|
||||
end
|
||||
|
||||
function _G.set_terminal_keymaps_insert()
|
||||
vim.keymap.set('n', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set('n', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set('n', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set('n', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||||
local opts = { buffer = 0 }
|
||||
vim.keymap.set("n", "<C-h>", [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set("n", "<C-j>", [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set("n", "<C-k>", [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set("n", "<C-l>", [[<Cmd>wincmd l<CR>]], opts)
|
||||
end
|
||||
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
||||
vim.cmd('lua set_terminal_keymaps_insert()')
|
||||
|
||||
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
|
||||
vim.cmd("lua set_terminal_keymaps_insert()")
|
||||
-- 错误列表UI
|
||||
map("n", "<leader>xx", "<cmd>TroubleToggle<cr>", noreopt)
|
||||
map("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>", noreopt)
|
||||
map("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>", noreopt)
|
||||
map("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>", noreopt)
|
||||
map("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>", noreopt)
|
||||
map("n", "gR", "<cmd>TroubleToggle lsp_references<cr>", noreopt)
|
||||
-- 高亮跳转
|
||||
map("n", "n", "n:Beacon<CR>", noreopt)
|
||||
map("n", "N", "N:Beacon<CR>", noreopt)
|
||||
map("n", "*", "*:Beacon<CR>", noreopt)
|
||||
map("n", "#", "#:Beacon<CR>", noreopt)
|
||||
-- markdown
|
||||
map("n", "<leader>mp", ":MarkdownPreviewToggle<CR>", noreopt)
|
||||
-- lspsage
|
||||
function _G.set_lspsage_keymaps()
|
||||
local keymap = vim.keymap.set
|
||||
-- LSP finder - Find the symbol's definition
|
||||
-- If there is no definition, it will instead be hidden
|
||||
-- When you use an action in finder like "open vsplit",
|
||||
-- you can use <C-t> to jump back
|
||||
keymap("n", "cf", "<cmd>Lspsaga lsp_finder<CR>")
|
||||
|
||||
-- Code action
|
||||
keymap({ "n", "v" }, "ca", "<cmd>Lspsaga code_action<CR>")
|
||||
|
||||
-- Rename all occurrences of the hovered word for the entire file
|
||||
keymap("n", "rn", "<cmd>Lspsaga rename<CR>")
|
||||
|
||||
-- Rename all occurrences of the hovered word for the selected files
|
||||
keymap("n", "<leader>rn", "<cmd>Lspsaga rename ++project<CR>")
|
||||
|
||||
-- Peek definition
|
||||
-- You can edit the file containing the definition in the floating window
|
||||
-- It also supports open/vsplit/etc operations, do refer to "definition_action_keys"
|
||||
-- It also supports tagstack
|
||||
-- Use <C-t> to jump back
|
||||
keymap("n", "gd", "<cmd>Lspsaga peek_definition<CR>")
|
||||
|
||||
-- Go to definition
|
||||
keymap("n", "gd", "<cmd>Lspsaga goto_definition<CR>")
|
||||
|
||||
-- Peek type definition
|
||||
-- You can edit the file containing the type definition in the floating window
|
||||
-- It also supports open/vsplit/etc operations, do refer to "definition_action_keys"
|
||||
-- It also supports tagstack
|
||||
-- Use <C-t> to jump back
|
||||
keymap("n", "gt", "<cmd>Lspsaga peek_type_definition<CR>")
|
||||
|
||||
-- Go to type definition
|
||||
keymap("n", "gt", "<cmd>Lspsaga goto_type_definition<CR>")
|
||||
|
||||
-- Show line diagnostics
|
||||
-- You can pass argument ++unfocus to
|
||||
-- unfocus the show_line_diagnostics floating window
|
||||
keymap("n", "<leader>sl", "<cmd>Lspsaga show_line_diagnostics<CR>")
|
||||
|
||||
-- Show cursor diagnostics
|
||||
-- Like show_line_diagnostics, it supports passing the ++unfocus argument
|
||||
keymap("n", "<leader>sc", "<cmd>Lspsaga show_cursor_diagnostics<CR>")
|
||||
|
||||
-- Show buffer diagnostics
|
||||
keymap("n", "<leader>sb", "<cmd>Lspsaga show_buf_diagnostics<CR>")
|
||||
|
||||
-- Diagnostic jump
|
||||
-- You can use <C-o> to jump back to your previous location
|
||||
keymap("n", "[e", "<cmd>Lspsaga diagnostic_jump_prev<CR>")
|
||||
keymap("n", "]e", "<cmd>Lspsaga diagnostic_jump_next<CR>")
|
||||
|
||||
-- Diagnostic jump with filters such as only jumping to an error
|
||||
keymap("n", "[E", function()
|
||||
require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR })
|
||||
end)
|
||||
keymap("n", "]E", function()
|
||||
require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR })
|
||||
end)
|
||||
|
||||
-- Toggle outline
|
||||
keymap("n", "<leader>o", "<cmd>Lspsaga outline<CR>")
|
||||
|
||||
-- Hover Doc
|
||||
-- If there is no hover doc,
|
||||
-- there will be a notification stating that
|
||||
-- there is no information available.
|
||||
-- To disable it just use ":Lspsaga hover_doc ++quiet"
|
||||
-- Pressing the key twice will enter the hover window
|
||||
keymap("n", "K", "<cmd>Lspsaga hover_doc<CR>")
|
||||
|
||||
-- If you want to keep the hover window in the top right hand corner,
|
||||
-- you can pass the ++keep argument
|
||||
-- Note that if you use hover with ++keep, pressing this key again will
|
||||
-- close the hover window. If you want to jump to the hover window
|
||||
-- you should use the wincmd command "<C-w>w"
|
||||
keymap("n", "K", "<cmd>Lspsaga hover_doc ++keep<CR>")
|
||||
|
||||
-- Call hierarchy
|
||||
keymap("n", "<Leader>ci", "<cmd>Lspsaga incoming_calls<CR>")
|
||||
keymap("n", "<Leader>co", "<cmd>Lspsaga outgoing_calls<CR>")
|
||||
|
||||
-- Floating terminal
|
||||
keymap({ "n", "t" }, "<A-d>", "<cmd>Lspsaga term_toggle<CR>")
|
||||
end
|
||||
|
||||
vim.cmd("lua set_lspsage_keymaps()")
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
vim.cmd[[colorscheme tokyonight]]
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
vim.cmd([[colorscheme gruvbox]])
|
||||
|
|
|
@ -1,9 +1,69 @@
|
|||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||
end
|
||||
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "vsnip" }, -- For vsnip users.
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities() --nvim-cmp
|
||||
|
||||
require("lspconfig")["golangci_lint_ls"].setup({
|
||||
on_attach = common_lsp_on_attach,
|
||||
flags = common_lsp_flags,
|
||||
})
|
||||
|
||||
require("lspconfig")["gopls"].setup({
|
||||
cmd = { "gopls" },
|
||||
on_attach = common_lsp_on_attach,
|
||||
flags = common_lsp_flags,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
gopls = {
|
||||
experimentalPostfixCompletions = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
shadow = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
init_options = { usePlaceholders = true },
|
||||
})
|
||||
|
|
|
@ -6,6 +6,20 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|||
require("lspconfig").html.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
require("lspconfig").cssls.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
require("lspconfig").tsserver.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
require("lspconfig").eslint.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
command = "EslintFixAll",
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,37 +1,12 @@
|
|||
-- Mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
common_lsp_on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set("n", "<space>wl", function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, bufopts)
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
local function buf_set_option(...)
|
||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
end
|
||||
end
|
||||
|
||||
common_lsp_flags = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require("lspconfig").sumneko_lua.setup({
|
||||
require("lspconfig").lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
|
|
|
@ -5,3 +5,7 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|||
require("lspconfig").jsonls.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
require("lspconfig").taplo.setup({})
|
||||
|
||||
require("lspconfig").yamlls.setup({})
|
|
@ -1 +0,0 @@
|
|||
require("lspconfig").taplo.setup({})
|
|
@ -0,0 +1,3 @@
|
|||
require("lspconfig").volar.setup({
|
||||
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" },
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
require("lspconfig").yamlls.setup({})
|
|
@ -0,0 +1,10 @@
|
|||
require("aerial").setup({
|
||||
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
|
||||
on_attach = function(bufnr)
|
||||
-- Jump forwards/backwards with '{' and '}'
|
||||
vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr })
|
||||
vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr })
|
||||
-- You probably also want to set a keymap to toggle aerial
|
||||
vim.keymap.set("n", "<leader>ol", "<cmd>AerialToggle!<CR>", { buffer = bufnr })
|
||||
end,
|
||||
})
|
|
@ -1 +1 @@
|
|||
require("auto-save").setup {}
|
||||
-- require("auto-save").setup {}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
require("bufferline").setup{
|
||||
options = {
|
||||
-- 使用 nvim 内置lsp
|
||||
diagnostics = "nvim_lsp",
|
||||
always_show_bufferline = false,
|
||||
-- 左侧让出 nvim-tree 的位置
|
||||
offsets = {{
|
||||
filetype = "NvimTree",
|
||||
text = "File Explorer",
|
||||
highlight = "Directory",
|
||||
text_align = "left"
|
||||
}}
|
||||
}
|
||||
}
|
||||
require("bufferline").setup({
|
||||
options = {
|
||||
-- 使用 nvim 内置lsp
|
||||
diagnostics = "nvim_lsp",
|
||||
always_show_bufferline = false,
|
||||
-- 左侧让出 nvim-tree 的位置
|
||||
offsets = {
|
||||
{
|
||||
filetype = "NvimTree",
|
||||
text = "File Explorer",
|
||||
highlight = "Directory",
|
||||
text_align = "left",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require("catppuccin").setup({
|
||||
integrations = {
|
||||
lsp_saga = true
|
||||
}
|
||||
})
|
|
@ -1,22 +1,22 @@
|
|||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
local null_ls = require("null-ls")
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.gofmt,
|
||||
null_ls.builtins.formatting.stylua,
|
||||
},
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
sources = {
|
||||
null_ls.builtins.formatting.gofmt,
|
||||
null_ls.builtins.formatting.stylua,
|
||||
},
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "LspFormatting", function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end, {})
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
command = "undojoin | LspFormatting",
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,40 +1,92 @@
|
|||
require('gitsigns').setup({
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
require("gitsigns").setup({
|
||||
signs = {
|
||||
add = { text = "│" },
|
||||
change = { text = "│" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
untracked = { text = "┆" },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000, -- Disable if file is longer than this (in lines)
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = "single",
|
||||
style = "minimal",
|
||||
relative = "cursor",
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
yadm = {
|
||||
enable = false,
|
||||
},
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map('n', ']c', function()
|
||||
if vim.wo.diff then return ']c' end
|
||||
vim.schedule(function() gs.next_hunk() end)
|
||||
return '<Ignore>'
|
||||
end, {expr=true})
|
||||
-- Navigation
|
||||
map("n", "]c", function()
|
||||
if vim.wo.diff then
|
||||
return "]c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
map('n', '[c', function()
|
||||
if vim.wo.diff then return '[c' end
|
||||
vim.schedule(function() gs.prev_hunk() end)
|
||||
return '<Ignore>'
|
||||
end, {expr=true})
|
||||
map("n", "[c", function()
|
||||
if vim.wo.diff then
|
||||
return "[c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
-- Actions
|
||||
map({'n', 'v'}, '<leader>hs', ':Gitsigns stage_hunk<CR>')
|
||||
map({'n', 'v'}, '<leader>hr', ':Gitsigns reset_hunk<CR>')
|
||||
map('n', '<leader>hS', gs.stage_buffer)
|
||||
map('n', '<leader>hu', gs.undo_stage_hunk)
|
||||
map('n', '<leader>hR', gs.reset_buffer)
|
||||
map('n', '<leader>hp', gs.preview_hunk)
|
||||
map('n', '<leader>hb', function() gs.blame_line{full=true} end)
|
||||
map('n', '<leader>tb', gs.toggle_current_line_blame)
|
||||
map('n', '<leader>hd', gs.diffthis)
|
||||
map('n', '<leader>hD', function() gs.diffthis('~') end)
|
||||
map('n', '<leader>td', gs.toggle_deleted)
|
||||
-- Actions
|
||||
map({ "n", "v" }, "<leader>hs", ":Gitsigns stage_hunk<CR>")
|
||||
map({ "n", "v" }, "<leader>hr", ":Gitsigns reset_hunk<CR>")
|
||||
map("n", "<leader>hS", gs.stage_buffer)
|
||||
map("n", "<leader>hu", gs.undo_stage_hunk)
|
||||
map("n", "<leader>hR", gs.reset_buffer)
|
||||
map("n", "<leader>hp", gs.preview_hunk)
|
||||
map("n", "<leader>hb", function()
|
||||
gs.blame_line({ full = true })
|
||||
end)
|
||||
map("n", "<leader>tb", gs.toggle_current_line_blame)
|
||||
map("n", "<leader>hd", gs.diffthis)
|
||||
map("n", "<leader>hD", function()
|
||||
gs.diffthis("~")
|
||||
end)
|
||||
map("n", "<leader>td", gs.toggle_deleted)
|
||||
|
||||
-- Text object
|
||||
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
|
||||
end
|
||||
-- Text object
|
||||
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
require("go").setup()
|
||||
local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.go",
|
||||
callback = function()
|
||||
require("go.format").goimport()
|
||||
end,
|
||||
group = format_sync_grp,
|
||||
})
|
|
@ -0,0 +1 @@
|
|||
require("impatient")
|
|
@ -1,10 +1,10 @@
|
|||
vim.opt.list = true
|
||||
vim.opt.listchars:append "space:⋅"
|
||||
vim.opt.listchars:append "eol:↴"
|
||||
vim.opt.listchars:append("space:⋅")
|
||||
vim.opt.listchars:append("eol:↴")
|
||||
|
||||
require("indent_blankline").setup {
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
show_end_of_line = true,
|
||||
space_char_blankline = " ",
|
||||
}
|
||||
require("indent_blankline").setup({
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
show_end_of_line = true,
|
||||
space_char_blankline = " ",
|
||||
})
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
require("leap").add_default_mappings()
|
||||
require("leap").opts.highlight_unlabeled_phase_one_targets = true
|
||||
|
||||
require("flit").setup({
|
||||
keys = { f = "f", F = "F", t = "t", T = "T" },
|
||||
-- A string like "nv", "nvo", "o", etc.
|
||||
labeled_modes = "v",
|
||||
multiline = true,
|
||||
-- Like `leap`s similar argument (call-specific overrides).
|
||||
-- E.g.: opts = { equivalence_classes = {} }
|
||||
opts = {},
|
||||
})
|
|
@ -0,0 +1,6 @@
|
|||
require("lspsaga").setup({
|
||||
ui = {
|
||||
colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors(),
|
||||
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
|
||||
},
|
||||
})
|
|
@ -1,3 +1,6 @@
|
|||
require('lualine').setup({
|
||||
options = { theme = 'tokyonight' }
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
theme = "gruvbox",
|
||||
component_separators = { left = "|", right = "|" },
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
require("mason").setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
}
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require("mason-lspconfig").setup {
|
||||
ensure_installed = { "sumneko_lua", "rust_analyzer", "gopls", "golangci_lint_ls" },
|
||||
automatic_installation = true,
|
||||
}
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
"golangci_lint_ls",
|
||||
"tsserver",
|
||||
"volar",
|
||||
"taplo",
|
||||
"lemminx",
|
||||
"yamlls",
|
||||
"sqlls",
|
||||
"jsonls",
|
||||
"jdtls",
|
||||
"bashls",
|
||||
"cssls",
|
||||
"dockerls",
|
||||
"docker_compose_language_service",
|
||||
"eslint",
|
||||
"html",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
|
|
@ -1,29 +1,36 @@
|
|||
require("nvim-tree").setup({
|
||||
auto_reload_on_write = true,
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "u", action = "dir_up" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
}
|
||||
auto_reload_on_write = true,
|
||||
sort_by = "case_sensitive",
|
||||
sync_root_with_cwd = true,
|
||||
respect_buf_cwd = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_root = true,
|
||||
},
|
||||
filters = { custom = { ".git" } },
|
||||
view = {
|
||||
width = 30,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "u", action = "dir_up" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
},
|
||||
})
|
||||
|
||||
local function open_nvim_tree(data)
|
||||
-- buffer is a directory
|
||||
local directory = vim.fn.isdirectory(data.file) == 1
|
||||
if not directory then
|
||||
return
|
||||
end
|
||||
-- change to the directory
|
||||
vim.cmd.cd(data.file)
|
||||
-- open the tree
|
||||
require("nvim-tree.api").tree.open()
|
||||
-- buffer is a directory
|
||||
local directory = vim.fn.isdirectory(data.file) == 1
|
||||
if not directory then
|
||||
return
|
||||
end
|
||||
-- change to the directory
|
||||
vim.cmd.cd(data.file)
|
||||
-- open the tree
|
||||
require("nvim-tree.api").tree.open()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
require("project_nvim").setup({
|
||||
patterns = { "project.md" },
|
||||
exclude_dirs = { ".git", "node_modules", "dist", "target" },
|
||||
})
|
|
@ -1,7 +1,8 @@
|
|||
return require("packer").startup(function(use)
|
||||
use({ "wbthomason/packer.nvim" })
|
||||
-- 主题
|
||||
use({ "folke/tokyonight.nvim" })
|
||||
use({ "catppuccin/nvim", as = "catppuccin" })
|
||||
use({ "ellisonleao/gruvbox.nvim" })
|
||||
-- 文件树
|
||||
use({
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
|
@ -77,4 +78,81 @@ return require("packer").startup(function(use)
|
|||
})
|
||||
-- 格式化
|
||||
use({ "jose-elias-alvarez/null-ls.nvim" })
|
||||
-- 项目管理
|
||||
use({ "ahmedkhalf/project.nvim" })
|
||||
-- 优化启动速度
|
||||
use({ "lewis6991/impatient.nvim" })
|
||||
-- TODO 管理
|
||||
use({
|
||||
"folke/todo-comments.nvim",
|
||||
requires = "nvim-lua/plenary.nvim",
|
||||
})
|
||||
-- golang ide
|
||||
use({
|
||||
"ray-x/go.nvim",
|
||||
"ray-x/guihua.lua", -- recommended if need floating window support
|
||||
})
|
||||
use({
|
||||
"glepnir/lspsaga.nvim",
|
||||
branch = "main",
|
||||
requires = {
|
||||
{ "nvim-tree/nvim-web-devicons" },
|
||||
--Please make sure you install markdown and markdown_inline parser
|
||||
{ "nvim-treesitter/nvim-treesitter" },
|
||||
},
|
||||
})
|
||||
-- 自动完成相关
|
||||
use({
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-vsnip",
|
||||
"hrsh7th/vim-vsnip",
|
||||
})
|
||||
-- 代码大纲
|
||||
use({ "stevearc/aerial.nvim" })
|
||||
-- 错误列表
|
||||
use({
|
||||
"folke/trouble.nvim",
|
||||
requires = "nvim-tree/nvim-web-devicons",
|
||||
})
|
||||
-- 上下高亮跳动
|
||||
use({ "danilamihailov/beacon.nvim" })
|
||||
-- markdown lsp
|
||||
use({
|
||||
"iamcco/markdown-preview.nvim",
|
||||
run = "cd app && npm install",
|
||||
setup = function()
|
||||
vim.g.mkdp_filetypes = { "markdown" }
|
||||
end,
|
||||
ft = { "markdown" },
|
||||
})
|
||||
-- 跳转
|
||||
use({ "ggandor/leap.nvim" })
|
||||
use({ "ggandor/flit.nvim" })
|
||||
-- normal command line
|
||||
use({
|
||||
"VonHeikemen/fine-cmdline.nvim",
|
||||
requires = {
|
||||
{ "MunifTanjim/nui.nvim" },
|
||||
},
|
||||
})
|
||||
-- key帮助
|
||||
use({
|
||||
"folke/which-key.nvim",
|
||||
config = function()
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 300
|
||||
require("which-key").setup({
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
})
|
||||
end,
|
||||
})
|
||||
-- 高亮当前关键词
|
||||
use({ "RRethy/vim-illuminate" })
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||
end)
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
require('telescope').load_extension("lazygit")
|
||||
require("telescope").setup({
|
||||
extensions = {
|
||||
projects = {},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
require("todo-comments").setup({})
|
|
@ -0,0 +1 @@
|
|||
require("trouble").setup()
|
Loading…
Reference in New Issue