I am using neovim for the first time after using vim. I could use some neovim distro like NvChad or lazyVim. But i thought why now start from scratch and keep it lightweight.
I installed packer as my plugin manager
here's the code i put in the init.lua file .
-- Replace with your actual Neovim configuration file path
vim.cmd([[packadd packer.nvim]])
-- Replace with your actual Neovim configuration file path
local packer = require('packer')
packer.init({
use{
"kylenchui/nvim-surround",
tag = "*",
config = function()
require("nvim-surround").setup({})
end
}
})
-- Disable compatibility with vi which can cause unexpected issues.
vim.opt.compatible = false
-- Enable type file detection. NeoVim will be able to try to detect the type of file in use.
vim.cmd('filetype on')
-- Enable plugins and load plugin for the detected file type.
vim.cmd('filetype plugin on')
-- Load an indent file for the detected file type.
vim.cmd('filetype indent on')
-- Enable syntax highlighting.
vim.cmd('syntax enable')
-- Set relative line numbers.
vim.opt.relativenumber = true
-- Set shift width to 4 spaces.
vim.opt.shiftwidth = 4
-- Set tab width to 4 columns.
vim.opt.tabstop = 4
-- Use space characters instead of tabs.
vim.opt.expandtab = true
-- Do not save backup files.
vim.opt.backup = false
-- Do not let cursor scroll below or above N number of lines when scrolling.
vim.opt.scrolloff = 10
-- Do not wrap lines. Allow long lines to extend as far as the line goes.
vim.opt.wrap = false
-- While searching through a file, incrementally highlight matching characters as you type.
vim.opt.incsearch = true
-- Ignore capital letters during search.
vim.opt.ignorecase = true
-- Override the ignorecase option if searching for capital letters.
-- This will allow you to search specifically for capital letters.
vim.opt.smartcase = true
-- Show partial command you type in the last line of the screen.
vim.opt.showcmd = true
-- Show the mode you are in on the last line.
vim.opt.showmode = true
-- Show matching words during a search.
vim.opt.showmatch = true
-- Use highlighting when doing a search.
vim.opt.hlsearch = true
and this is the error I am facing:
Error detected while processing /home/ishtiaqdishan/.c onfig/nvim/init.lua: E5113: Error while calling lua chunk: /home/ishtiaqdis han/.config/nvim/init.lua:9: attempt to call global 'u se' (a nil value) stack traceback: /home/ishtiaqdishan/.config/nvim/init.lua:9: i n main chunk
How can i fix this issue? Can someone help with the problem?
Tried multiple method to install packer Tried to fix some lua syntax
nothing worked
You use packer.init
and looking at the quickstart part of the packer README.md, it seems like plugins are installed using packer.startup
. In there, you have to pass a function that takes a parameter use
.
...
local packer = require('packer')
packer.startup(function(use)
use{
"kylenchui/nvim-surround",
tag = "*",
config = function()
require("nvim-surround").setup({})
end
}
end)
...
And packer.init
seems to be for configuration of packer itself.