nvim-config/init.lua

113 lines
3 KiB
Lua
Raw Normal View History

2024-08-07 08:19:18 -07:00
if vim.g.vscode then
-- VSCode Neovim
require("user.vscode_keymaps")
else
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)
-- 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", {
lockfile = vim.fn.stdpath("data") .. "/lazy-lock.json", -- in data directory as normal location read only as managed by nix
dev = {
path = "~/Projects/Neovim",
},
2023-02-09 21:22:26 -08:00
})
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- [[ Setting options ]]
-- See `:help vim.o`
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Set highlight on search
vim.o.hlsearch = true
vim.o.incsearch = true
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- clipboard
vim.o.clipboard = "unnamedplus"
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Make line numbers default
vim.wo.number = true
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Enable mouse mode
vim.o.mouse = "a"
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Enable break indent
vim.o.breakindent = true
2023-02-05 15:42:52 -08:00
2024-08-25 21:24:24 -07:00
-- smart indenting
2024-10-06 23:00:23 -07:00
vim.o.smartindent = true
2024-08-25 21:24:24 -07:00
2024-08-07 08:19:18 -07:00
-- Save undo history
vim.o.undofile = true
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Decrease update time
vim.o.updatetime = 250
vim.wo.signcolumn = "yes"
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Set completeopt to have a better completion experience
vim.o.completeopt = "menuone,noselect"
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- [[ Basic Keymaps ]]
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
2023-02-05 15:42:52 -08:00
2024-08-07 08:19:18 -07:00
-- Remap for dealing with word wrap
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
2024-08-07 08:19:18 -07:00
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
2024-08-07 08:19:18 -07:00
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
2024-08-07 08:19:18 -07:00
end,
group = highlight_group,
pattern = "*",
})
2023-02-05 15:42:52 -08:00
2024-09-21 20:18:55 -07:00
-- sets the tab size for json files
vim.api.nvim_create_autocmd("FileType", {
2024-10-06 23:03:04 -07:00
pattern = { "json", "lua", "nix" },
2024-09-21 20:18:55 -07:00
callback = function()
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
end,
})
2024-08-07 08:19:18 -07:00
-- Terminal Escape Key Mapping
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]])
2023-02-28 19:00:36 -08:00
2024-08-07 08:19:18 -07:00
-- Diagnostic keymaps
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
2024-08-07 08:19:18 -07:00
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
end