complete basic config of my neovim
This commit is contained in:
@ -81,14 +81,17 @@ wk.register({
|
||||
wk.register({
|
||||
["<Leader>b"] = {
|
||||
name = "+Buffer",
|
||||
h = {":BufferLineCyclePrev<CR>", "Left tab"},
|
||||
l = {":BufferLineCycleNext<CR>", "Right tab"},
|
||||
k = {":bd<CR>", "Kill buffer"},
|
||||
k = {":Bdelete!<CR>", "Kill buffer"},
|
||||
o = {":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", "Close other buffer"},
|
||||
b = {":bp<CR>", "Last buffer"},
|
||||
n = {":ls<CR>", "Buffer numbers"},
|
||||
t = {":b ", "To buffer"},
|
||||
},
|
||||
})
|
||||
-- change left and right tab
|
||||
-- 左右Tab切换
|
||||
map("n", "<C-h>", ":BufferLineCyclePrev<CR>", opt)
|
||||
map("n", "<C-l>", ":BufferLineCycleNext<CR>", opt)
|
||||
|
||||
-- Mason
|
||||
wk.register({
|
||||
@ -123,5 +126,24 @@ pluginKeys.cmp = function(cmp)
|
||||
}
|
||||
end
|
||||
|
||||
-- dap keymaps
|
||||
wk.register({
|
||||
["<Leader>d"] = {
|
||||
name = "+Debug",
|
||||
r = {":lua require('dap').continue()<CR>", "Start debug"},
|
||||
b = {":lua require('dap').toggle_breakpoint()<CR>", "Set breakpoint"},
|
||||
c = {":lua require('dap').clear_breakpoints()<CR>", "Clear breakpoint"},
|
||||
e = {":lua require'dap'.close()<CR>"
|
||||
.. ":lua require'dap'.terminate()<CR>"
|
||||
.. ":lua require'dap.repl'.close()<CR>"
|
||||
.. ":lua require'dapui'.close()<CR>"
|
||||
.. ":lua require('dap').clear_breakpoints()<CR>"
|
||||
.. "<C-w>o<CR>", "Stop debug"},
|
||||
}
|
||||
})
|
||||
map("i", "<C-d>", ":lua require'dap'.continue()<CR>", opt)
|
||||
map("n", "<C-n>", ":lua require'dap'.step_into()<CR>", opt)
|
||||
map("n", "<C-o>", ":lua require'dap'.step_over()<CR>", opt)
|
||||
|
||||
|
||||
return pluginKeys
|
||||
|
34
lua/lsp/null-ls.lua
Normal file
34
lua/lsp/null-ls.lua
Normal file
@ -0,0 +1,34 @@
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
-- 每次自动选择null-ls作为formatter
|
||||
-- auto choose null-ls as formatter
|
||||
local lsp_formatting = function(bufnr)
|
||||
vim.lsp.buf.format({
|
||||
filter = function(client)
|
||||
-- apply whatever logic you want (in this example, we'll only use null-ls)
|
||||
return client.name == "null-ls"
|
||||
end,
|
||||
bufnr = bufnr,
|
||||
})
|
||||
end
|
||||
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
require("null-ls").builtins.formatting.stylua,
|
||||
require("null-ls").builtins.formatting.clang_format,
|
||||
},
|
||||
-- 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
|
||||
lsp_formatting(bufnr)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
@ -1,27 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local dap = require('dap')
|
||||
dap.adapters.codelldb = {
|
||||
type = 'server',
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = '/home/ubuntu/.local/share/nvim/mason/packages/codelldb/codelldb',
|
||||
args = {"--port", "${port}"}
|
||||
}
|
||||
}
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
39
lua/nvim-dap/cpptools.lua
Normal file
39
lua/nvim-dap/cpptools.lua
Normal file
@ -0,0 +1,39 @@
|
||||
-- https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb)
|
||||
|
||||
local dap = require("dap")
|
||||
|
||||
dap.adapters.cppdbg = {
|
||||
id = 'cppdbg',
|
||||
type = 'executable',
|
||||
command = '/Users/logicluo/.local/share/nvim/mason/packages/cpptools/extension/debugAdapters/bin/OpenDebugAD7',
|
||||
|
||||
}
|
||||
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "cppdbg",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopAtEntry = true,
|
||||
},
|
||||
{
|
||||
name = 'Attach to gdbserver :1234',
|
||||
type = 'cppdbg',
|
||||
request = 'launch',
|
||||
-- 根据系统需要修改
|
||||
MIMode = 'lldb',
|
||||
-- miDebuggerServerAddress = 'localhost:1234',
|
||||
-- miDebuggerPath = '/usr/bin/gdb',
|
||||
cwd = '${workspaceFolder}',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.c = dap.configurations.cpp
|
||||
dap.configurations.rust = dap.configurations.cpp
|
@ -6,9 +6,9 @@
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
|
||||
-- require("nvim-dap-virtual-text").setup({
|
||||
-- commented = true,
|
||||
-- })
|
||||
require("nvim-dap-virtual-text").setup({
|
||||
commented = true,
|
||||
})
|
||||
|
||||
vim.fn.sign_define("DapBreakpoint", {
|
||||
text = "🛑",
|
||||
@ -42,26 +42,26 @@ dapui.setup({
|
||||
repl = "r",
|
||||
toggle = "t",
|
||||
},
|
||||
-- sidebar = {
|
||||
-- -- You can change the order of elements in the sidebar
|
||||
-- elements = {
|
||||
-- -- Provide as ID strings or tables with "id" and "size" keys
|
||||
-- {
|
||||
-- id = "scopes",
|
||||
-- size = 0.25, -- Can be float or integer > 1
|
||||
-- },
|
||||
-- { id = "breakpoints", size = 0.25 },
|
||||
-- { id = "stacks", size = 0.25 },
|
||||
-- { id = "watches", size = 00.25 },
|
||||
-- },
|
||||
-- size = 40,
|
||||
-- position = "left", -- Can be "left", "right", "top", "bottom"
|
||||
-- },
|
||||
-- tray = {
|
||||
-- elements = { "repl" },
|
||||
-- size = 10,
|
||||
-- position = "bottom", -- Can be "left", "right", "top", "bottom"
|
||||
-- },
|
||||
layouts = {{
|
||||
-- You can change the order of elements in the sidebar
|
||||
elements = {
|
||||
-- Provide as ID strings or tables with "id" and "size" keys
|
||||
{
|
||||
id = "scopes",
|
||||
size = 0.25, -- Can be float or integer > 1
|
||||
},
|
||||
{ id = "breakpoints", size = 0.25 },
|
||||
{ id = "stacks", size = 0.25 },
|
||||
{ id = "watches", size = 00.25 },
|
||||
},
|
||||
size = 40,
|
||||
position = "left", -- Can be "left", "right", "top", "bottom"
|
||||
},
|
||||
{
|
||||
elements = { "repl" },
|
||||
size = 10,
|
||||
position = "bottom", -- Can be "left", "right", "top", "bottom"
|
||||
},},
|
||||
floating = {
|
||||
max_height = nil, -- These can be integers or a float between 0 and 1.
|
||||
max_width = nil, -- Floats will be treated as percentage of your screen.
|
||||
@ -86,4 +86,4 @@ dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
|
||||
require("nvim-dap.codelldb").setup()
|
||||
require("nvim-dap.cpptools")
|
||||
|
@ -1,13 +1,12 @@
|
||||
require("mason").setup({
|
||||
automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig)
|
||||
ui = {
|
||||
icons = {
|
||||
server_installed = "✓",
|
||||
server_pending = "➜",
|
||||
server_uninstalled = "✗"
|
||||
}
|
||||
}
|
||||
automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig)
|
||||
ui = {
|
||||
icons = {
|
||||
server_installed = "✓",
|
||||
server_pending = "➜",
|
||||
server_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
require("mason-lspconfig").setup()
|
||||
|
1
lua/plugin-config/neogit.lua
Normal file
1
lua/plugin-config/neogit.lua
Normal file
@ -0,0 +1 @@
|
||||
require("neogit").setup({})
|
208
lua/plugins.lua
208
lua/plugins.lua
@ -1,121 +1,129 @@
|
||||
return require('packer').startup(function()
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
return require("packer").startup(function()
|
||||
-- Packer can manage itself
|
||||
use("wbthomason/packer.nvim")
|
||||
|
||||
-- Nova theme for neovim light
|
||||
use({
|
||||
"zanglg/nova.nvim",
|
||||
config = function()
|
||||
-- support both dark and light style
|
||||
require("nova").setup({ background = "light" })
|
||||
-- Nova theme for neovim light
|
||||
use({
|
||||
"zanglg/nova.nvim",
|
||||
config = function()
|
||||
-- support both dark and light style
|
||||
require("nova").setup({ background = "light" })
|
||||
|
||||
-- load colorscheme
|
||||
require("nova").load()
|
||||
end,
|
||||
})
|
||||
-- load colorscheme
|
||||
require("nova").load()
|
||||
end,
|
||||
})
|
||||
|
||||
-- nvim-tree for file manage
|
||||
use {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
}
|
||||
-- git plugin like magit
|
||||
-- 类似magit的插件neogit
|
||||
use({ "TimUntersberger/neogit", requires = "nvim-lua/plenary.nvim" })
|
||||
|
||||
-- vim dashboard
|
||||
-- vim 开始界面
|
||||
use {'glepnir/dashboard-nvim'}
|
||||
-- nvim-tree for file manage
|
||||
use({
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
requires = "kyazdani42/nvim-web-devicons",
|
||||
})
|
||||
|
||||
-- vim dashboard
|
||||
-- vim 开始界面
|
||||
use({ "glepnir/dashboard-nvim" })
|
||||
|
||||
-- bufferline on the top
|
||||
-- 顶部状态栏
|
||||
use {'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons'}
|
||||
-- bufferline on the top
|
||||
-- 顶部状态栏
|
||||
use({ "akinsho/bufferline.nvim", requires = "kyazdani42/nvim-web-devicons" })
|
||||
|
||||
-- treesitter
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function() require('nvim-treesitter.install').update({ with_sync = true }) end,
|
||||
}
|
||||
|
||||
-- telescope
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
-- treesitter
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
run = function()
|
||||
require("nvim-treesitter.install").update({ with_sync = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- project
|
||||
-- 项目管理
|
||||
-- Lua
|
||||
use {
|
||||
"ahmedkhalf/project.nvim",
|
||||
}
|
||||
-- telescope
|
||||
use({
|
||||
"nvim-telescope/telescope.nvim",
|
||||
requires = { { "nvim-lua/plenary.nvim" } },
|
||||
})
|
||||
|
||||
-- whick-key
|
||||
use {
|
||||
'folke/which-key.nvim'
|
||||
}
|
||||
-- project
|
||||
-- 项目管理
|
||||
-- Lua
|
||||
use({
|
||||
"ahmedkhalf/project.nvim",
|
||||
})
|
||||
|
||||
-- comment
|
||||
use {
|
||||
'numToStr/Comment.nvim',
|
||||
}
|
||||
-- whick-key
|
||||
use({
|
||||
"folke/which-key.nvim",
|
||||
})
|
||||
|
||||
-- lualine for bottom stausline
|
||||
-- 底部状态栏
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
|
||||
}
|
||||
-- comment
|
||||
use({
|
||||
"numToStr/Comment.nvim",
|
||||
})
|
||||
|
||||
-- notify
|
||||
-- 弹窗消息通知
|
||||
use {
|
||||
'rcarriga/nvim-notify'
|
||||
}
|
||||
-- lualine for bottom stausline
|
||||
-- 底部状态栏
|
||||
use({
|
||||
"nvim-lualine/lualine.nvim",
|
||||
requires = { "kyazdani42/nvim-web-devicons", opt = true },
|
||||
})
|
||||
|
||||
-- autopairs
|
||||
-- 自动补全括号
|
||||
use {
|
||||
"windwp/nvim-autopairs",
|
||||
}
|
||||
-- notify
|
||||
-- 弹窗消息通知
|
||||
use({
|
||||
"rcarriga/nvim-notify",
|
||||
})
|
||||
|
||||
-- coderunner
|
||||
-- 代码运行
|
||||
use { 'CRAG666/code_runner.nvim', requires = 'nvim-lua/plenary.nvim' }
|
||||
-- autopairs
|
||||
-- 自动补全括号
|
||||
use({
|
||||
"windwp/nvim-autopairs",
|
||||
})
|
||||
|
||||
------------------- lsp --------------------------
|
||||
-- mason for lsp dap linter and others
|
||||
use {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
}
|
||||
|
||||
-- nlsp-settings
|
||||
-- 方便的lsp配置插件
|
||||
-- use {
|
||||
-- "tamago324/nlsp-settings.nvim"
|
||||
-- }
|
||||
-- coderunner
|
||||
-- 代码运行
|
||||
use({ "CRAG666/code_runner.nvim", requires = "nvim-lua/plenary.nvim" })
|
||||
|
||||
-- 补全引擎
|
||||
use("hrsh7th/nvim-cmp")
|
||||
-- Snippet 引擎
|
||||
use("hrsh7th/vim-vsnip")
|
||||
-- 补全源
|
||||
use("hrsh7th/cmp-vsnip")
|
||||
use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }
|
||||
use("hrsh7th/cmp-buffer") -- { name = 'buffer' },
|
||||
use("hrsh7th/cmp-path") -- { name = 'path' }
|
||||
use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' }
|
||||
use("hrsh7th/cmp-nvim-lsp-signature-help") -- { name = 'nvim_lsp_signature_help' }
|
||||
-- 常见编程语言代码段
|
||||
use("rafamadriz/friendly-snippets")
|
||||
-- UI 增强
|
||||
use("onsails/lspkind-nvim")
|
||||
------------------- lsp --------------------------
|
||||
-- mason for lsp dap linter and others
|
||||
use({
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
})
|
||||
|
||||
-- null-ls for formatter and others
|
||||
-- null-ls 用于格式化和其他
|
||||
use({
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
})
|
||||
|
||||
-- nlsp-settings
|
||||
-- 方便的lsp配置插件
|
||||
-- use {
|
||||
-- "tamago324/nlsp-settings.nvim"
|
||||
-- }
|
||||
|
||||
------------------- dap -----------------------
|
||||
-- dap for neovim
|
||||
-- dap ui和适配器
|
||||
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
|
||||
-- 补全引擎
|
||||
use("hrsh7th/nvim-cmp")
|
||||
-- Snippet 引擎
|
||||
use("hrsh7th/vim-vsnip")
|
||||
-- 补全源
|
||||
use("hrsh7th/cmp-vsnip")
|
||||
use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }
|
||||
use("hrsh7th/cmp-buffer") -- { name = 'buffer' },
|
||||
use("hrsh7th/cmp-path") -- { name = 'path' }
|
||||
use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' }
|
||||
use("hrsh7th/cmp-nvim-lsp-signature-help") -- { name = 'nvim_lsp_signature_help' }
|
||||
-- 常见编程语言代码段
|
||||
use("rafamadriz/friendly-snippets")
|
||||
-- UI 增强
|
||||
use("onsails/lspkind-nvim")
|
||||
|
||||
------------------- dap -----------------------
|
||||
-- dap for neovim
|
||||
-- dap ui和适配器
|
||||
use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap", "theHamsta/nvim-dap-virtual-text" } })
|
||||
end)
|
||||
|
Reference in New Issue
Block a user