terminalluaneovimcolor-schemetelescope.nvim

E5107: Error loading lua [string ":source (no file)"]:24: '}' expected near '='


I've never programmed in lua before and I'm trying to set a colorscheme for neovim, but when I paste the theme configuration, I'm getting this error(on the post title), seems like a syntax error, but I'm not sure. I'm using Tilix as terminal on Ubuntu with packer as package manager.

Here's the adapted config:

require('kanagawa').setup({
    compile = false,             -- enable compiling the colorscheme
    undercurl = true,            -- enable undercurls
    commentStyle = { italic = true },
    functionStyle = {},
    keywordStyle = { italic = true},
    statementStyle = { bold = true },
    typeStyle = {},
    transparent = true,         -- do not set background color      
            dimInactive = false,         -- dim inactive window `:h hl-NormalNC`
    terminalColors = { 0,17 = true },       -- define vim.g.terminal_color_{0,17}
    colors = {                   -- add/modify theme and palette colors
        palette = {},
        theme = { wave = {}, lotus = {}, dragon = {}, all = {} },
    },
    overrides = function(colors) -- add/modify highlights
        return {}
    theme = "wave",              -- Load "wave" theme when 'background' option is not set
    background = {dark = "dragon"}                                                        
  end  

vim.cmd("colorscheme kanagawa")

and here is what the creators made on github

-- Default options:
require('kanagawa').setup({
    compile = false,             -- enable compiling the colorscheme
    undercurl = true,            -- enable undercurls
    commentStyle = { italic = true },
    functionStyle = {},
    keywordStyle = { italic = true},
    statementStyle = { bold = true },
    typeStyle = {},
    transparent = false,         -- do not set background color
    dimInactive = false,         -- dim inactive window `:h hl-NormalNC`
    terminalColors = true,       -- define vim.g.terminal_color_{0,17}
    colors = {                   -- add/modify theme and palette colors
        palette = {},
        theme = { wave = {}, lotus = {}, dragon = {}, all = {} },
    },
    overrides = function(colors) -- add/modify highlights
        return {}
    end,
    theme = "wave",              -- Load "wave" theme when 'background' option is not set
    background = {               -- map the value of 'background' option to a theme
        dark = "wave",           -- try "dragon" !
        light = "lotus"
    },
})

-- setup must be called before loading
vim.cmd("colorscheme kanagawa")

Solution

  • The end keyword needs to be on the line above theme and then you're missing a closing brace + parenthesis }) below background. Tables need to be closed {} as do function calls (), so maybe make it a habit to go through and count the open vs closing characters to make sure they are equal.

    I would also consider using an editor with some language server protocol support for lua that can highlight syntax errors. The denizens here think these types of questions aren't great.