Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module called incline.helpers #65

Open
Samthesurf opened this issue Mar 27, 2024 · 7 comments
Open

No module called incline.helpers #65

Samthesurf opened this issue Mar 27, 2024 · 7 comments

Comments

@Samthesurf
Copy link

I copied one of the configs (the one involving nvim-navic and it tells me that incline.helpers doesn't exist and I don't understand why? I am on Neovim nightly

@b0o
Copy link
Owner

b0o commented Mar 27, 2024

Are you using lazy.nvim as your plugin manager? Can you share the config you used to add incline as a plugin? Also, can you try updating your plugins?

@Samthesurf
Copy link
Author

Samthesurf commented Mar 27, 2024

Yes I am using lazy as my package manager. This is the config I used:

return {
  "b0o/incline.nvim",
  name = "incline",
  version = "*",
  dependencies = { "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons" },
  config = function()
    local helpers = require("incline.helpers")
    local navic = require("nvim-navic")
    local devicons = require("nvim-web-devicons")
    require("incline").setup({
      window = {
        padding = 0,
        margin = { horizontal = 0, vertical = 0 },
      },
      render = function(props)
        local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
        if filename == "" then
          filename = "[No Name]"
        end
        local ft_icon, ft_color = devicons.get_icon_color(filename)
        local modified = vim.bo[props.buf].modified
        local res = {
          ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
          " ",
          { filename, gui = modified and "bold,italic" or "bold" },
          guibg = "#44406e",
        }
        if props.focused then
          for _, item in ipairs(navic.get_data(props.buf) or {}) do
            table.insert(res, {
              { " > ", group = "NavicSeparator" },
              { item.icon, group = "NavicIcons" .. item.type },
              { item.name, group = "NavicText" },
            })
          end
        end
        table.insert(res, " ")
        return res
      end,
    })
  end,
}

@b0o
Copy link
Owner

b0o commented Mar 27, 2024

Hi, I edited your comment to format the code.

To fix this, remove this line: version = "*",. Then update your plugins using lazy.nvim and restart neovim.

This will tell lazy.nvim to install the latest commit of Incline, rather than the latest release (which is quite old).

@Samthesurf
Copy link
Author

Hi, I edited your comment to format the code.

To fix this, remove this line: version = "*",. Then update your plugins using lazy.nvim and restart neovim.

This will tell lazy.nvim to install the latest commit of Incline, rather than the latest release (which is quite old).

It's working now but it just has the default look, it doesn't have the Nvim Navic look that was advertised.

@b0o
Copy link
Owner

b0o commented Mar 27, 2024

It works for me with that config, make sure you have an LSP attached and treesitter enabled.

2024-03-27_16-24-12_region

@Samthesurf
Copy link
Author

Yes I have both enabled, if you look below, you can see the lsps attached. Terminal_screen.png

@idr4n
Copy link

idr4n commented Nov 5, 2024

It's working now but it just has the default look, it doesn't have the Nvim Navic look that was advertised.

@Samthesurf If you are still having this issue, initially it was not working for me either. Then I realized that navic has to be included in the on_attach function as mentioned in their README by adding navic.attach(client, bufnr):

local navic = require("nvim-navic")

require("lspconfig").clangd.setup {
    on_attach = function(client, bufnr)
        navic.attach(client, bufnr)
    end
}

Alternative, looking at how barbecue.nvim plugin does it, you can create an autocmd for this as well:

    vim.api.nvim_create_autocmd("LspAttach", {
      desc = "Navic Attacher",
      group = vim.api.nvim_create_augroup("navic-attacher", {}),
      callback = function(a)
        local client = vim.lsp.get_client_by_id(a.data.client_id)
        if client and client.server_capabilities["documentSymbolProvider"] then
          navic.attach(client, a.buf)
        end
      end,
    })

I'm using the second option and it's working for me with this config:

return {
  "b0o/incline.nvim",
  event = "BufReadPre",
  dependencies = { "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons" },
  keys = {
    { "<leader>I", '<Cmd>lua require"incline".toggle()<Cr>', desc = "Incline: Toggle" },
  },
  config = function()
    local helpers = require("incline.helpers")
    local devicons = require("nvim-web-devicons")
    local navic = require("nvim-navic")

    vim.api.nvim_create_autocmd("LspAttach", {
      desc = "Navic Attacher",
      group = vim.api.nvim_create_augroup("idr4n/navic-attacher", {}),
      callback = function(a)
        local client = vim.lsp.get_client_by_id(a.data.client_id)
        if client and client.server_capabilities["documentSymbolProvider"] then
          navic.attach(client, a.buf)
        end
      end,
    })

    require("incline").setup({
      render = function(props)
        local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
        if filename == "" then
          filename = "[No Name]"
        end
        local ft_icon, ft_color = devicons.get_icon_color(filename)
        local modified = vim.bo[props.buf].modified
        local res = {
          ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
          " ",
          { filename, gui = modified and "bold,italic" or "bold" },
          guibg = "#44406e",
        }
        if props.focused then
          for _, item in ipairs(navic.get_data(props.buf) or {}) do
            table.insert(res, {
              { " > ", group = "NavicSeparator" },
              { item.icon, group = "NavicIcons" .. item.type },
              { item.name, group = "NavicText" },
            })
          end
        end
        table.insert(res, " ")
        return res
      end,
    })
  end,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants