SmiteshP / nvim-navic

Simple winbar/statusline plugin that shows your current code context
Apache License 2.0
1.35k stars 49 forks source link

when in barrel import typescript file navic errors and doesn't allow any type of actions #101

Closed sf8193 closed 1 year ago

sf8193 commented 1 year ago
  4 export * from './stuff'
  5 export * from './otherStuff'
  6 export * from './moreStuff'
  7 export * from './etc'
  8 export * from './mocks'
  9 export * from './reducers'

I get the error

Error detected while processing CursorMoved Autocommands for "<buffer=25>":
Error executing lua callback: ...site/pack/packer/start/nvim-navic/lua/nvim-navic/lib.lua:325: attempt to index field 'children
' (a nil value)
stack traceback:
        ...site/pack/packer/start/nvim-navic/lua/nvim-navic/lib.lua:325: in function 'update_context'
        ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:254: in function <...ite/pack/packer/start/nvim-navic/lua/n
vim-navic/init.lua:252>
Press ENTER or type command to continue

my setup

local function navic_info()
    return require("nvim-navic").get_location()
end

local function navic_ok()
    return require("nvim-navic").is_available()
end

require('lualine').setup{
  options = {
    theme = 'onedark',
  },
  sections = {
    lualine_x = {{
        navic_info,
        cond = navic_ok
    }},
  },
  tabline = {
    lualine_a = {
      {'buffers',hide_filename_extension = true, max_length = vim.o.columns },
    },
  },
}

local navic = require("nvim-navic")
local navbuddy = require("nvim-navbuddy")
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  -- Enable completion triggered by <c-x><c-o>
    if client.server_capabilities.documentSymbolProvider then
        navic.attach(client, bufnr)
        navbuddy.attach(client, bufnr)
    end
 // stuff
 end
SmiteshP commented 1 year ago

Are you on latest commit? I would guess PR #100 should have fixed this issue

sf8193 commented 1 year ago

yup that fixed it, thanks!