feat: cleanup config

Change folder architecture and separate all plugins into their own files
This commit is contained in:
Simon Lasbrugnas 2024-11-09 20:37:37 +01:00
parent 31a902784d
commit 4fabec4249
Signed by untrusted user who does not match committer: simon
GPG key ID: 86039876BA6ED8DE
32 changed files with 415 additions and 470 deletions

View file

@ -1,4 +1,24 @@
require("config.options") require("config.options")
require("config.keymaps") require("config.keymaps")
require("config.autocmds")
require("core.lazy") -- Boostrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ import = "custom/plugins" }, {
change_detection = {
notify = false,
},
})
vim.cmd([[colorscheme mellow]])

View file

@ -1,7 +1,6 @@
{ {
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" },
"cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
@ -10,8 +9,10 @@
"gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" },
"indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" },
"lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" },
"lazygit.nvim": { "branch": "main", "commit": "56760339a81cd1540d5a72fd9d93010a2677b55d" },
"lsp-zero.nvim": { "branch": "v4.x", "commit": "4f1e00bfe276758d30fec5d1eb161108ff8a959b" }, "lsp-zero.nvim": { "branch": "v4.x", "commit": "4f1e00bfe276758d30fec5d1eb161108ff8a959b" },
"lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" },
"lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mellow.nvim": { "branch": "main", "commit": "434a02d5f7637a24824569426176f37473205053" }, "mellow.nvim": { "branch": "main", "commit": "434a02d5f7637a24824569426176f37473205053" },
@ -19,8 +20,8 @@
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lspconfig": { "branch": "master", "commit": "d01864641c6e43c681c3e9f6cf4745c75fdd9dcc" }, "nvim-lspconfig": { "branch": "master", "commit": "d01864641c6e43c681c3e9f6cf4745c75fdd9dcc" },
"nvim-treesitter": { "branch": "master", "commit": "425b58968340bd5b4621c2a0d626c73556516d3d" }, "nvim-treesitter": { "branch": "master", "commit": "0603b3e3d21ebe2fa82dc5361a3d500e0d3ad3a8" },
"nvim-treesitter-context": { "branch": "master", "commit": "a2a334900d3643de585ac5c6140b03403454124f" }, "nvim-treesitter-context": { "branch": "master", "commit": "158377d700596367a91ea41818f76abdbf75a232" },
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
"oil.nvim": { "branch": "master", "commit": "52cc8a1fb35ea6ce1df536143add7ce7215c63c0" }, "oil.nvim": { "branch": "master", "commit": "52cc8a1fb35ea6ce1df536143add7ce7215c63c0" },
@ -28,8 +29,5 @@
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" },
"trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" }, "trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" },
"vim-fetch": { "branch": "master", "commit": "db3fd95eb0cf7e7e9effa1338b286db33e4a36c1" }, "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }
"vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }
} }

View file

@ -1,13 +0,0 @@
-- Remove trailing whitespace on save
-- vim.api.nvim_create_autocmd({"BufWritePre"}, {
-- group = vim.api.nvim_create_augroup("Default", {}),
-- pattern = "*",
-- command = [[%s/\s\+$//e]],
-- })
-- LSP Auto format on save
-- vim.api.nvim_create_autocmd({ "BufWritePre" }, {
-- group = vim.api.nvim_create_augroup("Default", {}),
-- pattern = "*",
-- command = [[lua vim.lsp.buf.format()]],
-- })

View file

@ -1,54 +1,49 @@
local set = vim.keymap.set
-- Leader key
vim.g.mapleader = " " vim.g.mapleader = " "
vim.keymap.set("n", "<leader>e", "<cmd>:Oil<CR>") -- Open file explorer
vim.keymap.set("i", "<C-c>", "<Esc>") set("n", "<leader>e", "<cmd>:Oil<CR>")
-- Use same behavior for <C-c> as <Esc>
set("i", "<C-c>", "<Esc>")
-- Keep things centered -- Keep things centered
vim.keymap.set("n", "n", "nzz") set("n", "n", "nzz")
vim.keymap.set("n", "N", "Nzz") set("n", "N", "Nzz")
vim.keymap.set("n", "<C-d>", "<C-d>zz") set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz") set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cnext<CR>zz") set("n", "<C-j>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-k>", "<cmd>cprev<CR>zz") set("n", "<C-k>", "<cmd>cprev<CR>zz")
-- Copy to system clipboard -- Copy to system clipboard
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]]) set({ "n", "v" }, "<leader>y", [["+y]])
-- Escape terminal mode -- Escape terminal mode
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") set("t", "<Esc>", "<C-\\><C-n>")
-- Toggle hlsearch if it's on, otherwise just do "enter" -- Delete buffer
vim.keymap.set("n", "<CR>", function() set("n", "<leader>bd", "<cmd>bd<CR>")
---@diagnostic disable-next-line: undefined-field
if vim.v.hlsearch == 1 then
vim.cmd.nohl()
return ""
else
return vim.keycode "<CR>"
end
end, { expr = true })
vim.keymap.set("n", "<leader>bd", "<cmd>bd<CR>")
-- Thanks to Mr. Primeagen -- Thanks to Mr. Primeagen
vim.keymap.set({ "n", "v" }, "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>") set({ "n", "v" }, "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- Replace all occurences of word
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
-- Move lines around in visual mode
set("v", "J", ":m '>+1<CR>gv=gv")
set("v", "K", ":m '<-2<CR>gv=gv")
-- Move between windows with actual arrow keys -- Move between windows with actual arrow keys
vim.keymap.set("n", "<Left>", "<C-w>h") set("n", "<Left>", "<C-w>h")
vim.keymap.set("n", "<Down>", "<C-w>j") set("n", "<Down>", "<C-w>j")
vim.keymap.set("n", "<Up>", "<C-w>k") set("n", "<Up>", "<C-w>k")
vim.keymap.set("n", "<Right>", "<C-w>l") set("n", "<Right>", "<C-w>l")
-- Duplicate line -- Duplicate line
vim.keymap.set("n", "<leader>d", "mzyyp`zj") set("n", "<leader>d", "mzyyp`zj")
-- Open a new terminal pane -- Open a new terminal pane
vim.keymap.set("n", "<leader>t", "<cmd>botright terminal<CR>") set("n", "<leader>t", "<cmd>botright terminal<CR>")
-- Focus the terminal pane
vim.keymap.set("n", "<leader>f", function()
local bufnr = vim.fn.bufnr("#")
vim.api.nvim_set_current_buf(bufnr)
end)

View file

@ -1,43 +1,60 @@
local opt = vim.opt local opt = vim.opt
-- Better line number display
opt.number = true opt.number = true
opt.relativenumber = true opt.relativenumber = true
-- Use tabs
opt.tabstop = 4 opt.tabstop = 4
opt.softtabstop = 4 opt.softtabstop = 4
opt.shiftwidth = 4 opt.shiftwidth = 4
opt.expandtab = false opt.expandtab = false
opt.smartindent = true opt.smartindent = true
-- Highlight cursor line
opt.cursorline = true opt.cursorline = true
-- Use line wrapping
opt.wrap = true opt.wrap = true
opt.linebreak = true opt.linebreak = true
opt.breakindent = true opt.breakindent = true
opt.showbreak = "> " opt.showbreak = "> "
-- show partial result in preview window for :substitute
opt.inccommand = "split" opt.inccommand = "split"
-- Better search settings
opt.hlsearch = false
opt.incsearch = true opt.incsearch = true
opt.smartcase = true
opt.ignorecase = true opt.ignorecase = true
opt.smartcase = true
-- Split the other way around
opt.splitbelow = true opt.splitbelow = true
opt.splitright = true opt.splitright = true
-- prevent comment insertion when pressing 'o' on a commented line
opt.formatoptions:remove "o" opt.formatoptions:remove "o"
-- Prevent pause on long listing that don't fit inside the buffer
opt.more = false
-- Undo settings
opt.swapfile = false opt.swapfile = false
opt.backup = false opt.backup = false
opt.undodir = os.getenv("HOME") .. "/.vim/undodir" opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
opt.undofile = true opt.undofile = true
opt.updatetime = 100
-- Enable 24 bits colors
opt.termguicolors = true opt.termguicolors = true
opt.scrolloff = 8 -- Minimal number of screen lines to keep above and below the cursor
opt.updatetime = 100 opt.scrolloff = 12
-- List of characters
opt.list = true opt.list = true
opt.listchars = "tab: ,extends:,precedes:,nbsp:·,trail:·" opt.listchars = "tab: ,extends:,precedes:,nbsp:·,trail:·"
-- System wide clipboard
opt.clipboard = "unnamedplus" opt.clipboard = "unnamedplus"
opt.more = false

View file

@ -1,17 +0,0 @@
-- Boostrap Lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ { import = "plugins" } })
vim.cmd([[colorscheme mellow]])

34
lua/custom/completion.lua Normal file
View file

@ -0,0 +1,34 @@
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
local lspkind = require "lspkind"
lspkind.init {}
cmp.setup({
completion = {
completeopt = "menu,menuone,noinsert",
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}, { "i", "c" }),
}),
-- Enable luasnip to handle snippet expansion for nvim-cmp
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
{ name = "buffer" },
}),
sorting = defaults.sorting,
})

View file

@ -1,67 +1,18 @@
local lsp_zero = require("lsp-zero") local lsp_zero = require("lsp-zero")
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
lspconfig.gleam.setup({}) local servers = {}
-- Autoload LSPs from ./config/*.lua files
lspconfig.lua_ls.setup({ for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/custom/lsp/config/*.lua", true)) do
settings = { local lua_path = ft_path:gsub(".*/lua/(.+)%.lua", "%1")
Lua = { local module_path = lua_path:gsub('/', '.')
diagnostics = { local config = require(module_path)
globals = { "vim" }, local name = module_path:match("%.([^%.]+)$")
}, lspconfig[name].setup(config)
}, table.insert(servers, name)
},
})
lspconfig.gopls.setup({
on_attach = function(_, bufnr)
-- autcmd format on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format()
end,
})
-- autocmd Organize Imports on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
local params = vim.lsp.util.make_range_params()
params.context = {only = {"source.organizeImports"}}
local result = vim.lsp.buf_request_sync(bufnr, "textDocument/codeAction", params, 1000)
for _, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
vim.lsp.util.apply_workspace_edit(r.edit, "utf-8")
else
vim.lsp.buf.execute_command(r.command)
end end
end
end
end,
})
end,
})
lspconfig.eslint.setup({
on_attach = function(_, bufnr)
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
command = "EslintFixAll",
})
end,
})
lsp_zero.set_sign_icons({
error = "",
warn = "",
hint = "",
info = ""
})
-- Configure Vim diagnostic
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = true, virtual_text = true,
severity_sort = true, severity_sort = true,
@ -74,6 +25,15 @@ vim.diagnostic.config({
}, },
}) })
-- Lsp icons
lsp_zero.set_sign_icons({
error = "",
warn = "",
hint = "",
info = ""
})
-- Keybindings
lsp_zero.on_attach(function(_, bufnr) lsp_zero.on_attach(function(_, bufnr)
local opts = { buffer = bufnr, remap = false } local opts = { buffer = bufnr, remap = false }
lsp_zero.default_keymaps({ buffer = bufnr }) lsp_zero.default_keymaps({ buffer = bufnr })
@ -92,16 +52,11 @@ lsp_zero.on_attach(function(_, bufnr)
vim.keymap.set("n", "<leader><leader>", function() vim.lsp.buf.format() end, opts) vim.keymap.set("n", "<leader><leader>", function() vim.lsp.buf.format() end, opts)
end) end)
-- Mason configuration
local ensure_installed = { "html", "rust_analyzer", "zls", "ts_ls" }
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
handlers = { handlers = {
lsp_zero.default_setup, lsp_zero.default_setup,
}, },
ensure_installed = { ensure_installed = vim.list_extend(ensure_installed, servers),
"lua_ls",
"html",
"eslint",
"gopls",
"rust_analyzer",
"zls",
},
}) })

View file

@ -0,0 +1,9 @@
return {
on_attach = function(_, bufnr)
-- Auto format with eslint fix all
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
command = "EslintFixAll",
})
end,
}

View file

@ -0,0 +1,43 @@
return {
settings = {
gopls = {
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
},
},
on_attach = function(_, bufnr)
-- Format document on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format()
end,
})
-- Auto organize imports on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
local params = vim.lsp.util.make_range_params()
params.context = { only = { "source.organizeImports" } }
local result = vim.lsp.buf_request_sync(bufnr, "textDocument/codeAction", params, 1000)
for _, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
vim.lsp.util.apply_workspace_edit(r.edit, "utf-8")
else
vim.lsp.buf.execute_command(r.command)
end
end
end
end,
})
end,
}

View file

@ -0,0 +1,9 @@
return {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
}

View file

@ -0,0 +1 @@
return { 'norcalli/nvim-colorizer.lua' }

View file

@ -0,0 +1 @@
return { "numToStr/Comment.nvim" }

View file

@ -0,0 +1,15 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"onsails/lspkind.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
{ "L3MON4D3/LuaSnip", build = "make install_jsregexp" },
"saadparwaiz1/cmp_luasnip",
},
config = function()
require "custom.completion"
end,
}

View file

@ -0,0 +1,13 @@
return {
"tpope/vim-fugitive",
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
keys = {
{ "<leader>gd", "<cmd>Gvdiffsplit!<CR>" },
{ "<leader>gl", "<cmd>Git blame -w -C -C -C<CR>" },
{ "<leader>gS", "<cmd>Git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD),<CR>"},
{ "<leader>gbs", "<cmd>Git bisect start<CR>" },
{ "<leader>gbg", "<cmd>Git bisect good<CR>" },
{ "<leader>gbb", "<cmd>Git bisect bad<CR>" },
{ "<leader>gbr", "<cmd>Git bisect reset<CR>" },
},
}

View file

@ -0,0 +1,28 @@
return {
"lewis6991/gitsigns.nvim",
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
opts = {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
},
keys = {
{ "[h", "<cmd>Gitsigns next_hunk<CR>", desc = "Next Hunk" },
{ "]h", "<cmd>Gitsigns prev_hunk<CR>", desc = "Prev Hunk" },
{ "<leader>ghr", "<cmd>Gitsigns reset_hunk<CR>", desc = "Reset Hunk" },
{ "<leader>ghR", "<cmd>Gitsigns reset_buffer<CR>", desc = "Reset Buffer" },
{ "<leader>ghp", "<cmd>Gitsigns preview_hunk<CR>", desc = "Preview Hunk" },
{
"<leader>ghb",
function()
package.loaded.gitsigns.blame_line({ full = true })
end,
desc = "Blame Line"
},
},
}

View file

@ -0,0 +1,18 @@
return {
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {
debounce = 100,
indent = {
char = "",
tab_char = "",
highlight = { "VertSplit" },
},
scope = {
enabled = true,
show_start = false,
show_end = false,
highlight = "LineNr",
},
},
}

View file

@ -0,0 +1,20 @@
return {
"kdheepak/lazygit.nvim",
lazy = true,
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
-- setting the keybinding for LazyGit with 'keys' is recommended in
-- order to load the plugin when the command is run for the first time
keys = {
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = "LazyGit" }
}
}

View file

@ -0,0 +1,18 @@
return {
"VonHeikemen/lsp-zero.nvim",
config = function()
require("custom.lsp.config")
end,
dependencies = {
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason-lspconfig.nvim" },
{ "folke/neodev.nvim" },
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
{ "ray-x/lsp_signature.nvim" },
}
}

View file

@ -0,0 +1,10 @@
return {
"williamboman/mason.nvim",
cmd = "Mason",
version = false,
build = ":MasonUpdate",
opts = {},
keys = {
{ "<leader>cm", "<cmd>Mason<cr>", desc = "Open Mason" },
},
}

View file

@ -0,0 +1 @@
return { "mellow-theme/mellow.nvim" }

View file

@ -0,0 +1,32 @@
return {
"stevearc/oil.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
CustomOilBar = function()
local path = vim.fn.expand "%"
path = path:gsub("oil://", "")
return " " .. vim.fn.fnamemodify(path, ":.")
end
require("oil").setup {
columns = { "icon" },
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-p>"] = false,
["<C-c>"] = "actions.close",
["<C-l>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
},
win_options = {
statusline = "%{v:lua.CustomOilBar()}",
},
}
end,
}

View file

@ -0,0 +1,21 @@
return {
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
lazy = false,
version = false,
dependencies = {
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
{ "nvim-lua/plenary.nvim" },
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
}
},
config = function()
require("custom.telescope")
end,
}

View file

@ -0,0 +1,13 @@
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
keys = {
{ "<leader>xx", "<cmd>Trouble diagnostics<CR>", desc = "Trouble Workspace Diagnostics" },
{ "<leader>xl", "<cmd>Trouble loclist<CR>", desc = "Trouble Loclist" },
{ "<leader>xq", "<cmd>Trouble quickfix<CR>", desc = "Trouble Quickfix" },
{ "<leader>xt", "<cmd>Trouble lsp_references<CR>", desc = "Trouble LSP References" },
{ "<leader>xj", function() require("trouble").next({ skip_groups = true, jump = true }) end, desc = "Trouble Next" },
{ "<leader>xk", function() require("trouble").previous({ skip_groups = true, jump = true }) end, desc = "Trouble Previous" },
},
}

24
lua/custom/telescope.lua Normal file
View file

@ -0,0 +1,24 @@
local actions = require("telescope.actions")
require("telescope").setup {
defaults = {
mappings = {
i = {
["<esc>"] = actions.close
},
},
}
}
local builtin = require "telescope.builtin"
local set = vim.keymap.set
set("n", "<C-p>", builtin.find_files)
set("n", "<leader>fb", builtin.current_buffer_fuzzy_find)
set("n", "<leader>fg", builtin.git_commits)
set("n", "<leader>fh", builtin.help_tags)
set("n", "<leader>p", function() builtin.live_grep { no_ignore = true } end)
set("n", "<leader>fa", function()
builtin.find_files({ follow = true, no_ignore = true, hidden = true, file_ignore_patterns = { '.git,node_modules' } })
end)
set("n", "<leader>ff", function() builtin.find_files({ follow = true, no_ignore = true, hidden = true }) end)

View file

@ -1,97 +0,0 @@
return {
{
"L3MON4D3/LuaSnip",
version = "2.*",
build = "make install_jsregexp",
dependencies = {
'nvim-treesitter/nvim-treesitter',
},
init = function()
local ls = require('luasnip')
ls.setup({
enable_autosnippets = true,
})
end
},
-- Autocomplete
{
"hrsh7th/nvim-cmp",
version = false,
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
},
opts = function()
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
local cmp_format = require("lsp-zero").cmp_format()
return {
completion = {
completeopt = "menu,menuone,noinsert",
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<C-CR>"] = function(fallback)
cmp.abort()
fallback()
end,
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
}),
sorting = defaults.sorting,
formatting = cmp_format,
}
end,
config = function(_, opts)
require("cmp").setup(opts)
end,
},
{
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
opts = {},
config = function(_, opts) require 'lsp_signature'.setup(opts) end,
},
-- Supermaven (copilot)
-- {
-- "supermaven-inc/supermaven-nvim",
-- config = function()
-- require("supermaven-nvim").setup({})
-- end,
-- },
-- GitHub Copilot
-- { "github/copilot.vim" },
-- Comment
{
"numToStr/Comment.nvim",
opts = {
-- add any options here
},
lazy = false,
config = function()
require("Comment").setup()
end
},
-- Surround
{ "tpope/vim-surround", event = "BufRead", },
-- Unimpaired
{ "tpope/vim-unimpaired", event = "BufRead", },
}

View file

@ -1,52 +0,0 @@
return {
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
keys = {
{ "<leader>xx", "<cmd>Trouble diagnostics<CR>", desc = "Trouble Workspace Diagnostics" },
{ "<leader>xl", "<cmd>Trouble loclist<CR>", desc = "Trouble Loclist" },
{ "<leader>xq", "<cmd>Trouble quickfix<CR>", desc = "Trouble Quickfix" },
{ "<leader>xt", "<cmd>Trouble lsp_references<CR>", desc = "Trouble LSP References" },
{ "<leader>xj", function() require("trouble").next({ skip_groups = true, jump = true }) end, desc = "Trouble Next" },
{ "<leader>xk", function() require("trouble").previous({ skip_groups = true, jump = true }) end, desc = "Trouble Previous" },
},
},
{ "wsdjeg/vim-fetch", event = "VeryLazy" },
{ "nvim-tree/nvim-web-devicons" },
{
"eandrju/cellular-automaton.nvim",
event = "VeryLazy",
keys = {
{ "<leader>mr", "<cmd>CellularAutomaton make_it_rain<CR>", desc = "Make it rain" },
},
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {},
config = function()
require("ibl").setup {
debounce = 100,
indent = {
char = "",
tab_char = "",
highlight = { "VertSplit" },
},
scope = {
enabled = true,
show_start = false,
show_end = false,
highlight = "LineNr",
},
}
end,
},
{ "mellow-theme/mellow.nvim" },
{
'norcalli/nvim-colorizer.lua',
config = function()
require('colorizer').setup()
end
},
}

View file

@ -1,50 +0,0 @@
return {
-- Fugitive
{
"tpope/vim-fugitive",
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
config = function()
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { silent = true, noremap = true, desc = desc })
end
map("n", "<leader>gd", "<cmd>Gvdiffsplit!<CR>", "Git Diff")
map("n", "<leader>gl", "<cmd>Git blame -w -C -C -C<CR>", "Git Blame")
map("n", "<leader>gS", "<cmd>Git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)<CR>",
"Git Push Set Upstream")
map("n", "<leader>gbs", "<cmd>Git bisect start<CR>", "Git Bisect Start")
map("n", "<leader>gbg", "<cmd>Git bisect good<CR>", "Git Bisect Good")
map("n", "<leader>gbb", "<cmd>Git bisect bad<CR>", "Git Bisect Bad")
map("n", "<leader>gbr", "<cmd>Git bisect reset<CR>", "Git Bisect Reset")
end
},
-- Gitsigns
{
"lewis6991/gitsigns.nvim",
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
opts = {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
on_attach = function(buffer)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
end
map("n", "[h", gs.next_hunk, "Next Hunk")
map("n", "]h", gs.prev_hunk, "Prev Hunk")
map({ "n", "v" }, "<leader>ghr", "<cmd>Gitsigns reset_hunk<CR>", "Reset Hunk")
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
map("n", "<leader>ghp", gs.preview_hunk, "Preview Hunk")
map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
end,
},
},
}

View file

@ -1,30 +0,0 @@
return {
-- LSP
{
"VonHeikemen/lsp-zero.nvim",
config = function()
require("plugins.lsp.config")
end,
dependencies = {
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason-lspconfig.nvim" },
{ "folke/neodev.nvim" },
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
}
},
-- Mason
{
"williamboman/mason.nvim",
cmd = "Mason",
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
build = ":MasonUpdate",
config = function(_, opts)
require("mason").setup(opts)
end
}
}

View file

@ -1,40 +0,0 @@
return {
{
"stevearc/oil.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
CustomOilBar = function()
local path = vim.fn.expand "%"
path = path:gsub("oil://", "")
return " " .. vim.fn.fnamemodify(path, ":.")
end
require("oil").setup {
columns = { "icon" },
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-p>"] = false,
["<C-c>"] = "actions.close",
["<C-l>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
},
win_options = {
statusline = "%{v:lua.CustomOilBar()}",
},
}
-- Open parent directory in current window
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
-- Open parent directory in floating window
vim.keymap.set("n", "<space>-", require("oil").toggle_float)
end,
},
}

View file

@ -1,51 +0,0 @@
return {
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
version = false,
dependencies = {
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
{ "nvim-lua/plenary.nvim" },
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
}
},
config = function()
local actions = require("telescope.actions")
require("telescope").setup {
defaults = {
mappings = {
i = {
["<esc>"] = actions.close
},
},
}
}
end,
keys = {
{ "<C-p>", "<cmd>Telescope find_files<CR>", desc = "Find files" },
{
"<leader>p",
function() require("telescope.builtin").live_grep({ no_ignore = true }) end,
desc = "Live Grep"
},
-- Search almost everything (except .git folder)
{
"<leader>fa",
function() require("telescope.builtin").find_files({ follow = true, no_ignore = true, hidden = true, file_ignore_patterns = { '.git' } }) end,
desc = "Find all files"
},
-- Search everything
{
"<leader>fl",
function() require("telescope.builtin").find_files({ follow = true, no_ignore = true, hidden = true }) end,
desc = "Find all files"
},
{ "<leader>fb", "<cmd>Telescope buffers<CR>", desc = "Find buffer" },
{ "<leader>fc", "<cmd>Telescope git_commits<CR>", desc = "Find commits" },
},
}