Setup nvim by lazyvim
- Create init.lua and setup for lazy
vim.cmd("set expandtab")
vim.cmd("set tabstop=2")
vim.cmd("set softtabstop=2")
vim.cmd("set shiftwidth=2")
vim.g.mapleader = " "
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)
local plugins = {}
local opts = {}
require("lazy").setup(plugins, opts)
- Add catppuccin to plugin for colorscheme, nvim-telescope and nvim-treesitter
local plugins = {
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 },
{
'nvim-telescope/telescope.nvim', tag = '0.1.5',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"}
}
- Setup catppuccin, telescope and treesitter
-- Color Scheme
require("catppuccin").setup()
vim.cmd.colorscheme "catppuccin"
-- Telescope
local builtin = require("telescope.builtin")
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
vim.keymap.set('n', '<leader>lg', builtin.live_grep, {})
-- Tree-sitter
local config = require("nvim-treesitter.configs")
config.setup({
ensure_installed = {"lua", "javascript", "typescript"},
highlight = { enable = true },
indent = { enable = true },
})
- setup neo-tree
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
}
-- Neo-tree
vim.keymap.set('n', '<leader>e', ':Neotree toggle<CR>')
- Separate plugin setting to different file
Move local block to new file lua/plugins.lua
return {
{ "catppuccin/nvim",
lazy = false,
name = "catppuccin",
priority = 1000
},
{
'nvim-telescope/telescope.nvim', tag = '0.1.5',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
}
}
And update init.lua
require("lazy").setup("plugins")
- Setup also move to separate file
Lazy auto merge the return setup, so we can move it to individual file like `lua/plugins/catppuccin.lua'
return {
"catppuccin/nvim",
lazy = false,
name = "catppuccin",
priority = 1000,
config = function()
vim.cmd.colorscheme "catppuccin"
end
}
And now we can move all plugin into separate file
- lua line
- install mason
- install mason-lspconfig
- nvim-lspconfig
Install telescope-ui-sleect.nvim
Install none-ls
- cmp_luasnip
- nvim-cmp
- friendly-snippets
- cmp-nvim-lsp
- nvim-dap
- nvim-dap-ui
// ys
ex..
S{ -> surround by {
ysw" -> select word and surround by "
ysa"( -> surround " by (
// delete
ds{
// change
cs({
// HTML
cst
dst