I am currently starting my first project and i wanted to use NeoVim to learn it from scratch and to be faster in the future. I watched the video from theprimeagen "0 to LSP", but his built is not up to date, f. ex. his lsp.lua file doesn´t work. I also wanted to switch from packer to lazy.
First, i tried to make a switch from packer to lazy, because in my research, i found out that this would be better.I changed the packer file from primeagen to a new lazy file with the following code:
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",
lazypath
})
end
vim.opt.rtp:prepend(lazypath)
local plugins = {
'wbthomason/packer.nvim',
{
'nvim-telescope/telescope.nvim',
tag = '0.1.0',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{
'rose-pine/neovim',
as = 'rose-pine',
config = function()
vim.cmd('colorscheme rose-pine')
end
},
{
"folke/trouble.nvim",
config = function()
require("trouble").setup {
icons = false,
-- Ihre Konfiguration hier
}
end
},
{
'nvim-treesitter/nvim-treesitter',
run = function()
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
ts_update()
end
},
"nvim-treesitter/playground",
"theprimeagen/harpoon",
"theprimeagen/refactoring.nvim",
"mbbill/undotree",
"tpope/vim-fugitive",
"nvim-treesitter/nvim-treesitter-context",
'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x',
dependencies = {
-- LSP Support
'neovim/nvim-lspconfig',
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Autocompletion
'hrsh7th/nvim-cmp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lua',
-- Snippets
'L3MON4D3/LuaSnip',
'rafamadriz/friendly-snippets',
}
}
local opts = {
-- Ihre Konfigurationsoptionen hier
}
require("lazy").setup(plugins, opts)
Can someone tell me why this doesn´t work? And could someone recommend me a NeoVim built?
Thx in Advance :)
You should try Kickstart Nvim, it's what I did when I started using Lazy because it gives you a very basic config. It's just easier to set your own config based on Kickstart because it gives you just what you need to start with a useful Neovim editor, as opposite to other distros, which gives you yet another editor (just my opinion).
This is my Neovim config, feel free to clone it, it's not perfect, but it works very well for me. I'm using Lazy and following the
spec
approach to define plugins.Now, there are a couple of things that you have to change:
Migration Guide
in https://github.com/folke/lazy.nvim, because there are some keywords that have different names or merged.dependencies
key needs to be defined per plugin. If you are migrating from packer, basically is what you have asrequires
.Instead of
as
, usename
.lazy = false
andpriority = 1000
to load it from startup.In the
config
function, the important one is thevim.cmd.colorscheme('rose-pine')
, which will set the color scheme to be loaded.The rest of settings inside the
config
function are just to get rid of most of the gold colors in those groups.The
BufWinEnter
event ensures Fugitive to be loaded as soon as you enter a buffer. https://neovim.io/doc/user/autocmd.html#BufWinEnterI hope this helps you.