Skip to main content

Recipes & Customization

Common customization patterns for LazyVim.

Make TokyoNight Transparent

lua/plugins/theme.lua
return {
"folke/tokyonight.nvim",
opts = {
transparent = true,
styles = {
sidebars = "transparent",
floats = "transparent",
},
},
}

Change Colorscheme

lua/plugins/core.lua
return {
{
"LazyVim/LazyVim",
opts = {
colorscheme = "catppuccin",
},
},
-- If not already installed
{ "catppuccin/nvim", name = "catppuccin" },
}

Add an nvim-cmp Source

lua/plugins/cmp.lua
return {
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
opts = function(_, opts)
table.insert(opts.sources, { name = "emoji" })
end,
}

Supertab (Tab for Completion & Snippets)

lua/plugins/cmp.lua
return {
"hrsh7th/nvim-cmp",
opts = function(_, opts)
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.snippet.active({ direction = 1 }) then
vim.schedule(function() vim.snippet.jump(1) end)
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif vim.snippet.active({ direction = -1 }) then
vim.schedule(function() vim.snippet.jump(-1) end)
else
fallback()
end
end, { "i", "s" }),
})
end,
}

Change Surround Mappings

lua/plugins/mini-surround.lua
return {
"echasnovski/mini.surround",
opts = {
mappings = {
add = "gsa",
delete = "gsd",
find = "gsf",
find_left = "gsF",
highlight = "gsh",
replace = "gsr",
update_n_lines = "gsn",
},
},
}

Use ESLint + Prettier

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.linting.eslint" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
}

Add Python LSP + Formatting

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.lang.python" },
}

-- Then configure formatters
return {
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
python = { "black" },
},
},
}

Add Rust Support

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.lang.rust" },
}

Add TypeScript/JavaScript Support

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.lang.typescript" },
}

Add Go Support

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.lang.go" },
}

Add Additional Treesitter Parsers

lua/plugins/treesitter.lua
return {
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, {
"docker",
"gitignore",
"graphql",
"http",
"rust",
"scss",
"sql",
})
end,
}

Ensure Additional Mason Tools

lua/plugins/mason.lua
return {
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"stylua", -- Already included
"shfmt",
"shellcheck",
"flake8",
"black",
"prettier",
"rust-analyzer",
},
},
}

Customize LSP Keymaps per Server

lua/plugins/lsp.lua
return {
"neovim/nvim-lspconfig",
opts = {
servers = {
-- Global LSP keymaps (all servers)
["*"] = {
keys = {
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", has = "codeAction" },
},
},
-- Server-specific keymaps
vtsls = {
keys = {
{ "<leader>co", function()
vim.lsp.buf.code_action({
apply = true,
context = { only = { "source.organizeImports" }, diagnostics = {} },
})
end, desc = "Organize Imports" },
},
},
},
},
}

Fix clangd Offset Encoding

lua/plugins/lsp.lua
return {
"neovim/nvim-lspconfig",
opts = {
setup = {
clangd = function(_, opts)
opts.capabilities.offsetEncoding = { "utf-16" }
end,
},
},
}

Disable Autoformat for Specific Filetypes

lua/config/autocmds.lua
vim.api.nvim_create_autocmd("FileType", {
pattern = { "lua", "markdown" },
callback = function()
vim.b.autoformat = false
end,
})

Project-Local LSP Config

Enable the neoconf extra, then create .neoconf.json in your project root:

{
"lspconfig": {
"pyright": {
"settings": {
"python": {
"analysis": {
"extraPaths": ["./src"]
}
}
}
}
}
}

Use fzf-lua Instead of Telescope

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.editor.fzf" },
}

Use blink.cmp Instead of nvim-cmp

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.coding.blink" },
}

Enable Harpoon2

lua/plugins/extras.lua
return {
{ import = "lazyvim.plugins.extras.editor.harpoon2" },
}