Files
nvim/init.lua
2026-04-21 01:12:43 -04:00

149 lines
5.4 KiB
Lua

-- Global settings.
vim.g.mapleader = " "
vim.opt.number = true
vim.opt.cursorline = true
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.filetype.add({
extension = {
shader = "hlsl"
}
})
vim.opt.termguicolors = true
vim.cmd("colorscheme mweh")
----------------------------------------------
--- Lazy nvim
-- Bootstrap lazy.nvim
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)
-- Setup lazy.nvim
require("lazy").setup({
spec = {
{
"neovim/nvim-lspconfig",
-- Lualine.
{ "nvim-lualine/lualine.nvim", dependencies = { 'nvim-tree/nvim-web-devicons' }, opts = {} },
-- Telescope.
{ "nvim-telescope/telescope.nvim", dependencies = { 'nvim-lua/plenary.nvim' } },
-- Neo tree.
{
"nvim-neo-tree/neo-tree.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim"
},
keys = {
{ "<C-n>", ":Neotree filesystem reveal left<CR>", {} }
},
opts = {}
},
-- Treesitter.
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
-- Mason.
{ "mason-org/mason.nvim", opts = {} },
-- Mason LSP config.
{
"mason-org/mason-lspconfig.nvim",
opts = {
ensure_installed = { "clangd", "neocmake", "jdtls", "ts_ls", "lua_ls", "pyright", "html", "cssls", "glsl_analyzer", "biome", "somesass_ls", "rust_analyzer", "texlab", },
},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",
},
},
-- cmp-nvim-lsp stuff for nvim-cmp, probably.
{ "hrsh7th/cmp-nvim-lsp" },
-- LuaSnip for Snipping.
{ "L3MON4D3/LuaSnip" },
-- Completions with nvim-cmp
{
"hrsh7th/nvim-cmp",
config = function()
local cmp = require("cmp")
require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
-- Keybinds for scrolling through documentation.
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["C-e"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
},
{
{ name = "buffer" },
}),
})
end,
},
-- Vimtex.
{
"lervag/vimtex",
lazy = false, -- we don't want to lazy load VimTeX
-- tag = "v2.15", -- uncomment to pin to a specific release
init = function()
-- VimTeX configuration goes here, e.g.
vim.g.vimtex_view_method = "zathura"
end
},
-- Rendering markdown
{
'MeanderingProgrammer/render-markdown.nvim',
dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' },
---@module 'render-markdown'
---@type render.md.UserConfig
opts = {},
},
},
},
install = { colorscheme = { "habamax" } },
checker = { enabled = true },
})
----------------------------------------------
--- Keybinds
-- Formatting keybinds.
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
-- Telescope keybinds.
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })