Update neovim config to use lazyvim
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
local gib_group = augroup('Gib', {})
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
local yank_group = augroup('HighlightYank', {})
|
||||
|
||||
function R(name)
|
||||
require("plenary.reload").reload_module(name)
|
||||
end
|
||||
|
||||
autocmd('TextYankPost', {
|
||||
group = yank_group,
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.highlight.on_yank({
|
||||
higroup = 'IncSearch',
|
||||
timeout = 40,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd({"BufWritePre"}, {
|
||||
group = gib_group,
|
||||
pattern = "*",
|
||||
command = [[%s/\s\+$//e]],
|
||||
})
|
||||
|
||||
autocmd({'BufWritePost'}, {
|
||||
pattern = 'init.lua',
|
||||
command = 'source <afile>',
|
||||
})
|
||||
|
||||
autocmd('FileType', {
|
||||
group = gib_group,
|
||||
pattern = 'markdown',
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd('LspAttach', {
|
||||
group = gib_group,
|
||||
callback = function(e)
|
||||
local opts = { buffer = e.buf }
|
||||
vim.keymap.set('n', '<leader>kf', function() vim.lsp.buf.format() end, opts)
|
||||
vim.keymap.set("n", "<leader>gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "<leader>kw", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>kd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>re", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
|
||||
-- Strip trailing whitespace on save
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
local view = vim.fn.winsaveview()
|
||||
vim.cmd([[keeppatterns %s/\s\+$//e]])
|
||||
vim.fn.winrestview(view)
|
||||
end,
|
||||
})
|
||||
@@ -1,4 +0,0 @@
|
||||
require'config.options'
|
||||
require'config.keymaps'
|
||||
require'config.lazy'
|
||||
require'config.autocmd'
|
||||
@@ -1,41 +1,66 @@
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = "\\"
|
||||
vim.keymap.set('n', '<leader><leader>s', ':update<CR> :source<CR>')
|
||||
vim.keymap.set('n', '<leader><leader>x', ':!chmod +x %<CR>', { silent = true })
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>h', '<C-w>h')
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>j', '<C-w>j')
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>k', '<C-w>k')
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>l', '<C-w>l')
|
||||
vim.keymap.set('n', '<leader>w', ':write<CR>')
|
||||
vim.keymap.set('n', '<leader>q', ':quit<CR>')
|
||||
-- Move the selected lines up or down one line and reselect
|
||||
vim.keymap.set('v', 'J', ':m \'>+1<CR>gv=gv')
|
||||
vim.keymap.set('v', 'K', ':m \'<-2<CR>gv=gv')
|
||||
-- Join the current line with the line below and reposition the cursor
|
||||
vim.keymap.set('n', 'J', 'mzJ`z')
|
||||
-- Scroll down or up and reposition the cursor
|
||||
vim.keymap.set('n', '<C-d>', '<C-d>zz')
|
||||
vim.keymap.set('n', '<C-u>', '<C-u>zz')
|
||||
-- Search forward and reposition the cursor
|
||||
vim.keymap.set('n', 'n', 'nzzzv')
|
||||
-- Search backward and reposition the cursor
|
||||
vim.keymap.set('n', 'N', 'Nzzzv')
|
||||
-- Paste the selection from the system clipboard
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>p', [["+p]])
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>P', [["+P]])
|
||||
-- Move selected text to the black hole register & replace with copied text.
|
||||
vim.keymap.set('x', '<leader>v', [["_dP]])
|
||||
-- Yank (copy) the selection to the system clipboard
|
||||
vim.keymap.set({'n', 'v'}, '<leader>y', [["+y]])
|
||||
-- Yank (copy) the entire buffer to the system clipboard
|
||||
vim.keymap.set('n', '<leader>yy', [["+Y]])
|
||||
-- Yank all the text in the file to the system clipboard
|
||||
vim.keymap.set('n', '<leader>YY', ':%y+<CR>')
|
||||
-- Delete the selection without yanking (copying) it
|
||||
vim.keymap.set({'n', 'v'}, '<leader>d', [["_d]])
|
||||
-- Delete the line without yanking (copying) it
|
||||
vim.keymap.set('n', '<leader>dd', [["_dd]])
|
||||
-- Map Q in Normal mode to do nothing (nop)
|
||||
vim.keymap.set('n', 'Q', '<nop>')
|
||||
-- Perform a search and replace operation using the word under the cursor
|
||||
vim.keymap.set('n', '<leader>sr', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
|
||||
-- Remove LazyVim's C-h/j/k/l window navigation (using <leader>h/j/k/l instead)
|
||||
pcall(vim.keymap.del, "n", "<C-h>")
|
||||
pcall(vim.keymap.del, "n", "<C-j>")
|
||||
pcall(vim.keymap.del, "n", "<C-k>")
|
||||
pcall(vim.keymap.del, "n", "<C-l>")
|
||||
pcall(vim.keymap.del, "t", "<C-h>")
|
||||
pcall(vim.keymap.del, "t", "<C-j>")
|
||||
pcall(vim.keymap.del, "t", "<C-k>")
|
||||
pcall(vim.keymap.del, "t", "<C-l>")
|
||||
-- Remove LazyVim's :Lazy shortcut — <leader>l is used for window navigation
|
||||
pcall(vim.keymap.del, "n", "<leader>l")
|
||||
|
||||
-- Window navigation
|
||||
vim.keymap.set({ "n", "v", "x" }, "<leader>h", "<C-w>h", { desc = "Go to left window", silent = true })
|
||||
vim.keymap.set({ "n", "v", "x" }, "<leader>j", "<C-w>j", { desc = "Go to lower window", silent = true })
|
||||
vim.keymap.set({ "n", "v", "x" }, "<leader>k", "<C-w>k", { desc = "Go to upper window", silent = true })
|
||||
vim.keymap.set({ "n", "v", "x" }, "<leader>l", "<C-w>l", { desc = "Go to right window", silent = true })
|
||||
|
||||
-- Buffer tab navigation
|
||||
vim.keymap.set("n", "<C-h>", "<cmd>BufferLineCyclePrev<cr>", { desc = "Previous buffer", silent = true })
|
||||
vim.keymap.set("n", "<C-l>", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer", silent = true })
|
||||
vim.keymap.set("n", "<C-j>", "<cmd>BufferLineMovePrev<cr>", { desc = "Move buffer left", silent = true })
|
||||
vim.keymap.set("n", "<C-k>", "<cmd>BufferLineMoveNext<cr>", { desc = "Move buffer right", silent = true })
|
||||
vim.keymap.set("n", "<C-q>", function() Snacks.bufdelete() end, { desc = "Close buffer", silent = true })
|
||||
vim.keymap.set("n", "<C-a>", function() Snacks.bufdelete.other() end, { desc = "Close other buffers", silent = true })
|
||||
|
||||
-- Disable ex mode
|
||||
vim.keymap.set("n", "Q", "<nop>")
|
||||
|
||||
-- Move selected lines up/down
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selection down", silent = true })
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selection up", silent = true })
|
||||
|
||||
-- Join line without moving cursor
|
||||
vim.keymap.set("n", "J", "mzJ`z", { desc = "Join line, keep cursor" })
|
||||
|
||||
-- Scroll and center
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Scroll down and center" })
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Scroll up and center" })
|
||||
|
||||
-- Search and center
|
||||
vim.keymap.set("n", "n", "nzzzv", { desc = "Next search result" })
|
||||
vim.keymap.set("n", "N", "Nzzzv", { desc = "Prev search result" })
|
||||
|
||||
-- Yank to system clipboard
|
||||
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "Yank to clipboard" })
|
||||
vim.keymap.set("n", "<leader>Y", '"+Y', { desc = "Yank line to clipboard" })
|
||||
vim.keymap.set("n", "<leader>YY", ":%y+<CR>", { desc = "Yank buffer to clipboard" })
|
||||
|
||||
-- Delete to black hole register (no yank side effect)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>d", '"_d', { desc = "Delete to black hole" })
|
||||
vim.keymap.set("n", "<leader>dd", '"_dd', { desc = "Delete line to black hole" })
|
||||
|
||||
-- Paste from system clipboard
|
||||
vim.keymap.set({ "n", "v", "x" }, "<leader>p", '"+p', { desc = "Paste from clipboard (after)" })
|
||||
vim.keymap.set({ "n", "v", "x" }, "<leader>P", '"+P', { desc = "Paste from clipboard (before)" })
|
||||
|
||||
-- Paste over selection without overwriting the yank register
|
||||
vim.keymap.set("x", "<leader>v", '"_dP', { desc = "Paste over selection" })
|
||||
|
||||
-- Utility
|
||||
vim.keymap.set("n", "<leader><leader>s", ":update<CR>:source<CR>", { desc = "Save and source file" })
|
||||
vim.keymap.set("n", "<leader><leader>x", ":!chmod +x %<CR>", { desc = "Make file executable" })
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"--branch=stable",
|
||||
lazyrepo,
|
||||
lazypath
|
||||
})
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
@@ -21,8 +14,47 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require'lazy'.setup({
|
||||
spec = { { import = 'plugins' } },
|
||||
install = { colorscheme = { 'tokyonight-moon' } },
|
||||
checker = { enabled = false },
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- LazyVim extras (must come before user plugins)
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
{ import = "lazyvim.plugins.extras.formatting.prettier" },
|
||||
{ import = "lazyvim.plugins.extras.linting.eslint" },
|
||||
{ import = "lazyvim.plugins.extras.editor.snacks_explorer" },
|
||||
{ import = "lazyvim.plugins.extras.editor.snacks_picker" },
|
||||
{ import = "lazyvim.plugins.extras.ai.supermaven" },
|
||||
-- import/override with your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
},
|
||||
install = { colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = {
|
||||
enabled = true, -- check for plugin updates periodically
|
||||
notify = false, -- notify on update
|
||||
}, -- automatically check for plugin updates
|
||||
performance = {
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.o.winborder = 'rounded'
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.expandtab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.swapfile = false
|
||||
vim.o.undodir = os.getenv('HOME') .. '/.vim/undodir'
|
||||
vim.o.undofile = true
|
||||
vim.o.hlsearch = true
|
||||
vim.o.incsearch = true
|
||||
vim.o.termguicolors = true
|
||||
vim.o.scrolloff = 4
|
||||
vim.o.signcolumn = 'yes'
|
||||
vim.o.updatetime = 50
|
||||
vim.opt.isfname:append('@-@')
|
||||
vim.cmd([[set list]])
|
||||
vim.cmd([[set listchars=trail:⋅,nbsp:⋅,tab:\ \ ]])
|
||||
vim.cmd(':hi statusline guibg=NONE')
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
|
||||
vim.opt.winborder = "rounded"
|
||||
vim.opt.updatetime = 50
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
vim.opt.listchars = { trail = "⋅", nbsp = "⋅", tab = " " }
|
||||
|
||||
vim.g.ai_cmp = true
|
||||
vim.g.markdown_recommended_style = 0
|
||||
|
||||
Reference in New Issue
Block a user