nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.44k stars 213 forks source link

Can't open properly neorg files #696

Closed roland-5 closed 1 year ago

roland-5 commented 1 year ago

Prerequisites

Neovim Version

v0.9.0-dev-550+g3ea1524cf8a

Neorg setup

    use({
        "nvim-neorg/neorg",
        run = ":Neorg sync-parsers", -- This is the important bit!
        ft = "norg",
        after = "nvim-treesitter",
        config = function()
            require("neorg").setup({
                load = {
                    ["core.defaults"] = {},
                    ["core.norg.dirman"] = {
                        config = {
                            workspaces = {
                                dokumenty = "/home/roland/Dokumenty/neorg",
                            },
                        },
                    },
                    ["core.norg.completion"] = {
                        config = {
                            engine = "nvim-cmp",
                        },
                    },
                    ["core.norg.concealer"] = {
                        config = {
                            width = "content",
                        },
                    },
                },
            })
            vim.api.nvim_set_hl(0, "@neorg.tags.ranged_verbatim.code_block", { bg = "#504945" })
        end,
    })

Actual behavior

If I try open any neorg files it show error. I accidentally deleted my ~/.local/share/nvim folder and after I tried PackerSync I have this problem, if I try open .norg files and only there.

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:21: Error executing lua: /usr/share/nvim/runtime/filetype.lua:22: Vim(
append):Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 29 f
or language norg
stack traceback:
        [C]: in function '_ts_parse_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: in function 'get_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:52: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:45: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:96: in function 'get_parser'
        .../start/nvim-treesitter/lua/nvim-treesitter/highlight.lua:34: in function 'start'
        .../start/nvim-treesitter/lua/nvim-treesitter/highlight.lua:42: in function 'attach'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:505: in function 'attach_module'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:528: in function 'reattach_module'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:131: in function <...er/start/nvim-treesitter/lua/nvim-treesitter/con
figs.lua:130>
        [C]: in function 'nvim_cmd'
        /usr/share/nvim/runtime/filetype.lua:22: in function </usr/share/nvim/runtime/filetype.lua:21>
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/filetype.lua:21: in function </usr/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        /usr/share/nvim/runtime/filetype.lua:22: in function </usr/share/nvim/runtime/filetype.lua:21>
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/filetype.lua:21: in function </usr/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/filetype.lua:21: in function </usr/share/nvim/runtime/filetype.lua:10>
Error detected while processing BufReadPost Autocommands for "*.norg"..FileType Autocommands for "*":
Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 29 for langu
age norg
stack traceback:
        [C]: in function '_ts_parse_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: in function 'get_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:52: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:45: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:96: in function 'get_parser'
        .../start/nvim-treesitter/lua/nvim-treesitter/highlight.lua:34: in function 'start'
        .../start/nvim-treesitter/lua/nvim-treesitter/highlight.lua:42: in function 'attach'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:505: in function 'attach_module'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:528: in function 'reattach_module'
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:131: in function <...er/start/nvim-treesitter/lua/nvim-treesitter/con
figs.lua:130>
Error detected while processing BufEnter Autocommands for "*.norg":
E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 29 for language
 norg
stack traceback:
        [C]: in function '_ts_parse_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: in function 'get_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:52: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:45: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:96: in function 'get_parser'
        ...ua/neorg/modules/core/integrations/treesitter/module.lua:511: in function 'get_document_root'
        ...ker/start/neorg/lua/neorg/modules/core/syntax/module.lua:105: in function 'check_code_block_type'
        ...ker/start/neorg/lua/neorg/modules/core/syntax/module.lua:479: in function 'on_event'
        ...e/nvim/site/pack/packer/start/neorg/lua/neorg/events.lua:153: in function 'broadcast_event'
        ...art/neorg/lua/neorg/modules/core/autocommands/module.lua:44: in function '_neorg_module_autocommand_triggered'
        [string ":lua"]:1: in main chunk

Expected behavior

To be working.

Steps to reproduce

My init.lua

-- load plugin manager first
require('plugins._packer')
-- automatically compile init.lua with packer, after any changes in plugins file
vim.cmd('autocmd BufWritePost plugins.lua PackerCompile')

-- hide command bar
vim.o.cmdheight = 0

-- inactive mouse right click menu
vim.o.mouse = ""

vim.o.completeopt = menu,menuone,noselect

vim.o.termguicolors = true

vim.o.diffopt = linematch
vim.o.clipboard = unnamedplus

-- for neorg
vim.opt.foldlevel = 10
vim.opt.conceallevel = 2
-- vim.opt.concealcursor = "n"

-- prevent typo when pressing `wq` or `q`
vim.cmd[[
  cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
  cnoreabbrev <expr> Q ((getcmdtype() is# ':' && getcmdline() is# 'Q')?('q'):('Q'))
  cnoreabbrev <expr> WQ ((getcmdtype() is# ':' && getcmdline() is# 'WQ')?('wq'):('WQ'))
  cnoreabbrev <expr> Wq ((getcmdtype() is# ':' && getcmdline() is# 'Wq')?('wq'):('Wq'))
]]

-- autocmd to create parent directory for folders than don't exist
vim.cmd([[
    autocmd BufWritePre * call mkdir(expand("<afile>:h"), "p")
]])

--vim.cmd("setlocal spell spelllang=pl")

-- Show line numbers
vim.opt.number = true
-- Relative line numbers
vim.opt.relativenumber = true

-- change cwd to current directory
vim.cmd('lcd %:p:h')

-- ccc.nvim ------------------------------------------------------------------------------------------------------------------------------------------
local ccc = require("ccc")
local mapping = ccc.mapping
ccc.setup({
    highlighter = {
        auto_enable = true,
    },
    pickers = {
        ccc.picker.hex,
        ccc.picker.css_rgb,
        ccc.picker.css_hsl,
        ccc.picker.css_name,
    },
})

-- gruvbox theme ------------------------------------------------------------------------------------------------------------------------------------------
vim.opt.background = "dark" -- or "light" for light mode
-- setup must be called before loading the colorscheme
-- Default options:
require("gruvbox").setup({
  undercurl = true,
  underline = true,
  bold = true,
  italic = true, -- will make italic comments and special strings
  inverse = true, -- invert background for search, diffs, statuslines and errors
  invert_selection = false,
  invert_signs = false,
  invert_tabline = false,
  invert_intend_guides = false,
  contrast = "hard", -- can be "hard" or "soft"
  overrides = {
      Normal = {bg = "#000000"}
  },
})
vim.cmd("colorscheme gruvbox")

-- theme kanagawa as gruvbox ------------------------------------------------------------------------------------------------------------------------------
-- local default_colors = require("kanagawa.colors").setup()
--
-- local overrides = {
--     Boolean = { fg = "#d3869b", style = "NONE" },
--     Comment = { fg = "#928374" },
--     Constant = { fg = "#d3869b" },
--     Delimiter = { fg = "#bdae93" },
--     EndOfBuffer = { fg = "#504945" },
--     ErrorMsg = { fg = "#000000", bg = "#fb4934", style = "bold" },
--     FloatBorder = { fg = "#665c54" },
--     Function = { fg ="#b8bb26", style = "bold" },
--     Identifier = { fg = "#83a598" },
--     IncSearch = { fg = "#000000", bg = "#fe8019" },
--     Keyword = { fg = "#fb4934", style = "NONE" },
--     LineNr = { fg = "#7c6f64" },
--     MatchParen = { fg = "NONE", bg = "#665c54" },
--     MoreMsg = { fg = "#fe8019", bg = "#000000", style = "bold" },
--     NonText = { fg = "#504945", style = "NONE" },
--     Normal = { fg = "#ebdbb2", bg ="#000000" },
--     NormalFloat = { bg ="#504945" },
--     Operator = { fg = "#ebdbb2" },
--     Pmenu = { bg = "#504945" },
--     PmenuSel = { bg ="#83a598" },
--     PreProc = { fg = "#8ec07c" },
--     Search = { fg = "#000000", bg = "#fabd2f" },
--     Special = { fg = "#fe8019" },
--     SpecialChar = { fg = "#fb4934" },
--     SpecialKey = { fg = "#a89984" },
--     Statement = { fg = "#fb4934", style = "NONE" },
--     StatusLine = { bg = "#504945" },
--     String = { fg = "#b8bb26" },
--     Structure = { fg = "#8ec07c" },
--     TSAttribute = { fg = "#8ec07c" },
--     TSPunctDelimiter = { fg = "#bdae93" },
--     TabLineFill = { fg = "#776b61", bg = "#3c3836" },
--     TabLineSel = { fg = "#b8bb26", bg = "#3c3836" },
--     Title = { fg = "#b8bb26" },
--     Todo = { fg = "#000000", bg = "#689d6a", style = "bold,italic" },
--     Type = { fg = "#fabd2f" },
--     Underlined = { fg = "#83a598" },
--     VertSplit  = { bg = "NONE" },
--     Visual = { bg = "#665c54" },
--     WarningMsg = { fg = "#fb4934", style = "bold" }
-- }
--
-- require'kanagawa'.setup({ overrides = overrides })
-- vim.cmd('colorscheme kanagawa')

--Enable break indent
vim.opt.breakindent = true

--Save undo history
-- vim.opt.undofile = true

--Case insensitive searching UNLESS /C or capital in search
vim.opt.ignorecase = true
vim.opt.smartcase = true

-- Highlight on yank
vim.api.nvim_exec(
  [[
  augroup YankHighlight
    autocmd!
    autocmd TextYankPost * silent! lua vim.highlight.on_yank()
  augroup end
]],
  false
)

--Map blankline
vim.g.indent_blankline_char = '┊'
vim.g.indent_blankline_filetype_exclude = { 'help', 'packer' }
vim.g.indent_blankline_buftype_exclude = { 'terminal', 'nofile' }
vim.g.indent_blankline_char_highlight = 'LineNr'
vim.g.indent_blankline_show_trailing_blankline_indent = false

-- Gitsigns
require('gitsigns').setup {
  signs = {
    add = { hl = 'GitGutterAdd', text = '+' },
    change = { hl = 'GitGutterChange', text = '~' },
    delete = { hl = 'GitGutterDelete', text = '_' },
    topdelete = { hl = 'GitGutterDelete', text = '‾' },
    changedelete = { hl = 'GitGutterChange', text = '~' },
  },
}

-- cmp setup config ---------------------------------------------------------------------------------------------------------------------------------------
local cmp = require'cmp'

cmp.setup({
  snippet = {
    -- REQUIRED - you must specify a snippet engine
    expand = function(args)
      require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
    end,
  },
  window = {
    -- completion = cmp.config.window.bordered(),
    -- documentation = cmp.config.window.bordered(),
  },
  mapping = cmp.mapping.preset.insert({
    ['<C-b>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.abort(),
    ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
  }),
  sources = cmp.config.sources({
    { name = 'nvim_lsp' },
    { name = 'luasnip' }, -- For luasnip users.
  }, {
    { name = 'buffer' },
  })
})

-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
  sources = cmp.config.sources({
    { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
  }, {
    { name = 'buffer' },
  })
})

-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
  mapping = cmp.mapping.preset.cmdline(),
  sources = {
    { name = 'buffer' }
  }
})

-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
  mapping = cmp.mapping.preset.cmdline(),
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  })
})

-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['rust_analyzer'].setup {
  capabilities = capabilities
}

-- Telescope ----------------------------------------------------------------------------------------------------------------------------------------------
require('telescope').setup {
  defaults = {
    mappings = {
      i = {
        ['<C-u>'] = false,
        ['<C-d>'] = false,
      },
    },
  },
}
--Add leader shortcuts
vim.api.nvim_set_keymap('n', '<leader><space>', [[<cmd>lua require('telescope.builtin').buffers()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sf', [[<cmd>lua require('telescope.builtin').find_files({previewer = false})<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sb', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sh', [[<cmd>lua require('telescope.builtin').help_tags()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>st', [[<cmd>lua require('telescope.builtin').tags()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sd', [[<cmd>lua require('telescope.builtin').grep_string()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sp', [[<cmd>lua require('telescope.builtin').live_grep()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>so', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<CR>]], { noremap = true, silent = true })

-- Treesitter configuration -------------------------------------------------------------------------------------------------------------------------------
-- Parsers must be installed manually via :TSInstall
require('nvim-treesitter.configs').setup {
    ensure_installed = { "norg", "fish" },
    highlight = {
    enable = true, -- false will disable the whole extension
  },
  incremental_selection = {
    enable = true,
    keymaps = {
      init_selection = 'gnn',
      scope_incremental = 'grc',
    },
  },
  indent = {
    enable = true,
  },
  textobjects = {
    select = {
      enable = true,
      lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
      keymaps = {
        -- You can use the capture groups defined in textobjects.scm
        ['af'] = '@function.outer',
        ['if'] = '@function.inner',
        ['ac'] = '@class.outer',
        ['ic'] = '@class.inner',
      },
    },
    move = {
      enable = true,
      set_jumps = true, -- whether to set jumps in the jumplist
      goto_next_start = {
        [']m'] = '@function.outer',
        [']]'] = '@class.outer',
      },
      goto_next_end = {
        [']M'] = '@function.outer',
        [']['] = '@class.outer',
      },
      goto_previous_start = {
        ['[m'] = '@function.outer',
        ['[['] = '@class.outer',
      },
      goto_previous_end = {
        ['[M'] = '@function.outer',
        ['[]'] = '@class.outer',
      },
    },
  },
}

-- LSP settings
local nvim_lsp = require 'lspconfig'
local on_attach = function(_, bufnr)
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

  local opts = { noremap = true, silent = true }
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  -- vim.api.nvim_buf_set_keymap(bufnr, 'v', '<leader>ca', '<cmd>lua vim.lsp.buf.range_code_action()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
  vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
end

-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)

-- Enable the following language servers
local servers = { 'rust_analyzer' }
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    capabilities = capabilities,
  }
end

-- Make runtime files discoverable to the server
local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, 'lua/?.lua')
table.insert(runtime_path, 'lua/?/init.lua')

  -- Setup lspconfig.
  local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
  -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
  require('lspconfig')['rust_analyzer'].setup {
    capabilities = capabilities
  }

-- barbar.nvim --------------------------------------------------------------------------------------------------------------------------------------------
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }

-- Move to previous/next
map('n', '<A-,>', ':BufferPrevious<CR>', opts)
map('n', '<A-.>', ':BufferNext<CR>', opts)
-- Re-order to previous/next
map('n', '<A-<>', ':BufferMovePrevious<CR>', opts)
map('n', '<A->>', ' :BufferMoveNext<CR>', opts)
-- Goto buffer in position...
map('n', '<A-1>', ':BufferGoto 1<CR>', opts)
map('n', '<A-2>', ':BufferGoto 2<CR>', opts)
map('n', '<A-3>', ':BufferGoto 3<CR>', opts)
map('n', '<A-4>', ':BufferGoto 4<CR>', opts)
map('n', '<A-5>', ':BufferGoto 5<CR>', opts)
map('n', '<A-6>', ':BufferGoto 6<CR>', opts)
map('n', '<A-7>', ':BufferGoto 7<CR>', opts)
map('n', '<A-8>', ':BufferGoto 8<CR>', opts)
map('n', '<A-9>', ':BufferGoto 9<CR>', opts)
map('n', '<A-0>', ':BufferLast<CR>', opts)
-- Close buffer
map('n', '<A-c>', ':BufferClose<CR>', opts)
-- Wipeout buffer
--                 :BufferWipeout<CR>
-- Close commands
--                 :BufferCloseAllButCurrent<CR>
--                 :BufferCloseBuffersLeft<CR>
--                 :BufferCloseBuffersRight<CR>
-- Magic buffer-picking mode
map('n', '<C-p>', ':BufferPick<CR>', opts)
-- Sort automatically by...
map('n', '<Space>bd', ':BufferOrderByDirectory<CR>', opts)
map('n', '<Space>bl', ':BufferOrderByLanguage<CR>', opts)

-- Other:
-- :BarbarEnable - enables barbar (enabled by default)
-- :BarbarDisable - very bad command, should never be used

-- Set barbar's options
vim.g.bufferline = {
  -- Enable/disable animations
  animation = true,

  -- Enable/disable auto-hiding the tab bar when there is a single buffer
  auto_hide = false,

  -- Enable/disable current/total tabpages indicator (top right corner)
  tabpages = true,

  -- Enable/disable close button
  closable = true,

  -- Enables/disable clickable tabs
  --  - left-click: go to buffer
  --  - middle-click: delete buffer
  clickable = true,

  -- Enable/disable icons
  -- if set to 'numbers', will show buffer index in the tabline
  -- if set to 'both', will show buffer index and icons in the tabline
  icons = true,

  -- If set, the icon color will follow its corresponding buffer
  -- highlight group. By default, the Buffer*Icon group is linked to the
  -- Buffer* group (see Highlighting below). Otherwise, it will take its
  -- default value as defined by devicons.
  icon_custom_colors = false,

  -- Configure icons on the bufferline.
  icon_separator_active = '▎',
  icon_separator_inactive = '▎',
  icon_close_tab = '',
  icon_close_tab_modified = '●',
  icon_pinned = '車',

  -- Sets the maximum padding width with which to surround each tab
  maximum_padding = 1,

  -- Sets the maximum buffer name length.
  maximum_length = 30,

  -- If set, the letters for each buffer in buffer-pick mode will be
  -- assigned based on their name. Otherwise or in case all letters are
  -- already assigned, the behavior is to assign letters in order of
  -- usability (see order below)
  semantic_letters = true,

  -- New buffer letters are assigned in this order. This order is
  -- optimal for the qwerty keyboard layout but might need adjustement
  -- for other layouts.
  letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP',

  -- Sets the name of unnamed buffers. By default format is "[Buffer X]"
  -- where X is the buffer number. But only a static string is accepted here.
  no_name_title = nil,
}

function searchCount()
    local search = vim.fn.searchcount({maxcount = 0}) -- maxcount = 0 makes the number not be capped at 99
    local searchCurrent = search.current
    local searchTotal = search.total
    if searchCurrent > 0 and vim.v.hlsearch ~= 0 then
        return "/"..vim.fn.getreg("/").." ["..searchCurrent.."/"..searchTotal.."]"
    else
        return ""
    end
end

-- Eviline config for lualine -----------------------------------------------------------------------------------------------------------------------------
-- Author: shadmansaleh
-- Credit: glepnir
local lualine = require('lualine')

-- Color table for highlights
-- stylua: ignore
local colors = {
  bg       = '#202328',
  fg       = '#bbc2cf',
  yellow   = '#ECBE7B',
  cyan     = '#008080',
  darkblue = '#081633',
  green    = '#98be65',
  orange   = '#FF8800',
  violet   = '#a9a1e1',
  magenta  = '#c678dd',
  blue     = '#51afef',
  red      = '#ec5f67',
}

local conditions = {
  buffer_not_empty = function()
    return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
  end,
  hide_in_width = function()
    return vim.fn.winwidth(0) > 80
  end,
  check_git_workspace = function()
    local filepath = vim.fn.expand('%:p:h')
    local gitdir = vim.fn.finddir('.git', filepath .. ';')
    return gitdir and #gitdir > 0 and #gitdir < #filepath
  end,
}

-- Config
local config = {
  options = {
    globalstatus = true,
    -- Disable sections and component separators
    component_separators = '',
    section_separators = '',
    refresh = { statusline = 500 },
    theme = {
      -- We are going to use lualine_c an lualine_x as left and
      -- right section. Both are highlighted by c theme .  So we
      -- are just setting default looks o statusline
      normal = { c = { fg = colors.fg, bg = colors.bg } },
      inactive = { c = { fg = colors.fg, bg = colors.bg } },
    },
  },
  sections = {
    -- these are to remove the defaults
    lualine_a = {search_cnt},
    lualine_b = {},
    lualine_y = {},
    lualine_z = {},
    -- These will be filled later
    lualine_c = {},
    lualine_x = {{ searchCount }, 'tabs', 'fileformat', 'filetype'},
  },
  inactive_sections = {
    -- these are to remove the defaults
    lualine_a = {},
    lualine_b = {},
    lualine_y = {},
    lualine_z = {},
    lualine_c = {},
    lualine_x = {},
  },
}

-- Inserts a component in lualine_c at left section
local function ins_left(component)
  table.insert(config.sections.lualine_c, component)
end

-- Inserts a component in lualine_x ot right section
local function ins_right(component)
  table.insert(config.sections.lualine_x, component)
end

ins_left {
  function()
    return '▊'
  end,
  color = { fg = colors.blue }, -- Sets highlighting of component
  padding = { left = 0, right = 1 }, -- We don't need space before this
}

ins_left {
  -- mode component
  function()
    return ''
  end,
  color = function()
    -- auto change color according to neovims mode
    local mode_color = {
      n = colors.red,
      i = colors.green,
      v = colors.blue,
      [''] = colors.blue,
      V = colors.blue,
      c = colors.magenta,
      no = colors.red,
      s = colors.orange,
      S = colors.orange,
      [''] = colors.orange,
      ic = colors.yellow,
      R = colors.violet,
      Rv = colors.violet,
      cv = colors.red,
      ce = colors.red,
      r = colors.cyan,
      rm = colors.cyan,
      ['r?'] = colors.cyan,
      ['!'] = colors.red,
      t = colors.red,
    }
    return { fg = mode_color[vim.fn.mode()] }
  end,
  padding = { right = 1 },
}

ins_left {
  -- filesize component
  'filesize',
  cond = conditions.buffer_not_empty,
}

ins_left {
  'filename',
  cond = conditions.buffer_not_empty,
  color = { fg = colors.magenta, gui = 'bold' },
}

ins_left { 'location' }

ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }

ins_left {
  'diagnostics',
  sources = { 'nvim_diagnostic' },
  symbols = { error = ' ', warn = ' ', info = ' ' },
  diagnostics_color = {
    color_error = { fg = colors.red },
    color_warn = { fg = colors.yellow },
    color_info = { fg = colors.cyan },
  },
}

-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
  function()
    return '%='
  end,
}

ins_left {
  -- Lsp server name .
  function()
    local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
    local clients = vim.lsp.get_active_clients()
    if next(clients) == nil then
      return 'No Active Lsp'
    end
    for _, client in ipairs(clients) do
      local filetypes = client.config.filetypes
      if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
        table.insert(clientNames, client.name)
      end
    end
    if #clientNames == 0 then
      return 'No Active Lsp'
    end
    local msg = ''
    local maxClientsToPrint = 3
    local separator = '·'
    for i = 1, math.min(maxClientsToPrint, #clientNames) do
      msg = msg..(i == 1 and '' or separator)..clientNames[i]
    end
    if #clientNames > maxClientsToPrint then
      msg = msg..separator..'+'..(#clientNames - maxClientsToPrint)
    end
    return msg
  end,
  icon = ' LSP:',
  color = { fg = '#ffffff', gui = 'bold' },
}

-- Add components to right sections
ins_right {
  'o:encoding', -- option component same as &encoding in viml
  fmt = string.upper, -- I'm not sure why it's upper case either ;)
  cond = conditions.hide_in_width,
  color = { fg = colors.green, gui = 'bold' },
}

ins_right {
  'fileformat',
  fmt = string.upper,
  icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
  color = { fg = colors.green, gui = 'bold' },
}

ins_right {
  'branch',
  icon = '',
  color = { fg = colors.violet, gui = 'bold' },
}

ins_right {
  'diff',
  -- Is it me or the symbol for modified us really weird
  symbols = { added = ' ', modified = '柳 ', removed = ' ' },
  diff_color = {
    added = { fg = colors.green },
    modified = { fg = colors.orange },
    removed = { fg = colors.red },
  },
  cond = conditions.hide_in_width,
}

ins_right {
  function()
    return '▊'
  end,
  color = { fg = colors.blue },
  padding = { left = 1 },
}

-- Now don't forget to initialize lualine
lualine.setup(config)

-- HighStr.nvim -------------------------------------------------------------------------------------------------------------------------------------------
local high_str = require("high-str")

high_str.setup({
    verbosity = 0,
    saving_path = "/tmp/highstr/",
    highlight_colors = {
        -- color_id = {"bg_hex_code",<"fg_hex_code"/"smart">}
        color_0 = {"#0c0d0e", "smart"}, -- Cosmic charcoal
        color_1 = {"#e5c07b", "smart"}, -- Pastel yellow
        color_2 = {"#7FFFD4", "smart"}, -- Aqua menthe
        color_3 = {"#8A2BE2", "smart"}, -- Proton purple
        color_4 = {"#FF4500", "smart"}, -- Orange red
        color_5 = {"#008000", "smart"}, -- Office green
        color_6 = {"#0000FF", "smart"}, -- Just blue
        color_7 = {"#FFC0CB", "smart"}, -- Blush pink
        color_8 = {"#FFF9E3", "smart"}, -- Cosmic latte
        color_9 = {"#7d5c34", "smart"}, -- Fallow brown
    }
})
vim.api.nvim_set_keymap(
    "v",
    "<F3>",
    ":<c-u>HSHighlight 1<CR>",
    {
        noremap = true,
        silent = true
    }
)

vim.api.nvim_set_keymap(
    "v",
    "<F4>",
    ":<c-u>HSRmHighlight<CR>",
    {
        noremap = true,
        silent = true
    }
)

-- Comment.nvim -------------------------------------------------------------------------------------------------------------------------------------------
require('Comment').setup()
local ft = require('Comment.ft')
ft.set('fish', '#%s')
vim.cmd([[
    autocmd BufNewFile,BufRead *.conf set ft=conf
]])

-- nvim-surround ------------------------------------------------------------------------------------------------------------------------------------------
-- require("nvim-surround").setup({
--     keymaps = { -- vim-surround style keymaps
--         insert = "ys",
--         visual = "S",
--         delete = "ds",
--         change = "cs",
--     },
--     delimiters = {
--         pairs = {
--             ["("] = { "( ", " )" },
--             [")"] = { "(", ")" },
--             ["{"] = { "{ ", " }" },
--             ["}"] = { "{", "}" },
--             ["<"] = { "< ", " >" },
--             [">"] = { "<", ">" },
--             ["["] = { "[ ", " ]" },
--             ["]"] = { "[", "]" },
--         },
--         separators = {
--             ["'"] = { "'", "'" },
--             ['"'] = { '"', '"' },
--             ["`"] = { "`", "`" },
--         },
--         HTML = {
--             ["t"] = true, -- Use "t" for HTML-style mappings
--         },
--         aliases = {
--             ["a"] = ">", -- Single character aliases apply everywhere
--             ["b"] = ")",
--             ["B"] = "}",
--             ["r"] = "]",
--             ["q"] = { '"', "'", "`" }, -- Table aliases only apply for changes/deletions
--         },
--     }
-- })

-- nvim-lastplace -----------------------------------------------------------------------------------------------------------------------------------------
require'nvim-lastplace'.setup{}
-- lua-fzf --------------------------------------------------------------------------------------------------------------------------------
vim.api.nvim_set_keymap('n', '<c-P>',
    "<cmd>lua require('fzf-lua').files()<CR>",
    { noremap = true, silent = true })

Potentially conflicting plugins

No response

Other information

No response

Help

None

Implementation help

No response

austinliuigi commented 1 year ago

I'm experiencing the same issue; started occuring after updating neorg today.

My previous working version was a79bf59

MichaelVessia commented 1 year ago

I was getting the same error after update. I ran :TSUninstall norg, then :TSInstall norg then :Neorg sync-parsers and the errors are gone.

roland-5 commented 1 year ago

I was getting the same error after update. I ran :TSUninstall norg, then :TSInstall norg then :Neorg sync-parsers and the errors are gone.

Damn, thanks, that worked for me.

Edit. But now it's without highlighting colors. ps_20221224044251

max397574 commented 1 year ago

the "invalid node type error" occurs when the queries and the parser aren't synced. You should PackerSync or Lazy sync and TSUpdate norg @vhyrro perhaps create a pinned issue where you say this

roland-5 commented 1 year ago

I tried many options, but it's still without colors and if norg parser (?) update it show "invalid node type error".

max397574 commented 1 year ago

do you perhaps have custom queries?

roland-5 commented 1 year ago

My packer.lua

local ensure_packer = function()
    local fn = vim.fn
    local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
    if fn.empty(fn.glob(install_path)) > 0 then
        fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
        vim.cmd([[packadd packer.nvim]])
        return true
    end
    return false
end

local packer_bootstrap = ensure_packer()

return require("packer").startup(function(use)
    -- Packer can manage itself as an optional plugin
    use("wbthomason/packer.nvim")
    -- Gruvbox theme use { 'ellisonleao/gruvbox.nvim', branch = 'nvim-set-hl' }
    use("ellisonleao/gruvbox.nvim")
    -- Create Color Code in neovim
    use("uga-rosa/ccc.nvim")
    -- better syntax highlighting
    use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
    -- builtin lsp config
    use("neovim/nvim-lspconfig")
    -- A fast and easy to configure statusline plugin for neovim.
    use("nvim-lualine/lualine.nvim")
    -- lua `fork` of vim-web-devicons for neovim
    use("kyazdani42/nvim-web-devicons")
    -- A completion plugin for neovim coded in Lua.
    use("hrsh7th/cmp-nvim-lsp")
    use("hrsh7th/cmp-buffer")
    use("hrsh7th/cmp-path")
    use("hrsh7th/cmp-cmdline")
    use("hrsh7th/nvim-cmp")
    -- Snippets plugin
    use("L3MON4D3/LuaSnip")
    use("saadparwaiz1/cmp_luasnip")
    -- An implementation of the Popup API from vim in Neovim. Hope to upstream when complete
    use("nvim-lua/popup.nvim")
    -- plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice.
    use("nvim-lua/plenary.nvim")
    -- vim plugin for ansible
    use("pearofducks/ansible-vim")
    -- magit for neovim
    -- use 'TimUntersberger/neogit'
    -- A neovim tabline plugin
    use("romgrk/barbar.nvim")
    -- Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
    use("nvim-lua/lsp-status.nvim")
    -- lazygit
    use("kdheepak/lazygit.nvim")
    -- telescope
    use("nvim-telescope/telescope.nvim")
    -- File Browser extension for telescope.nvim
    use("nvim-telescope/telescope-file-browser.nvim")
    -- Dev setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.
    use("folke/lua-dev.nvim")
    -- Highlight, list and search todo comments in your projects
    use("folke/todo-comments.nvim")
    -- A NeoVim plugin for highlighting visual selections like in a normal document editor!
    use("Pocco81/HighStr.nvim")
    --Rust tools
    use("simrat39/rust-tools.nvim")
    -- lsp signature hint when you type
    use("ray-x/lsp_signature.nvim")
    -- Modernity meets insane extensibility. The future of organizing your life in Neovim.
    -- use 'nvim-neorg/neorg'
    use({
        "nvim-neorg/neorg",
        run = ":Neorg sync-parsers", -- This is the important bit!
        ft = "norg",
        after = "nvim-treesitter",
        config = function()
            require("neorg").setup({
                load = {
                    ["core.defaults"] = {},
                    ["core.norg.dirman"] = {
                        config = {
                            workspaces = {
                                dokumenty = "/home/roland/Dokumenty/neorg",
                            },
                        },
                    },
                    ["core.norg.completion"] = {
                        config = {
                            engine = "nvim-cmp",
                        },
                    },
                    ["core.norg.concealer"] = {
                        config = {
                            width = "content",
                        },
                    },
                },
            })
            vim.api.nvim_set_hl(0, "@neorg.tags.ranged_verbatim.code_block", { bg = "#504945" })
        end,
    })
    -- A neovim plugin that helps you keep track of your keymaps.
    use("lazytanuki/nvim-mapper")
    -- Debug Adapter Protocol client implementation for Neovim (>= 0.5)
    use("mfussenegger/nvim-dap")
    -- comment.nvim
    use("numToStr/Comment.nvim")
    -- Git signs written in pure lua
    use("lewis6991/gitsigns.nvim")
    -- A Neovim plugin for adding/changing/deleting surrounding delimiter pairs. Written with heart in Lua.
    use({
        "kylechui/nvim-surround",
        config = function()
            require("nvim-surround").setup({
                -- Configuration here, or leave empty to use defaults
            })
        end,
    })
    -- A Lua rewrite of vim-lastplace
    use("ethanholz/nvim-lastplace")
    -- Improved fzf.vim written in lua
    use("ibhagwan/fzf-lua")

    -- Automatically set up your configuration after cloning packer.nvim
    -- Put this at the end after all plugins
    if packer_bootstrap then
        require("packer").sync()
    end
end)
max397574 commented 1 year ago

this has nothing to do with packer custom queries would be some files inside after/queries/norg/ or queries/norg/ in your config folder

roland-5 commented 1 year ago

Then no.

danymat commented 1 year ago

Related to errors: what happens if you remove: vim.api.nvim_set_hl(0, "@neorg.tags.ranged_verbatim.code_block", { bg = "#504945" })

Related to highlights: https://github.com/nvim-neorg/neorg/issues/690#issuecomment-1364326077

roland-5 commented 1 year ago

Related to errors: what happens if you remove: vim.api.nvim_set_hl(0, "@neorg.tags.ranged_verbatim.code_block", { bg = "#504945" })

Related to highlights: #690 (comment)

Deleting this line you mention and ft = "norg", and after = "nvim-treesitter", finally helped me. After this there are no errors and colors back again.

danymat commented 1 year ago

Happy that I helped ! Can we close this issue ?