COMPLETE rewrite of neovim config to see if we can speed things up!
This commit is contained in:
69
configs/dotfiles/nvim/lua/config/init.lua
Normal file
69
configs/dotfiles/nvim/lua/config/init.lua
Normal file
@ -0,0 +1,69 @@
|
||||
require('config.set')
|
||||
require('config.remap')
|
||||
require("config.lazy")
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
local GibGroup = augroup('Gib', {})
|
||||
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
local yank_group = augroup('HighlightYank', {})
|
||||
|
||||
function R(name)
|
||||
require("plenary.reload").reload_module(name)
|
||||
end
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
templ = 'templ',
|
||||
}
|
||||
})
|
||||
|
||||
autocmd('TextYankPost', {
|
||||
group = yank_group,
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
vim.highlight.on_yank({
|
||||
higroup = 'IncSearch',
|
||||
timeout = 40,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd({"BufWritePre"}, {
|
||||
group = GibGroup,
|
||||
pattern = "*",
|
||||
command = [[%s/\s\+$//e]],
|
||||
})
|
||||
|
||||
autocmd('BufEnter', {
|
||||
group = GibGroup,
|
||||
callback = function()
|
||||
if vim.bo.filetype == "zig" then
|
||||
vim.cmd.colorscheme("tokyonight-moon")
|
||||
else
|
||||
vim.cmd.colorscheme("tokyonight-moon")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
autocmd('LspAttach', {
|
||||
group = GibGroup,
|
||||
callback = function(e)
|
||||
local opts = { buffer = e.buf }
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "<leader>H", function() vim.lsp.buf.hover() 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)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
end
|
||||
})
|
||||
|
||||
--vim.g.netrw_browse_split = 0
|
||||
--vim.g.netrw_banner = 0
|
||||
--vim.g.netrw_winsize = 25
|
27
configs/dotfiles/nvim/lua/config/lazy.lua
Normal file
27
configs/dotfiles/nvim/lua/config/lazy.lua
Normal file
@ -0,0 +1,27 @@
|
||||
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 })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
--vim.g.mapleader = " "
|
||||
--vim.g.maplocalleader = "\\"
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ import = 'plugins' },
|
||||
},
|
||||
install = { colorscheme = { "tokyonight-moon" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true },
|
||||
})
|
71
configs/dotfiles/nvim/lua/config/remap.lua
Normal file
71
configs/dotfiles/nvim/lua/config/remap.lua
Normal file
@ -0,0 +1,71 @@
|
||||
-- Remaps
|
||||
---------------------------------------------
|
||||
-- Set leader to space
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- 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"}, "<leader>v", [["+p]])
|
||||
vim.keymap.set({"n", "v"}, "<leader>V", [["+P]])
|
||||
|
||||
-- Move selected text to the black hole register & replace with copied text.
|
||||
vim.keymap.set("x", "<leader>p", [["_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>Y", [["+Y]])
|
||||
|
||||
-- Yank all the text in the file to the system clipboard
|
||||
vim.keymap.set("n", "<leader>YY", "gg\"+yG")
|
||||
|
||||
-- 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>")
|
||||
|
||||
-- Format the current buffer using the language server protocol (LSP)
|
||||
vim.keymap.set("n", "<leader>kf", vim.lsp.buf.format)
|
||||
|
||||
-- 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>]])
|
||||
|
||||
-- Make the current file executable (chmod +x)
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||
|
||||
-- Source the current file
|
||||
vim.keymap.set("n", "<leader><leader>", vim.cmd.so)
|
||||
|
||||
|
||||
-- Jump to the next location in the quickfix list and reposition the cursor
|
||||
-- vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||
|
||||
-- Jump to the previous location in the quickfix list and reposition the cursor
|
||||
-- vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
||||
|
||||
-- Jump to the next location in the location list and reposition the cursor
|
||||
--vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||
|
||||
-- Jump to the previous location in the location list and reposition the cursor
|
||||
--vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
34
configs/dotfiles/nvim/lua/config/set.lua
Normal file
34
configs/dotfiles/nvim/lua/config/set.lua
Normal file
@ -0,0 +1,34 @@
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
--vim.opt.expandtab = true
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = true
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.incsearch = true
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
vim.cmd([[set list]])
|
||||
--vim.cmd([[set listchars=trail:⋅]])
|
||||
vim.cmd([[set listchars=trail:⋅,nbsp:⋅,tab:\ \ ]])
|
||||
|
||||
vim.opt.colorcolumn = "100"
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
--vim.cmd([[colorscheme tokyonight-moon]])
|
Reference in New Issue
Block a user