Files
neovim-config/init.lua
2026-07-25 20:52:59 -05:00

104 lines
2.9 KiB
Lua

vim.g.mapleader = "\\"
vim.cmd("colorscheme slate")
vim.opt.ww = "<,>,[,],h,l"
vim.opt.linebreak = true
vim.opt.number = true
vim.opt.ruler = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.smarttab = true
-- writing mode for markdown files
vim.api.nvim_create_autocmd("FileType", {
pattern = { "markdown", "text", "tex" },
callback = function()
vim.opt_local.spell = true
vim.keymap.set("n", "j", "gj", { buffer = true })
vim.keymap.set("n", "k", "gk", { buffer = true })
end,
})
-- Bootstrap lazy.nvim (from https://lazy.folke.io/installation)
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)
require("lazy").setup({
-- Better syntax highlighting
{
"nvim-treesitter/nvim-treesitter",
lazy = false,
build = ":TSUpdate",
},
-- temporarily disable b/c it wasn't working
-- { "arborist-ts/arborist.nvim" }, -- replacement for treesitter w/ auto-install on opening files
-- LSP configs
{ "neovim/nvim-lspconfig" },
{ "mason-org/mason.nvim" },
{ "mason-org/mason-lspconfig.nvim",
opts = {
ensure_installed = { "pyright", "ts_ls", "clangd" },
},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",
},
},
{ "saghen/blink.cmp",
version = "1.*",
dependencies = { 'rafamadriz/friendly-snippets' },
opts = {
keymap = {
preset = "default",
['<CR>'] = { 'select_and_accept', 'fallback' },
['<Tab>'] = { 'snippet_forward', 'select_and_accept', 'fallback' },
},
completion = {
documentation = { auto_show = true },
},
sources = { default = { 'lsp', 'path' } }, -- add 'snippets' for e.g. a pre-formatted `for` loop
},
},
})
-- require("arborist").setup({
-- install_popular = false,
-- prefer_wasm = false,
-- })
-- turn on treesitter highlighting
vim.api.nvim_create_autocmd('FileType', {
pattern = { '*' },
callback = function()
pcall(vim.treesitter.start)
end,
})
-- LSP stuff
vim.keymap.set('n', ' ', vim.lsp.buf.hover, {})
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
vim.keymap.set('n', 'gD', vim.lsp.buf.references, {})
vim.keymap.set('n', 'cd', vim.lsp.buf.rename, {})
vim.keymap.set('n', 'g.', vim.lsp.buf.code_action, {})
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float)