nvim-config/init.lua

95 lines
2.4 KiB
Lua
Raw Normal View History

2023-02-10 21:20:55 -08:00
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,
2023-02-09 21:22:26 -08:00
})
2023-02-05 15:42:52 -08:00
end
2023-02-10 21:20:55 -08:00
vim.opt.rtp:prepend(lazypath)
2023-02-05 15:42:52 -08:00
2023-02-10 21:20:55 -08:00
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
require("lazy").setup("plugins", {
2023-02-24 19:12:24 -08:00
lockfile = vim.fn.stdpath("data") .. "/lazy-lock.json", -- in data directory as normal location read only as managed by nix
dev = {
2023-02-24 19:12:24 -08:00
path = "~/Projects/Neovim",
},
})
2023-02-05 15:42:52 -08:00
-- [[ Setting options ]]
-- See `:help vim.o`
-- Set highlight on search
2023-03-01 21:52:13 -08:00
vim.o.hlsearch = true
2023-02-05 15:42:52 -08:00
vim.o.incsearch = true
-- clipboard
2023-02-09 21:22:26 -08:00
vim.o.clipboard = "unnamedplus"
2023-02-05 15:42:52 -08:00
-- Make line numbers default
vim.wo.number = true
-- Enable mouse mode
2023-02-09 21:22:26 -08:00
vim.o.mouse = "a"
2023-02-05 15:42:52 -08:00
-- Enable break indent
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Decrease update time
vim.o.updatetime = 250
2023-02-09 21:22:26 -08:00
vim.wo.signcolumn = "yes"
2023-02-05 15:42:52 -08:00
2023-02-10 21:20:55 -08:00
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
2023-02-05 15:42:52 -08:00
-- Set completeopt to have a better completion experience
2023-02-09 21:22:26 -08:00
vim.o.completeopt = "menuone,noselect"
2023-02-05 15:42:52 -08:00
-- [[ Basic Keymaps ]]
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
2023-02-09 21:22:26 -08:00
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
2023-02-05 15:42:52 -08:00
-- Remap for dealing with word wrap
2023-02-09 21:22:26 -08:00
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
2023-02-05 15:42:52 -08:00
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
2023-02-09 21:22:26 -08:00
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", {
2023-02-05 15:42:52 -08:00
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
2023-02-09 21:22:26 -08:00
pattern = "*",
2023-02-05 15:42:52 -08:00
})
2023-02-28 19:00:36 -08:00
-- Terminal Escape Key Mapping
2024-05-18 22:04:13 -07:00
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]])
2023-02-28 19:00:36 -08:00
2023-02-05 15:42:52 -08:00
-- Diagnostic keymaps
2023-02-09 21:22:26 -08:00
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float)
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist)
2023-02-05 15:42:52 -08:00
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et