serii81
@serii81
Я люблю phр...

Как исправить ошибку в lua файле?

Добрый день.
Хочу в свой neovim подключить плагин, написанный для lua.

Если просто подключить, то работает.
Plug 'goolord/alpha-nvim'
lua << EOF
  require'alpha'.setup(require'alpha.themes.dashboard'.config)
EOF


Ошибки появляются при попытки настройки плагина.

Plug 'goolord/alpha-nvim'

lua << EOF
  require'alpha'.setup(require'alpha.themes.dashboard'.config)
  local dashboard =require'alpha'.setup(require'alpha.themes.dashboard'.config) 
  dashboard.section.header.val = {
    [[                               __                ]],
    [[  ___     ___    ___   __  __ /\_\    ___ ___    ]],
    [[ / _ `\  / __`\ / __`\/\ \/\ \\/\ \  / __` __`\  ]],
    [[/\ \/\ \/\  __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
    [[\ \_\ \_\ \____\ \____/\ \___/  \ \_\ \_\ \_\ \_\]],
    [[ \/_/\/_/\/____/\/___/  \/__/    \/_/\/_/\/_/\/_/]],
  }
  dashboard.section.buttons.val = {
    dashboard.button("f", "  Find file", ":Telescope find_files <CR>"),
    dashboard.button("p", "  Find project", ":Telescope projects <CR>"),
    dashboard.button("r", "  Recently used files", ":Telescope oldfiles <CR>"),
    dashboard.button("c", "  Configuration", ":e ~/.config/nvim/init.lua <CR>"),
    dashboard.button("q", "  Quit Neovim", ":qa<CR>"),
  }

  local function footer()
  -- NOTE: requires the fortune-mod package to work
    -- local handle = io.popen("fortune")
    -- local fortune = handle:read("*a")
    -- handle:close()
    -- return fortune
    return "chrisatmachine.com"
  end

  dashboard.section.footer.val = footer()

  dashboard.section.footer.opts.hl = "Type"
  dashboard.section.header.opts.hl = "Include"
  dashboard.section.buttons.opts.hl = "Keyword"

  dashboard.opts.opts.noautocmd = true
  -- vim.cmd([[autocmd User AlphaReady echo 'ready']])
  alpha.setup(dashboard.opts)
EOF


И сама ошибка.

Error detected while processing /home/serii/nvim-coc/plugins.vim:
line  117:
E5108: Error executing lua [string ":lua"]:2: attempt to index local 'dashboard' (a nil value)
stack traceback:
        [string ":lua"]:2: in main chunk


Я так понимаю что нужн убрать первый require.

Но тогда появляется другая ошибка.

Error detected while processing /home/serii/nvim-coc/plugins.vim:
line  116:
E5108: Error executing lua [string ":lua"]:1: attempt to index global 'dashboard' (a nil value)
stack traceback:
        [string ":lua"]:1: in main chunk


Мне просто это плагин очень нравится, но на lua пока переходить нету времени, свой neovim пока устраивает.

Спасибо за помощь.
  • Вопрос задан
  • 280 просмотров
Решения вопроса 1
serii81
@serii81 Автор вопроса
Я люблю phр...
Нашел ответ из нескольких источников.
telescope:
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' }

lua << EOF
require('telescope').load_extension('projects')
EOF


Alpa и projects

" require'alpha'.setup(require'alpha.themes.dashboard'.config)
  
lua << EOF
 local alpha = require'alpha'
        local dashboard = require'alpha.themes.dashboard'
        dashboard.section.header.val = 'foo'
        dashboard.section.buttons.val = {
          dashboard.button("f", "  Find file", ":Telescope find_files <CR>"),
          dashboard.button("p", "  Find project", ":Telescope projects <CR>"),
          dashboard.button("r", "  Recently used files", ":Telescope oldfiles <CR>"),
          dashboard.button("c", "  Configuration", ":e ~/.config/nvim/init.vim <CR>"),
          dashboard.button("q", "  Quit Neovim", ":qa<CR>"),
        }
        alpha.setup(dashboard.opts)
EOF

Plug 'ahmedkhalf/project.nvim'

lua << EOF
  require("project_nvim").setup {
    -- your configuration comes here
    -- or leave it empty to use the default settings
    -- refer to the configuration section below
  }
EOF
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы