complete basic config of my neovim

This commit is contained in:
gameloader 2022-10-07 12:15:17 +08:00
parent d783c6fa4f
commit eb733b4c66
10 changed files with 308 additions and 215 deletions

View File

@ -1,24 +1,26 @@
require('basic').load_default_options()
require("basic").load_default_options()
require('plugins')
require("plugins")
require('keybindings')
require("keybindings")
require('plugin-config/nvim-tree')
require('plugin-config/bufferline')
require('plugin-config/treesitter')
require('plugin-config/telescope')
require('plugin-config/whichkey')
require('plugin-config/comment')
require('plugin-config/mason')
require('plugin-config/lualine')
require('plugin-config/notify')
require('plugin-config/nvim-autopairs')
require('plugin-config/project')
require('plugin-config/dashboard')
require('plugin-config/coderunner')
require("plugin-config/nvim-tree")
require("plugin-config/bufferline")
require("plugin-config/treesitter")
require("plugin-config/telescope")
require("plugin-config/whichkey")
require("plugin-config/comment")
require("plugin-config/mason")
require("plugin-config/lualine")
require("plugin-config/notify")
require("plugin-config/nvim-autopairs")
require("plugin-config/project")
require("plugin-config/dashboard")
require("plugin-config/coderunner")
require("plugin-config/neogit")
require('lsp')
require('lsp.cmp')
require("lsp")
require("lsp.cmp")
require("lsp.null-ls")
require('nvim-dap')
require("nvim-dap")

View File

@ -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
View 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,
})

View File

@ -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
View 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

View File

@ -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")

View File

@ -4,10 +4,9 @@ require("mason").setup({
icons = {
server_installed = "",
server_pending = "",
server_uninstalled = ""
}
}
server_uninstalled = "",
},
},
})
require("mason-lspconfig").setup()

View File

@ -0,0 +1 @@
require("neogit").setup({})

View File

@ -1,6 +1,6 @@
return require('packer').startup(function()
return require("packer").startup(function()
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use("wbthomason/packer.nvim")
-- Nova theme for neovim light
use({
@ -12,82 +12,93 @@ return require('packer').startup(function()
-- load colorscheme
require("nova").load()
end,
})
})
-- git plugin like magit
-- 类似magit的插件neogit
use({ "TimUntersberger/neogit", requires = "nvim-lua/plenary.nvim" })
-- nvim-tree for file manage
use {
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
}
use({
"kyazdani42/nvim-tree.lua",
requires = "kyazdani42/nvim-web-devicons",
})
-- vim dashboard
-- vim 开始界面
use {'glepnir/dashboard-nvim'}
use({ "glepnir/dashboard-nvim" })
-- bufferline on the top
-- 顶部状态栏
use {'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons'}
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,
}
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'} }
}
use({
"nvim-telescope/telescope.nvim",
requires = { { "nvim-lua/plenary.nvim" } },
})
-- project
-- 项目管理
-- Lua
use {
use({
"ahmedkhalf/project.nvim",
}
})
-- whick-key
use {
'folke/which-key.nvim'
}
use({
"folke/which-key.nvim",
})
-- comment
use {
'numToStr/Comment.nvim',
}
use({
"numToStr/Comment.nvim",
})
-- lualine for bottom stausline
-- 底部状态栏
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
}
use({
"nvim-lualine/lualine.nvim",
requires = { "kyazdani42/nvim-web-devicons", opt = true },
})
-- notify
-- 弹窗消息通知
use {
'rcarriga/nvim-notify'
}
use({
"rcarriga/nvim-notify",
})
-- autopairs
-- 自动补全括号
use {
use({
"windwp/nvim-autopairs",
}
})
-- coderunner
-- 代码运行
use { 'CRAG666/code_runner.nvim', requires = 'nvim-lua/plenary.nvim' }
use({ "CRAG666/code_runner.nvim", requires = "nvim-lua/plenary.nvim" })
------------------- lsp --------------------------
-- mason for lsp dap linter and others
use {
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配置插件
@ -111,11 +122,8 @@ return require('packer').startup(function()
-- UI 增强
use("onsails/lspkind-nvim")
------------------- dap -----------------------
-- dap for neovim
-- dap ui和适配器
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap", "theHamsta/nvim-dap-virtual-text" } })
end)

View File

@ -49,8 +49,8 @@ local function save_profiles(threshold)
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/ubuntu/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/ubuntu/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/ubuntu/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/ubuntu/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/ubuntu/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
local package_path_str = "/Users/logicluo/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/logicluo/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/logicluo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/logicluo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/logicluo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
@ -76,158 +76,173 @@ time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["Comment.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/Comment.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
["bufferline.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/bufferline.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/bufferline.nvim",
url = "https://github.com/akinsho/bufferline.nvim"
},
["cmp-buffer"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/cmp-buffer",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer"
},
["cmp-cmdline"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/cmp-cmdline",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/cmp-cmdline",
url = "https://github.com/hrsh7th/cmp-cmdline"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-nvim-lsp-signature-help"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help",
url = "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help"
},
["cmp-path"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/cmp-path",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
["cmp-vsnip"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/cmp-vsnip",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/cmp-vsnip",
url = "https://github.com/hrsh7th/cmp-vsnip"
},
["code_runner.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/code_runner.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/code_runner.nvim",
url = "https://github.com/CRAG666/code_runner.nvim"
},
["dashboard-nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/dashboard-nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/dashboard-nvim",
url = "https://github.com/glepnir/dashboard-nvim"
},
["friendly-snippets"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/friendly-snippets",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/friendly-snippets",
url = "https://github.com/rafamadriz/friendly-snippets"
},
["lspkind-nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/lspkind-nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/lspkind-nvim",
url = "https://github.com/onsails/lspkind-nvim"
},
["lualine.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/lualine.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
["mason-lspconfig.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/mason.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/mason.nvim",
url = "https://github.com/williamboman/mason.nvim"
},
neogit = {
loaded = true,
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/neogit",
url = "https://github.com/TimUntersberger/neogit"
},
["nova.nvim"] = {
config = { "\27LJ\2\nc\0\0\3\0\5\0\f6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\0016\0\0\0'\2\1\0B\0\2\0029\0\4\0B\0\1\1K\0\1\0\tload\1\0\1\15background\nlight\nsetup\tnova\frequire\0" },
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nova.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nova.nvim",
url = "https://github.com/zanglg/nova.nvim"
},
["null-ls.nvim"] = {
loaded = true,
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/null-ls.nvim",
url = "https://github.com/jose-elias-alvarez/null-ls.nvim"
},
["nvim-autopairs"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
url = "https://github.com/windwp/nvim-autopairs"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-cmp",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-dap"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-dap",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-dap",
url = "https://github.com/mfussenegger/nvim-dap"
},
["nvim-dap-ui"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-dap-ui",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-dap-ui",
url = "https://github.com/rcarriga/nvim-dap-ui"
},
["nvim-dap-virtual-text"] = {
loaded = true,
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-dap-virtual-text",
url = "https://github.com/theHamsta/nvim-dap-virtual-text"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-notify"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-notify",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-notify",
url = "https://github.com/rcarriga/nvim-notify"
},
["nvim-tree.lua"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
url = "https://github.com/kyazdani42/nvim-tree.lua"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-web-devicons"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons"
},
["packer.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/packer.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/plenary.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["project.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/project.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/project.nvim",
url = "https://github.com/ahmedkhalf/project.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/telescope.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["vim-vsnip"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/vim-vsnip",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/vim-vsnip",
url = "https://github.com/hrsh7th/vim-vsnip"
},
["which-key.nvim"] = {
loaded = true,
path = "/home/ubuntu/.local/share/nvim/site/pack/packer/start/which-key.nvim",
path = "/Users/logicluo/.local/share/nvim/site/pack/packer/start/which-key.nvim",
url = "https://github.com/folke/which-key.nvim"
}
}