refactor and some lazy loading
This commit is contained in:
parent
854f067991
commit
103961e892
7 changed files with 155 additions and 120 deletions
9
.gitmodules
vendored
9
.gitmodules
vendored
|
|
@ -62,13 +62,13 @@
|
||||||
path = pack/general/start/git-blame.nvim
|
path = pack/general/start/git-blame.nvim
|
||||||
url = https://github.com/f-person/git-blame.nvim
|
url = https://github.com/f-person/git-blame.nvim
|
||||||
[submodule "nvim-dap"]
|
[submodule "nvim-dap"]
|
||||||
path = pack/general/start/nvim-dap
|
path = pack/general/opt/nvim-dap
|
||||||
url = https://github.com/mfussenegger/nvim-dap
|
url = https://github.com/mfussenegger/nvim-dap
|
||||||
[submodule "pack/general/start/nvim-dap-go"]
|
[submodule "pack/general/start/nvim-dap-go"]
|
||||||
path = pack/general/start/nvim-dap-go
|
path = pack/general/opt/nvim-dap-go
|
||||||
url = https://github.com/leoluz/nvim-dap-go
|
url = https://github.com/leoluz/nvim-dap-go
|
||||||
[submodule "pack/general/start/nvim-dap-ui"]
|
[submodule "pack/general/start/nvim-dap-ui"]
|
||||||
path = pack/general/start/nvim-dap-ui
|
path = pack/general/opt/nvim-dap-ui
|
||||||
url = https://github.com/rcarriga/nvim-dap-ui
|
url = https://github.com/rcarriga/nvim-dap-ui
|
||||||
[submodule "pack/general/start/vim-helm"]
|
[submodule "pack/general/start/vim-helm"]
|
||||||
path = pack/general/start/vim-helm
|
path = pack/general/start/vim-helm
|
||||||
|
|
@ -109,3 +109,6 @@
|
||||||
[submodule "pack/general/start/lsp_lines.nvim"]
|
[submodule "pack/general/start/lsp_lines.nvim"]
|
||||||
path = pack/general/start/lsp_lines.nvim
|
path = pack/general/start/lsp_lines.nvim
|
||||||
url = https://git.sr.ht/~whynothugo/lsp_lines.nvim
|
url = https://git.sr.ht/~whynothugo/lsp_lines.nvim
|
||||||
|
[submodule "pack/general/opt/crates.nvim"]
|
||||||
|
path = pack/general/opt/crates.nvim
|
||||||
|
url = https://github.com/Saecki/crates.nvim
|
||||||
|
|
|
||||||
264
init.lua
264
init.lua
|
|
@ -1,3 +1,4 @@
|
||||||
|
vim.loader.enable()
|
||||||
---- Aliases ----
|
---- Aliases ----
|
||||||
local cmd = vim.cmd
|
local cmd = vim.cmd
|
||||||
local g = vim.g
|
local g = vim.g
|
||||||
|
|
@ -115,8 +116,7 @@ vim.keymap.set("v", "<", "<gv")
|
||||||
vim.keymap.set("n", "<C-L>", ":nohlsearch<CR>")
|
vim.keymap.set("n", "<C-L>", ":nohlsearch<CR>")
|
||||||
|
|
||||||
---- Treesitter ----
|
---- Treesitter ----
|
||||||
local ts = require("nvim-treesitter.configs")
|
require("nvim-treesitter.configs").setup({
|
||||||
ts.setup({
|
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
ignore_install = {},
|
ignore_install = {},
|
||||||
|
|
@ -203,8 +203,7 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
})
|
})
|
||||||
|
|
||||||
---- formatter.nvim ----
|
---- formatter.nvim ----
|
||||||
local formatter = require("formatter")
|
require("formatter").setup({
|
||||||
formatter.setup({
|
|
||||||
filetype = {
|
filetype = {
|
||||||
lua = {
|
lua = {
|
||||||
require("formatter.filetypes.lua").stylua,
|
require("formatter.filetypes.lua").stylua,
|
||||||
|
|
@ -220,6 +219,57 @@ formatter.setup({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
---- LuaSnip
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
require("luasnip.loaders.from_lua").lazy_load()
|
||||||
|
luasnip.config.set_config({
|
||||||
|
store_selection_keys = "<c-s>",
|
||||||
|
})
|
||||||
|
vim.keymap.set({ "i", "s" }, "<Tab>", function()
|
||||||
|
if luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
vim.api.nvim_feedkeys(
|
||||||
|
vim.api.nvim_replace_termcodes("<Tab>", true, false, true),
|
||||||
|
"n", -- noremap to avoid infinite recursion
|
||||||
|
true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
|
||||||
|
if luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
---- completion-nvim
|
||||||
|
local cmp = require("cmp")
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
|
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "crates" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
---- LSP ----
|
---- LSP ----
|
||||||
local lsp = require("lspconfig")
|
local lsp = require("lspconfig")
|
||||||
|
|
||||||
|
|
@ -277,8 +327,21 @@ local servers = {
|
||||||
tflint = {},
|
tflint = {},
|
||||||
tsserver = {},
|
tsserver = {},
|
||||||
}
|
}
|
||||||
-- Setup loop moved to the cmp section, since calling setup multiple times
|
|
||||||
-- overrides the previous calls.
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
lsp.util.default_config = vim.tbl_deep_extend("force", lsp.util.default_config, { capabilities = capabilities })
|
||||||
|
for server, add_to_config in pairs(servers) do
|
||||||
|
local config = {
|
||||||
|
on_attach = on_lsp_attach,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for k, v in pairs(add_to_config) do
|
||||||
|
config[k] = v
|
||||||
|
end
|
||||||
|
lsp[server].setup(config)
|
||||||
|
end
|
||||||
|
|
||||||
-- Auto format on save
|
-- Auto format on save
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
|
|
@ -298,7 +361,6 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
---- Plugins ----
|
|
||||||
---- nvim-lint ----
|
---- nvim-lint ----
|
||||||
local lint = require("lint")
|
local lint = require("lint")
|
||||||
local clippy_format = "%E%f:%l:%c: %\\d%#:%\\d%# %.%\\{-}"
|
local clippy_format = "%E%f:%l:%c: %\\d%#:%\\d%# %.%\\{-}"
|
||||||
|
|
@ -385,73 +447,7 @@ for ft, ft_linters in pairs(linters) do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
---- LuaSnip
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
require("luasnip.loaders.from_lua").lazy_load()
|
|
||||||
luasnip.config.set_config({
|
|
||||||
store_selection_keys = "<c-s>",
|
|
||||||
})
|
|
||||||
vim.keymap.set({ "i", "s" }, "<Tab>", function()
|
|
||||||
if luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
vim.api.nvim_feedkeys(
|
|
||||||
vim.api.nvim_replace_termcodes("<Tab>", true, false, true),
|
|
||||||
"n", -- noremap to avoid infinite recursion
|
|
||||||
true
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
|
|
||||||
if luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
---- completion-nvim
|
|
||||||
local cmp = require("cmp")
|
|
||||||
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
window = {
|
|
||||||
-- completion = cmp.config.window.bordered(),
|
|
||||||
-- documentation = cmp.config.window.bordered(),
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
|
||||||
["<C-e>"] = cmp.mapping.abort(),
|
|
||||||
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
|
||||||
}),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "luasnip" },
|
|
||||||
{ name = "path" },
|
|
||||||
{ name = "buffer" },
|
|
||||||
{ name = "crates" },
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Setup lspconfig.
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
lsp.util.default_config = vim.tbl_deep_extend("force", lsp.util.default_config, { capabilities = capabilities })
|
|
||||||
for server, add_to_config in pairs(servers) do
|
|
||||||
local config = {
|
|
||||||
on_attach = on_lsp_attach,
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 150,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for k, v in pairs(add_to_config) do
|
|
||||||
config[k] = v
|
|
||||||
end
|
|
||||||
lsp[server].setup(config)
|
|
||||||
end
|
|
||||||
---- gitblame
|
---- gitblame
|
||||||
local gitblame = require("gitblame")
|
local gitblame = require("gitblame")
|
||||||
gitblame.setup({
|
gitblame.setup({
|
||||||
|
|
@ -515,30 +511,41 @@ vim.keymap.set("n", "<Leader>cg", builtin.grep_string)
|
||||||
vim.keymap.set("n", "<Leader>:", builtin.commands)
|
vim.keymap.set("n", "<Leader>:", builtin.commands)
|
||||||
vim.keymap.set("n", "<Leader>s", telescope.extensions.luasnip.luasnip)
|
vim.keymap.set("n", "<Leader>s", telescope.extensions.luasnip.luasnip)
|
||||||
---- nvim-dap
|
---- nvim-dap
|
||||||
local dap = require("dap")
|
vim.g.dap_loaded = false
|
||||||
vim.fn.sign_define("DapBreakpoint", { text = "🟥", texthl = "", linehl = "", numhl = "" })
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
vim.fn.sign_define("DapStopped", { text = "▶️", texthl = "", linehl = "", numhl = "" })
|
pattern = { "go" },
|
||||||
-- Set keymaps to control the debugge
|
callback = function()
|
||||||
vim.keymap.set("n", "<leader>dc", dap.continue)
|
vim.g.dap_loaded = true
|
||||||
vim.keymap.set("n", "<leader>do", dap.step_over)
|
vim.cmd("packadd nvim-dap")
|
||||||
vim.keymap.set("n", "<leader>di", dap.step_into)
|
vim.cmd("packadd nvim-dap-ui")
|
||||||
vim.keymap.set("n", "<leader>dO", dap.step_out)
|
vim.cmd("packadd nvim-go")
|
||||||
vim.keymap.set("n", "<leader>db", dap.toggle_breakpoint)
|
|
||||||
vim.keymap.set("n", "<leader>dB", function()
|
local dap = require("dap")
|
||||||
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
vim.fn.sign_define("DapBreakpoint", { text = "🟥", texthl = "", linehl = "", numhl = "" })
|
||||||
end)
|
vim.fn.sign_define("DapStopped", { text = "▶️", texthl = "", linehl = "", numhl = "" })
|
||||||
local dapui = require("dapui")
|
-- Set keymaps to control the debugger
|
||||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
vim.keymap.set("n", "<leader>dc", dap.continue)
|
||||||
dapui.open()
|
vim.keymap.set("n", "<leader>do", dap.step_over)
|
||||||
end
|
vim.keymap.set("n", "<leader>di", dap.step_into)
|
||||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
vim.keymap.set("n", "<leader>dO", dap.step_out)
|
||||||
dapui.close()
|
vim.keymap.set("n", "<leader>db", dap.toggle_breakpoint)
|
||||||
end
|
vim.keymap.set("n", "<leader>dB", function()
|
||||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||||
dapui.close()
|
end)
|
||||||
end
|
local dapui = require("dapui")
|
||||||
-- nvim-dap-go
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
require("dap-go").setup()
|
dapui.open()
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
-- nvim-dap-go
|
||||||
|
require("dap-go").setup()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
---- web-devicons
|
---- web-devicons
|
||||||
require("nvim-web-devicons").setup()
|
require("nvim-web-devicons").setup()
|
||||||
|
|
@ -549,31 +556,56 @@ vim.keymap.set('n', '<leader>yy', '<leader>y_', { remap = true })
|
||||||
vim.keymap.set('v', '<leader>y', require('osc52').copy_visual)
|
vim.keymap.set('v', '<leader>y', require('osc52').copy_visual)
|
||||||
|
|
||||||
---- crates
|
---- crates
|
||||||
local crates = require('crates')
|
vim.g.crates_loaded = false
|
||||||
crates.setup()
|
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
||||||
vim.keymap.set('n', '<leader>cv', crates.show_versions_popup)
|
pattern = { "Cargo.toml" },
|
||||||
vim.keymap.set('n', '<leader>cf', crates.show_features_popup)
|
callback = function()
|
||||||
vim.keymap.set('n', '<leader>cd', crates.show_dependencies_popup)
|
if vim.g.crates_loaded then
|
||||||
vim.keymap.set('n', '<leader>cu', crates.update_crate)
|
return
|
||||||
vim.keymap.set('v', '<leader>cu', crates.update_crates)
|
end
|
||||||
vim.keymap.set('n', '<leader>ca', crates.update_all_crates)
|
vim.g.crates_loaded = true
|
||||||
vim.keymap.set('n', '<leader>cD', crates.open_documentation)
|
vim.cmd("packadd crates.nvim")
|
||||||
|
|
||||||
|
local crates = require('crates')
|
||||||
|
crates.setup()
|
||||||
|
vim.keymap.set('n', '<leader>cv', crates.show_versions_popup)
|
||||||
|
vim.keymap.set('n', '<leader>cf', crates.show_features_popup)
|
||||||
|
vim.keymap.set('n', '<leader>cd', crates.show_dependencies_popup)
|
||||||
|
vim.keymap.set('n', '<leader>cu', crates.update_crate)
|
||||||
|
vim.keymap.set('v', '<leader>cu', crates.update_crates)
|
||||||
|
vim.keymap.set('n', '<leader>ca', crates.update_all_crates)
|
||||||
|
vim.keymap.set('n', '<leader>cD', crates.open_documentation)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
---- neotest
|
---- neotest
|
||||||
local neotest = require("neotest")
|
vim.g.neotest_loaded = false
|
||||||
neotest.setup({
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
adapters = {
|
pattern = { "rust" },
|
||||||
require("neotest-rust")
|
callback = function()
|
||||||
}
|
if vim.g.neotest_loaded then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.g.neotest_loaded = true
|
||||||
|
vim.cmd("packadd neotest")
|
||||||
|
vim.cmd("packadd neotest-rust")
|
||||||
|
|
||||||
|
local neotest = require("neotest")
|
||||||
|
neotest.setup({
|
||||||
|
adapters = {
|
||||||
|
require("neotest-rust")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
vim.keymap.set('n', '<leader>tr', function() neotest.run.run() end)
|
||||||
|
vim.keymap.set('n', '<leader>tf', function() neotest.run.run(vim.fn.expand("%")) end)
|
||||||
|
vim.keymap.set('n', '<leader>ts', function() neotest.run.stop() end)
|
||||||
|
vim.keymap.set('n', '<leader>tt', function() neotest.summary.toggle() end)
|
||||||
|
end
|
||||||
})
|
})
|
||||||
vim.keymap.set('n', '<leader>tr', function() neotest.run.run() end)
|
|
||||||
vim.keymap.set('n', '<leader>tf', function() neotest.run.run(vim.fn.expand("%")) end)
|
|
||||||
vim.keymap.set('n', '<leader>ts', function() neotest.run.stop() end)
|
|
||||||
vim.keymap.set('n', '<leader>tt', function() neotest.summary.toggle() end)
|
|
||||||
---- lsp_lines
|
---- lsp_lines
|
||||||
require("lsp_lines").setup()
|
require("lsp_lines").setup()
|
||||||
-- Disable virtual_text since it's redundant due to lsp_lines.
|
-- Disable virtual_text since it's redundant due to lsp_lines.
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
virtual_lines = { only_current_line = true },
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
1
pack/general/opt/crates.nvim
Submodule
1
pack/general/opt/crates.nvim
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit db629b5cfb2aa8de9e44efb795657297ee95ca91
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit d5caf28aba49e81ac4099426231f3cf3c151013a
|
|
||||||
Loading…
Add table
Reference in a new issue