I'm trying to use nvim on Ubuntu WSL.
I installed it with AppImage because with apt
it seems to be quite old version.
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage
Then I'm trying to install packer etc to customize it following this blogpost: Turning Neovim into a Full-Fledged Code Editor with Lua
Every time I open nvim ./nvim.appimage
I get this:
Error detected while processing /home/rr/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/rr/.config/nvim/lua/vars.lua:4: attempt to index local 'g' (a function value)
stack traceback:
/home/rr/.config/nvim/lua/vars.lua:4: in main chunk
[C]: in function 'require'
/home/rr/.config/nvim/init.lua:10: in main chunk
Error detected while processing /tmp/.mount_nvim.aiftKrm/usr/share/nvim/runtime/filetype.lua:
E5113: Error while calling lua chunk: .../.mount_nvim.aiftKrm/usr/share/nvim/runtime/filetype.lua:1: attempt to index field 'g' (a function value)
stack traceback:
.../.mount_nvim.aiftKrm/usr/share/nvim/runtime/filetype.lua:1: in main chunk
E5113: Error while calling lua chunk: .../.mount_nvim.aiftKrm/usr/share/nvim/runtime/filetype.lua:1: attempt to index field 'g' (a function value)
stack traceback:
.../.mount_nvim.aiftKrm/usr/share/nvim/runtime/filetype.lua:1: in main chunk
Error detected while processing /tmp/.mount_nvim.aiftKrm/usr/share/nvim/runtime/syntax/syntax.vim:
line 42:
E121: Undefined variable: s:did_ft
Error detected while processing /tmp/.mount_nvim.aiftKrm/usr/share/nvim/runtime/plugin/man.lua:
E5113: Error while calling lua chunk: ...mount_nvim.aiftKrm/usr/share/nvim/runtime/plugin/man.lua:1: attempt to index field 'g' (a function value)
stack traceback:
...mount_nvim.aiftKrm/usr/share/nvim/runtime/plugin/man.lua:1: in main chunk
Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...m.aiftKrm/usr/share/nvim/runtime/plugin/editorconfig.lua:6: attempt to index field 'g' (a function value)
stack traceback:
...m.aiftKrm/usr/share/nvim/runtime/plugin/editorconfig.lua:6: in function <...m.aiftKrm/usr/share/nvim/runtime/plugin/editorconfig.lua:4>
Press ENTER or type command to continue
My current set up is:
.config/nvim/
├── init.lua
├── lua
│ ├── keys.lua
│ ├── opts.lua
│ ├── plug.lua
│ └── vars.lua
└── site
└── pack
└── packer
init.lua
cat .config/nvim/init.lua
--[[ init.lua ]]
-- LEADER
-- These keybindings need to be defined before the first
-- is called; otherwise, it will default to "\"
vim.g.mapleader = ","
vim.g.localleader = "\\"
-- IMPORTS
require("vars") -- Variables
require('opts') -- Options
require('keys') -- Keymaps
require('plug') -- Plugins
plug.lua
cat .config/nvim/lua/plug.lua
-- [[ plug.lua ]]
return require("packer").startup(function(use)
use "wbthomason/packer.nvim"
use "nvim-tree/nvim-tree.lua"
end
)
vars.lua
cat .config/nvim/lua/vars.lua
--[[ vars.lua ]]
vim.g = vim.api.nvim_set_var
local g = vim.g
g.t_co = 256
g.background = "dark"
-- Update the packpath
local packer_path = vim.fn.stdpath("config") .. "/site"
vim.o.packpath = vim.o.packpath .. "," .. packer_path
I am new in using vim/nvim and lua, what am I doing wrong?
There are couple of things I want to point out.
(with lazy.nvim, lsp, linting)
you can checkout my github repo for that.-- Don't do like this(it's a mess).
vim.g = vim.api.nvim_set_var
local g = vim.g
g.t_co = 256
g.background = "dark"
-- You can easily set variables using nvim api like this
vim.opt.background = "dark"