Lazy
This commit is contained in:
parent
e5b6b47c64
commit
06f22de2ca
1 changed files with 79 additions and 119 deletions
180
init.lua
180
init.lua
|
|
@ -1,94 +1,89 @@
|
||||||
local ensure_packer = function()
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
local fn = vim.fn
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
vim.fn.system({
|
||||||
if fn.empty(fn.glob(install_path)) > 0 then
|
"git",
|
||||||
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
|
"clone",
|
||||||
vim.cmd([[packadd packer.nvim]])
|
"--filter=blob:none",
|
||||||
return true
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
end
|
"--branch=stable", -- latest stable release
|
||||||
return false
|
lazypath,
|
||||||
end
|
|
||||||
|
|
||||||
local packer_bootstrap = ensure_packer()
|
|
||||||
|
|
||||||
require("packer").init({
|
|
||||||
autoremove = true,
|
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
require("packer").startup(function(use)
|
require("lazy").setup({
|
||||||
use("wbthomason/packer.nvim")
|
{ "NeogitOrg/neogit", dependencies = "nvim-lua/plenary.nvim" },
|
||||||
use("lewis6991/fileline.nvim")
|
"wbthomason/packer.nvim",
|
||||||
use("mfussenegger/nvim-dap")
|
"lewis6991/fileline.nvim",
|
||||||
use({
|
"mfussenegger/nvim-dap",
|
||||||
|
{
|
||||||
"stevearc/stickybuf.nvim",
|
"stevearc/stickybuf.nvim",
|
||||||
config = function()
|
opts = {},
|
||||||
require("stickybuf").setup()
|
},
|
||||||
end,
|
"famiu/bufdelete.nvim",
|
||||||
})
|
"neovim/nvim-lspconfig",
|
||||||
use("famiu/bufdelete.nvim")
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
use("neovim/nvim-lspconfig")
|
"tiagovla/scope.nvim",
|
||||||
use("jose-elias-alvarez/null-ls.nvim")
|
{
|
||||||
use({ "TimUntersberger/neogit", requires = "nvim-lua/plenary.nvim" })
|
|
||||||
use("tiagovla/scope.nvim")
|
|
||||||
use({
|
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
config = function()
|
event = "VeryLazy",
|
||||||
|
init = function()
|
||||||
vim.o.timeout = true
|
vim.o.timeout = true
|
||||||
vim.o.timeoutlen = 300
|
vim.o.timeoutlen = 300
|
||||||
require("which-key").setup({})
|
|
||||||
end,
|
end,
|
||||||
})
|
opts = {},
|
||||||
use({
|
},
|
||||||
|
{
|
||||||
"folke/trouble.nvim",
|
"folke/trouble.nvim",
|
||||||
requires = "nvim-tree/nvim-web-devicons",
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
config = function()
|
opts = {},
|
||||||
require("trouble").setup({
|
},
|
||||||
auto_open = true,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use({
|
|
||||||
"j-hui/fidget.nvim",
|
"j-hui/fidget.nvim",
|
||||||
config = function()
|
"terrortylor/nvim-comment",
|
||||||
require("fidget").setup()
|
{ "akinsho/bufferline.nvim", version = "*", dependencies = "nvim-tree/nvim-web-devicons" },
|
||||||
end,
|
"petertriho/nvim-scrollbar",
|
||||||
})
|
{
|
||||||
use("terrortylor/nvim-comment")
|
|
||||||
use({ "akinsho/bufferline.nvim", tag = "*", requires = "nvim-tree/nvim-web-devicons" })
|
|
||||||
use("petertriho/nvim-scrollbar")
|
|
||||||
use({
|
|
||||||
"nvim-tree/nvim-tree.lua",
|
"nvim-tree/nvim-tree.lua",
|
||||||
requires = {
|
version = "*",
|
||||||
"nvim-tree/nvim-web-devicons", -- optional
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("nvim-tree").setup({})
|
require("nvim-tree").setup({})
|
||||||
end,
|
end,
|
||||||
})
|
},
|
||||||
use("hrsh7th/nvim-cmp")
|
|
||||||
use({
|
"hrsh7th/nvim-cmp",
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||||
"hrsh7th/cmp-vsnip",
|
"hrsh7th/cmp-vsnip",
|
||||||
"hrsh7th/cmp-path",
|
"hrsh7th/cmp-path",
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-buffer",
|
||||||
after = { "hrsh7th/nvim-cmp" },
|
"hrsh7th/vim-vsnip",
|
||||||
requires = { "hrsh7th/nvim-cmp" },
|
"simrat39/rust-tools.nvim",
|
||||||
|
"nvim-lua/popup.nvim",
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
"rebelot/kanagawa.nvim",
|
||||||
})
|
})
|
||||||
use("hrsh7th/vim-vsnip")
|
|
||||||
use("simrat39/rust-tools.nvim")
|
|
||||||
use("nvim-lua/popup.nvim")
|
|
||||||
use("nvim-lua/plenary.nvim")
|
|
||||||
use("nvim-telescope/telescope.nvim")
|
|
||||||
use({ "ellisonleao/gruvbox.nvim" })
|
|
||||||
use("rebelot/kanagawa.nvim")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- the first run will install packer and our plugins
|
-- Vim options
|
||||||
if packer_bootstrap then
|
vim.wo.number = true
|
||||||
require("packer").sync()
|
vim.o.wrap = false
|
||||||
return
|
vim.g.mapleader = ","
|
||||||
end
|
vim.wo.signcolumn = "yes" -- prevents jitter
|
||||||
|
vim.opt.updatetime = 100
|
||||||
|
vim.o.background = "dark" -- or "light" for light mode
|
||||||
|
vim.cmd([[colorscheme kanagawa]])
|
||||||
|
-- Set completeopt to have a better completion experience
|
||||||
|
-- :help completeopt
|
||||||
|
-- menuone: popup even when there's only one match
|
||||||
|
-- noinsert: Do not insert text until a selection is made
|
||||||
|
-- noselect: Do not auto-select, nvim-cmp plugin will handle this for us.
|
||||||
|
vim.o.completeopt = "menuone,noinsert,noselect"
|
||||||
|
-- Avoid showing extra messages when using completion
|
||||||
|
vim.opt.shortmess = vim.opt.shortmess + "c"
|
||||||
|
|
||||||
local function on_attach(client, buffer)
|
local function on_attach(client, buffer)
|
||||||
if client.supports_method("textDocument/formatting") then
|
if client.supports_method("textDocument/formatting") then
|
||||||
|
|
@ -106,7 +101,7 @@ local function on_attach(client, buffer)
|
||||||
end
|
end
|
||||||
|
|
||||||
local keymap_opts = { buffer = buffer }
|
local keymap_opts = { buffer = buffer }
|
||||||
-- Code navigation and shortcuts
|
|
||||||
vim.keymap.set("n", "<c-]>", vim.lsp.buf.definition, keymap_opts)
|
vim.keymap.set("n", "<c-]>", vim.lsp.buf.definition, keymap_opts)
|
||||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, keymap_opts)
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, keymap_opts)
|
||||||
vim.keymap.set("n", "gD", vim.lsp.buf.implementation, keymap_opts)
|
vim.keymap.set("n", "gD", vim.lsp.buf.implementation, keymap_opts)
|
||||||
|
|
@ -128,14 +123,10 @@ local function on_attach(client, buffer)
|
||||||
group = diag_float_grp,
|
group = diag_float_grp,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Goto previous/next diagnostic warning/error
|
|
||||||
vim.keymap.set("n", "g[", vim.diagnostic.goto_prev, keymap_opts)
|
vim.keymap.set("n", "g[", vim.diagnostic.goto_prev, keymap_opts)
|
||||||
vim.keymap.set("n", "g]", vim.diagnostic.goto_next, keymap_opts)
|
vim.keymap.set("n", "g]", vim.diagnostic.goto_next, keymap_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Configure LSP through rust-tools.nvim plugin.
|
|
||||||
-- rust-tools will configure and enable certain LSP features for us.
|
|
||||||
-- See https://github.com/simrat39/rust-tools.nvim#configuration
|
|
||||||
require("rust-tools").setup({
|
require("rust-tools").setup({
|
||||||
tools = {
|
tools = {
|
||||||
runnables = {
|
runnables = {
|
||||||
|
|
@ -148,18 +139,10 @@ require("rust-tools").setup({
|
||||||
other_hints_prefix = "",
|
other_hints_prefix = "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- all the opts to send to nvim-lspconfig
|
|
||||||
-- these override the defaults set by rust-tools.nvim
|
|
||||||
-- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
|
|
||||||
server = {
|
server = {
|
||||||
-- on_attach is a callback called when the language server attachs to the buffer
|
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
settings = {
|
settings = {
|
||||||
-- to enable rust-analyzer settings visit:
|
|
||||||
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
|
|
||||||
["rust-analyzer"] = {
|
["rust-analyzer"] = {
|
||||||
-- enable clippy on save
|
|
||||||
checkOnSave = {
|
checkOnSave = {
|
||||||
command = "clippy",
|
command = "clippy",
|
||||||
},
|
},
|
||||||
|
|
@ -168,8 +151,7 @@ require("rust-tools").setup({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Setup Completion
|
-- Completion
|
||||||
-- See https://github.com/hrsh7th/nvim-cmp#basic-configuration
|
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
|
|
@ -180,7 +162,6 @@ cmp.setup({
|
||||||
mapping = {
|
mapping = {
|
||||||
["<Up>"] = cmp.mapping.select_prev_item(),
|
["<Up>"] = cmp.mapping.select_prev_item(),
|
||||||
["<Down>"] = cmp.mapping.select_next_item(),
|
["<Down>"] = cmp.mapping.select_next_item(),
|
||||||
-- Add tab support
|
|
||||||
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
||||||
["<Tab>"] = cmp.mapping.select_next_item(),
|
["<Tab>"] = cmp.mapping.select_next_item(),
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
|
@ -192,8 +173,6 @@ cmp.setup({
|
||||||
select = true,
|
select = true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Installed sources
|
|
||||||
sources = {
|
sources = {
|
||||||
{ name = "nvim_lsp" },
|
{ name = "nvim_lsp" },
|
||||||
{ name = "nvim_lsp_signature_help" },
|
{ name = "nvim_lsp_signature_help" },
|
||||||
|
|
@ -203,17 +182,15 @@ cmp.setup({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Folder tree
|
||||||
local function open_nvim_tree(data)
|
local function open_nvim_tree(data)
|
||||||
-- buffer is a directory
|
|
||||||
local directory = vim.fn.isdirectory(data.file) == 1
|
local directory = vim.fn.isdirectory(data.file) == 1
|
||||||
|
|
||||||
if not directory then
|
if not directory then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- change to the directory
|
|
||||||
vim.cmd.cd(data.file)
|
vim.cmd.cd(data.file)
|
||||||
|
|
||||||
-- open the tree
|
|
||||||
require("nvim-tree.api").tree.open()
|
require("nvim-tree.api").tree.open()
|
||||||
end
|
end
|
||||||
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||||
|
|
@ -230,9 +207,6 @@ require("bufferline").setup({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Scrollbar
|
|
||||||
require("scrollbar").setup()
|
|
||||||
|
|
||||||
-- Scope
|
-- Scope
|
||||||
require("scope").setup({
|
require("scope").setup({
|
||||||
restore_state = false,
|
restore_state = false,
|
||||||
|
|
@ -275,19 +249,5 @@ null_ls.setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Vim options
|
-- Scroll bar
|
||||||
vim.wo.number = true
|
require("scrollbar").setup()
|
||||||
vim.o.wrap = false
|
|
||||||
vim.g.mapleader = ","
|
|
||||||
vim.wo.signcolumn = "yes" -- prevents jitter
|
|
||||||
vim.opt.updatetime = 100
|
|
||||||
vim.o.background = "dark" -- or "light" for light mode
|
|
||||||
vim.cmd([[colorscheme kanagawa]])
|
|
||||||
-- Set completeopt to have a better completion experience
|
|
||||||
-- :help completeopt
|
|
||||||
-- menuone: popup even when there's only one match
|
|
||||||
-- noinsert: Do not insert text until a selection is made
|
|
||||||
-- noselect: Do not auto-select, nvim-cmp plugin will handle this for us.
|
|
||||||
vim.o.completeopt = "menuone,noinsert,noselect"
|
|
||||||
-- Avoid showing extra messages when using completion
|
|
||||||
vim.opt.shortmess = vim.opt.shortmess + "c"
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue